784c221f995749852d58a56aaa4bd717a34d3f02
Re-keying alone could not undo an existing shared charge. It handed the single entity to whichever client was looked at first and left the other order pointing at a charge it does not own. Because :sales-order/charges is a component attribute, that is not untidy but dangerous: retracting either order deletes a charge the other still needs. It also produced double tender when the second client re-imported and created its own. split-and-rekey-charges! now gives every order its own charge. The first order to claim a shared charge keeps it, re-keyed to that order's client and location; every other order gets a copy carrying the same amounts, scoped to itself, with its reference repointed. Afterwards no charge has more than one parent order and the component relationship means what it says. charges-with-multiple-parents is the §3.3 gate, which must read zero before any historical cleanup or voided-order retraction is safe. Four tests cover it: that the shared condition exists to begin with, that the split produces two distinct entities with amounts copied and one parent each, that an unshared charge is only re-keyed, and that re-running changes nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Description
No description provided
Languages
Clojure
91%
CSS
4.2%
Sass
2.3%
HTML
1.2%
HCL
0.4%
Other
0.7%