fix(reconcile): fill earliest month deficit first in multi-month allocations #35
Reference in New Issue
Block a user
Delete Branch "fix/fill-first-multi-month-allocation"
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?
What
Multi-month payment allocation was splitting each transaction proportionally across matched months based on total expected fees, ignoring what prior transactions had already paid into those months.
Surfaced by: Matyáš Thér paid 200 CZK (for 2026-02) then 550 CZK (for 2026-02 + 2026-03). The 550 was being split 366.67/183.33 by the proportional formula instead of filling 2026-02's remaining deficit (300) and spilling 250 into 2026-03. Result: 566/183 instead of the correct 500/250.
Fix
Replace the greedy + proportional branches in both Python and Go reconcilers with a single fill-first loop:
alloc = min(remaining, max(0, expected − paid_so_far)).Files
scripts/match_payments.py— Python reconciler (canonical)go/internal/domain/reconcile/reconcile.go— Go reconciler