> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Accounting and accrual runs

> How Lender books to the ledger — accounting profiles and posting rules, durable posting intents, accrual runs and retries, and journal references.

export const GDoubleEntry = ({children}) => <Tooltip headline="Double-entry accounting" tip="Every financial movement is recorded as at least two operations: a debit from one account and a credit to another, ensuring the system always balances." cta="See glossary" href="/en/glossary">
    {children}
  </Tooltip>;

export const GLedger = ({children}) => <Tooltip headline="Ledger" tip="The core financial book that records all transactions, balances, and operations for an organization — the single source of truth for a business unit's finances." cta="See glossary" href="/en/glossary">
    {children}
  </Tooltip>;

Every financial event in a credit journey ends up in the <GLedger>ledger</GLedger>. Lender's accounting layer is how it gets there: a product declares its posting rules once, and from then on disbursements, repayments, accruals, and reversals all book automatically and traceably.

## Accounting profiles and posting rules

***

An **accounting profile** binds a product version to the ledger. It defines the **posting rules** — the <GDoubleEntry>double-entry</GDoubleEntry> legs that fire for each kind of financial event — and the ledger organization and ledger the resulting transactions book into. You create a profile per product:

`POST /api/v1/loan-products/{id}/accounting-profiles`

Posting rules are validated when the profile is created, so a product cannot go live with legs that would not balance.

## Posting intents and the relay

***

Lender does not call the ledger inline. When a financial event happens, it persists a durable **posting intent** in the same database transaction that changes domain state, then a relay posts the balanced transaction to Midaz asynchronously. This is what makes bookings reliable:

* **No lost postings** — the intent is committed with the state change, in a transactional outbox.
* **Idempotent** — each posting carries a deterministic key, so retries collapse to one ledger transaction.
* **Fails closed** — if routing cannot resolve a non-empty ledger target, the post is refused rather than written to the wrong place.

The full path is described in [Lender in the platform](/en/lender/lender-in-the-platform).

## Accrual runs

***

Interest and other time-based amounts are recognized by an **accrual run** — a batch that computes what accrued over a period across the book and produces the postings for it.

<Steps>
  <Step title="Start a run">
    `POST /api/v1/accrual-runs` queues an accrual run.
  </Step>

  <Step title="Retry if needed">
    `POST /api/v1/accrual-runs/{id}/retry` re-queues the items of a run that did not complete, without re-accruing what already succeeded.
  </Step>
</Steps>

## Journal references

***

A **journal reference** ties a Lender financial event to the ledger transaction that recorded it, so you can trace a posting in both directions.

| Operation                             | Purpose                                        |
| ------------------------------------- | ---------------------------------------------- |
| `GET /api/v1/journal-references`      | Look up a journal reference by correlation id. |
| `GET /api/v1/journal-references/{id}` | Read a single journal reference.               |

<Tip>
  Reconcile Lender against the ledger by correlation id: a journal reference points at the exact Midaz transaction a repayment or accrual produced.
</Tip>

## Next steps

***

<Card title="Portfolio and delinquency" icon="chart-line" href="/en/lender/portfolio-and-delinquency" horizontal>
  See the accounted book in aggregate.
</Card>

<Card title="Brazil regulatory pack" icon="brazilian-real-sign" href="/en/lender/brazil-regulatory-pack" horizontal>
  Layer CET, IOF, and PDD staging on top of the accounting model.
</Card>
