fix(backend): set Remittance.claim_id symmetrically in reconcile.run

T12's list_unmatched filters Remittance by claim_id IS NULL. T10's
reconcile.run was only setting Claim.matched_remittance_id, leaving
auto-matched remits visible in the orphan bucket. Mirror the FK on
both sides so both list_unmatched filters produce consistent results.

T12 implementer flagged this as out-of-scope; addressed here as a
small follow-up so the Reconciliation page works correctly end-to-end.
This commit is contained in:
Tyler
2026-06-19 23:28:17 -06:00
parent aa7cd7654d
commit 3318c9418a
+4
View File
@@ -287,6 +287,10 @@ def run(session, batch_id: str) -> ReconcileResult:
else:
m.claim.state = ClaimState.REVERSED
m.claim.matched_remittance_id = m.remittance.id
# Symmetric FK: also set Remittance.claim_id so list_unmatched (which
# filters on Remittance.claim_id IS NULL) correctly drops auto-matched
# remits from the orphan bucket. Manual matches do this too.
m.remittance.claim_id = m.claim.id
session.add(ActivityEvent(
ts=datetime.now(timezone.utc), kind=intent.activity_kind,