chore: replace int amount_cents for string storage and decimal pkg

This commit is contained in:
juancwu 2026-03-14 14:43:39 -04:00
commit c8a1eb5b7a
No known key found for this signature in database
45 changed files with 706 additions and 587 deletions

View file

@ -1,6 +1,10 @@
package model
import "time"
import (
"time"
"github.com/shopspring/decimal"
)
type FundingSourceType string
@ -10,16 +14,17 @@ const (
)
type Receipt struct {
ID string `db:"id"`
LoanID string `db:"loan_id"`
SpaceID string `db:"space_id"`
Description string `db:"description"`
TotalAmountCents int `db:"total_amount_cents"`
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"`
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 struct {
@ -27,7 +32,8 @@ type ReceiptFundingSource struct {
ReceiptID string `db:"receipt_id"`
SourceType FundingSourceType `db:"source_type"`
AccountID *string `db:"account_id"`
AmountCents int `db:"amount_cents"`
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"`
}