Match split parts as transfers and refuse the split parent
NI
11d ago+206+206+012345678901234567890123456789-34-34-01234567890123456789
A split part can be linked as a transfer through the category menu and the "set as transfer" rule, but the transaction drawer doesn't offer it and Transfer::Matcher (assistant, MCP) refuses it. The drawer does offer it on the split parent. Its amount is already in the parts, so linking both the parent and a part reduces a loan twice for one payment.
Now:
- The drawer offers the transfer matcher on a split part that has no transfer yet, and no longer on the parent.
Transfer::Matcheraccepts a split part, lists it as a candidate and still refuses the parent.- The match dialog refuses a split parent on either side.
- Splitting a transaction removes a pending transfer suggestion on it and syncs both accounts. The suggestion pairs the whole amount, and confirming it later would link the parent.
Entry#split_once!locks the transfer before the transaction, the orderTransfer#confirm!andTransfer#destroy!use.
Not in this PR:
- Splitting a payment that is already linked, the other half of #4784: unlink it first.
- A suggestion that carries a fee stays when its transaction is split, as today: destroying it would delete the fee.
- Existing data: a split parent that is already linked stays linked, and a suggestion left on an existing split can still be confirmed.
Validation
- New tests for the matcher, the match dialog, the drawer and
split_once!, including a race ofsplit_once!againstconfirm!. Without the transfer lock that race deadlocked in 5 of 5 runs. bin/rails test: 19,259 runs, 0 failures.- System tests for splits, transfers, transactions and bulk transfers: 35 runs, 0 failures.
- RuboCop, ERB lint and Brakeman are clean.
Summary by cubic
Allows matching a split part as a transfer and refuses the split parent, so a loan payment isn't reduced twice when both the parent and a part are linked.
- The drawer offers the transfer matcher on a split part without a transfer, and no longer on the parent.
Transfer::Matcheraccepts a split part and lists it as a candidate; the parent is still refused.- The match dialog refuses a split parent on either side.
- Splitting a transaction removes a pending transfer suggestion on the whole amount and syncs both accounts; suggestions with fees are kept.
split_once!locks transfers before the transaction to prevent a race withconfirm!.
Summary by CodeRabbit
- New Features
- Match individual parts of a split transaction to transfers, including loan payments. Split parent transactions cannot be matched; a message explains that users should match a part instead.
- Bug Fixes
- Transfer-matching and related settings actions are shown only where applicable for split transactions.
- When splitting a transaction, a pending suggested transfer without a fee is removed and the affected account is synced. Transfers with fees remain intact.
- Improved handling of concurrent splitting and transfer confirmation.