@final-commerce/command-frame 0.9.0-online.3 → 0.9.0-online.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -116,6 +116,7 @@ export interface CFActiveRefundDetails {
116
116
  buttonsDisabled?: Record<string, boolean>;
117
117
  isRefund?: boolean;
118
118
  customSalesQuantities?: Record<string, number>;
119
+ /** Keyed by cart-fee id, plus the reserved key `'shipping'` for the order's shipping. 0/1 each. */
119
120
  cartFeesRefunds?: Record<string, number>;
120
121
  tipsRefunds?: Record<string, number>;
121
122
  refundProcessingStatus?: CFRefundProcessingStatus | null;
@@ -96,7 +96,7 @@ export function mockRefundBreakdown(rows, items) {
96
96
  return { type: row.type, itemKey: row.itemKey, quantity, amounts: scale(row.amounts, quantity / row.quantity) };
97
97
  })
98
98
  .filter((r) => r.quantity > 0);
99
- const totals = { items: 0, discounts: 0, fees: 0, tax: 0, tip: 0, total: 0 };
99
+ const totals = { items: 0, discounts: 0, fees: 0, shipping: 0, tax: 0, tip: 0, total: 0 };
100
100
  for (const r of selected) {
101
101
  const a = r.amounts;
102
102
  if (r.type === 'fee')
@@ -20,12 +20,13 @@ export interface GetRefundPlanParams {
20
20
  items?: {
21
21
  /**
22
22
  * `internalId` / `variantId` for a product, `customSaleId`, cart-fee id, tip
23
- * `transactionId`, or a booking's own `internalId` on `order.reservations[]`.
23
+ * `transactionId`, a booking's own `internalId` on `order.reservations[]`, or
24
+ * `'shipping'` for the order's shipping (all or nothing, like a fee).
24
25
  */
25
26
  itemKey: string;
26
27
  quantity: number;
27
28
  /** Optional hint; inferred from the order when omitted. */
28
- type?: 'product' | 'customSale' | 'fee' | 'tip' | 'reservation';
29
+ type?: 'product' | 'customSale' | 'fee' | 'tip' | 'reservation' | 'shipping';
29
30
  }[];
30
31
  }
31
32
  export interface RefundPlanSource {
@@ -79,7 +80,7 @@ export interface RefundPlanLeg {
79
80
  rounding: number;
80
81
  };
81
82
  }
82
- export type RefundPlanRowType = 'product' | 'customSale' | 'fee' | 'tip';
83
+ export type RefundPlanRowType = 'product' | 'customSale' | 'fee' | 'tip' | 'shipping';
83
84
  /** One tax rate's share of a row's refund (minor units). */
84
85
  export interface RefundPlanTaxLine {
85
86
  name: string;
@@ -107,7 +108,7 @@ export interface RefundPlanAmounts {
107
108
  total: number;
108
109
  }
109
110
  /**
110
- * One refundable row of the order — a line item, custom sale, cart fee or tip —
111
+ * One refundable row of the order — a line item, custom sale, cart fee, shipping or tip —
111
112
  * served ready to render. Rows with nothing left to refund are not listed.
112
113
  */
113
114
  export interface RefundPlanRow {
@@ -121,7 +122,7 @@ export interface RefundPlanRow {
121
122
  attributes?: string;
122
123
  /** Tip rows only: the tender that took the tip (`card`, `cash`, …). */
123
124
  paymentType?: string;
124
- /** Quantity originally sold. Fees and tips are `1` — all or nothing. */
125
+ /** Quantity originally sold. Fees, shipping and tips are `1` — all or nothing. */
125
126
  quantity: number;
126
127
  /** Quantity still refundable — the stepper's max. */
127
128
  refundableQuantity: number;
@@ -137,7 +138,7 @@ export interface RefundPlanSelectedRow {
137
138
  }
138
139
  /**
139
140
  * The selection's goods value broken down for display. Minor units;
140
- * `items − discounts + fees + tax + tip === total === allocation.itemTotal`.
141
+ * `items − discounts + fees + shipping + tax + tip === total === allocation.itemTotal`.
141
142
  */
142
143
  export interface RefundPlanTotals {
143
144
  /** Σ selected line subtotals (before discounts, tax excluded). */
@@ -146,6 +147,8 @@ export interface RefundPlanTotals {
146
147
  discounts: number;
147
148
  /** Σ selected cart fees, tax excluded. */
148
149
  fees: number;
150
+ /** The order's shipping when selected, tax excluded; 0 otherwise. */
151
+ shipping: number;
149
152
  tax: number;
150
153
  tip: number;
151
154
  total: number;
@@ -5,6 +5,7 @@ export const mockGetRemainingRefundableQuantities = async (_params) => {
5
5
  lineItems: {},
6
6
  customSales: {},
7
7
  cartFees: {},
8
+ shipping: 0,
8
9
  tips: {},
9
10
  reservations: {},
10
11
  timestamp: new Date().toISOString(),
@@ -11,6 +11,11 @@ export interface GetRemainingRefundableQuantitiesResponse {
11
11
  * 0/1 semantics: `1` = still refundable, `0` = already refunded.
12
12
  */
13
13
  cartFees: Record<string, number>;
14
+ /**
15
+ * The order's shipping: `1` = still refundable, `0` = already refunded or the order has none.
16
+ * Refunded with `itemKey: 'shipping'`, all or nothing.
17
+ */
18
+ shipping: number;
14
19
  /**
15
20
  * Remaining refundable tips, keyed by the paying method's
16
21
  * `transactionId` — the same key `processPartialRefund` takes for
@@ -134,7 +134,7 @@ export interface ProcessPartialRefundParams {
134
134
  /** internalId or variantId, customSaleId, or a booking's own internalId. */
135
135
  itemKey: string;
136
136
  quantity: number;
137
- type?: 'product' | 'customSale' | 'fee' | 'tip' | 'reservation';
137
+ type?: 'product' | 'customSale' | 'fee' | 'tip' | 'reservation' | 'shipping';
138
138
  /**
139
139
  * Per-item stock disposition for a refunded **product** line — the
140
140
  * headless equivalent of the old refund popup's per-row restock/damaged
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.9.0-online.3",
3
+ "version": "0.9.0-online.4",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",