Skip to content

Double entry accounting milestone 3 - #82

Merged
chongfun merged 2 commits into
double_entry_accounting_milestone_2from
double_entry_accounting_milestone_3
Aug 24, 2026
Merged

Double entry accounting milestone 3#82
chongfun merged 2 commits into
double_entry_accounting_milestone_2from
double_entry_accounting_milestone_3

Conversation

@chongfun

Copy link
Copy Markdown
Owner

Implement Milestone 3 of the Rental Domain and Double-Entry Accounting Architecture.

At the end of this milestone:

RentTerm
    │
    ▼
Charge(kind: rent)
    │
    ▼
JournalEntry
    ├── Dr Tenant Receivable
    └── Cr Rental Income

and:

Charge(kind: late_fee)
    │
    ▼
JournalEntry
    ├── Dr Tenant Receivable
    └── Cr Late Fee Income

and:

Expense
    │
    ▼
Charge(kind: reimbursement)
    │
    ▼
JournalEntry
    ├── Dr Tenant Receivable
    └── Cr Reimbursement Income

must all work through the accounting foundation established in Milestone 2.

ScheduledRent and TenantCharge must be removed.

Tenancy balance must become:

sum(
  Tenant Receivable postings
  for this tenancy
  through the requested accounting date
)

rather than a reconstruction from domain tables.

@chongfun chongfun self-assigned this Aug 16, 2026
…cked balances

- Introduce the unified Charge model replacing ScheduledRent and TenantCharge:
  - Add kind enum ('rent', 'late_fee', 'utility', 'reimbursement', 'other')
  - Enforce positive amount_cents, service period validations, and posting immutability
  - Add partial unique index on [tenancy_id, service_period_start] for active rent charges
- Implement charge accounting and lifecycle services:
  - Add other_tenant_income to Accounting::ChartOfAccounts
  - Implement Charges::PostService (Dr Tenant Receivable / Cr Income Account)
  - Implement Charges::CreateService, Charges::CreateFeeService, and Charges::CreateReimbursementService
  - Implement Charges::VoidService using Accounting::ReverseEntryService
- Automate rent charge generation:
  - Implement RentCharges::GenerateService and RentCharges::GenerateThroughService
  - Add GenerateDueRentChargesJob on daily Solid Queue schedule in config/recurring.yml
  - Hook generation into Tenancies::CreateService and RentTerms::ChangeService
  - Add retroactive change protection and month-start constraints in RentTerms::ChangeService
  - Add active charge protection in Tenancies::UpdateService
- Replace and remove ScheduledRent and TenantCharge tables, models, controllers, views, and specs
- Implement transitional payment bridge in TenantPayments::CreateService (Dr Cash / Cr Tenant Receivable)
- Rewrite Tenancies::BalanceQuery to calculate balances strictly from ledger postings
- Update UI views and partials to follow standard double-entry sign conventions
@chongfun
chongfun force-pushed the double_entry_accounting_milestone_3 branch from 4c880f0 to 7c1504a Compare August 21, 2026 06:03
@chongfun
chongfun merged commit c6b143d into main Aug 24, 2026
5 checks passed
@chongfun
chongfun deleted the double_entry_accounting_milestone_3 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