.. _maker-template-loan: 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. .. py:function:: 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: **name** : str Loan name; required. It must be unique among the lines of this kind in the entity. **draw** : scalar, 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. **rate** : scalar, 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. **repay** : scalar, 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. **opening** : scalar, Quantity, Series, or dict, optional Opening loan balance before the first period, in the entity's currency. **target** : scalar, 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_during** : bool 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_into** : LineItem, 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. **counterparty** : Entity, 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_investment** : bool, 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``. **actuals** : dict, 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. .. rubric:: 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 `_. .. rubric:: 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 ----------------------------- * :doc:`IFRS general `: ``co.bs.loan`` * :doc:`US GAAP general `: ``co.bs.loan`` * :doc:`J-GAAP general `: ``co.bs.loan`` * :doc:`bank `: ``co.bs.loan``