Skip to content

Double entry accounting milestone 5 - #84

Merged
chongfun merged 2 commits into
double_entry_accounting_milestone_4from
double_entry_accounting_milestone_5
Aug 24, 2026
Merged

Double entry accounting milestone 5#84
chongfun merged 2 commits into
double_entry_accounting_milestone_4from
double_entry_accounting_milestone_5

Conversation

@chongfun

Copy link
Copy Markdown
Owner

Turn Expense into an immutable posted financial source event.

After this milestone:

Expense
├── property
├── rentable_unit optional
├── expense_kind
├── amount_cents
├── paid_on
├── vendor_name
├── external_reference
├── description
└── lifecycle
      │
      ▼
JournalEntry
├── Dr mapped Expense account
└── Cr Cash

A reimbursement remains a separate event:

Expense
    │
    ├── Charge(reimbursement) -> Tenancy A
    └── Charge(reimbursement) -> Tenancy B

so:

$300 utility Expense
    Dr Utilities Expense     300
    Cr Cash                  300

$150 reimbursement Charge A
    Dr Tenant Receivable     150
    Cr Reimbursement Income  150

$150 reimbursement Charge B
    Dr Tenant Receivable     150
    Cr Reimbursement Income  150

produces exactly:

1 Expense
2 Charges
3 JournalEntries
6 Postings

@chongfun chongfun self-assigned this Aug 17, 2026
…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
chongfun force-pushed the double_entry_accounting_milestone_5 branch from 0fbf816 to c8ef16e Compare August 21, 2026 06:03
@chongfun
chongfun merged commit 71602b6 into main Aug 24, 2026
5 checks passed
@chongfun
chongfun deleted the double_entry_accounting_milestone_5 branch August 24, 2026 00:59
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