model

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenTypeEmailVerify   = "email_verify"
	TokenTypePasswordReset = "password_reset"
	TokenTypeEmailChange   = "email_change"
	TokenTypeMagicLink     = "magic_link"
)
View Source
const (
	FileTypeAvatar = "avatar"
)

Variables

This section is empty.

Functions

func FormatDecimal added in v1.11.2

func FormatDecimal(d decimal.Decimal) string

FormatDecimal formats a decimal for form input values like "12.50"

func FormatMoney added in v1.11.2

func FormatMoney(d decimal.Decimal) string

FormatMoney formats a decimal as a dollar string like "$12.50"

Types

type AccountTransfer added in v1.2.0

type AccountTransfer struct {
	ID                 string            `db:"id"`
	AccountID          string            `db:"account_id"`
	Amount             decimal.Decimal   `db:"amount"`
	AmountCents        int               `db:"amount_cents"` // deprecated: kept for SELECT * compatibility
	Direction          TransferDirection `db:"direction"`
	Note               string            `db:"note"`
	RecurringDepositID *string           `db:"recurring_deposit_id"`
	CreatedBy          string            `db:"created_by"`
	CreatedAt          time.Time         `db:"created_at"`
}

type AccountTransferWithAccount added in v1.8.0

type AccountTransferWithAccount struct {
	AccountTransfer
	AccountName string `db:"account_name"`
}

type Budget added in v1.4.0

type Budget struct {
	ID          string          `db:"id"`
	SpaceID     string          `db:"space_id"`
	Amount      decimal.Decimal `db:"amount"`
	AmountCents int             `db:"amount_cents"` // deprecated: kept for SELECT * compatibility
	Period      BudgetPeriod    `db:"period"`
	StartDate   time.Time       `db:"start_date"`
	EndDate     *time.Time      `db:"end_date"`
	IsActive    bool            `db:"is_active"`
	CreatedBy   string          `db:"created_by"`
	CreatedAt   time.Time       `db:"created_at"`
	UpdatedAt   time.Time       `db:"updated_at"`
}

type BudgetPeriod added in v1.4.0

type BudgetPeriod string
const (
	BudgetPeriodWeekly  BudgetPeriod = "weekly"
	BudgetPeriodMonthly BudgetPeriod = "monthly"
	BudgetPeriodYearly  BudgetPeriod = "yearly"
)

type BudgetStatus added in v1.4.0

type BudgetStatus string
const (
	BudgetStatusOnTrack BudgetStatus = "on_track"
	BudgetStatusWarning BudgetStatus = "warning"
	BudgetStatusOver    BudgetStatus = "over"
)

type BudgetWithSpent added in v1.4.0

type BudgetWithSpent struct {
	Budget
	Tags       []*Tag
	Spent      decimal.Decimal
	Percentage float64
	Status     BudgetStatus
}

func (*BudgetWithSpent) TagNames added in v1.7.0

func (b *BudgetWithSpent) TagNames() string

type DailySpending added in v1.4.0

type DailySpending struct {
	Date  time.Time       `db:"date"`
	Total decimal.Decimal `db:"total"`
}

type Expense

type Expense struct {
	ID                 string          `db:"id"`
	SpaceID            string          `db:"space_id"`
	CreatedBy          string          `db:"created_by"`
	Description        string          `db:"description"`
	Amount             decimal.Decimal `db:"amount"`
	AmountCents        int             `db:"amount_cents"` // deprecated: kept for SELECT * compatibility
	Type               ExpenseType     `db:"type"`
	Date               time.Time       `db:"date"`
	PaymentMethodID    *string         `db:"payment_method_id"`
	RecurringExpenseID *string         `db:"recurring_expense_id"`
	CreatedAt          time.Time       `db:"created_at"`
	UpdatedAt          time.Time       `db:"updated_at"`
}

type ExpenseItem

type ExpenseItem struct {
	ExpenseID string `db:"expense_id"`
	ItemID    string `db:"item_id"`
}

type ExpenseTag

type ExpenseTag struct {
	ExpenseID string `db:"expense_id"`
	TagID     string `db:"tag_id"`
}

type ExpenseType

type ExpenseType string
const (
	ExpenseTypeExpense ExpenseType = "expense"
	ExpenseTypeTopup   ExpenseType = "topup"
)

type ExpenseWithTags

type ExpenseWithTags struct {
	Expense
	Tags []*Tag
}

type ExpenseWithTagsAndMethod added in v1.3.0

type ExpenseWithTagsAndMethod struct {
	Expense
	Tags          []*Tag
	PaymentMethod *PaymentMethod
}

type File

type File struct {
	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"`
	Filename     string    `db:"filename"`
	OriginalName string    `db:"original_name"`
	MimeType     string    `db:"mime_type"`
	Size         int64     `db:"size"`
	StoragePath  string    `db:"storage_path"`
	CreatedAt    time.Time `db:"created_at"`
}

type Frequency added in v1.4.0

type Frequency string
const (
	FrequencyDaily    Frequency = "daily"
	FrequencyWeekly   Frequency = "weekly"
	FrequencyBiweekly Frequency = "biweekly"
	FrequencyMonthly  Frequency = "monthly"
	FrequencyYearly   Frequency = "yearly"
)

type FundingSourceType added in v1.11.0

type FundingSourceType string
const (
	FundingSourceBalance FundingSourceType = "balance"
	FundingSourceAccount FundingSourceType = "account"
)

type InvitationStatus

type InvitationStatus string
const (
	InvitationStatusPending  InvitationStatus = "pending"
	InvitationStatusAccepted InvitationStatus = "accepted"
	InvitationStatusExpired  InvitationStatus = "expired"
)

type ListCardData

type ListCardData struct {
	List        *ShoppingList
	Items       []*ListItem
	CurrentPage int
	TotalPages  int
}

type ListItem

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"`
}

type ListWithUncheckedItems

type ListWithUncheckedItems struct {
	List  *ShoppingList
	Items []*ListItem
}

type Loan added in v1.11.0

type Loan struct {
	ID                  string          `db:"id"`
	SpaceID             string          `db:"space_id"`
	Name                string          `db:"name"`
	Description         string          `db:"description"`
	OriginalAmount      decimal.Decimal `db:"original_amount"`
	OriginalAmountCents int             `db:"original_amount_cents"` // deprecated: kept for SELECT * compatibility
	InterestRateBps     int             `db:"interest_rate_bps"`
	StartDate           time.Time       `db:"start_date"`
	EndDate             *time.Time      `db:"end_date"`
	IsPaidOff           bool            `db:"is_paid_off"`
	CreatedBy           string          `db:"created_by"`
	CreatedAt           time.Time       `db:"created_at"`
	UpdatedAt           time.Time       `db:"updated_at"`
}

type LoanWithPaymentSummary added in v1.11.0

type LoanWithPaymentSummary struct {
	Loan
	TotalPaid    decimal.Decimal
	Remaining    decimal.Decimal
	ReceiptCount int
}

type MoneyAccount added in v1.2.0

type MoneyAccount struct {
	ID        string    `db:"id"`
	SpaceID   string    `db:"space_id"`
	Name      string    `db:"name"`
	CreatedBy string    `db:"created_by"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type MoneyAccountWithBalance added in v1.2.0

type MoneyAccountWithBalance struct {
	MoneyAccount
	Balance decimal.Decimal
}

type MonthlySpending added in v1.4.0

type MonthlySpending struct {
	Month string          `db:"month"`
	Total decimal.Decimal `db:"total"`
}

type PaymentMethod added in v1.3.0

type PaymentMethod struct {
	ID        string            `db:"id"`
	SpaceID   string            `db:"space_id"`
	Name      string            `db:"name"`
	Type      PaymentMethodType `db:"type"`
	LastFour  *string           `db:"last_four"`
	CreatedBy string            `db:"created_by"`
	CreatedAt time.Time         `db:"created_at"`
	UpdatedAt time.Time         `db:"updated_at"`
}

type PaymentMethodExpenseSummary added in v1.13.0

type PaymentMethodExpenseSummary struct {
	PaymentMethodID   string          `db:"payment_method_id"`
	PaymentMethodName string          `db:"payment_method_name"`
	PaymentMethodType string          `db:"payment_method_type"`
	TotalAmount       decimal.Decimal `db:"total_amount"`
}

type PaymentMethodType added in v1.3.0

type PaymentMethodType string
const (
	PaymentMethodTypeCredit PaymentMethodType = "credit"
	PaymentMethodTypeDebit  PaymentMethodType = "debit"
)

type Profile

type Profile struct {
	ID        string    `db:"id"`
	UserID    string    `db:"user_id"`
	Name      string    `db:"name"`
	Timezone  *string   `db:"timezone"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

func (*Profile) Location added in v1.10.0

func (p *Profile) Location() *time.Location

Location returns the *time.Location for this profile's timezone. Returns UTC if timezone is nil or invalid.

type Receipt added in v1.11.0

type Receipt struct {
	ID                 string          `db:"id"`
	LoanID             string          `db:"loan_id"`
	SpaceID            string          `db:"space_id"`
	Description        string          `db:"description"`
	TotalAmount        decimal.Decimal `db:"total_amount"`
	TotalAmountCents   int             `db:"total_amount_cents"` // deprecated: kept for SELECT * compatibility
	Date               time.Time       `db:"date"`
	RecurringReceiptID *string         `db:"recurring_receipt_id"`
	CreatedBy          string          `db:"created_by"`
	CreatedAt          time.Time       `db:"created_at"`
	UpdatedAt          time.Time       `db:"updated_at"`
}

type ReceiptFundingSource added in v1.11.0

type ReceiptFundingSource struct {
	ID               string            `db:"id"`
	ReceiptID        string            `db:"receipt_id"`
	SourceType       FundingSourceType `db:"source_type"`
	AccountID        *string           `db:"account_id"`
	Amount           decimal.Decimal   `db:"amount"`
	AmountCents      int               `db:"amount_cents"` // deprecated: kept for SELECT * compatibility
	LinkedExpenseID  *string           `db:"linked_expense_id"`
	LinkedTransferID *string           `db:"linked_transfer_id"`
}

type ReceiptFundingSourceWithAccount added in v1.11.0

type ReceiptFundingSourceWithAccount struct {
	ReceiptFundingSource
	AccountName string
}

type ReceiptWithSources added in v1.11.0

type ReceiptWithSources struct {
	Receipt
	Sources []ReceiptFundingSource
}

type ReceiptWithSourcesAndAccounts added in v1.11.0

type ReceiptWithSourcesAndAccounts struct {
	Receipt
	Sources []ReceiptFundingSourceWithAccount
}

type RecurringExpense added in v1.4.0

type RecurringExpense struct {
	ID              string          `db:"id"`
	SpaceID         string          `db:"space_id"`
	CreatedBy       string          `db:"created_by"`
	Description     string          `db:"description"`
	Amount          decimal.Decimal `db:"amount"`
	AmountCents     int             `db:"amount_cents"` // deprecated: kept for SELECT * compatibility
	Type            ExpenseType     `db:"type"`
	PaymentMethodID *string         `db:"payment_method_id"`
	Frequency       Frequency       `db:"frequency"`
	StartDate       time.Time       `db:"start_date"`
	EndDate         *time.Time      `db:"end_date"`
	NextOccurrence  time.Time       `db:"next_occurrence"`
	IsActive        bool            `db:"is_active"`
	CreatedAt       time.Time       `db:"created_at"`
	UpdatedAt       time.Time       `db:"updated_at"`
}

type RecurringExpenseWithTags added in v1.4.0

type RecurringExpenseWithTags struct {
	RecurringExpense
	Tags []*Tag
}

type RecurringExpenseWithTagsAndMethod added in v1.4.0

type RecurringExpenseWithTagsAndMethod struct {
	RecurringExpense
	Tags          []*Tag
	PaymentMethod *PaymentMethod
}

type RecurringReceipt added in v1.11.0

type RecurringReceipt struct {
	ID               string          `db:"id"`
	LoanID           string          `db:"loan_id"`
	SpaceID          string          `db:"space_id"`
	Description      string          `db:"description"`
	TotalAmount      decimal.Decimal `db:"total_amount"`
	TotalAmountCents int             `db:"total_amount_cents"` // deprecated: kept for SELECT * compatibility
	Frequency        Frequency       `db:"frequency"`
	StartDate        time.Time       `db:"start_date"`
	EndDate          *time.Time      `db:"end_date"`
	NextOccurrence   time.Time       `db:"next_occurrence"`
	IsActive         bool            `db:"is_active"`
	CreatedBy        string          `db:"created_by"`
	CreatedAt        time.Time       `db:"created_at"`
	UpdatedAt        time.Time       `db:"updated_at"`
}

type RecurringReceiptSource added in v1.11.0

type RecurringReceiptSource struct {
	ID                 string            `db:"id"`
	RecurringReceiptID string            `db:"recurring_receipt_id"`
	SourceType         FundingSourceType `db:"source_type"`
	AccountID          *string           `db:"account_id"`
	Amount             decimal.Decimal   `db:"amount"`
	AmountCents        int               `db:"amount_cents"` // deprecated: kept for SELECT * compatibility
}

type RecurringReceiptWithLoan added in v1.11.0

type RecurringReceiptWithLoan struct {
	RecurringReceipt
	LoanName string
	Sources  []RecurringReceiptSource
}

type RecurringReceiptWithSources added in v1.11.0

type RecurringReceiptWithSources struct {
	RecurringReceipt
	Sources []RecurringReceiptSource
}

type Role

type Role string
const (
	RoleOwner  Role = "owner"
	RoleMember Role = "member"
)

type ShoppingList

type ShoppingList struct {
	ID        string    `db:"id"`
	SpaceID   string    `db:"space_id"`
	Name      string    `db:"name"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type Space

type Space struct {
	ID        string    `db:"id"`
	Name      string    `db:"name"`
	OwnerID   string    `db:"owner_id"`
	Timezone  *string   `db:"timezone"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

func (*Space) Location added in v1.10.0

func (s *Space) Location() *time.Location

Location returns the *time.Location for this space's timezone. Returns nil if timezone is not set, so callers can distinguish "not set" from "UTC".

type SpaceInvitation

type SpaceInvitation struct {
	Token     string           `db:"token"`
	SpaceID   string           `db:"space_id"`
	InviterID string           `db:"inviter_id"`
	Email     string           `db:"email"`
	Status    InvitationStatus `db:"status"`
	ExpiresAt time.Time        `db:"expires_at"`
	CreatedAt time.Time        `db:"created_at"`
	UpdatedAt time.Time        `db:"updated_at"`
}

type SpaceMember

type SpaceMember struct {
	SpaceID  string    `db:"space_id"`
	UserID   string    `db:"user_id"`
	Role     Role      `db:"role"`
	JoinedAt time.Time `db:"joined_at"`
}

type SpaceMemberWithProfile

type SpaceMemberWithProfile struct {
	SpaceID  string    `db:"space_id"`
	UserID   string    `db:"user_id"`
	Role     Role      `db:"role"`
	JoinedAt time.Time `db:"joined_at"`
	Name     string    `db:"name"`
	Email    string    `db:"email"`
}

type SpendingReport added in v1.4.0

type SpendingReport struct {
	ByTag           []*TagExpenseSummary
	ByPaymentMethod []*PaymentMethodExpenseSummary
	DailySpending   []*DailySpending
	MonthlySpending []*MonthlySpending
	TopExpenses     []*ExpenseWithTagsAndMethod
	TotalIncome     decimal.Decimal
	TotalExpenses   decimal.Decimal
	NetBalance      decimal.Decimal
}

type Tag

type Tag struct {
	ID        string    `db:"id"`
	SpaceID   string    `db:"space_id"`
	Name      string    `db:"name"`
	Color     *string   `db:"color"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type TagExpenseSummary

type TagExpenseSummary struct {
	TagID       string          `db:"tag_id"`
	TagName     string          `db:"tag_name"`
	TagColor    *string         `db:"tag_color"`
	TotalAmount decimal.Decimal `db:"total_amount"`
}

type Token

type Token struct {
	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"`
	UsedAt    *time.Time `db:"used_at"`
	CreatedAt time.Time  `db:"created_at"`
}

func (*Token) IsExpired

func (t *Token) IsExpired() bool

func (*Token) IsUsed

func (t *Token) IsUsed() bool

func (*Token) IsValid

func (t *Token) IsValid() bool

type TransferDirection added in v1.2.0

type TransferDirection string
const (
	TransferDirectionDeposit    TransferDirection = "deposit"
	TransferDirectionWithdrawal TransferDirection = "withdrawal"
)

type User

type User struct {
	ID    string `db:"id"`
	Email string `db:"email"`
	// Allow null for passwordless users
	PasswordHash    *string    `db:"password_hash"`
	PendingEmail    *string    `db:"pending_email"`
	EmailVerifiedAt *time.Time `db:"email_verified_at"`
	CreatedAt       time.Time  `db:"created_at"`
}

func (*User) HasPassword

func (u *User) HasPassword() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL