Loans (loan)#

One signature and one documentation text are shared by every maker listed at the end of this page. The call is shown for co.bs.loan; the other kinds take the same arguments.

co.bs.loan(name, draw=None, rate=0, repay=None, *, opening=None, target=None, capitalize_during=None, capitalize_into=None, counterparty=None, net_investment=False, actuals=None)#

Add a borrowing with interest and repayment entries.

The line’s value is the loan balance at the end of each period. Interest is the rate times the opening balance and is expensed in the layout’s interest kind unless it is capitalized. Draws and repayments move cash.

Parameters:
namestr

Loan name; required. It must be unique among the lines of this kind in the entity.

drawscalar, Quantity, Series, or dict, optional

Amount drawn, in the entity’s currency per period. A dict maps period labels or indices to amounts and draws 0 in the other periods.

ratescalar, Quantity, or Series, default=0

Interest rate, dimensionless per period: 0.01 is 1% of the opening balance in each period, whether the period is a month or a year. A rate per time, such as 0.12 / b.year, is integrated by period length. None books no interest.

repayscalar, Quantity, Series, dict, or callable, optional

Amount repaid, in the entity’s currency per period, never more than the opening balance. A dict maps period labels or indices to amounts; a callable receives this loan and returns the repayment.

openingscalar, Quantity, Series, or dict, optional

Opening loan balance before the first period, in the entity’s currency.

targetscalar, Quantity, Series, or dict, optional

Closing balance to hold in each period, in the entity’s currency. Leave draw and repay unset when giving it.

capitalize_duringbool or Series, optional

Periods in which interest is capitalized instead of expensed: a condition that is true in those periods. It does not combine with counterparty.

capitalize_intoLineItem, optional

The construction line of this entity that receives the capitalized interest. Requires capitalize_during. Without it, capitalized interest goes to a shared construction-in-progress account that is never depreciated.

counterpartyEntity, optional

The lender, another entity of the same model. It books the matching loan receivable, the draws and repayments, and the interest as income. It does not combine with target or capitalize_during.

net_investmentbool, default=False

Treat a loan to a lender with another functional currency as part of the net investment, which sends the exchange difference to other comprehensive income in consolidation. Requires counterparty.

actualsdict, optional

Historical closing balances for periods up to Model.actual_until, as {period: amount}. Requires Model(..., actual_until=...).

Returns:
LineItem

The loan line, valued at its closing balance. Its interest, principal and draw attributes are the interest on the opening balance, the repayment actually made, and the draw; interest_expense is the interest expensed and capitalized_interest the interest capitalized. draw_or_repay(amount) borrows (positive) or repays (negative) an extra amount in each period.

Raises:
TypeError

At construction, if net_investment is not a bool or is given without counterparty; if target is combined with draw or repay; if counterparty is not an entity or is combined with target or capitalize_during; if capitalize_into lacks capitalize_during or is not a construction line of this entity; or if an amount has a type boki cannot use in an expression.

ValueError

At construction, if a loan with this name already exists, counterparty is this entity or belongs to another model, or the lender’s layout has no income kind for interest or foreign-exchange differences.

UnitError

At construction, if an amount is in a unit other than the entity’s currency.

IndexError

At evaluation, if a period of draw, repay, opening or target is outside the model timeline.

Notes

The documentation of each maker starts this section with the maker’s kind, its side, and the section and cash-flow class of the kind; the layout pages list them.

A draw debits cash and credits the loan; a repayment debits the loan and credits cash. Interest is calculated on the opening balance. Without capitalize_during it is expensed. With it, interest in the selected periods is capitalized into a shared construction-in-progress account, which is never depreciated, or with capitalize_into into the cost of that construction line, which depreciates it after completion. See the loans section and the consolidation guide for loans between entities.

Examples

Use a monthly model to see a per-time rate integrated over each month:

>>> import boki as b
>>> m = b.Model("Loan", start="2027-01", periods=2, step=b.month)
>>> co = m.entity("A", standard=b.IFRS)
>>> loan = co.bs.loan("Term loan", draw={0: 100}, rate=0.12 / b.year)
>>> r = m.render()
>>> round(r.value(loan.interest, "2027-02"), 8)
1.0

Makers that use this template#