1058d641e78f23825ea7ce3e98f4d361828e152c
Manual verification against real data (Task 3) found balanceHistory drifted from team.balance for real teams, since team.balance carries historical adjustments (e.g. from the removed legacy backend) that don't trace back to the current payment/credit/expense rows. Forward-summing those rows from zero could never be trusted to tie out. Rewrite balanceHistory to anchor on team.balance (the authoritative current value) and walk the movements backward, newest to oldest, undoing each one to reconstruct earlier month-end balances. This guarantees the most recent point equals team.balance by construction, and is mathematically identical to the old forward sum for teams whose movements fully explain their balance. monthlyFlow/topOutstanding are unaffected and left as-is. Updated teams.service.spec.ts to use a fixture where team.balance intentionally does not equal the sum of its own movements, so the tests actually exercise the drift-handling behavior instead of a case where forward-sum and backward-anchor happen to coincide. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Description
No description provided
Languages
TypeScript
88.2%
HTML
7.1%
SCSS
3.7%
Shell
0.6%
Handlebars
0.3%
Other
0.1%