feat: activate draft leases into rent dues (#28)

This commit is contained in:
nessar committed 2026-08-17 14:18:15 +02:00
1 parent 971ffd6feb
commit c2afe515c0
42 files changed
+1735 -113

No files matched your search

@@ -3,3 +3,7 @@
**Status**: accepted
Within Rental Management, `Lease` owns its contractual lifecycle, dates, rent terms, and lease-party relationships while referencing independent `Apartment` and `Tenant` aggregates by ID. Activation freezes the landlord identity and address, apartment address, tenant identities and addresses, guarantors, and financial terms; later changes are effective-dated immutable `LeaseAmendment` records that preserve both contract versions and may only recalculate future unpaid dues. `RentDue` and `RentPayment` are independent aggregates; a positive payment owns allocations whose sum cannot exceed the amount received, each allocation cannot exceed its due's remaining balance, and one payment may cover multiple dues only within the same lease. Any surplus stays unallocated. `Guarantor` remains internal to `Lease` until it gains an independent lifecycle or must be shared across leases.
A new `Lease` is always a mutable, permanently deletable `DRAFT`; draft overlap is allowed and creates no dues. Explicit activation rejects inclusive overlap with active or archived leases for the same apartment, then creates one uniquely constrained `RentDue` per occupied calendar month. Boundary months prorate rent and charges by occupied calendar days, while settlement and due-date timing remain independent facts on the due.
Until Mongo transactions replace the single-instance lock, activation retries reconcile any dues left by a failed draft activation and draft dues remain hidden from queries.