Line item#
A LineItem is what a line maker returns (co.pl.revenue("Sales", 100)): a series that belongs to an
entity’s books. The LineMaker page describes how lines are created, and the Line makers pages the
arguments of each kind.
- class boki.LineItem(name, expr, entity, kind, account, category=None)#
Series that is one line of an entity’s statements: its name, kind, and the account that holds it.
A line item is what
co.pl.<kind>(...)andco.bs.<kind>(...)return. It is a Series, so it supports all the operations of one (arithmetic,lag,sum, …), and it also knows which entity, accounting standard and kind it belongs to. Its value is a flow for a profit-and-loss kind (the amount recognized in each period) and a closing balance for a balance-sheet kind; the template of the kind says which. The line’s amounts were posted to the entity’s double-entry books when it was created, so a line cannot be changed afterwards.- Parameters:
- namestr
Name of the line, unique among the lines of its kind in the entity.
- exprSeries
The values of the line: its flow, or the closing balance of its account.
- entityEntity
The entity whose books hold the line.
- kindstr
Name of the layout kind, such as
"revenue"or"loan".- accountAccount
The ledger account the line reads. Internal.
- categorystr | None
Free-text label that groups lines in totals, such as
"Products".Nonemeans no label.
- Attributes:
- namestr
Name of the line, as it appears in statements.
- kindstr
Name of the layout kind, as in
co.pl.<kind>.- entityEntity
The entity whose books hold the line.
- standardStandard
The accounting standard of the entity.
- layoutLayout
The layout of the entity’s statements.
- categorystr or None
Label given at creation.
LineMaker.total_of(category=...)totals the lines that share one.- counterpartyLineItem or None
For a trade with another entity (
counterparty=on the maker), the same trade in the other entity’s books; otherwiseNone. The link is symmetric.- unitfrozenset or None
Dimensions of the line’s values, as for any series.
Nonewhile the entity’s currency is not yet known.- balanceSeries
Closing balance of the line in each period, on most balance-sheet lines (
co.bs.<kind>). For most kinds it has the same values as the line itself.- depreciationLineItem
Depreciation expense of the asset, on fixed-asset lines, as a line of the layout’s depreciation kind. On construction lines, only when
complete_at=was given.- drawSeries
Amount drawn in each period, on loans: the
draw=argument.- interestSeries
Interest accrued in each period, on loans: the rate times the opening balance. A rate per time is integrated by the period length. With a rate, it is the sum of
interest_expenseandcapitalized_interest; withrate=Noneit is 0 and no interest line is booked.- principalSeries
Principal repaid in each period, on loans: the
repay=amount, never more than the opening balance.- interest_expenseLineItem
The part of the interest booked as expense, on loans: a line of the layout’s interest kind (with
rate=None, the zero interest series).- capitalized_interestSeries
The part of the interest added to construction in progress instead of expense, on loans; 0 without
capitalize_during=.- nolNOL
Loss carryforward of an income tax line computed from
rate=andbase=: a named tuple withbalance,usedandtaxableseries. Absent withnol=Falseor when the amount was given.
See also
boki.LineMakerCreates the lines of one kind and totals them.
boki.series.NamedThe series type that line items extend.
Notes
Only the line makers create line items, so user code never constructs one. A line also exists for the other side of a trade, such as the buyer’s cost for a seller’s revenue; read it from
counterparty. What each kind posts, and which attributes it has, is documented with the maker of the kind. The double-entry bookkeeping note explains the postings.Examples
A loan drawn in the first month, repaid in the last two, with interest of 12% a year on the opening balance:
>>> import boki as b >>> m = b.Model("Loan", start="2027-01", periods=4, step=b.month) >>> co = m.entity("Co", standard=b.IFRS) >>> co.bs.opening(cash=1000) >>> loan = co.bs.loan("Bank loan", draw={0: 600}, rate=0.12 / b.year, repay={2: 100, 3: 100}) >>> r = m.render() >>> r[loan] [600.0, 600.0, 500.0, 400.0] >>> [round(v, 2) for v in r[loan.interest]] [0.0, 6.0, 6.0, 5.0] >>> r[loan.principal] [0, 0, 100, 100] >>> loan.kind, loan.entity is co, loan.layout.name ('loan', True, 'IFRS general')
Revenue lines carry a category and are totalled by the maker:
>>> m = b.Model("Sales", start="2027-01", periods=3, step=b.month) >>> co = m.entity("Co", standard=b.IFRS) >>> product = co.pl.revenue("Product", 100, category="Products") >>> service = co.pl.revenue("Service", 40, category="Services") >>> r = m.render() >>> r.value(co.pl.revenue.total_of(category="Services"), "2027-02") 40
- property change#
Change during each period: the closing value minus the opening.
- Returns:
- Series
This period’s value minus
opening. For a balance-sheet line it is the movement of the balance in the period; for a flow it is the change from the previous period.
See also
boki.LineItem.openingThe value at the start of each period.
Examples
The movement of a loan balance:
>>> import boki as b >>> m = b.Model("Loan", start="2027-01", periods=3, step=b.month) >>> co = m.entity("Co", standard=b.IFRS) >>> co.bs.opening(cash=1000) >>> loan = co.bs.loan("Bank loan", draw={0: 600}, repay={2: 100}) >>> r = m.render() >>> r[loan.change] [600.0, 0.0, -100.0]
- property opening#
Value at the start of each period: the previous period’s closing balance of a balance-sheet line.
- Returns:
- Series
For a balance-sheet line, the previous period’s closing balance, which in the first period is the opening balance declared for the line (
opening=, or 0). For a profit-and-loss line it is the previous period’s value, 0 before the first period, as for any Series.
See also
boki.Series.openingThe same for a plain series.
boki.LineItem.changeThis period’s value minus the opening.
Examples
>>> import boki as b >>> m = b.Model("Deposit", start="2027-01", periods=3, step=b.month) >>> co = m.entity("Co", standard=b.IFRS) >>> co.bs.opening(cash=800, retained_earnings=1000) >>> deposit = co.bs.asset("Deposit", opening=200) >>> r = m.render() >>> [float(v) for v in r[deposit.opening]] [200.0, 200.0, 200.0]
The method draw_or_repay exists on loan lines only, so it has its own page: Loan line members.