Before you start
- Create the loan product and a version first. See Define a loan product.
- To configure a chart, your role needs
loan_productwriteandaccountingwrite. The operator, editor, and admin roles hold both. - To change a chart, or to designate a suspense account, your role needs
accountingsupersede. Only the admin role holds it.
The product ledger
A chart names the Midaz organization and the Midaz ledger that the postings of the product book into.
- Under multi-tenant mode, the organization is required. Under single-tenant mode, a chart with no target falls back to the default of the environment.
- Name only the organization, and Lender reuses the ledger that the product already books into there. If the product has none, Lender finds or creates a ledger named
lender-product-<loan product id>. The response names the ledger it chose. - Every version of a product books into the ledger that the first configured version chose (
LENDER-0453). Several products can share one ledger. - Lender refuses a ledger that has route validation turned on (
LENDER-0452). Lender sends no accounting route to Midaz. - Lender refuses an organization or a ledger that Midaz does not know (
LENDER-0442). If Midaz does not answer, Lender answers503withLENDER-0441. Repeat the request.
MIDAZ_LEDGER_ACCOUNT_PROVISIONING_ENABLED is true by default. See Configuration and deploy. Lender then adopts the asset by code or creates it. It creates each account before the first posting to that account.
- The nature of a leg sets the account type. A credit nature creates a
depositaccount. A debit nature creates alender_debitaccount. - The direction of an account is fixed when the account is created.
- Lender adopts an account that already exists. It checks the direction of the account against the nature of the leg, and it refuses the posting if they differ.
<prefix>:<id>. The prefix is yours, with at most 17 characters. The id is the 32 hex digits of the loan account id. Lender creates a per-contract account for a borrower position with the CRM holder of the contract as its owner.
Anatomy of a posting rule
A posting rule maps one accounting event to 2 to 16 legs. A rule can also carry
metadata, a map of text values. Each leg moves money on one account.
Per-contract positions
A leg that books what one borrower owes must be per contract (LENDER-0408). These are the amount codes: principal, interest, fees, penalties, unapplied_cash, assignment_retained, and returned_payment. Two kinds of leg are the exception:
- A revenue or expense leg.
- The credit of
accrual_withholdingto rendas a apropriar.
origination_fee credit on disbursement and the accrual_fee_amortization debit. A shared fee account is accepted, but it blocks every write-off (LENDER-0411), and no chart change can fix it.
Some accounts are never per contract:
- The revenue tax account, because it is a liability of the institution to the tax authority (
LENDER-0419). - A revenue or an expense account (
LENDER-0987). - The counterparty account of
renegotiation_derecognitionandrenegotiation_recognition. This bridge account is one account for the product.
Example
This is thedisbursement rule of a chart. The account codes are only an illustration.
@external/<ASSET> is the account that Midaz creates for each asset. It records money that enters the ledger or leaves it. See Accounts.
Your treasury account can live in the same ledger. Then the cash leg can name it. Lender turns on negative balance only for the credit accounts it lists for that, and never for the cash account. See Balance overdraft. Midaz therefore refuses a disbursement that is larger than the balance of that account. The posting parks as a case (LENDER-0458). Keep the cash in the account.
The accounting events
A chart can carry three kinds of event: events every chart needs, optional events, and events that Lender derives.
Required events
Lender refuses a chart that lacks one of these events.
The two constitutions credit two different allowance accounts. Lender refuses a chart that credits one account for both (
LENDER-0455).
Optional events
The last column says what happens if you leave it out.
For the assignment events, see Assignment of receivables.
Events you do not configure
Lender derives these events from the rules above. A chart cannot carry them. If you send one, Lender answers422.
Checks Lender runs on your chart
Lender checks the chart when you configure it or change it. It writes nothing when a check fails.
Configuring a chart for a version that already has one answers
409 Conflict.
The Lender error list holds the full text of each code.
Read a chart back
The list shows, for each chart,
eventTypes, missingEventTypes, effectiveFrom, and createdAt. missingEventTypes names the required events for which the chart has no rule. It is empty when the chart is complete.
The read by id returns the whole chart. It has postingRules with their legs, midazOrganizationId, midazLedgerId, effectiveFrom, and createdAt. It has no coverage field. An id that Lender does not know answers 404 with LENDER-0454.
Change the chart
You configure a version once. Its first chart governs from
1900-01-01, and a second configure call answers 409. Every chart is immutable. A version keeps a chain of dated charts, and a change adds one dated chart to every configured version of the product.
A change belongs to the product, not to a version.
POST /api/v1/loan-products/{id}/accounting-profiles/supersessions
The body carries the complete new chart and effectiveFrom. effectiveFrom is always the first day of a month that has not opened by tomorrow. On the last day of a month, the earliest choice is the first day of the month after next. The new chart books into the same ledger as the old one (LENDER-0443).
The new chart keeps every per-contract position of the old chart. A shared balance account keeps its account and its mode: an allowance, a payable, or cash. Revenue and expense accounts can change. Lender refuses a change that sends two positions of one per-contract account to different accounts (LENDER-0986).
The chart in force on a day is the chart with the greatest effectiveFrom at or below that day. A contract stays on the chart that holds its balance until the balance transfers.
1
Record the change
Send the change. Read
movedPositions in the answer. It lists each position whose balance changes account.2
Let the balances move
The balance of a contract moves inside its first posting after the change. The close of the effective month moves the contracts that had no posting. Nothing else is required.
3
Optional: sweep the contracts that still wait
After the close of the month before the effective day,
POST /api/v1/loan-products/{id}/accounting-profiles/supersessions/sweeps moves them now, with one posting for each contract. It needs an X-Idempotency header. Every rerun needs a new key, because the same key replays the earlier answer.4
Clear what holds a contract
LENDER-0450 lists the possible causes, not the one that applies to a contract, and every contract that was ready did move. Check them in order: the close of the month before the effective day; an earlier change that is still open (sweep that one first); parked postings (see Accounting and accrual runs); an amount that the ledger holds. Then rerun the sweep under a new X-Idempotency key. Do not repeat it in a loop.Suspense accounts
Some postings need a suspense account. A disbursement in parts and a compensating adjustment use them. You designate one account for each currency and role.
PUT /api/v1/internal/accounting/suspense-accounts/{currency}/{role} designates the account, with gl_account in the body. A designated account must already exist in the ledger. Lender never creates it, unless it has the exact name of the default.
A contract keeps the account that holds its first amount in a role. A new account applies to contracts that have none. When Lender provisions ledger accounts, a BRL role with no designated account books into the default. GET on the same path answers 404 with LENDER-0449 when you designated none. See Accounting.
In the Console
The screen to configure a chart needs the same two permissions as the API. Open Credit, open the product and the version, and choose Configure accounting profile. See Credit.
1
Choose the financial institution
Financial institution names the organization. Lender creates the ledger of the product in it, or reuses the ledger it already created.
2
Review the sheet
The sheet starts as a copy of the latest chart of the product, when the screen can edit every rule of it. Review every account before you record.
3
Mark the per-contract legs
Mark each leg that books a borrower position as Per contract.
4
Record the chart
Record accounting profile saves the chart for good. Closing the page discards a sheet you did not record.
payroll_payer_provision_constitution, payroll_payer_provision_reversal, refinance_payoff, refinance_payoff_reversal, assignment_derecognition, assignment_retained_settlement, assignment_repurchase, credit_loss_recovery, and compensation_control.
The screen does not record these events: accrual_fee_amortization, charge_appropriation, renegotiation_derecognition, renegotiation_recognition, assignment_secured_borrowing, assignment_funding_amortization, assignment_funding_payoff, and the four returned_payment_* events. To carry one of them, send the chart with POST /api/v1/loan-products/{id}/accounting-profiles, with the same two permissions. A product renegotiates substantially only with the pair renegotiation_derecognition and renegotiation_recognition, so you send that chart through the API.
The screen does not copy a chart that has a rule it cannot edit. The sheet then opens empty, and the notice This chart has rules this screen cannot edit names those rules.
Reconcile with Midaz
Each posting is a Midaz transaction. Use these fields to find it.
See Accounting and accrual runs for receipts, journal references, and parked postings.
Next steps
Accounting and accrual runs
See how a posting reaches the ledger, and how accrual runs book interest.
Define a loan product
Create the product and the version that the chart serves.
Credit in the Console
Configure the chart and run chart changes in the Console.
Brazil regulatory pack
Layer CET, IOF, and PDD staging on top of the accounting model.

