[BTAPI-73] Fix Wealthsimple sync flip-flop on settling transactions #90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bug/BTAPI-73"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ticket
BTAPI-73 Wealthsimple sync flip-flops a settling transaction's amount, sending duplicate revision pushes
Summary
wsIdactivities within a single fetch before the upsert loop, preferring the settled node over a pending duplicate (and the lateroccurredAtwhen both agree on pendingness) — this is the fix for the actual bug: two coexisting feed nodes for one purchase no longer let "whichever is later in array order" decide the stored amount/pending flag.wsId,canonicalId,status,amount,merchantfor both the kept and dropped side) to distinguish a routine pending/posted collapse from a genuine two-purchase collision, shouldderiveExternalIdever produce one.occurredAttiebreak independent of array position, a 3+-node collapse, the stale-settled-guard (now pinned againstmerchant/canonicalId/date, not justamount), and the collapse log itself.Follow-up (not part of this PR)
ws:syncCLI racing the automatic cron/doorbell engine) could theoretically still slip a stale pending activity through in the snapshot-to-write window. This would need new DB-layer conditional-update plumbing beyond this ticket's scope; documented as a known, vanishingly-unlikely residual limitation for this single-user app rather than fixed here.