feat(savings): Add savings module with categories, transactions, recurring plans
- Categories: regular, deposits, credits, recurring, multi-user, accounts - Transactions: deposits and withdrawals with user tracking - Recurring plans: monthly payment obligations per user - Stats: overdues calculation with allocation algorithm - Excludes is_account categories from total sums - Documentation: docs/SAVINGS.md
This commit is contained in:
@@ -7,21 +7,30 @@ import (
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
ID int64 `db:"id" json:"id"`
|
||||
UserID int64 `db:"user_id" json:"user_id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Description string `db:"description" json:"description"`
|
||||
Icon string `db:"icon" json:"icon"`
|
||||
Color string `db:"color" json:"color"`
|
||||
DueDate sql.NullTime `db:"due_date" json:"-"`
|
||||
DueDateStr *string `db:"-" json:"due_date"`
|
||||
Priority int `db:"priority" json:"priority"`
|
||||
ReminderTime sql.NullString `db:"reminder_time" json:"-"`
|
||||
ReminderTimeStr *string `db:"-" json:"reminder_time"`
|
||||
CompletedAt sql.NullTime `db:"completed_at" json:"-"`
|
||||
Completed bool `db:"-" json:"completed"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
ID int64 `db:"id" json:"id"`
|
||||
UserID int64 `db:"user_id" json:"user_id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Description string `db:"description" json:"description"`
|
||||
Icon string `db:"icon" json:"icon"`
|
||||
Color string `db:"color" json:"color"`
|
||||
DueDate sql.NullTime `db:"due_date" json:"-"`
|
||||
DueDateStr *string `db:"-" json:"due_date"`
|
||||
Priority int `db:"priority" json:"priority"`
|
||||
ReminderTime sql.NullString `db:"reminder_time" json:"-"`
|
||||
ReminderTimeStr *string `db:"-" json:"reminder_time"`
|
||||
CompletedAt sql.NullTime `db:"completed_at" json:"-"`
|
||||
Completed bool `db:"-" json:"completed"`
|
||||
// Recurring task fields
|
||||
IsRecurring bool `db:"is_recurring" json:"is_recurring"`
|
||||
RecurrenceType sql.NullString `db:"recurrence_type" json:"-"`
|
||||
RecurrenceTypeStr *string `db:"-" json:"recurrence_type"`
|
||||
RecurrenceInterval int `db:"recurrence_interval" json:"recurrence_interval"`
|
||||
RecurrenceEndDate sql.NullTime `db:"recurrence_end_date" json:"-"`
|
||||
RecurrenceEndStr *string `db:"-" json:"recurrence_end_date"`
|
||||
ParentTaskID sql.NullInt64 `db:"parent_task_id" json:"-"`
|
||||
ParentTaskIDPtr *int64 `db:"-" json:"parent_task_id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (t *Task) ProcessForJSON() {
|
||||
@@ -47,24 +56,46 @@ func (t *Task) ProcessForJSON() {
|
||||
}
|
||||
}
|
||||
t.Completed = t.CompletedAt.Valid
|
||||
|
||||
// Process recurring fields
|
||||
if t.RecurrenceType.Valid {
|
||||
t.RecurrenceTypeStr = &t.RecurrenceType.String
|
||||
}
|
||||
if t.RecurrenceEndDate.Valid {
|
||||
s := t.RecurrenceEndDate.Time.Format("2006-01-02")
|
||||
t.RecurrenceEndStr = &s
|
||||
}
|
||||
if t.ParentTaskID.Valid {
|
||||
t.ParentTaskIDPtr = &t.ParentTaskID.Int64
|
||||
}
|
||||
}
|
||||
|
||||
type CreateTaskRequest struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
DueDate *string `json:"due_date,omitempty"`
|
||||
Priority int `json:"priority,omitempty"`
|
||||
ReminderTime *string `json:"reminder_time,omitempty"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
DueDate *string `json:"due_date,omitempty"`
|
||||
Priority int `json:"priority,omitempty"`
|
||||
ReminderTime *string `json:"reminder_time,omitempty"`
|
||||
// Recurring fields
|
||||
IsRecurring bool `json:"is_recurring,omitempty"`
|
||||
RecurrenceType *string `json:"recurrence_type,omitempty"`
|
||||
RecurrenceInterval int `json:"recurrence_interval,omitempty"`
|
||||
RecurrenceEndDate *string `json:"recurrence_end_date,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateTaskRequest struct {
|
||||
Title *string `json:"title,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Icon *string `json:"icon,omitempty"`
|
||||
Color *string `json:"color,omitempty"`
|
||||
DueDate *string `json:"due_date,omitempty"`
|
||||
Priority *int `json:"priority,omitempty"`
|
||||
ReminderTime *string `json:"reminder_time,omitempty"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Icon *string `json:"icon,omitempty"`
|
||||
Color *string `json:"color,omitempty"`
|
||||
DueDate *string `json:"due_date,omitempty"`
|
||||
Priority *int `json:"priority,omitempty"`
|
||||
ReminderTime *string `json:"reminder_time,omitempty"`
|
||||
// Recurring fields
|
||||
IsRecurring *bool `json:"is_recurring,omitempty"`
|
||||
RecurrenceType *string `json:"recurrence_type,omitempty"`
|
||||
RecurrenceInterval *int `json:"recurrence_interval,omitempty"`
|
||||
RecurrenceEndDate *string `json:"recurrence_end_date,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user