fix(reports): foot subtotals by calculation weight, not a plain sum - #1304
Merged
Conversation
_check_totals_foot summed presentation children with no regard to balance type, so a debit-nature child under a credit-nature subtotal (interest expense under Nonoperating Income, a contra under Revenues, accumulated depreciation under PP&E net) was counted with the wrong sign and the check reported a difference on a subtotal the calc DAG had computed correctly — on Harbinger's FY2025 income statement, 7,511.40, exactly twice the 3,755.70 interest expense. Income-statement and balance-sheet rows are natural-signed per element, so a child whose balance type differs from its parent's now enters with weight -1 — XBRL's own calculation-weight rule. Cash-flow rows are cash-effect signed and foot as a plain sum by construction, so that validator keeps the plain sum. Warning-only either way; passed/status unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_check_totals_footsummed a subtotal's presentation children with no regard to balance type. A debit-nature child under a credit-nature subtotal — interest expense under Nonoperating Income, a contra under Revenues, accumulated depreciation under PP&E net — was counted with the wrong sign, and the check reported a "difference" on a subtotal the calc DAG had computed correctly. Surfaced the moment #1303 started naming columns: on Harbinger's FY2025 income statement,[2025-12-31] Subtotal 'Nonoperating Income (Expense)' (-4484.45) does not match sum of children (3026.95), difference: 7511.40— exactly 2 × the 3,755.70 interest expense. The subtotal was right; the check was wrong.Change
_child_weight)._derive_cash_flow_facts/_reconcile_operating_to_cashand foot as a plain sum by construction, so_validate_cash_flowpassessign_by_balance=False.passed/statusare unaffected.Tests
Five new cases in
test_guard_rails.py::TestTotalsFoot: the Harbinger FY2025 nonoperating section verbatim (no warning), the same shape with a genuinely wrong subtotal (one warning, right numbers), contra-revenue under Revenues, accumulated depreciation under PP&E net, and Harbinger's July 2026 operating section footing as a plain sum on the cash flow.just test-codeclean;tests/operations,tests/routers/extensions,tests/middleware/mcp— 4,986 passed.