feat: salvar data original da transação e data de vencimento no cartão

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]>
This commit is contained in:
2026-05-27 16:25:52 -03:00
co-authored by Claude Sonnet 4.6
parent 9ba3a3678b
commit 2b0aa352d5
7 changed files with 40 additions and 15 deletions
+7 -3
View File
@@ -62,10 +62,14 @@ func (r *transactionRepo) BulkInsert(ctx context.Context, rows []model.ImportRow
if row.ExternalID != "" {
extID = &row.ExternalID
}
var origDate *string
if row.OriginalDate != "" {
origDate = &row.OriginalDate
}
_, err := tx.Exec(ctx, `
INSERT INTO transactions (date, amount, description, type, source, external_id, category_id)
VALUES ($1, $2, $3, $4, 'import', $5, $6)`,
row.Date, row.Amount, row.Description, row.Type, extID, row.CategoryID)
INSERT INTO transactions (date, original_date, amount, description, type, source, external_id, category_id)
VALUES ($1, $2, $3, $4, $5, 'import', $6, $7)`,
row.Date, origDate, row.Amount, row.Description, row.Type, extID, row.CategoryID)
if err != nil {
return count, err
}