platform-types 1.10.779 → 1.10.781

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.
package/dist/cart.d.ts CHANGED
@@ -538,11 +538,11 @@ declare global {
538
538
  /**
539
539
  * Whether this promotion waives the cart's shipping.
540
540
  *
541
- * ⚠️ `CartTotals.shipping` is structurally `0` today — nothing in the
542
- * api computes a shipping cost yet, by design, because it is chosen at
543
- * checkout. So the waiver currently changes no money, and this flag is the
544
- * only place the GRANT survives to be read by whoever lands the shipping
545
- * quote. Do not read its absence as "shipping was charged".
541
+ * ⚠️ `CartTotals.shipping` stays structurally `0`: the cart has no
542
+ * delivery method, so the shipping cost is chosen at checkout. Storefront
543
+ * checkout reads this flag there: a priced delivery method (`Method.fee`)
544
+ * books its freight line at `0` with `Order.freight.waivedBy: 'promotion'`.
545
+ * Do not read its absence as "shipping was charged".
546
546
  */
547
547
  shippingWaived?: boolean;
548
548
  }
package/dist/cjs/order.js CHANGED
@@ -109,7 +109,8 @@ const positiveUnits = (value) => (typeof value === 'number' && value > 0 ? value
109
109
  * The ONE reader of the per-line fulfilment ledger (`OrderLine.fulfilledQuantity`).
110
110
  *
111
111
  * - A missing `fulfilledQuantity` counts as 0; lines with no or zero `quantity`
112
- * are ignored on both sides of the ratio.
112
+ * are ignored on both sides of the ratio, and so is a freight line
113
+ * (`lineKind: 'freight'` with no `productId`), which is never shipped.
113
114
  * - `deliveredAt > 0` with no `shipments` is `complete` — a whole-order delivery
114
115
  * that never went through the shipment ledger.
115
116
  * - A `disabled` or cancelled row is `none`, whatever timestamps it carries: a
@@ -120,6 +121,12 @@ const orderFulfilmentProgress = (order) => {
120
121
  let orderedUnits = 0;
121
122
  let fulfilledUnits = 0;
122
123
  for (const line of order.items ?? []) {
124
+ // A freight line is a charge, never handed over, so it would hold a
125
+ // fully shipped order at `partial` forever. The same test as
126
+ // `isFreightLine` (`stacks/helpers/discountCalculations.ts`), inlined
127
+ // because contracts import nothing from `stacks/`.
128
+ if (line?.lineKind === 'freight' && line.productId === undefined)
129
+ continue;
123
130
  const ordered = positiveUnits(line?.quantity);
124
131
  if (ordered === 0)
125
132
  continue;
@@ -279,6 +286,9 @@ exports.orderFulfilmentProgress = orderFulfilmentProgress;
279
286
  * is refused after it, like every other refusal at commit.
280
287
  * - `ORDER_HAS_KIT_LINES` · 409 — `mode: 'edit'` on an order holding a kit line
281
288
  * (`CartLine.kit`). Cancel or return the order instead. Nothing was written.
289
+ * - `ORDER_HAS_FREIGHT_LINE` · 409 — `mode: 'edit'` on an order holding a
290
+ * freight line (`OrderLine.lineKind: 'freight'`). Cancel or return the order
291
+ * instead. Nothing was written.
282
292
  * - `CART_PROMOTION_UNAVAILABLE` · 409 — the insert leg converting a STORED
283
293
  * ticket whose promotion ended, was paused, deleted, has not started or is
284
294
  * no longer cart-applicable; the `PromotionRefusal` rides `data.reason`. No
@@ -377,6 +387,15 @@ exports.orderFulfilmentProgress = orderFulfilmentProgress;
377
387
  * - `DELIVERY_METHOD_NOT_FOUND` · 400 — `deliveryMethod` is not in the store's
378
388
  * delivery catalogue, including an absent/empty catalogue. `data: {}`;
379
389
  * refused before reading the cart.
390
+ * - `DELIVERY_FEE_CURRENCY_UNSUPPORTED` · 409 — the chosen delivery method
391
+ * carries a `fee` and the cart is not in the store's order currency
392
+ * (`config.displayCurrency`, pesos when unset), the currency the fee is
393
+ * stated in. `data: {}`; refused after the re-price.
394
+ * - `DELIVERY_FEE_CHANGED` · 409 — `expectedFreight` (absent reads as `0`)
395
+ * differs from the freight the server computes for the chosen delivery
396
+ * method. `data: DeliveryFeeChangedData` carries the server figure; show it
397
+ * and confirm again. Refused after the re-price and the minimum purchase,
398
+ * before any order id, coupon redemption or write.
380
399
  * - `ORDER_INVALID_CART` · 400 — the normalized cart has no finite numeric
381
400
  * `totals.grandTotal`. `data: {}`; refused before repricing/allocation.
382
401
  * - `CART_CHANGED_SINCE_CONFIRM` · 409 — the body sent `expectedCartId` /
@@ -611,6 +630,8 @@ exports.ORDER_ERROR_CODES = [
611
630
  'CART_PROMOTION_UNAVAILABLE',
612
631
  // `mode: 'edit'` on an order holding a kit line; cancel or return it instead.
613
632
  'ORDER_HAS_KIT_LINES',
633
+ // `mode: 'edit'` on an order holding a freight line; cancel or return it instead.
634
+ 'ORDER_HAS_FREIGHT_LINE',
614
635
  // Create-leg refusals about the sale's source, already answered on the wire.
615
636
  'ORDER_TARGET_REQUIRED',
616
637
  'ORDER_SOURCE_CONFLICT',
@@ -650,6 +671,10 @@ exports.ORDER_ERROR_CODES = [
650
671
  'CART_PRICES_CHANGED',
651
672
  'ORDER_ID_COLLISION',
652
673
  'DELIVERY_METHOD_NOT_FOUND',
674
+ // A priced delivery method (`Method.fee`): the freight moved since the shopper
675
+ // saw it, or the cart is not in the store's order currency.
676
+ 'DELIVERY_FEE_CHANGED',
677
+ 'DELIVERY_FEE_CURRENCY_UNSUPPORTED',
653
678
  'ORDER_BELOW_MINIMUM_PURCHASE',
654
679
  'ORDER_INVALID_CART',
655
680
  // The storefront's confirmed-cart pin (`StorefrontOrderCreateRequest.expectedCartId` / `expectedCartVersion`).
package/dist/cjs/store.js CHANGED
@@ -139,6 +139,14 @@ exports.STORE_MODULE_ERROR_CODES = [
139
139
  * entry naming no list of the store, with `data: { field, value }` where
140
140
  * `field` is `<catalog>[<row>].availability.priceLists[<entry>]`.
141
141
  *
142
+ * - `DELIVERY_FEE_INVALID` — `POST /store` only: a delivery row's `fee` carries
143
+ * an amount or a `freeAbove` that is not a finite number of at least `0` at
144
+ * the order currency's ledger scale, with `data: { field }` where `field` is
145
+ * `deliveryMethods[<row>].fee.<key>`; or a `paymentMethods` row carries a
146
+ * `fee` at all, with `field` `paymentMethods[<row>].fee`. A `fee` that is not
147
+ * an object, or that carries a key other than those two, is
148
+ * `VALIDATION_FAILED`.
149
+ *
142
150
  * Request refusal, `409`:
143
151
  * - `WHOLESALE_LIST_REQUIRED` — an `ecommerce` save turns
144
152
  * `config.wholesaleRequests` on while the store holds no
@@ -177,6 +185,7 @@ exports.STORE_PATCH_ERROR_CODES = [
177
185
  'DISPLAY_CURRENCY_NOT_INVOICEABLE',
178
186
  'PRODUCT_CURRENCY_NOT_INVOICEABLE',
179
187
  'PRICE_LIST_NOT_FOUND',
188
+ 'DELIVERY_FEE_INVALID',
180
189
  'WHOLESALE_LIST_REQUIRED',
181
190
  'FORBIDDEN',
182
191
  'STORE_NOT_FOUND',
package/dist/order.d.ts CHANGED
@@ -5,6 +5,32 @@ declare global {
5
5
  grandTotal: number;
6
6
  currency: string;
7
7
  }
8
+ /**
9
+ * `409 DELIVERY_FEE_CHANGED`'s `data`: the freight the server computed for
10
+ * the chosen delivery method, in the order currency, `0` when the method is
11
+ * unpriced or its fee is waived. Show it and confirm again with it as
12
+ * `StorefrontOrderCreateRequest.expectedFreight`.
13
+ */
14
+ interface DeliveryFeeChangedData {
15
+ freight: number;
16
+ }
17
+ /**
18
+ * Why a priced delivery method charged nothing: the goods total met the
19
+ * method's `fee.freeAbove`, or the cart's promotion waives shipping.
20
+ */
21
+ type OrderFreightWaiver = 'freeAbove' | 'promotion';
22
+ /**
23
+ * Which priced delivery method booked this order's freight line, and why it
24
+ * charged nothing when it did. METADATA only, never money: the charge is the
25
+ * `lineKind: 'freight'` line in `items`, which is what `total`, the payment
26
+ * attempt, the receivable and the voucher all read.
27
+ */
28
+ interface OrderFreight {
29
+ /** The `Store.deliveryMethods` row id whose `fee` was charged. */
30
+ methodId: number;
31
+ /** Present only when the line booked at 0 because the fee was waived. */
32
+ waivedBy?: OrderFreightWaiver;
33
+ }
8
34
  /**
9
35
  * A coupon as it was redeemed onto an order — the grant frozen at
10
36
  * consumption, plus the money it actually took.
@@ -250,6 +276,25 @@ declare global {
250
276
  productIds: string[];
251
277
  }
252
278
  interface OrderLine extends CartLine {
279
+ /**
280
+ * What kind of line this is. Absent means a goods (or service) line, which is
281
+ * every line written before freight existed: forward-only, never backfilled.
282
+ *
283
+ * `'freight'`: a server-owned, productless delivery charge. It carries no
284
+ * `productId` — a line naming one is goods whatever this says
285
+ * (`isFreightLine`); the order discount never applies to it, it moves no
286
+ * stock and writes no `SALE#` row, and it is never returnable or shippable.
287
+ * A return never credits it: the freight stays with the store.
288
+ *
289
+ * Fiscally the voucher reads the line's OWN stored `ivaType`, stamped from
290
+ * the store's `integrations.afip.freight` when the line is written, so a
291
+ * later config change never re-rates it. Only its Concepto is read live off
292
+ * that config, on a factura; a credit note restates its factura's.
293
+ *
294
+ * ⚠️ **Server-owned.** No order writer accepts it from a client;
295
+ * `stripServerOwnedLineFields` drops a caller-sent value.
296
+ */
297
+ lineKind?: 'freight';
253
298
  /** Base unit frozen from the product at sale; absent means unknown, never inferred on historical lines. */
254
299
  unit?: ProductUnit;
255
300
  /** Server-owned denomination of finite cost; absent means unknown. */
@@ -908,12 +953,17 @@ declare global {
908
953
  * deduction skips a service line rather than moving inventory a second
909
954
  * time.
910
955
  *
911
- * `Order.discount` is a percentage and does NOT reach those lines — and
912
- * must not, since the two units cannot be added and converting between
913
- * them does not round-trip. The service order is the sole owner of its own
914
- * total (its own `discount` is already spent in the lines above), so the
915
- * figure invoiced is the figure the customer agreed to. The percentage
916
- * still applies normally to any goods bought in the same visit.
956
+ * ⚠️ `Order.discount` DOES reach those lines. The ticket's own absolute
957
+ * `discount` is already spent in them, and `POST /orders` refuses an
958
+ * operator percentage on an order carrying this pointer; but a same-visit
959
+ * handover whose counter basket carries a discount stores
960
+ * `goodsDiscountPercent` (`_deliverOrder.ts`, `buildDeliveryOrderRow`): the
961
+ * basket's discount over the FULL gross, basket plus service lines. Every
962
+ * per-line site (`chargedLineTotal`, `buildInvoiceEconomics`) then cuts
963
+ * EVERY line by it, service lines included, so the order's total discount
964
+ * equals the basket's while being spread across the repair too. With no
965
+ * basket discount it is `0` and the service lines are billed exactly as
966
+ * minted. Only a freight line (`lineKind`) is ever exempt.
917
967
  */
918
968
  serviceOrderId?: string;
919
969
  /**
@@ -1165,6 +1215,13 @@ declare global {
1165
1215
  * nothing else can tell a second release from a first.
1166
1216
  */
1167
1217
  coupons?: OrderCoupon[];
1218
+ /**
1219
+ * Present only on a storefront order placed on a delivery method that
1220
+ * carries a `fee` (`Method.fee`), and then always beside exactly one
1221
+ * `lineKind: 'freight'` line. Server-owned: written by storefront checkout
1222
+ * and by no other writer, and stripped from an operator body.
1223
+ */
1224
+ freight?: OrderFreight;
1168
1225
  orderPrinted?: boolean;
1169
1226
  tagPrinted?: boolean;
1170
1227
  /**
@@ -2413,6 +2470,17 @@ declare global {
2413
2470
  * transaction refuses too.
2414
2471
  */
2415
2472
  expectedCartVersion?: number;
2473
+ /**
2474
+ * The freight the storefront showed for `deliveryMethod`, in the order
2475
+ * currency: the row's `fee.amount`, or `0` when `fee.freeAbove` is met by the
2476
+ * cart's `grandTotal` or the cart's promotion waives shipping. Omit it (or
2477
+ * send `0`) for an unpriced method. The server recomputes it and refuses a
2478
+ * different figure `409 DELIVERY_FEE_CHANGED` with `data.freight`
2479
+ * (`DeliveryFeeChangedData`), writing nothing. ⚠️ Omitting it on a method
2480
+ * whose fee comes to more than `0` is refused the same way: the shopper is
2481
+ * never charged a freight they were not shown.
2482
+ */
2483
+ expectedFreight?: number;
2416
2484
  }
2417
2485
  interface ZebraTag {
2418
2486
  orderId: string;
@@ -2542,7 +2610,8 @@ type OrderFulfilmentProgressInput = Pick<Partial<Order>, 'items' | 'shipments' |
2542
2610
  * The ONE reader of the per-line fulfilment ledger (`OrderLine.fulfilledQuantity`).
2543
2611
  *
2544
2612
  * - A missing `fulfilledQuantity` counts as 0; lines with no or zero `quantity`
2545
- * are ignored on both sides of the ratio.
2613
+ * are ignored on both sides of the ratio, and so is a freight line
2614
+ * (`lineKind: 'freight'` with no `productId`), which is never shipped.
2546
2615
  * - `deliveredAt > 0` with no `shipments` is `complete` — a whole-order delivery
2547
2616
  * that never went through the shipment ledger.
2548
2617
  * - A `disabled` or cancelled row is `none`, whatever timestamps it carries: a
@@ -2692,6 +2761,9 @@ export declare const orderFulfilmentProgress: (order: OrderFulfilmentProgressInp
2692
2761
  * is refused after it, like every other refusal at commit.
2693
2762
  * - `ORDER_HAS_KIT_LINES` · 409 — `mode: 'edit'` on an order holding a kit line
2694
2763
  * (`CartLine.kit`). Cancel or return the order instead. Nothing was written.
2764
+ * - `ORDER_HAS_FREIGHT_LINE` · 409 — `mode: 'edit'` on an order holding a
2765
+ * freight line (`OrderLine.lineKind: 'freight'`). Cancel or return the order
2766
+ * instead. Nothing was written.
2695
2767
  * - `CART_PROMOTION_UNAVAILABLE` · 409 — the insert leg converting a STORED
2696
2768
  * ticket whose promotion ended, was paused, deleted, has not started or is
2697
2769
  * no longer cart-applicable; the `PromotionRefusal` rides `data.reason`. No
@@ -2790,6 +2862,15 @@ export declare const orderFulfilmentProgress: (order: OrderFulfilmentProgressInp
2790
2862
  * - `DELIVERY_METHOD_NOT_FOUND` · 400 — `deliveryMethod` is not in the store's
2791
2863
  * delivery catalogue, including an absent/empty catalogue. `data: {}`;
2792
2864
  * refused before reading the cart.
2865
+ * - `DELIVERY_FEE_CURRENCY_UNSUPPORTED` · 409 — the chosen delivery method
2866
+ * carries a `fee` and the cart is not in the store's order currency
2867
+ * (`config.displayCurrency`, pesos when unset), the currency the fee is
2868
+ * stated in. `data: {}`; refused after the re-price.
2869
+ * - `DELIVERY_FEE_CHANGED` · 409 — `expectedFreight` (absent reads as `0`)
2870
+ * differs from the freight the server computes for the chosen delivery
2871
+ * method. `data: DeliveryFeeChangedData` carries the server figure; show it
2872
+ * and confirm again. Refused after the re-price and the minimum purchase,
2873
+ * before any order id, coupon redemption or write.
2793
2874
  * - `ORDER_INVALID_CART` · 400 — the normalized cart has no finite numeric
2794
2875
  * `totals.grandTotal`. `data: {}`; refused before repricing/allocation.
2795
2876
  * - `CART_CHANGED_SINCE_CONFIRM` · 409 — the body sent `expectedCartId` /
@@ -2942,6 +3023,6 @@ export declare const orderFulfilmentProgress: (order: OrderFulfilmentProgressInp
2942
3023
  * `SUBSCRIPTION_READONLY`) sit on the order CREATE leg only: an edit is not a new
2943
3024
  * order, so `bareOrderPostHandler` routes past `requireMetered` entirely.
2944
3025
  */
2945
- export declare const ORDER_ERROR_CODES: readonly ["ORDER_COST_DENOMINATION_UNKNOWN", "SERVICE_ORDER_DELIVERY_MANAGED", "ORDER_NOT_FOUND", "ORDER_LOCKED", "ORDER_NOT_READY", "ORDER_DELIVERED_ANOTHER_DAY", "ORDER_DELIVERY_STATE_UNCHANGED", "ORDER_ILLEGAL_TRANSITION", "ORDER_VERSION_CONFLICT", "CUSTOMER_NOT_FOUND", "CUSTOMER_MERGED", "ORDER_HAS_NO_CUSTOMER", "CUSTOMER_ANONYMIZED", "FX_CONVERSION_UNAVAILABLE", "ROLE_FORBIDDEN", "ORDER_CANCELLED", "PAYMENT_SETTLED_ON_ANOTHER_ORDER", "ORDER_HAS_SHIPMENTS", "ORDER_HAS_RETURNS", "SHIPMENT_QUANTITY_EXCEEDED", "SHIPMENT_LINE_MISMATCH", "SHIPMENT_NOT_FOUND", "SHIPMENT_LIMIT_REACHED", "SHIPMENT_TOO_LARGE", "ORDER_FULFILMENT_EXTERNAL", "SHIPMENT_FAILED", "ADMIN_REQUIRED", "IDEMPOTENCY_KEY_REQUIRED", "INVALID_IDEMPOTENCY_KEY", "IDEMPOTENCY_KEY_REUSE", "IDEMPOTENCY_IN_PROGRESS", "IDEMPOTENCY_LOCK_CONTENTION", "IDEMPOTENCY_KEY_FAILED", "IDEMPOTENT_RESPONSE_NOT_CACHED", "ORDER_CANCELLATION_NOT_PROTECTED", "ORDER_CANCELLATION_COMMITTED", "ORDER_CANCELLATION_LOCKED", "ORDER_CANCELLATION_TOO_LARGE", "ORDER_CANCELLATION_FAILED", "SALE_LEDGER_RETRACTION_REFUSED", "SALE_LEDGER_ROW_NOT_OWNED", "PRODUCT_NOT_FOUND", "PRODUCT_SALE_LIMIT_EXCEEDED", "PRODUCT_SALE_LIMIT_INVALID", "DEPOSIT_SOURCE_NOT_ALLOWED", "DEPOSIT_CURRENCY_MISMATCH", "DEPOSIT_EXCEEDS_TOTAL", "DEPOSIT_FREEZE_REQUIRES_INVOICE", "DEPOSIT_FREEZE_INVOICE_PENDING", "DEPOSIT_CHARACTERIZATION_CONFLICT", "DEPOSIT_FREEZE_INVOICE_NOT_QUALIFYING", "DEPOSIT_INVOICED_ORDER_MUST_FREEZE", "DEPOSIT_FROZEN_ORDER_MUST_FREEZE", "DEPOSIT_REFERENCE_IS_LINKED_PAYMENT", "DEPOSIT_DUPLICATE_REFERENCE", "TILL_TENDER_REQUIRES_DEPOSIT", "PAYMENT_REFERENCED_BY_DEPOSIT", "ORDER_HAS_UNREFUNDED_DEPOSIT", "ORDER_PRICE_FROZEN", "DEPOSIT_NOT_FOUND", "DEPOSIT_ALREADY_REFUNDED", "UNIT_QUANTITY_NOT_WHOLE", "UNIT_REVISION_STALE", "UNIT_QUANTITY_UNREPRESENTABLE", "KIT_RECIPE_CHANGED", "CART_PROMOTION_UNAVAILABLE", "ORDER_HAS_KIT_LINES", "ORDER_TARGET_REQUIRED", "ORDER_SOURCE_CONFLICT", "ORDER_CUSTOMER_REQUIRED", "BASKET_EMPTY", "BASKET_CHANGED_DURING_CHECKOUT", "CART_VERSION_CREATE_ONLY", "CART_VERSION_REQUIRES_CART_ID", "CART_REVISION_STALE", "CART_CUSTOMER_MISMATCH", "COUNTER_SALE_CREATE_ONLY", "SOLD_AT_CREATE_ONLY", "SOLD_AT_IN_FUTURE", "ORDER_TENDER_CREATE_ONLY", "CREDIT_OVERRIDE_CREATE_ONLY", "ON_ACCOUNT_CREATE_ONLY", "ON_ACCOUNT_WITH_TENDERS", "TENDERS_REQUIRE_COUNTER_SALE", "LINES_REQUIRE_COUNTER_SALE", "PRODUCT_COST_UNKNOWN", "PRICE_CHANGE_DISABLED", "LINE_DISCOUNT_EXCEEDS_MAX", "CUSTOMER_DISABLED", "SHIFT_NOT_AVAILABLE", "SOLD_AT_OUTSIDE_SHIFT", "ORDER_CURRENCY_NOT_SUBSCRIBED", "PAYMENT_METHODS_NOT_CONFIGURED", "PAYMENT_METHOD_NOT_FOUND", "PAYMENT_METHOD_UNAVAILABLE", "CART_PRICES_CHANGED", "ORDER_ID_COLLISION", "DELIVERY_METHOD_NOT_FOUND", "ORDER_BELOW_MINIMUM_PURCHASE", "ORDER_INVALID_CART", "CART_CHANGED_SINCE_CONFIRM", "EMAIL_VERIFICATION_REQUIRED", "ACCOUNT_DISABLED", "CUSTOMER_ACCESS_PENDING", "CUSTOMER_ACCESS_REJECTED", "CURRENCY_MISMATCH", "SHIFT_NOT_OPEN", "ORDER_DISCOUNT_AFTER_INVOICE", "ORDER_DISCOUNT_ON_SERVICE_ORDER", "ORDER_DISCOUNT_ON_MARKETPLACE_ORDER", "ORDER_INVOICE_METHOD_OUTSTANDING_FACTURA", "ORDER_SERVICE_PERIOD_AFTER_INVOICE", "ORDER_ATTEMPT_COMMITTED", "ORDER_ATTEMPT_ABANDONED", "ORDER_ATTEMPT_KEY_EXPIRED", "ORDER_ATTEMPT_KEY_SCOPE_MISMATCH", "ORDER_COMPLETION_ATTEMPT_COMMITTED", "ORDER_COMPLETION_ATTEMPT_ABANDONED"];
3026
+ export declare const ORDER_ERROR_CODES: readonly ["ORDER_COST_DENOMINATION_UNKNOWN", "SERVICE_ORDER_DELIVERY_MANAGED", "ORDER_NOT_FOUND", "ORDER_LOCKED", "ORDER_NOT_READY", "ORDER_DELIVERED_ANOTHER_DAY", "ORDER_DELIVERY_STATE_UNCHANGED", "ORDER_ILLEGAL_TRANSITION", "ORDER_VERSION_CONFLICT", "CUSTOMER_NOT_FOUND", "CUSTOMER_MERGED", "ORDER_HAS_NO_CUSTOMER", "CUSTOMER_ANONYMIZED", "FX_CONVERSION_UNAVAILABLE", "ROLE_FORBIDDEN", "ORDER_CANCELLED", "PAYMENT_SETTLED_ON_ANOTHER_ORDER", "ORDER_HAS_SHIPMENTS", "ORDER_HAS_RETURNS", "SHIPMENT_QUANTITY_EXCEEDED", "SHIPMENT_LINE_MISMATCH", "SHIPMENT_NOT_FOUND", "SHIPMENT_LIMIT_REACHED", "SHIPMENT_TOO_LARGE", "ORDER_FULFILMENT_EXTERNAL", "SHIPMENT_FAILED", "ADMIN_REQUIRED", "IDEMPOTENCY_KEY_REQUIRED", "INVALID_IDEMPOTENCY_KEY", "IDEMPOTENCY_KEY_REUSE", "IDEMPOTENCY_IN_PROGRESS", "IDEMPOTENCY_LOCK_CONTENTION", "IDEMPOTENCY_KEY_FAILED", "IDEMPOTENT_RESPONSE_NOT_CACHED", "ORDER_CANCELLATION_NOT_PROTECTED", "ORDER_CANCELLATION_COMMITTED", "ORDER_CANCELLATION_LOCKED", "ORDER_CANCELLATION_TOO_LARGE", "ORDER_CANCELLATION_FAILED", "SALE_LEDGER_RETRACTION_REFUSED", "SALE_LEDGER_ROW_NOT_OWNED", "PRODUCT_NOT_FOUND", "PRODUCT_SALE_LIMIT_EXCEEDED", "PRODUCT_SALE_LIMIT_INVALID", "DEPOSIT_SOURCE_NOT_ALLOWED", "DEPOSIT_CURRENCY_MISMATCH", "DEPOSIT_EXCEEDS_TOTAL", "DEPOSIT_FREEZE_REQUIRES_INVOICE", "DEPOSIT_FREEZE_INVOICE_PENDING", "DEPOSIT_CHARACTERIZATION_CONFLICT", "DEPOSIT_FREEZE_INVOICE_NOT_QUALIFYING", "DEPOSIT_INVOICED_ORDER_MUST_FREEZE", "DEPOSIT_FROZEN_ORDER_MUST_FREEZE", "DEPOSIT_REFERENCE_IS_LINKED_PAYMENT", "DEPOSIT_DUPLICATE_REFERENCE", "TILL_TENDER_REQUIRES_DEPOSIT", "PAYMENT_REFERENCED_BY_DEPOSIT", "ORDER_HAS_UNREFUNDED_DEPOSIT", "ORDER_PRICE_FROZEN", "DEPOSIT_NOT_FOUND", "DEPOSIT_ALREADY_REFUNDED", "UNIT_QUANTITY_NOT_WHOLE", "UNIT_REVISION_STALE", "UNIT_QUANTITY_UNREPRESENTABLE", "KIT_RECIPE_CHANGED", "CART_PROMOTION_UNAVAILABLE", "ORDER_HAS_KIT_LINES", "ORDER_HAS_FREIGHT_LINE", "ORDER_TARGET_REQUIRED", "ORDER_SOURCE_CONFLICT", "ORDER_CUSTOMER_REQUIRED", "BASKET_EMPTY", "BASKET_CHANGED_DURING_CHECKOUT", "CART_VERSION_CREATE_ONLY", "CART_VERSION_REQUIRES_CART_ID", "CART_REVISION_STALE", "CART_CUSTOMER_MISMATCH", "COUNTER_SALE_CREATE_ONLY", "SOLD_AT_CREATE_ONLY", "SOLD_AT_IN_FUTURE", "ORDER_TENDER_CREATE_ONLY", "CREDIT_OVERRIDE_CREATE_ONLY", "ON_ACCOUNT_CREATE_ONLY", "ON_ACCOUNT_WITH_TENDERS", "TENDERS_REQUIRE_COUNTER_SALE", "LINES_REQUIRE_COUNTER_SALE", "PRODUCT_COST_UNKNOWN", "PRICE_CHANGE_DISABLED", "LINE_DISCOUNT_EXCEEDS_MAX", "CUSTOMER_DISABLED", "SHIFT_NOT_AVAILABLE", "SOLD_AT_OUTSIDE_SHIFT", "ORDER_CURRENCY_NOT_SUBSCRIBED", "PAYMENT_METHODS_NOT_CONFIGURED", "PAYMENT_METHOD_NOT_FOUND", "PAYMENT_METHOD_UNAVAILABLE", "CART_PRICES_CHANGED", "ORDER_ID_COLLISION", "DELIVERY_METHOD_NOT_FOUND", "DELIVERY_FEE_CHANGED", "DELIVERY_FEE_CURRENCY_UNSUPPORTED", "ORDER_BELOW_MINIMUM_PURCHASE", "ORDER_INVALID_CART", "CART_CHANGED_SINCE_CONFIRM", "EMAIL_VERIFICATION_REQUIRED", "ACCOUNT_DISABLED", "CUSTOMER_ACCESS_PENDING", "CUSTOMER_ACCESS_REJECTED", "CURRENCY_MISMATCH", "SHIFT_NOT_OPEN", "ORDER_DISCOUNT_AFTER_INVOICE", "ORDER_DISCOUNT_ON_SERVICE_ORDER", "ORDER_DISCOUNT_ON_MARKETPLACE_ORDER", "ORDER_INVOICE_METHOD_OUTSTANDING_FACTURA", "ORDER_SERVICE_PERIOD_AFTER_INVOICE", "ORDER_ATTEMPT_COMMITTED", "ORDER_ATTEMPT_ABANDONED", "ORDER_ATTEMPT_KEY_EXPIRED", "ORDER_ATTEMPT_KEY_SCOPE_MISMATCH", "ORDER_COMPLETION_ATTEMPT_COMMITTED", "ORDER_COMPLETION_ATTEMPT_ABANDONED"];
2946
3027
  export type OrderErrorCode = (typeof ORDER_ERROR_CODES)[number];
2947
3028
  export {};
package/dist/order.js CHANGED
@@ -103,7 +103,8 @@ const positiveUnits = (value) => (typeof value === 'number' && value > 0 ? value
103
103
  * The ONE reader of the per-line fulfilment ledger (`OrderLine.fulfilledQuantity`).
104
104
  *
105
105
  * - A missing `fulfilledQuantity` counts as 0; lines with no or zero `quantity`
106
- * are ignored on both sides of the ratio.
106
+ * are ignored on both sides of the ratio, and so is a freight line
107
+ * (`lineKind: 'freight'` with no `productId`), which is never shipped.
107
108
  * - `deliveredAt > 0` with no `shipments` is `complete` — a whole-order delivery
108
109
  * that never went through the shipment ledger.
109
110
  * - A `disabled` or cancelled row is `none`, whatever timestamps it carries: a
@@ -114,6 +115,12 @@ export const orderFulfilmentProgress = (order) => {
114
115
  let orderedUnits = 0;
115
116
  let fulfilledUnits = 0;
116
117
  for (const line of order.items ?? []) {
118
+ // A freight line is a charge, never handed over, so it would hold a
119
+ // fully shipped order at `partial` forever. The same test as
120
+ // `isFreightLine` (`stacks/helpers/discountCalculations.ts`), inlined
121
+ // because contracts import nothing from `stacks/`.
122
+ if (line?.lineKind === 'freight' && line.productId === undefined)
123
+ continue;
117
124
  const ordered = positiveUnits(line?.quantity);
118
125
  if (ordered === 0)
119
126
  continue;
@@ -272,6 +279,9 @@ export const orderFulfilmentProgress = (order) => {
272
279
  * is refused after it, like every other refusal at commit.
273
280
  * - `ORDER_HAS_KIT_LINES` · 409 — `mode: 'edit'` on an order holding a kit line
274
281
  * (`CartLine.kit`). Cancel or return the order instead. Nothing was written.
282
+ * - `ORDER_HAS_FREIGHT_LINE` · 409 — `mode: 'edit'` on an order holding a
283
+ * freight line (`OrderLine.lineKind: 'freight'`). Cancel or return the order
284
+ * instead. Nothing was written.
275
285
  * - `CART_PROMOTION_UNAVAILABLE` · 409 — the insert leg converting a STORED
276
286
  * ticket whose promotion ended, was paused, deleted, has not started or is
277
287
  * no longer cart-applicable; the `PromotionRefusal` rides `data.reason`. No
@@ -370,6 +380,15 @@ export const orderFulfilmentProgress = (order) => {
370
380
  * - `DELIVERY_METHOD_NOT_FOUND` · 400 — `deliveryMethod` is not in the store's
371
381
  * delivery catalogue, including an absent/empty catalogue. `data: {}`;
372
382
  * refused before reading the cart.
383
+ * - `DELIVERY_FEE_CURRENCY_UNSUPPORTED` · 409 — the chosen delivery method
384
+ * carries a `fee` and the cart is not in the store's order currency
385
+ * (`config.displayCurrency`, pesos when unset), the currency the fee is
386
+ * stated in. `data: {}`; refused after the re-price.
387
+ * - `DELIVERY_FEE_CHANGED` · 409 — `expectedFreight` (absent reads as `0`)
388
+ * differs from the freight the server computes for the chosen delivery
389
+ * method. `data: DeliveryFeeChangedData` carries the server figure; show it
390
+ * and confirm again. Refused after the re-price and the minimum purchase,
391
+ * before any order id, coupon redemption or write.
373
392
  * - `ORDER_INVALID_CART` · 400 — the normalized cart has no finite numeric
374
393
  * `totals.grandTotal`. `data: {}`; refused before repricing/allocation.
375
394
  * - `CART_CHANGED_SINCE_CONFIRM` · 409 — the body sent `expectedCartId` /
@@ -604,6 +623,8 @@ export const ORDER_ERROR_CODES = [
604
623
  'CART_PROMOTION_UNAVAILABLE',
605
624
  // `mode: 'edit'` on an order holding a kit line; cancel or return it instead.
606
625
  'ORDER_HAS_KIT_LINES',
626
+ // `mode: 'edit'` on an order holding a freight line; cancel or return it instead.
627
+ 'ORDER_HAS_FREIGHT_LINE',
607
628
  // Create-leg refusals about the sale's source, already answered on the wire.
608
629
  'ORDER_TARGET_REQUIRED',
609
630
  'ORDER_SOURCE_CONFLICT',
@@ -643,6 +664,10 @@ export const ORDER_ERROR_CODES = [
643
664
  'CART_PRICES_CHANGED',
644
665
  'ORDER_ID_COLLISION',
645
666
  'DELIVERY_METHOD_NOT_FOUND',
667
+ // A priced delivery method (`Method.fee`): the freight moved since the shopper
668
+ // saw it, or the cart is not in the store's order currency.
669
+ 'DELIVERY_FEE_CHANGED',
670
+ 'DELIVERY_FEE_CURRENCY_UNSUPPORTED',
646
671
  'ORDER_BELOW_MINIMUM_PURCHASE',
647
672
  'ORDER_INVALID_CART',
648
673
  // The storefront's confirmed-cart pin (`StorefrontOrderCreateRequest.expectedCartId` / `expectedCartVersion`).
package/dist/store.d.ts CHANGED
@@ -1599,6 +1599,29 @@ declare global {
1599
1599
  /** ISO date; stops applying on or after. Omitted => open-ended. */
1600
1600
  expiresAt?: string;
1601
1601
  }
1602
+ /**
1603
+ * An AFIP Iva Id — one of `IVA_TYPES` (`services/fiscalCatalogs.ts`): 3 (0 %),
1604
+ * 9 (2,5 %), 8 (5 %), 4 (10,5 %), 5 (21 %), 6 (27 %). `number`, like every
1605
+ * `ivaType` in this contract, so a line's stored rate and a configured one
1606
+ * compare without a cast; the catalog, not this type, is the authority.
1607
+ * ⚠️ Not every write path validates against it: `PATCH /store` does
1608
+ * (`afipPatchSchema`), but `POST /store` and `POST /tenants` take `afip`
1609
+ * unvalidated, so a reader falls back on an out-of-catalog value
1610
+ * (`resolveFreightFiscal`) rather than trusting the row.
1611
+ */
1612
+ type IvaTypeId = number;
1613
+ /**
1614
+ * How the store's freight line (`OrderLine.lineKind: 'freight'`) is declared
1615
+ * to ARCA. Configuration the store's accountant decides, not a fact the code
1616
+ * can derive: whether delivery is a separate service or an accessory of the
1617
+ * sale, and at which rate, depends on how the store sells.
1618
+ */
1619
+ interface AfipFreightFiscal {
1620
+ /** The alícuota stamped on the freight line, and so declared in `Iva[]`. */
1621
+ ivaType: IvaTypeId;
1622
+ /** Whether the freight line counts as goods or as a service for `Concepto`. */
1623
+ concepto: 'goods' | 'services';
1624
+ }
1602
1625
  interface Afip {
1603
1626
  production: boolean;
1604
1627
  address?: string;
@@ -1669,6 +1692,14 @@ declare global {
1669
1692
  fceEnabled?: boolean;
1670
1693
  wscdcEnabled?: boolean;
1671
1694
  fceReceivedCheckpoint?: number;
1695
+ /**
1696
+ * The freight line's IVA rate and Concepto. Absent means the platform
1697
+ * default, `ivaType` 5 (21 %) and `concepto` `'goods'`
1698
+ * (`DEFAULT_FREIGHT_FISCAL`); read it through `resolveFreightFiscal`, never
1699
+ * directly. ADMIN-tier on `PATCH /store` (`PRIVILEGED_AFIP_FIELDS`); `null`
1700
+ * clears it back to the default.
1701
+ */
1702
+ freight?: AfipFreightFiscal;
1672
1703
  }
1673
1704
  /**
1674
1705
  * Write shape for the `afip` key of `PATCH /store`'s body. The wire accepts an
@@ -1683,6 +1714,7 @@ declare global {
1683
1714
  iibbTransparency?: Afip['iibbTransparency'] | null;
1684
1715
  iibbJurisdictions?: IibbJurisdictionConfig[] | null;
1685
1716
  actividades?: number[] | null;
1717
+ freight?: AfipFreightFiscal | null;
1686
1718
  }
1687
1719
  /**
1688
1720
  * Write shape for the `config` key of `PATCH /store`'s body. Two things the
@@ -1812,6 +1844,45 @@ declare global {
1812
1844
  * is sent back without `availability`; sending a valid rule replaces it.
1813
1845
  */
1814
1846
  availability?: StorefrontDesignVisibility;
1847
+ /**
1848
+ * The price of this DELIVERY method, charged on a storefront order as one
1849
+ * server-owned freight line (`OrderLine.lineKind: 'freight'`). ABSENT means
1850
+ * unpriced: the order books no freight, exactly as before the key existed.
1851
+ * Any delivery row may carry one, the pickup row included. Written by
1852
+ * `POST /store`; carried by every read of a `deliveryMethods` row, the
1853
+ * storefront `GET /store` and the CUSTOMER STORE frame included, because it
1854
+ * is the price the shopper pays.
1855
+ *
1856
+ * DELIVERY rows only. The row type is shared, but `POST /store` refuses a
1857
+ * `fee` on a `paymentMethods` row (`400 DELIVERY_FEE_INVALID`, `data.field`
1858
+ * `paymentMethods[<row>].fee`), and every read drops one a legacy payment
1859
+ * row still holds — nothing charges it there.
1860
+ */
1861
+ fee?: MethodFee;
1862
+ }
1863
+ /**
1864
+ * A delivery method's price, in the store's order currency
1865
+ * (`config.displayCurrency`, pesos when unset) and IVA-inclusive like every
1866
+ * line price.
1867
+ *
1868
+ * `POST /store` refuses `400 DELIVERY_FEE_INVALID` (with `data.field`) unless
1869
+ * both numbers are finite, at least `0`, and representable at that currency's
1870
+ * ledger scale (2 decimals for every seeded currency). On read, a stored fee
1871
+ * is dropped, never coerced, only when it breaks the SHAPE (a key other than
1872
+ * these two, or an amount that is not a finite number of at least `0`); a
1873
+ * stored amount off the ledger scale is still read, and checkout rounds it to
1874
+ * the scale.
1875
+ */
1876
+ interface MethodFee {
1877
+ /** What the method charges. `0` books a freight line at `0`. */
1878
+ amount: number;
1879
+ /**
1880
+ * The goods total from which the method is free: when the cart's
1881
+ * `grandTotal` (after every discount, freight never included) is at least
1882
+ * this, the freight line books at `0` with `Order.freight.waivedBy:
1883
+ * 'freeAbove'`. Absent means never free by amount.
1884
+ */
1885
+ freeAbove?: number;
1815
1886
  }
1816
1887
  interface FiscalCondition {
1817
1888
  CbteTipo: {
@@ -2412,6 +2483,14 @@ export type StoreModuleRefusalBody = {
2412
2483
  * entry naming no list of the store, with `data: { field, value }` where
2413
2484
  * `field` is `<catalog>[<row>].availability.priceLists[<entry>]`.
2414
2485
  *
2486
+ * - `DELIVERY_FEE_INVALID` — `POST /store` only: a delivery row's `fee` carries
2487
+ * an amount or a `freeAbove` that is not a finite number of at least `0` at
2488
+ * the order currency's ledger scale, with `data: { field }` where `field` is
2489
+ * `deliveryMethods[<row>].fee.<key>`; or a `paymentMethods` row carries a
2490
+ * `fee` at all, with `field` `paymentMethods[<row>].fee`. A `fee` that is not
2491
+ * an object, or that carries a key other than those two, is
2492
+ * `VALIDATION_FAILED`.
2493
+ *
2415
2494
  * Request refusal, `409`:
2416
2495
  * - `WHOLESALE_LIST_REQUIRED` — an `ecommerce` save turns
2417
2496
  * `config.wholesaleRequests` on while the store holds no
@@ -2432,5 +2511,5 @@ export type StoreModuleRefusalBody = {
2432
2511
  * checks, the display-currency lock, the storefront fence) are not listed
2433
2512
  * either. Cross-cutting refusals: check `GATING_ERROR_CODES` as well.
2434
2513
  */
2435
- export declare const STORE_PATCH_ERROR_CODES: readonly ["STORE_CONFIG_FORBIDDEN", "STORE_ECOMMERCE_FORBIDDEN", "STORE_FISCAL_FIELD_FORBIDDEN", "STORE_JURISDICTION_FORBIDDEN", "AFIP_RELACION_FLAG_FORBIDDEN", "FX_TABLE_FORBIDDEN", "FX_AUTO_UPDATE_FORBIDDEN", "FIELD_NOT_WRITABLE_HERE", "AFIP_POINT_OF_SALE_NOT_CLEARABLE", "CURRENCY_CATALOG_ID_UNKNOWN", "ARS_RATE_MUST_BE_ONE", "CURRENCY_RATE_ABOVE_CEILING", "FX_CATALOG_ID_UNKNOWN", "FX_SOURCE_ID_UNKNOWN", "DISPLAY_CURRENCY_NOT_INVOICEABLE", "PRODUCT_CURRENCY_NOT_INVOICEABLE", "PRICE_LIST_NOT_FOUND", "WHOLESALE_LIST_REQUIRED", "FORBIDDEN", "STORE_NOT_FOUND"];
2514
+ export declare const STORE_PATCH_ERROR_CODES: readonly ["STORE_CONFIG_FORBIDDEN", "STORE_ECOMMERCE_FORBIDDEN", "STORE_FISCAL_FIELD_FORBIDDEN", "STORE_JURISDICTION_FORBIDDEN", "AFIP_RELACION_FLAG_FORBIDDEN", "FX_TABLE_FORBIDDEN", "FX_AUTO_UPDATE_FORBIDDEN", "FIELD_NOT_WRITABLE_HERE", "AFIP_POINT_OF_SALE_NOT_CLEARABLE", "CURRENCY_CATALOG_ID_UNKNOWN", "ARS_RATE_MUST_BE_ONE", "CURRENCY_RATE_ABOVE_CEILING", "FX_CATALOG_ID_UNKNOWN", "FX_SOURCE_ID_UNKNOWN", "DISPLAY_CURRENCY_NOT_INVOICEABLE", "PRODUCT_CURRENCY_NOT_INVOICEABLE", "PRICE_LIST_NOT_FOUND", "DELIVERY_FEE_INVALID", "WHOLESALE_LIST_REQUIRED", "FORBIDDEN", "STORE_NOT_FOUND"];
2436
2515
  export type StorePatchErrorCode = (typeof STORE_PATCH_ERROR_CODES)[number];
package/dist/store.js CHANGED
@@ -134,6 +134,14 @@ export const STORE_MODULE_ERROR_CODES = [
134
134
  * entry naming no list of the store, with `data: { field, value }` where
135
135
  * `field` is `<catalog>[<row>].availability.priceLists[<entry>]`.
136
136
  *
137
+ * - `DELIVERY_FEE_INVALID` — `POST /store` only: a delivery row's `fee` carries
138
+ * an amount or a `freeAbove` that is not a finite number of at least `0` at
139
+ * the order currency's ledger scale, with `data: { field }` where `field` is
140
+ * `deliveryMethods[<row>].fee.<key>`; or a `paymentMethods` row carries a
141
+ * `fee` at all, with `field` `paymentMethods[<row>].fee`. A `fee` that is not
142
+ * an object, or that carries a key other than those two, is
143
+ * `VALIDATION_FAILED`.
144
+ *
137
145
  * Request refusal, `409`:
138
146
  * - `WHOLESALE_LIST_REQUIRED` — an `ecommerce` save turns
139
147
  * `config.wholesaleRequests` on while the store holds no
@@ -172,6 +180,7 @@ export const STORE_PATCH_ERROR_CODES = [
172
180
  'DISPLAY_CURRENCY_NOT_INVOICEABLE',
173
181
  'PRODUCT_CURRENCY_NOT_INVOICEABLE',
174
182
  'PRICE_LIST_NOT_FOUND',
183
+ 'DELIVERY_FEE_INVALID',
175
184
  'WHOLESALE_LIST_REQUIRED',
176
185
  'FORBIDDEN',
177
186
  'STORE_NOT_FOUND',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.779",
3
+ "version": "1.10.781",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",