fix(reports/cartes): Budget Adherence card filtered out all expense categories #113
No reviewers
Labels
No labels
source:analyste
source:defenseur
source:human
source:medic
status:approved
status:blocked
status:in-progress
status:needs-fix
status:ready
status:review
status:triage
type:bug
type:feature
type:infra
type:refactor
type:schema
type:security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: maximus/Simpl-Resultat#113
Loading…
Reference in a new issue
No description provided.
Delete branch "issue-112-budget-adherence-signed-fix"
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?
Fixes #112
What
The Cartes budget-adherence card was always telling the user "no budgeted categories this month" even when they had set budgets on expense categories. The filter
r.monthBudget > 0was rejecting every expense row becausebudgetServicesigns expense budgets as negative.Fix
Route every adherence computation through
Math.abs():Math.abs(r.monthBudget) > 0instead ofr.monthBudget > 0Math.abs(r.monthActual) <= Math.abs(r.monthBudget)actualandbudgetboth absolute before computingoverrunAbs/overrunPctbudgetfield returned onworstOverrunsentries is now the absolute value (was previously signed)Added an explanatory code comment on the signed-value pitfall so this doesn't get reintroduced.
Test
New regression test in
reportService.cartes.test.tsthat:categoriesTotal = 2,categoriesInTarget = 1, exactly oneworstOverrunsentryactual = 350,budget = 200,overrunAbs = 150,overrunPct ≈ 75This test fails on
main(withAssertionError: expected 0 to be 2) and passes after the fix — confirming the bug was reproducible and is now resolved.Verification
npm test -- --run: 122/122 passing (+1 regression test)npm run build: green[Unreleased] > Fixed