Imported payments don't update debt balance (balance_delta always NULL) #49
Labels
No Label
architecture
backend
bug
feature
frontend
priority:critical
priority:high
priority:low
priority:medium
priority:nice-to-have
ux
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: null/BillTracker#49
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: CRITICAL 🔴
Affected Files
services/spreadsheetImportService.js—createPaymentFromImport()andimportRelatedPaidMonthsForNewBill()routes/bills.js— import-related payment creation pathsclient/pages/SnowballPage.jsx— projection reads balance_deltaProblem
Every payment creation path except spreadsheet import correctly computes and stores
balance_deltathen updates the bill'scurrent_balance:toggle-paid→ callscomputeBalanceDelta()→ updatescurrent_balancequick-pay→ callscomputeBalanceDelta()→ updatescurrent_balancebulk-pay→ callscomputeBalanceDelta()→ updatescurrent_balancerestore→ checksbalance_delta IS NOT NULL→ reverses correctlyBut imported payments:
INSERT INTO paymentsnever includesbalance_deltacomputeBalanceDelta()or updatescurrent_balanceImpact
balance_delta IS NULLand silently skips the balance reversal, so the debt balance never recovers.Root Cause
spreadsheetImportService.jsline ~1439 creates payment rows with:No
balance_deltacolumn. No call tocomputeBalanceDelta(). Nocurrent_balanceupdate on the parent bill.Fix
computeBalanceDelta()logic used by all other payment paths.current_balanceusing the delta.balance_delta = 0correctly (not just NULL checks).Acceptance Criteria
balance_deltacorrectlycurrent_balanceis updated after import