Skip to content

[Disbursement] Use associations from lenses to find CTs and CPTs - #14592

Open
Luke-Oldenburg wants to merge 8 commits into
mainfrom
lro-disbursement-ct-cpt-use-li
Open

[Disbursement] Use associations from lenses to find CTs and CPTs#14592
Luke-Oldenburg wants to merge 8 commits into
mainfrom
lro-disbursement-ct-cpt-use-li

Conversation

@Luke-Oldenburg

Copy link
Copy Markdown
Contributor

Summary of the problem

Describe your changes

@Luke-Oldenburg
Luke-Oldenburg requested a review from a team August 12, 2026 20:45
Comment thread spec/models/disbursement_spec.rb Fixed
Comment thread spec/models/disbursement_spec.rb Fixed
Luke-Oldenburg and others added 4 commits August 12, 2026 23:35
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>
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.

1 participant