Kaizen
Browse modulesPricingpricing/sharedTypes

Type Alias: LineCalculation<TLineItem *extends* [`LineItemContext`](LineItemContext.md)>

type LineCalculation<TLineItem extends LineItemContext> = {
  applied: AppliedAction[];
  base_cents: number;
  line_item: TLineItem;
  pricing_unit: string;
  quantity: number;
  subtotal_cents: number;
};

Defined in: shared/pricing/types/calculation.ts:59

Per-line calculation result. base_cents is the line's starting subtotal after quantity scaling — i.e. (sum of BASE_PRICE amount_cents on the single matched base-phase rule, or line_item.base_price_cents, or 0) × quantity. Successive applied actions chain off that base.

applied[] includes BASE_PRICE actions when a base-phase rule matched (so the breakdown is renderable as a full invoice without consulting base_cents separately). Lines that fall back to line_item.base_price_cents have no base entries in applied[] — there's no rule to attribute the base to — but base_cents still reflects the starting value.

quantity is the number of billable units along pricing_unit, EXCEPT on a line whose base rule declares a duration axis (BasePriceAction.per), where it is the product of both axes — 2 attendees × 3 hours = 6 attendee-hours. It is always the true multiplier, so the base_cents identity above holds either way; renderers wanting to show the axes separately read per off the BASE_PRICE action in applied[].

Type Parameters

Type Parameter
TLineItem extends LineItemContext

Properties

applied

applied: AppliedAction[];

Defined in: shared/pricing/types/calculation.ts:64


base_cents

base_cents: number;

Defined in: shared/pricing/types/calculation.ts:63


line_item

line_item: TLineItem;

Defined in: shared/pricing/types/calculation.ts:60


pricing_unit

pricing_unit: string;

Defined in: shared/pricing/types/calculation.ts:61


quantity

quantity: number;

Defined in: shared/pricing/types/calculation.ts:62


subtotal_cents

subtotal_cents: number;

Defined in: shared/pricing/types/calculation.ts:65

On this page