std/pricing
std/pricing
Import from @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.
Members
| Name | Type | Description |
|---|---|---|
code | string | |
label | string | |
bucket | string | |
band | number | |
quantity | Decimal | null | |
amount | Amount<C> |
Source: 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.
Parameters
| Name | Type | Description |
|---|---|---|
ctx | C |
|
bands | readonly Band[] | |
values | Values | |
quantity? | DecimalLike | null |
Source: 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.
Parameters
| Name | Type | Description |
|---|---|---|
ctx | C |
|
lines | readonly Line[] | |
values | Values |
Source: packages/std/src/pricing.ts:86