Add RejectedTransfer model, simplify auto matching #1690
Reference in New Issue
Block a user
Delete Branch "1661-allow-auto-matched-transfers-to-have-an-inflow-that-occurs-before-outflow"
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?
This PR addresses and fixes #1630 and #1661 along with a few other simplifications.
Rejected transfers
Previously, the
Transfermodel had 3 possible status codes:approved,pending, andrejected.The
rejectedstatus introduced a large group of edge cases that made the UI, auto matching logic, and overall transfer domain more confusing:Transferrecords since a user could reject one and then add the same transaction to another. This made it sotransaction.transfer?needed to query ahas_manyrelationship to decide whether a transaction was part of a confirmed transfer.The sole reason we had this status was to keep track of transaction pairs that the user had explicitly rejected to avoid auto-matching them again. Adding
RejectedTransferdrastically simplifies the required domain logic while giving us a simple way to "remember" which transfers have been rejected by the user already.Auto matching validation updates
Transferrecords with the same transaction in both, leaving the user with a confusing matching approve/reject scenarioConsolidation of auto-matching logic
Previously, there were 2 places in the codebase we were duplicating the "auto matching" conditions:
Transfer.auto_match_for_accountentry.transfer_match_candidatesThis created a brittle scenario where a user was able to manually match transactions based on a different criteria than we were matching during account syncs. This logic is now consolidated into a scope of
account.transfer_match_candidateswhich is consumed by bothaccount.auto_match_transfers!andentry.transfer_match_candidates.