Ao importar fatura de cartão com PaymentDate configurado, a data efetiva da transação passa a ser o vencimento e a data de compra é preservada em original_date. Migration 013 adiciona a coluna original_date em transactions. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
50 lines
2.1 KiB
Go
50 lines
2.1 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
type Transaction struct {
|
|
ID int `json:"id"`
|
|
Date string `json:"date"` // YYYY-MM-DD
|
|
Amount float64 `json:"amount"`
|
|
Description string `json:"description"`
|
|
Type string `json:"type"` // income | expense
|
|
Source string `json:"source"` // manual | import
|
|
CategoryID *int `json:"category_id"`
|
|
AccountID *int `json:"account_id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// ImportRow is a parsed-but-not-yet-saved transaction from a file.
|
|
type ImportRow struct {
|
|
Date string `json:"date"` // effective date (payment date for credit cards)
|
|
OriginalDate string `json:"original_date"` // purchase date from the CSV (empty for non-credit imports)
|
|
Amount float64 `json:"amount"`
|
|
Description string `json:"description"`
|
|
Type string `json:"type"`
|
|
CategoryID *int `json:"category_id,omitempty"`
|
|
ExternalID string `json:"external_id,omitempty"` // FITID from OFX
|
|
IsDuplicate bool `json:"is_duplicate"`
|
|
}
|
|
|
|
// ImportResult is the response after confirming an import.
|
|
type ImportResult struct {
|
|
Imported int `json:"imported"`
|
|
Duplicates int `json:"duplicates"`
|
|
Errors int `json:"errors"`
|
|
}
|
|
|
|
// CSVMapping tells the parser which CSV column index holds each field.
|
|
type CSVMapping struct {
|
|
DateColumn int `json:"date_column"`
|
|
AmountColumn int `json:"amount_column"`
|
|
DescriptionColumn int `json:"description_column"`
|
|
DateFormat string `json:"date_format"` // Go time format, e.g. "02/01/2006"
|
|
HasHeader bool `json:"has_header"`
|
|
DecimalSeparator string `json:"decimal_separator"` // "." or ","
|
|
FieldSeparator string `json:"field_separator"` // "," or ";"
|
|
SkipNegative bool `json:"skip_negative"` // skip rows with negative amount (e.g. credit card bill payments)
|
|
AllExpenses bool `json:"all_expenses"` // treat all rows as expense (credit card statements)
|
|
PaymentDate string `json:"payment_date"` // YYYY-MM-DD; when set, overrides date for all rows (credit card due date)
|
|
}
|