Make export() idempotent instead of duplicating payments - #83
Open
VaibhavRaina wants to merge 1 commit into
Open
Make export() idempotent instead of duplicating payments#83VaibhavRaina wants to merge 1 commit into
VaibhavRaina wants to merge 1 commit into
Conversation
Calling export() twice on the same SepaTransfer or SepaDD doubled the transaction count and control sums, because _finalize_batch() appended the batch nodes to the live document on every call. This bites anyone who exports once to validate or preview and again to write the file. Finalize a copy of the document instead, so repeated exports (including after adding more payments) always reflect exactly the payments that were added. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PtpcFAThUxrGAyCyxiiEC5
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.
Problem
Calling
export()more than once on the sameSepaTransfer/SepaDDduplicates the payments._finalize_batch()appends the batchPmtInfnodes to the live document on every call, so the second export reports twice the transaction count and control sum, and the third export three times. This bites the common flow of exporting once to validate or preview and once more to write the file.Fix
export()now finalizes a copy of the document and serializes that, leaving the original untouched. Repeated exports return the same output, and payments added between exports are included exactly once. Single-export behaviour and output are unchanged (the existing fixture tests still pass byte-for-byte).Tests
tests/test_repeated_export.py, parametrized overSepaTransfer/SepaDDand batch/non-batch, checking the group header totals, per-PmtInftotals and transaction count across three consecutive exports and after adding a payment.pytest(64 passed),flake8andisort -care clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01PtpcFAThUxrGAyCyxiiEC5