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,againstorcounterpartysay otherwise; Notes lists the valid combinations. The line is also counted in the kind’stotal. Lines share the receivable, payable, deferred revenue, prepaid, and VAT accounts thatsettle,recognizeandvatopen.- 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. Giveamountordata; when both are given,datais used.- datadict, optional
Amounts for selected periods as
{period: amount}, with the units ofamount. Other periods book 0. It replacesamountwhen 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 andb.even(3)settles one third in each of three periods. The weights must sum to 1, and ab.curvemust 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 assettle.- 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 ofsettle. 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.bsline orco.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 withsettle,cash,recognize,vat,openingorcounterparty.- vatscalar or Series, optional
Tax rate on the amount, a dimensionless ratio such as
0.1for 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_settlementpays the net balance. It does not combine withagainstorcounterparty.- 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.inventoryorother.bs.fixed_assetbooks a sale of goods or equipment by a revenue line and needsmarginandusedorlife. The returned line’scounterpartyattribute is the other entity’s line.- marginscalar or Series, optional
Seller’s profit as a dimensionless share of the price:
0.3on a price of 100 is an intercompany profit of 30. Required with an assetcounterparty. 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 as5 * 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
settleuses and is collected (paid) in the first periods. Requiressettle. It does not combine withcounterpartyoragainst.- opening_collectdict, optional
{period: amount}replacing the default collection schedule ofopening: 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 toopening. Requiresopening.- actualsdict, optional
Historical amounts for periods up to
Model.actual_until, as{period: amount}. RequiresModel(..., actual_until=...).
- Returns:
- LineItem
The new line. Its value in each period is the amount recognized in profit. With
counterparty, itscounterpartyattribute is the matching line of the other entity.
- Raises:
- TypeError
At construction, if an argument combination is not valid:
openingoropening_collectis given withoutsettle, oropening_collectwithoutopening;openingis combined withcounterpartyoragainst, oropening_collectis not a non-empty dict of plain amounts;againstis combined withsettle,cash,recognizeorvat, or is not a line item or balance;margin,usedorlifeis given without an assetcounterparty;counterpartyis not a PL kind of another entity or itsinventoryorfixed_asset, isincome_tax, takes the same side as this line, or is combined withagainstorvat;an asset
counterpartyis used on a kind other thanrevenue, is combined withrecognize, or lacksmargin,used(inventory) orlife(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,recognizeorusedis not a distribution: weights that do not sum to 1, or ab.curvethat does not end in 0;a line with this name already exists for this kind;
counterpartybelongs to this entity or to another model;againstis an account of another entity;lifeis not positive;openingis negative,opening_collecthas a negative amount or does not add up toopening, orsettle=b.delay(0)leaves nothing outstanding andopening_collectis missing.
- UnitError
At construction, if an amount is in a unit other than the entity’s currency,
marginis not dimensionless, orlifeis not a time.- IndexError
At construction, if a period of
opening_collectis outside the model timeline. At evaluation, if a period ofamount,dataorcashis 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 (
amountonly): 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 withoutsettle): the same entries with the cash given bycash.cashwins when both are given;settleis still checked, andopeningstill uses it.Deferred recognition (
recognize, optionally withsettleorcash): when booked, debit cash (or the receivable, whensettleorcashis 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, withsettle): see below.Trade with another entity (
counterparty, optionally withsettle,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.inventoryorother.bs.fixed_asset, withmargin, andusedorlife; optionallysettleorcash): the seller books revenue and the buyer books the asset at the price. Only therevenuekind may do this, andrecognize,againstandvatare not allowed. The buyer’s asset is named<name> (<seller>); the buyer’s use of inventory becomes itscogs, 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 weightsw[k], the share of a period’s amount settledkperiods later, the balance outstanding after periodjisT[j], the sum ofw[k]fork > j, and periodjcollectsopening * T[j] / sum(T).settle=b.delay(2)collects half ofopeningin each of the first two periods.settle=b.delay(0)leaves nothing outstanding, soopening_collectis required. Opening balances of lines withsettleadd up in the shared receivable (payable); do not declareco.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_costUS GAAP general:
co.pl.revenue,co.pl.cogs,co.pl.sga,co.pl.other_income,co.pl.other_expense,co.pl.interest_expenseJ-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_lossbank:
co.pl.interest_income,co.pl.interest_expense,co.pl.provision,co.pl.non_interest_income,co.pl.non_interest_expense