Revenue and expense lines (pl_line)#

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

co.pl.revenue(name, amount=None, *, data=None, settle=None, recognize=None, cash=None, category=None, against=None, vat=None, counterparty=None, margin=None, used=None, life=None, opening=None, opening_collect=None, actuals=None)#

Add a line to this revenue or expense kind and book its amount in every period.

The line’s value in a period is the amount recognized in that period’s profit. The amount is booked against cash unless settle, cash, recognize, against or counterparty say otherwise; Notes lists the valid combinations. The line is also counted in the kind’s total. Lines share the receivable, payable, deferred revenue, prepaid, and VAT accounts that settle, recognize and vat open.

Parameters:
namestr

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

amountscalar, Quantity, Series, or dict, optional

Amount booked in each period, in the entity’s currency per period. A plain number is in the entity’s currency. A quantity per time, such as 100 * JPY / b.month, is integrated by period length. A dict maps period labels, indices, or dates to amounts and books 0 in the other periods. Give amount or data; when both are given, data is used.

datadict, optional

Amounts for selected periods as {period: amount}, with the units of amount. Other periods book 0. It replaces amount when both are given.

settleKernel, optional

How the cash moves after the booking period. The line accrues in the shared receivable (revenue kinds) or payable (expense kinds), and cash follows the kernel weights: b.delay(2) settles two periods later and b.even(3) settles one third in each of three periods. The weights must sum to 1, and a b.curve must end in 0.

recognizeKernel, optional

When the profit is recognized. The amount is billed in the booking period into deferred revenue (revenue kinds) or prepaid expenses (expense kinds), and the line’s value follows the kernel: b.even(12) recognizes an annual prepayment over twelve monthly periods. The kernel has the same limits as settle.

cashscalar, Quantity, Series, or dict, optional

Cash received (revenue kinds) or paid (expense kinds) in each period, in the entity’s currency per period, with the forms of amount. It replaces the cash schedule of settle. What the cash does not cover stays in the shared receivable or payable, which can turn negative to show a deferral.

categorystr, optional

Free-text label stored on the line as LineItem.category. total_of(category=...) of the maker totals the lines with the same label.

againstLineItem or balance, optional

A line item or balance in this entity’s books, such as a co.bs line or co.bs.cash, that takes the other side of the entry instead of cash: a revenue line debits it and an expense line credits it. No cash moves. It does not combine with settle, cash, recognize, vat, opening or counterparty.

vatscalar or Series, optional

Tax rate on the amount, a dimensionless ratio such as 0.1 for 10%. The line stays net of tax, and the tax is booked in the shared VAT account: collected on a revenue line and paid on an expense line, with the cash timing of the line. Entity.vat_settlement pays the net balance. It does not combine with against or counterparty.

counterpartyLineMaker, optional

The other side of a trade with another entity of the same model. other.pl.<kind> of the opposite side (a cost for a revenue line, a revenue for a cost line) books the same amount in both entities. other.bs.inventory or other.bs.fixed_asset books a sale of goods or equipment by a revenue line and needs margin and used or life. The returned line’s counterparty attribute is the other entity’s line.

marginscalar or Series, optional

Seller’s profit as a dimensionless share of the price: 0.3 on a price of 100 is an intercompany profit of 30. Required with an asset counterparty. It does not change either entity’s separate books; consolidation uses it to eliminate the unrealized profit.

usedKernel, optional

With counterparty=other.bs.inventory, required: how the buyer uses up the purchased inventory. The weights give the share used each period after the purchase, and the use becomes the buyer’s cost of sales.

lifeQuantity or Unit, optional

With counterparty=other.bs.fixed_asset, required: the buyer’s useful life as a time such as 5 * b.year. The buyer depreciates each purchase straight-line over it, from the purchase period. It must be positive.

openingscalar or Quantity, optional

Amount outstanding at the model start from this line’s earlier sales (earlier purchases, for an expense kind), in the entity’s currency. It is added to the opening balance of the shared receivable (payable) that settle uses and is collected (paid) in the first periods. Requires settle. It does not combine with counterparty or against.

opening_collectdict, optional

{period: amount} replacing the default collection schedule of opening: the amounts collected (paid) in the listed periods. Periods are indices, dates, or labels. Amounts are plain numbers or quantities, not negative, and add up to opening. Requires opening.

actualsdict, optional

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

Returns:
LineItem

The new line. Its value in each period is the amount recognized in profit. With counterparty, its counterparty attribute is the matching line of the other entity.

Raises:
TypeError

At construction, if an argument combination is not valid:

  • opening or opening_collect is given without settle, or opening_collect without opening;

  • opening is combined with counterparty or against, or opening_collect is not a non-empty dict of plain amounts;

  • against is combined with settle, cash, recognize or vat, or is not a line item or balance;

  • margin, used or life is given without an asset counterparty;

  • counterparty is not a PL kind of another entity or its inventory or fixed_asset, is income_tax, takes the same side as this line, or is combined with against or vat;

  • an asset counterparty is used on a kind other than revenue, is combined with recognize, or lacks margin, used (inventory) or life (fixed asset), or is given the other kind’s argument;

  • an amount has a type boki cannot use in an expression.

ValueError

At construction, if a value is not valid:

  • settle, recognize or used is not a distribution: weights that do not sum to 1, or a b.curve that does not end in 0;

  • a line with this name already exists for this kind;

  • counterparty belongs to this entity or to another model;

  • against is an account of another entity;

  • life is not positive;

  • opening is negative, opening_collect has a negative amount or does not add up to opening, or settle=b.delay(0) leaves nothing outstanding and opening_collect is missing.

UnitError

At construction, if an amount is in a unit other than the entity’s currency, margin is not dimensionless, or life is not a time.

IndexError

At construction, if a period of opening_collect is outside the model timeline. At evaluation, if a period of amount, data or cash is outside it.

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 revenue line is described first; an expense line mirrors it, with the expense in place of the revenue, the payable in place of the receivable, and prepaid expenses in place of deferred revenue.

  • Cash on booking (amount only): debit cash, credit revenue.

  • Settled later (settle): debit the shared receivable and credit revenue when booked; the cash arrives by the kernel (debit cash, credit receivable).

  • Own cash schedule (cash, with or without settle): the same entries with the cash given by cash. cash wins when both are given; settle is still checked, and opening still uses it.

  • Deferred recognition (recognize, optionally with settle or cash): when booked, debit cash (or the receivable, when settle or cash is given) and credit deferred revenue; the revenue is recognized by the kernel (debit deferred revenue, credit revenue).

  • Against an account (against): debit that account and credit revenue; no cash moves.

  • VAT (vat, with any of the first four): the tax follows the cash timing of the line.

  • Opening balance (opening, with settle): see below.

  • Trade with another entity (counterparty, optionally with settle, cash, recognize): the same expression and timing are booked in both entities, converted to the other entity’s currency, so the two sides cannot differ. Consolidation removes the entries of the trade itself.

  • Asset sale to another entity (counterparty=other.bs.inventory or other.bs.fixed_asset, with margin, and used or life; optionally settle or cash): the seller books revenue and the buyer books the asset at the price. Only the revenue kind may do this, and recognize, against and vat are not allowed. The buyer’s asset is named <name> (<seller>); the buyer’s use of inventory becomes its cogs, and the buyer’s depreciation goes to the layout’s depreciation expense.

With opening, the default schedule assumes the earlier sales were steady: each earlier period sold the same amount on the same terms. With kernel weights w[k], the share of a period’s amount settled k periods later, the balance outstanding after period j is T[j], the sum of w[k] for k > j, and period j collects opening * T[j] / sum(T). settle=b.delay(2) collects half of opening in each of the first two periods. settle=b.delay(0) leaves nothing outstanding, so opening_collect is required. Opening balances of lines with settle add up in the shared receivable (payable); do not declare co.bs.receivable("Accounts receivable", opening=...) next to them.

See the account and settlement table, the opening receivables guide, intercompany transactions, and intercompany asset sales.

Examples

Revenue collected one month later, in a monthly model:

>>> import boki as b
>>> months = ["2027-01", "2027-02", "2027-03"]
>>> m = b.Model("Sales", start="2027-01", periods=3, step=b.month)
>>> co = m.entity("A", standard=b.IFRS)
>>> sales = co.pl.revenue("Sales", 100, settle=b.delay(1))
>>> r = m.render()
>>> [round(r.value(sales, month)) for month in months]
[100, 100, 100]
>>> [round(r.value(co.bs.cash, month)) for month in months]
[0, 100, 200]

An amount per time is integrated by the length of each period, so a quarterly model books three months at once:

>>> from boki.units import JPY
>>> m = b.Model("Fees", start="2027-01", periods=2, step=3 * b.month)
>>> co = m.entity("A", standard=b.IFRS)
>>> fee = co.pl.revenue("Fee", 100 * JPY / b.month)
>>> r = m.render()
>>> [round(r.value(fee, quarter)) for quarter in ("2027-01", "2027-04")]
[300, 300]

An annual prepayment paid up front and recognized over three months:

>>> m = b.Model("Insurance", start="2027-01", periods=4, step=b.month)
>>> co = m.entity("A", standard=b.IFRS)
>>> co.bs.opening(cash=1000)
>>> premium = co.pl.sga("Premium", {0: 300}, recognize=b.even(3))
>>> r = m.render()
>>> [round(r.value(premium, month)) for month in months + ["2027-04"]]
[100, 100, 100, 0]
>>> [round(r.value(co.bs.cash, month)) for month in months + ["2027-04"]]
[700, 700, 700, 700]

An opening receivable of 240 on terms of two months is collected half in each of the first two periods:

>>> m = b.Model("Opening", start="2027-01", periods=3, step=b.month)
>>> co = m.entity("A", standard=b.IFRS)
>>> sales = co.pl.revenue("Sales", 100, settle=b.delay(2), opening=240)
>>> r = m.render()
>>> [round(r.value(co.bs.cash, month)) for month in months]
[120, 240, 340]

A subsidiary’s sale to its parent is booked once and appears in both entities’ books:

>>> m = b.Model("Group", start="2027-01", periods=2, step=b.month)
>>> parent = m.entity("Parent", standard=b.IFRS)
>>> sub = m.entity("Sub", standard=b.IFRS)
>>> parent.bs.opening(cash=1000)
>>> parts = sub.pl.revenue("Parts", 100, counterparty=parent.pl.cogs)
>>> r = m.render()
>>> round(r.value(parts, "2027-01")), round(r.value(parts.counterparty, "2027-01"))
(100, 100)
>>> parts.counterparty.kind
'cogs'

Makers that use this template#

  • IFRS general: co.pl.revenue, co.pl.cogs, co.pl.sga, co.pl.other_income, co.pl.other_expense, co.pl.finance_income, co.pl.finance_cost

  • US GAAP general: co.pl.revenue, co.pl.cogs, co.pl.sga, co.pl.other_income, co.pl.other_expense, co.pl.interest_expense

  • J-GAAP general: co.pl.revenue, co.pl.cogs, co.pl.sga, co.pl.non_operating_income, co.pl.non_operating_expense, co.pl.special_gain, co.pl.special_loss

  • bank: co.pl.interest_income, co.pl.interest_expense, co.pl.provision, co.pl.non_interest_income, co.pl.non_interest_expense