跳到主要内容

std/pricing

std/pricing

导入自 @norbital-ai/std/pricing

std/pricing (§3.7, M2): catalogue lines → bands → formula → bucket → line. A catalogue line carries ordered bands of formula text; a band that holds (when) takes a slice of the quantity (take, default all that is left) and prices it (price, reading the slice as the root quantity); each priced slice is one line in the catalogue line's bucket. Payroll overtime bands, allowance families, CRM price breaks and commissions are all this shape.

PricedLine type

type PricedLine<C = Ctx> = {
    readonly code: string;
    readonly label: string;
    readonly bucket: string;
    readonly band: number;
    readonly quantity: Decimal | null;
    readonly amount: Amount<C>;
};

A priced line: its code, label, bucket and band, the quantity (or null) and the amount.

成员

名称类型说明
codestring
labelstring
bucketstring
bandnumber
quantityDecimal | null
amountAmount<C>

源码: packages/std/src/pricing.ts:32

band function

function band<C extends Ctx>(ctx: C, bands: readonly Band[], values: Values, quantity?: DecimalLike | null): Slice<C>[]

The slices one band list prices. With no quantity the first band that holds prices the whole (a flat amount); with one, bands take slices in order until it is used up.

参数

名称类型说明
ctxC
  • roots: R
  • numbers: M
bandsreadonly Band[]
valuesValues
quantity?DecimalLike | null

源码: packages/std/src/pricing.ts:52

pricedLines function

function pricedLines<C extends Ctx>(ctx: C, lines: readonly Line[], values: Values): PricedLine<C>[]

Every catalogue line priced through its bands, one PricedLine per slice, in catalogue order.

参数

名称类型说明
ctxC
  • roots: R
  • numbers: M
linesreadonly Line[]
valuesValues

源码: packages/std/src/pricing.ts:86