- Create 003_quick_add_library.sql with quick_add_items table and user index - Add QuickAddItem struct to models.go following Category pattern - Add ListQuickAddItems, CreateQuickAddItem, UpdateQuickAddItem, DeleteQuickAddItem to queries.go
135 lines
4.5 KiB
Go
135 lines
4.5 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type CategoryType string
|
|
|
|
const (
|
|
CategoryBill CategoryType = "bill"
|
|
CategoryVariableExpense CategoryType = "variable_expense"
|
|
CategoryDebt CategoryType = "debt"
|
|
CategorySaving CategoryType = "saving"
|
|
CategoryInvestment CategoryType = "investment"
|
|
CategoryIncome CategoryType = "income"
|
|
)
|
|
|
|
type ItemTier string
|
|
|
|
const (
|
|
ItemTierFixed ItemTier = "fixed"
|
|
ItemTierVariable ItemTier = "variable"
|
|
ItemTierOneOff ItemTier = "one_off"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Email string `json:"email"`
|
|
PasswordHash string `json:"-"`
|
|
OIDCSubject *string `json:"oidc_subject,omitempty"`
|
|
DisplayName string `json:"display_name"`
|
|
PreferredLocale string `json:"preferred_locale"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type Category struct {
|
|
ID uuid.UUID `json:"id"`
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Name string `json:"name"`
|
|
Type CategoryType `json:"type"`
|
|
Icon string `json:"icon"`
|
|
SortOrder int `json:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type Budget struct {
|
|
ID uuid.UUID `json:"id"`
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Name string `json:"name"`
|
|
StartDate time.Time `json:"start_date"`
|
|
EndDate time.Time `json:"end_date"`
|
|
Currency string `json:"currency"`
|
|
CarryoverAmount decimal.Decimal `json:"carryover_amount"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type BudgetItem struct {
|
|
ID uuid.UUID `json:"id"`
|
|
BudgetID uuid.UUID `json:"budget_id"`
|
|
CategoryID uuid.UUID `json:"category_id"`
|
|
CategoryName string `json:"category_name,omitempty"`
|
|
CategoryType CategoryType `json:"category_type,omitempty"`
|
|
ItemTier ItemTier `json:"item_tier"`
|
|
BudgetedAmount decimal.Decimal `json:"budgeted_amount"`
|
|
ActualAmount decimal.Decimal `json:"actual_amount"`
|
|
Notes string `json:"notes"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type BudgetTotals struct {
|
|
IncomeBudget decimal.Decimal `json:"income_budget"`
|
|
IncomeActual decimal.Decimal `json:"income_actual"`
|
|
BillsBudget decimal.Decimal `json:"bills_budget"`
|
|
BillsActual decimal.Decimal `json:"bills_actual"`
|
|
ExpensesBudget decimal.Decimal `json:"expenses_budget"`
|
|
ExpensesActual decimal.Decimal `json:"expenses_actual"`
|
|
DebtsBudget decimal.Decimal `json:"debts_budget"`
|
|
DebtsActual decimal.Decimal `json:"debts_actual"`
|
|
SavingsBudget decimal.Decimal `json:"savings_budget"`
|
|
SavingsActual decimal.Decimal `json:"savings_actual"`
|
|
InvestmentsBudget decimal.Decimal `json:"investments_budget"`
|
|
InvestmentsActual decimal.Decimal `json:"investments_actual"`
|
|
Available decimal.Decimal `json:"available"`
|
|
}
|
|
|
|
type BudgetDetail struct {
|
|
Budget
|
|
Items []BudgetItem `json:"items"`
|
|
Totals BudgetTotals `json:"totals"`
|
|
}
|
|
|
|
type Template struct {
|
|
ID uuid.UUID `json:"id"`
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Name string `json:"name"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type TemplateItem struct {
|
|
ID uuid.UUID `json:"id"`
|
|
TemplateID uuid.UUID `json:"template_id"`
|
|
CategoryID uuid.UUID `json:"category_id"`
|
|
CategoryName string `json:"category_name,omitempty"`
|
|
CategoryType CategoryType `json:"category_type,omitempty"`
|
|
CategoryIcon string `json:"category_icon,omitempty"`
|
|
ItemTier ItemTier `json:"item_tier"`
|
|
BudgetedAmount *decimal.Decimal `json:"budgeted_amount"`
|
|
SortOrder int `json:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type TemplateDetail struct {
|
|
Template
|
|
Items []TemplateItem `json:"items"`
|
|
}
|
|
|
|
type QuickAddItem struct {
|
|
ID uuid.UUID `json:"id"`
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Name string `json:"name"`
|
|
Icon string `json:"icon"`
|
|
SortOrder int `json:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|