[510] Add sum checks against values in financial_report_exporter - #594
Merged
Conversation
…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>
|
@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! 🚀 |
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
financial_report_exporteracceptedentrieswhose amounts did not have to equal the reportamount, so inconsistent allocations could be serialized as a valid spreadsheet.FINANCIAL_REPORT_SUM_MISMATCHand is not exported.Implementation
assertFinancialReportSplitSumvalidates every split and the base throughvalidateFinancialAmount, guards digit-limit overflow on the running total, and requiressum(splits) === base.validateFinancialReportExporterParamsandfinancial_report_exporterthrow on mismatch;exportFinancialReportreturns{ ok: false, code: SUM_MISMATCH }.entries(or passing an empty array) still emits a single total row, matching previous empty-allocation behavior.Calculation / serialization behavior
bigint); there is no floating-point tolerance.Validation
__tests__/financial_report_exporter_split_sum.test.tsfor exact match, under/over allocation, multiple splits, zero splits, empty entries, and failed async export.npm test -- --testPathPatterns=financial_report_exporter, fullnpm test,npm run lint, andnpx tsc --noEmitpassed.Reviewer notes
audit_ledger_sum_checker.Closes #510
Made with Cursor