Double entry accounting milestone 5 - #84
Merged
chongfun merged 2 commits intoAug 24, 2026
Merged
Conversation
…rections
Transition the Expense model to integer cents, ledger-backed double-entry
accounting, and unit scoping. Replace destructive edits/deletions with
ledger-reversing correction and void lifecycles for both expenses and charges.
Key Changes:
- Expense Model & Schema:
- Migrate amount to amount_cents with virtual decimal accessors.
- Add optional rentable_unit_id for unit-scoped expense tracking.
- Add posted_at, voided_at, and superseded_by_id lifecycle columns.
- Add immutability guards prohibiting direct in-place mutation of posted records.
- Double-Entry Expense Posting & Chart of Accounts:
- Add Expenses::CreateService and Expenses::PostService mapping 15 expense categories
to dedicated Chart of Accounts keys (debit Expense, credit Cash/Accounts Payable).
- Provision Milestone 5 expense accounts (auto/travel, commissions, mortgage interest,
other interest) for existing users via migration.
- Expense & Charge Corrections and Voids:
- Implement Expenses::CorrectService and Expenses::VoidService reversing ledger entries
at expense.paid_on with idempotency and audit trails.
- Implement Charges::CorrectService and Charges::VoidService reversing ledger entries
with strict idempotency checks, distinguishing period-event voids from historical restatements.
- Automatically restate active reimbursement charges onto replacement expenses during
expense corrections at their original charge dates, eliminating historical balance doubling.
- Enforce consistent global lock hierarchy (source Expense -> Charge) across all
reimbursement creations, corrections, and voids to prevent race conditions.
- UI, Reporting & Test Coverage:
- Replace expense edit/delete views with correction workflows, dynamic Stimulus unit
filtering, and audit trail presentation.
- Update Schedule E report generator and financial queries to pull from double-entry postings.
- Add comprehensive unit, request, concurrency, and system specs (972 examples, 0 failures,
98.16% line coverage, 91.68% branch coverage).
chongfun
force-pushed
the
double_entry_accounting_milestone_5
branch
from
August 21, 2026 06:03
0fbf816 to
c8ef16e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turn
Expenseinto an immutable posted financial source event.After this milestone:
A reimbursement remains a separate event:
so:
produces exactly: