Add split_transaction rule action
Merged
GF
1mo ago+3222+3222+0123456789012345678901234567890123456789-459-459-012345678901234567890123456789
Summary
Adds a new rule action (split_transaction) that automatically splits matching transactions into multiple entries, closing the gap where recurring transactions (shared subscriptions, bundled charges) had to be split manually every time via the existing split dialog.
- Supports two modes: fixed amount per split row, or percentage of the transaction total
- Each split row can optionally set a category, merchant, and tags
- Reuses
Entry#split!for the actual split (extended to accept an optional per-split merchant/tags override, falling back to the parent's merchant / no tags as before) - Fixed-amount mode requires an exact
Amount =condition on the rule, since the configured shares can only reliably sum to a known total — enforced both at save time and defensively per-transaction at apply time, so a single mismatched match is skipped rather than corrupting data or failing the whole rule run - Category/merchant/tag ids are re-validated against the current family at apply time (not just trusted from the saved config), in case something was deleted after the rule was created
- Split rows are real, individually-named form fields (not a JS-serialized blob), so the browser's native form submission is the source of truth
Test plan
-
bin/rails test(full suite passes; only pre-existing, unrelated failures on this reviewer's local test-stack config were observed, not present in CI) -
bin/rubocop -f github -a -
bundle exec erb_lint ./app/**/*.erb -a -
bin/brakeman --no-pager(0 warnings) - Manually verified in the browser: creating a rule with a fixed-amount split (with and without a matching
Amount =condition), a percentage split, adding/removing split rows, and applying the rule to real transactions
🤖 Generated with Claude Code
Summary by CodeRabbit
- New Features
- Added rule actions that split matching transactions into fixed amounts, percentages, or a combination, with category, merchant, and tag options for each split.
- Added live split-total feedback and controls for adding or removing rows.
- Split transactions can now have individual merchants and tags; a child without a specified merchant inherits the original transaction’s merchant.
- Split details are supported when importing and exporting rules.
- Bug Fixes
- Prevented concurrent rule actions from splitting the same transaction more than once.