Skip to content

Unify From/To columns into Account + Counterparty + signed Amount#129

Draft
kramerc wants to merge 1 commit into
mainfrom
unify-from-to-columns
Draft

Unify From/To columns into Account + Counterparty + signed Amount#129
kramerc wants to merge 1 commit into
mainfrom
unify-from-to-columns

Conversation

@kramerc

@kramerc kramerc commented Apr 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the From/To selects on the transactions table and inline form with Account (anchor), Counterparty, and a single signed Amount field.
  • On account-scoped views (/accounts/:id/transactions) the anchor is implicit; the form drops a field. On the unfiltered view, an explicit Account column appears alongside Counterparty.
  • Direction is inferred from the amount's sign: -5.00 = outflow (anchor as src), 5.00 = inflow (anchor as dest). The sign is stripped before reaching the model — amount_minor stays positive.

Status

Draft / shelved. Open question: "Counterparty" is finance jargon and feels off for category-like accounts (Groceries, Salary). No replacement landed on yet — leaving as-is for now.

Test plan

  • bin/rails test — model tests for anchor_account / counterparty_account / signed_amount_minor_for across all five transaction kinds plus an asset↔asset transfer; controller tests for negative/positive amount translation on POST and PATCH; JSON API still works with src/dest directly.
  • bin/rails test:system — header layout (scoped vs unfiltered), signed-amount class on both perspectives, inline create on both views with negative + positive amounts.
  • bin/rubocop clean.
  • bin/brakeman clean.
  • Manual UI dogfooding (deferred — system tests cover the JS + CSS path via Capybara/Selenium; visual pass still worth doing before unshelving).

🤖 Generated with Claude Code

Replaces the From/To selects on the transactions table and inline form
with an anchor account, a counterparty, and a single signed Amount field.
On account-scoped views (/accounts/:id/transactions) the anchor is
implicit (= the viewed account), so the form drops a field. On the
unfiltered view an explicit Account column appears alongside Counterparty.

Direction is inferred from the amount's sign: negative = outflow (anchor
as src), zero/positive/blank = inflow (anchor as dest). The sign is
stripped before reaching the model — amount_minor stays positive — so
double-entry semantics are unchanged.

Adds Transaction#anchor_account / counterparty_account /
signed_amount_minor_for(account), helper methods for form pre-fill, and
a translate_form_params step in TransactionsController. JSON API still
accepts src_account_id / dest_account_id directly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.18750% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
app/helpers/transactions_helper.rb 86.20% 4 Missing ⚠️
app/controllers/transactions_controller.rb 95.65% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Simplify selecting payee (expense) and payer (revenue) on transactions

1 participant