add expenses management

This commit is contained in:
juancwu 2026-01-14 20:40:36 +00:00
commit f8ddf152e4
16 changed files with 611 additions and 29 deletions

39
internal/model/expense.go Normal file
View file

@ -0,0 +1,39 @@
package model
import "time"
type ExpenseType string
const (
ExpenseTypeExpense ExpenseType = "expense"
ExpenseTypeTopup ExpenseType = "topup"
)
type Expense struct {
ID string `db:"id"`
SpaceID string `db:"space_id"`
CreatedBy string `db:"created_by"`
Description string `db:"description"`
AmountCents int `db:"amount_cents"`
Type ExpenseType `db:"type"`
Date time.Time `db:"date"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type ExpenseTag struct {
ExpenseID string `db:"expense_id"`
TagID string `db:"tag_id"`
}
type ExpenseItem struct {
ExpenseID string `db:"expense_id"`
ItemID string `db:"item_id"`
}
type TagExpenseSummary struct {
TagID string `db:"tag_id"`
TagName string `db:"tag_name"`
TagColor string `db:"tag_color"`
TotalAmount int `db:"total_amount"`
}

View file

@ -9,8 +9,8 @@ const (
)
type File struct {
ID string `db:"id"`
UserID string `db:"user_id"` // Who owns/created this file
ID string `db:"id"`
UserID string `db:"user_id"` // Who owns/created this file
OwnerType string `db:"owner_type"` // "user", "profile", etc. - the entity that owns the file
OwnerID string `db:"owner_id"` // Polymorphic FK
Type string `db:"type"`

View file

@ -3,8 +3,8 @@ package model
import "time"
type Profile struct {
ID string `db:"id"`
UserID string `db:"user_id"`
ID string `db:"id"`
UserID string `db:"user_id"`
Name string `db:"name"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`

View file

@ -11,11 +11,11 @@ type ShoppingList struct {
}
type ListItem struct {
ID string `db:"id"`
ListID string `db:"list_id"`
Name string `db:"name"`
IsChecked bool `db:"is_checked"`
CreatedBy string `db:"created_by"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID string `db:"id"`
ListID string `db:"list_id"`
Name string `db:"name"`
IsChecked bool `db:"is_checked"`
CreatedBy string `db:"created_by"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}

View file

@ -5,8 +5,8 @@ import (
)
type Token struct {
ID string `db:"id"`
UserID string `db:"user_id"`
ID string `db:"id"`
UserID string `db:"user_id"`
Type string `db:"type"` // "email_verify" or "password_reset"
Token string `db:"token"`
ExpiresAt time.Time `db:"expires_at"`

View file

@ -3,7 +3,7 @@ package model
import "time"
type User struct {
ID string `db:"id"`
ID string `db:"id"`
Email string `db:"email"`
// Allow null for passwordless users
PasswordHash *string `db:"password_hash"`