Final banking step. User-managed: each month, paste your bank statement
totals into the form. We don't auto-compute interest — bank's number is
authoritative.
Schema:
- credit_cards: bankName, cardName, last4, creditLimit, statementDay,
dueDay, interestRate (monthly nominal %), bankAccountId (optional FK,
payments expense from this account), archived, notes.
- credit_card_statements: cardId, period (YYYY-MM), statementDate,
dueDate, totalDebt, minimumPayment, paidAmount, status
(pending/partial/paid/overdue), financeEntryId (link to last payment).
- Indexes on (tenantId, archived) for cards and (tenantId, cardId) +
(tenantId, status, dueDate) for statements.
Server (lib/appwrite/credit-card-actions.ts):
- create/update/archive(toggle)/delete for cards. Card delete cascades
through statements + their finance_entries.
- createStatementAction: computes status from dueDate + paidAmount.
- payStatementAction: partial-payment friendly. Creates a single
finance_entry expense for the pay amount, capped at remaining balance,
bankAccountId carried from the card. Recomputes status: paid (full),
partial (some + pre-due), overdue (past due with anything < total).
- deleteStatementAction: removes linked finance_entry too.
- All audit-logged.
UI (/finance/cards):
- 3 stat cards: aktif kart sayısı, bekleyen toplam, vadesi geçmiş ekstre.
- Per-card panel: bank/name/last4, limit + statement/due day + monthly
interest, current outstanding. Statement table inside card with status
badges, Öde button (opens partial-payment dialog), delete button.
- CardFormSheet for card CRUD, StatementFormSheet for statement creation
with default period/dates derived from card's statementDay/dueDay.
Sidebar Finans submenu now functional: Banka hesapları → /finance/banks,
Krediler → /finance/loans, Kredi kartları → /finance/cards.