Skip to content

feat: Implement Split Transactions#139

Merged
hendripermana merged 1 commit into
mainfrom
feature/split-transactions
May 24, 2026
Merged

feat: Implement Split Transactions#139
hendripermana merged 1 commit into
mainfrom
feature/split-transactions

Conversation

@hendripermana
Copy link
Copy Markdown
Owner

Summary

Implements split transactions feature, allowing users to break a single transaction into multiple categorized sub-entries while maintaining the original total amount.

Changes

Database

  • Migration: Added parent_entry_id column to entries table with foreign key and index

Models

  • Entry: Added split!, unsplit!, update_parent_from_splits! methods, split_children/parent_entry associations, validations for split integrity
  • Transaction: Added splittable? helper
  • User: Added split_transaction/unsplit_transaction permission methods

Controllers

  • SplitsController: Full CRUD for split entries (new, create, edit, update, destroy)
  • TransactionsController: Added split/unsplit actions

Views

  • Split creation and editing forms with dynamic row management
  • Split group display partial for transaction detail view
  • Parent row indicator in transaction list
  • Updated transaction show page with split details

JavaScript

  • split_transaction_controller.js: Stimulus controller for dynamic split form management (add/remove rows, real-time validation, amount distribution)

Tests

  • entry_split_test.rb: 15 model tests covering split creation, validation, amount integrity, and edge cases
  • splits_controller_test.rb: 17 controller tests covering CRUD operations, authorization, and error handling

Security

  • ✅ Brakeman scan: Clean
  • ✅ RuboCop: Compliant
  • ✅ All tests passing

How to Test

  1. Run migration: bin/rails db:migrate
  2. Navigate to any transaction detail page
  3. Click "Split Transaction" to create sub-entries
  4. Verify amounts must sum to the original total
  5. Test unsplit to restore the original transaction

- Add parent_entry_id column to entries table for parent-child relationships
- Add SplitsController with new, create, edit, update, destroy actions
- Add Stimulus split_transaction_controller for dynamic form management
- Add views: split creation/editing forms, split group display, parent row
- Update transaction views to show split indicators and child entries
- Add TransactionsController#split and #unsplit actions
- Add EntriesHelper for split-related view helpers
- Add comprehensive model tests (entry_split_test.rb)
- Add comprehensive controller tests (splits_controller_test.rb)
- Security: Brakeman clean, RuboCop compliant
@hendripermana hendripermana merged commit f183910 into main May 24, 2026
5 checks passed
@hendripermana hendripermana deleted the feature/split-transactions branch May 24, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant