fix(reports): a zero credit balance renders as $0.00, not -$0.00 - #1306
Conversation
_natural_sign negates credit-normal balances, so an account whose debits exactly equal its credits came out as -0.0 — equal to zero everywhere except the formatter, which printed "-$0.00" for Accounts Payable on a live balance sheet. Return an unsigned zero from the sign flip, and normalize -0.0 where rows leave the renderer so no other sign-flipping path can reintroduce it.
|
@claude please review this PR |
|
Claude finished @jfrench9's task in 2m 54s —— View job Review: fix(reports) — negative-zero credit balances
Summary: Small, well-targeted fix. I verified the fix is sound:
Minor, non-blocking observations:
Nothing here blocks merging — the fix correctly resolves the reported Note: I wasn't able to execute |
Summary
On a live balance sheet,
Accounts Payable, Currentrendered as −$0.00 when the account's debits exactly equalled its credits. The value leaving the API was a literal-0.0:_natural_signnegates credit-normal balances, and-(0.0)is-0.0— equal to zero for every comparison and filter in the renderer, but formatted with a sign by the app. Subtotals happened to come out clean because their rollup starts from an integer accumulator; leaf rows carried the raw value through.Changes
operations/roboledger/reports/fact_grid.py_natural_signreturns an unsigned0.0for a zero credit balance instead of negating it._unsigned_zeroapplied where rows leave_build_rows, so no other sign-flipping path (cash-flow deltas, equity reducers) can reintroduce-0.0on a rendered row.tests/operations/roboledger/reports/test_fact_grid.py— two regressions that check the sign withmath.copysign(the existingtest_zeropassed on-0.0, since-0.0 == 0.0): the helper directly, and a_build_rowscase with a zero-balance credit leaf that stays visible because its prior period is non-zero — the exact shape seen on prod.Breaking Changes
None. Response shapes are unchanged; only a signed zero becomes an unsigned zero.
Testing
just test— full unit suite: 14,193 passed, 42 skipped (223 in the reports/reads modules specifically).just test-code— clean; re-run by the pre-commit hook.live-financial-statement(balance sheet, YTD) on the Harbinger ledger returned"values": [-0.0, 195.94]for AP before the fix.Certification