[Disbursement] Use associations from lenses to find CTs and CPTs - #14592
Open
Luke-Oldenburg wants to merge 8 commits into
Open
[Disbursement] Use associations from lenses to find CTs and CPTs#14592Luke-Oldenburg wants to merge 8 commits into
Luke-Oldenburg wants to merge 8 commits into
Conversation
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Disbursement#canonical_transactions/#canonical_pending_transactions now match by Ledger::Item#linked_object instead of hcb_code, but that data was only ever set by an after_create_commit callback chain (CT/CPT#assign_ledger_item -> Ledger::Item#assign_linked_object!), so it wasn't visible until the enclosing transaction committed. Real callers (Disbursement#mark_approved!, CardGrant#topup!/withdraw!/transfer_money) query it earlier, still inside that same transaction, so the query always saw zero rows and card grant balances silently computed as 0. Make CT/CPT#assign_ledger_item run on after_create (ordered after write_hcb_code, which it depends on via local_hcb_code) instead of after_create_commit, and have it call the now-public Ledger::Item#assign_linked_object! synchronously right after wiring up a freshly created ledger item. The original after_create_commit callback on Ledger::Item stays as a defensive, idempotent fallback. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…reate" This reverts commit da5ad80.
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 of the problem
Describe your changes