Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
Rentals accounting fixes (from the 2026-10-07 end-to-end check)
Source: .ai/runs/2026-10-07-rentals-accounting-e2e.md, findings 1–5.
1. Early-return credits become credit memos
Problem. An early-return credit is a negative Rental line. When an invoice nets
negative, it cannot be applied to another invoice or refunded, because
invoiceSettlementBase.appliedAmount is non-negative and refunds only target memos.
Design. Follow the contract-cancellation precedent (post-customer-contract
cancel → a Draft credit memo with customerContractId; post-memo posts contract
legs).
- Schema (one migration).
memo.rentalAgreementId: composite FK torentalAgreement.rentalBillingPeriod.memoId: the credit memo that bills an adjustment row. It is exclusive withsalesInvoiceLineId.revenueRecognitionSchedule.memoId: the negative Deferral rows a memo wrote.- Run
generate:typesafterwards. Add backup manifest entries if required.
create-rental-invoices. AnisAdjustmentperiod never goes on an invoice.- All of an agreement's due adjustments go on one Draft credit memo, amount =
Σ credits at currency decimals. The periods are stamped
memoIdand set toInvoiced. - The memo stays Draft for review. Early-return credits are already held today, so this keeps that behaviour.
planRentalInvoicesloses the early-return hold.
- All of an agreement's due adjustments go on one Draft credit memo, amount =
Σ credits at currency decimals. The periods are stamped
post-memo. Add a rental branch next to the contract branch.- For each adjustment period, reuse
planRentalLineandrentalScheduleRows(move them tosrc/lib/sopost-sales-invoiceandpost-memoshare them). - Legs: Dr Deferred Revenue up to the period's Planned Deferral rows, the rest Dr Rental Income, Cr AR. These legs replace the generic reason leg.
- Write the negative Deferral rows with
memoId.
- For each adjustment period, reuse
- Void a posted rental memo.
- Allowed only while none of its Deferral rows is Posted or claimed by a Draft run, and nothing has applied or refunded the memo (the existing consumed-memo guard).
- It reverses the journal, deletes its Planned rows and returns the periods to
PendingwithmemoIdcleared, so the next run re-credits them. - Otherwise it is refused, as a contract credit is.
- Delete a Draft memo. Release the stamps in the same transaction: periods go
back to
Pending. This is the counterpart ofdeleteSalesInvoiceReleasingRentals. - Kept. The legacy path, posting a negative
Rentline on an invoice, keeps working for existing drafts. - UI.
- The memo page names its rental agreement.
- The agreement's Billing Periods card links an adjustment to its memo.
- The Invoice action's flash counts memos.
- Tests.
- Pure: invoice planning, and memo legs (via the shared planner).
- Live DB: post a memo, apply it to an invoice through a payment, refund it, and void it.
2. Rental amounts at settlement precision (done)
rateCharge,calendarMonthCharge,periodCharge,generateRentalBillingPeriodsandleasePaymentTermstakedecimals, the agreement currency'sdecimalPlaces.- Every caller passes it:
post-rental-agreementactivate and return,create-rental-invoicesroll-forward, and the ERP preview throughuseCurrencyDecimals.
3. A sales-type unit cannot start before the activation month
salesTypeRequirementError gains today. It refuses a Sale line whose agreement
startDate is before the first of the current month, in the company timezone.
- Activation runs the check.
RentalCommencementPreviewshows it in Review and in the Activate confirmation, viauseCompanyToday.
Dating commencement at the start date instead was rejected. Depreciation for the months in between would already have posted on an asset the lease had sold.
4. Warning when net investment exceeds fair value
- Pure helper
netInvestmentExceedsFairValue(pv, fairValue)inlessor-lease. - The warning is shown on the unit's Accounting treatment panel and in
RentalCommencementPreview. - It is a warning only; activation is not refused.
- Copy: "Discounted at X%, the payments and residual are worth more than the unit's fair value. A lease is valued at the rate implicit in it — raise the discount rate or check the fair value."
5. Deposits fund only their own document
- Allocator.
FundingSourcegains an optional scope:rentalAgreementId(andsalesOrderId).FundingRequestgains the agreement ids (and sales order ids) its target invoice bills.allocatePaymentFundingskips a source outside a request's scope. This requires a per-source cursor instead of one shared one. - Current payment. A deposit Receipt's own cash may only be applied to its document's invoices.
- Callers. The scope is threaded through
replaceInvoiceSettlements,post-payment(re-derivation),loadOnAccountSources, and thePaymentApplyTablepreview. The open-invoice list carries each invoice's agreement ids. - Tests. Allocator unit tests, plus one live
post-paymenttest.
Order
- Finish item 2's tests (lessor, sales.utils).
- Item 3.
- Item 4.
- Item 5.
- Item 1.
Re-run the end-to-end scenario at the end.
Status
All five items implemented and verified 2026-10-07; see the run log.