Interface: RefundableOrderView
Defined in: shared/checkout/refund-breakdown.ts:55
computeRefundBreakdown — the pure refund engine (proposal §Refunds,
"one engine, three modes").
Component model (adopted reading of algorithm clause 2)
Order-level adjustment rows remain SINGLE components refunded as
adjustment items — the rows themselves are never split per line.
Clause 2's "distribute proportionally across lines" governs the
ATTRIBUTION math: when the refund scope is a subset of lines, each
order-scoped customer adjustment's remaining refundable is distributed
across ALL of the order's lines in proportion to subtotalCents, with
the rounding remainder pinned to the LAST line, and only the in-scope
lines' attributions enter the refundable base. For scope: "order" the
attributions sum back to the full remaining (the pinning guarantees
this), so no distribution is needed.
This is the reading under which a full-order 100% refund's
requestedAmountCents equals the remaining customer total exactly:
line items refund responsiblePartyShareCents (the line's customer-borne
base) and the order-level customer discount/fee rows appear as their own
signed adjustment items (discounts negative), mirroring the additive
customerTotal = Σ shares + Σ customer-borne adjustments (excl. inclusive tax) formula. Splitting the rows into the line shares as well would
double-count them.
Sign conventions
- Adjustment components keep the signed
amountCentsof their row: discounts negative, fees/taxes positive.requestedAmountCentsis the signed sum over non-inclusive-tax items. alreadyRefundedByComponentcarries SIGNED settled cents in the same convention (a half-settled −1000 discount maps to −500), soremaining = attributable − settledholds uniformly (clause 1).
Inclusive tax (clause 5)
kind=tax ∧ taxInclusive components produce items (GL/reclaim rows) but
never contribute to requestedAmountCents nor to the base that
percentage/amount math scales — the line refund already returns that
money, mirroring the customer-total formula's exclusion.
Properties
adjustments
adjustments: {
amountCents: number;
id: string;
kind: "discount" | "fee" | "tax";
lineItemId: string | null;
responsibleParty: "organization" | "customer" | "platform";
scope: "line" | "order";
taxInclusive: boolean | null;
}[];Defined in: shared/checkout/refund-breakdown.ts:63
amountCents
amountCents: number;id
id: string;kind
kind: "discount" | "fee" | "tax";lineItemId
lineItemId: string | null;responsibleParty
responsibleParty: "organization" | "customer" | "platform";scope
scope: "line" | "order";taxInclusive
taxInclusive: boolean | null;alreadyRefundedByComponent
alreadyRefundedByComponent: Map<string, number>;Defined in: shared/checkout/refund-breakdown.ts:72
customerTotalCents
customerTotalCents: number;Defined in: shared/checkout/refund-breakdown.ts:57
lineItems
lineItems: {
id: string;
responsiblePartyShareCents: number;
subtotalCents: number;
}[];Defined in: shared/checkout/refund-breakdown.ts:58
id
id: string;responsiblePartyShareCents
responsiblePartyShareCents: number;subtotalCents
subtotalCents: number;tenders
tenders: {
capturedCents: number;
disputedCents?: number;
paymentId: string;
refundedCents: number;
tenderMethod: | "check"
| "unknown"
| "other"
| "card"
| "gift_card"
| "account_balance"
| "bank_transfer"
| "cash"
| "warrant"
| "wallet"
| "money_order";
}[];Defined in: shared/checkout/refund-breakdown.ts:73
capturedCents
capturedCents: number;disputedCents?
optional disputedCents?: number;Non-negative net dispute exposure from recomputeTender — money the
bank has already withdrawn via chargeback. Refund capacity must not
commit it again. Optional for fixtures predating dispute awareness.
paymentId
paymentId: string;refundedCents
refundedCents: number;tenderMethod
tenderMethod:
| "check"
| "unknown"
| "other"
| "card"
| "gift_card"
| "account_balance"
| "bank_transfer"
| "cash"
| "warrant"
| "wallet"
| "money_order";