Kaizen
Browse modulesPricingpricing/sharedFunctions

Function: assertTierQuantityLimits()

function assertTierQuantityLimits(lines: readonly TierQuantityLine[], limits: readonly TierQuantityLimit[]): void;

Defined in: shared/pricing/tier-quantity-limits.ts:110

Throw if any tier's summed quantity across lines exceeds its declared cap.

Lines whose rateTierId has no entry in limits, or whose entry has a null maxQuantity, are unconstrained — absence of a cap is not a violation, so an incomplete limits list can only ever under-enforce, never spuriously reject. Callers that must not under-enforce should load limits for every tier their lines reference.

Non-positive quantities are summed as-is rather than rejected: the caller owns quantity validity (e.g. CartService.assertQuantity), and quietly treating a negative as zero here would let it mask a sibling line's overage.

Reports the FIRST violation in rateTierId order, not in line order, so the same basket always fails on the same tier regardless of how the lines were assembled.

Parameters

ParameterType
linesreadonly TierQuantityLine[]
limitsreadonly TierQuantityLimit[]

Returns

void

On this page