Skip to content

[510] Add sum checks against values in financial_report_exporter - #594

Merged
godamongstmen897 merged 1 commit into
Goldii-locks:mainfrom
Goodnessukaigwe:fix/510-add-sum-checks-against-values-in-financial_report_exporter
Sep 29, 2026
Merged

godamongstmen897 merged 1 commit into
Goldii-locks:mainfrom
Goodnessukaigwe:fix/510-add-sum-checks-against-values-in-financial_report_exporter

Conversation

@Goodnessukaigwe

Copy link
Copy Markdown
Contributor

Summary

  • financial_report_exporter accepted entries whose amounts did not have to equal the report amount, so inconsistent allocations could be serialized as a valid spreadsheet.
  • Split totals are now asserted against the base amount using exact bigint arithmetic. A mismatch is FINANCIAL_REPORT_SUM_MISMATCH and is not exported.

Implementation

  • assertFinancialReportSplitSum validates every split and the base through validateFinancialAmount, guards digit-limit overflow on the running total, and requires sum(splits) === base.
  • validateFinancialReportExporterParams and financial_report_exporter throw on mismatch; exportFinancialReport returns { ok: false, code: SUM_MISMATCH }.
  • Omitting entries (or passing an empty array) still emits a single total row, matching previous empty-allocation behavior.

Calculation / serialization behavior

  • Comparison is exact (bigint); there is no floating-point tolerance.
  • Under-allocation and over-allocation are both rejected.

Validation

  • Added __tests__/financial_report_exporter_split_sum.test.ts for exact match, under/over allocation, multiple splits, zero splits, empty entries, and failed async export.
  • npm test -- --testPathPatterns=financial_report_exporter, full npm test, npm run lint, and npx tsc --noEmit passed.

Reviewer notes

  • Reuses the existing exporter error-code family rather than importing the ledger checker’s split helper, so this change stays isolated from audit_ledger_sum_checker.

Closes #510

Made with Cursor

…se amount

Reconcile entry allocations against the report amount with exact bigint arithmetic so under- and over-allocation cannot be exported as a valid spreadsheet.

Co-authored-by: Cursor <cursoragent@cursor.com>
@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@Goodnessukaigwe Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@godamongstmen897
godamongstmen897 merged commit e8059f8 into Goldii-locks:main Sep 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sum checks against values in financial_report_exporter

2 participants