@sixtyninecommerce/admin 0.9.0 → 0.11.0

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.
Files changed (258) hide show
  1. package/README.md +4598 -128
  2. package/dist/catalog/assets.d.ts +120 -8
  3. package/dist/catalog/assets.js +98 -12
  4. package/dist/catalog/collections.d.ts +279 -14
  5. package/dist/catalog/collections.js +246 -15
  6. package/dist/catalog/index.d.ts +9 -2
  7. package/dist/catalog/index.js +4 -0
  8. package/dist/catalog/products.d.ts +318 -17
  9. package/dist/catalog/products.js +182 -14
  10. package/dist/catalog/properties.d.ts +102 -14
  11. package/dist/catalog/properties.js +13 -0
  12. package/dist/catalog/recommendations.d.ts +261 -0
  13. package/dist/catalog/recommendations.js +145 -0
  14. package/dist/catalog/reviews.d.ts +368 -0
  15. package/dist/catalog/reviews.js +318 -0
  16. package/dist/catalog/types.d.ts +17 -1
  17. package/dist/catalog/types.js +10 -0
  18. package/dist/catalog/variant-find.d.ts +136 -0
  19. package/dist/catalog/variant-find.js +239 -0
  20. package/dist/catalog/variants.d.ts +282 -25
  21. package/dist/catalog/variants.js +173 -25
  22. package/dist/catalog/visibility.d.ts +20 -5
  23. package/dist/catalog/visibility.js +19 -1
  24. package/dist/client.d.ts +116 -9
  25. package/dist/client.js +41 -7
  26. package/dist/content/assets.d.ts +286 -0
  27. package/dist/content/assets.js +181 -0
  28. package/dist/content/items.d.ts +269 -0
  29. package/dist/content/items.js +170 -0
  30. package/dist/content/types.d.ts +282 -0
  31. package/dist/content/types.js +100 -0
  32. package/dist/customers/age-verification.d.ts +66 -0
  33. package/dist/customers/age-verification.js +79 -0
  34. package/dist/customers/credit.d.ts +263 -0
  35. package/dist/customers/credit.js +244 -0
  36. package/dist/customers/delivery-preferences.d.ts +120 -0
  37. package/dist/customers/delivery-preferences.js +97 -0
  38. package/dist/customers/groups.d.ts +207 -0
  39. package/dist/customers/groups.js +438 -0
  40. package/dist/customers/index.d.ts +447 -37
  41. package/dist/customers/index.js +313 -40
  42. package/dist/customers/invitation-status.d.ts +57 -0
  43. package/dist/customers/invitation-status.js +21 -0
  44. package/dist/customers/notes.d.ts +67 -0
  45. package/dist/customers/notes.js +51 -0
  46. package/dist/customers/notification-recipients.d.ts +97 -0
  47. package/dist/customers/notification-recipients.js +84 -0
  48. package/dist/customers/saved-lists.d.ts +42 -0
  49. package/dist/customers/saved-lists.js +61 -0
  50. package/dist/customers/vat.d.ts +83 -0
  51. package/dist/customers/vat.js +46 -0
  52. package/dist/customers/wire.d.ts +20 -0
  53. package/dist/customers/wire.js +35 -0
  54. package/dist/documents/ar.d.ts +307 -0
  55. package/dist/documents/ar.js +254 -0
  56. package/dist/documents/index.d.ts +731 -21
  57. package/dist/documents/index.js +436 -24
  58. package/dist/documents/pdf.d.ts +2 -0
  59. package/dist/documents/pdf.js +11 -0
  60. package/dist/fulfillments/create.d.ts +167 -0
  61. package/dist/fulfillments/create.js +216 -0
  62. package/dist/fulfillments/index.d.ts +121 -10
  63. package/dist/fulfillments/index.js +120 -2
  64. package/dist/fulfillments/payment-policy.d.ts +64 -0
  65. package/dist/fulfillments/payment-policy.js +140 -0
  66. package/dist/fulfillments/warehouse.d.ts +724 -0
  67. package/dist/fulfillments/warehouse.js +914 -0
  68. package/dist/geo/index.d.ts +119 -0
  69. package/dist/geo/index.js +107 -0
  70. package/dist/index.d.ts +129 -30
  71. package/dist/index.js +47 -9
  72. package/dist/integrations/afas-actions.d.ts +234 -0
  73. package/dist/integrations/afas-actions.js +310 -0
  74. package/dist/integrations/afas-types.d.ts +483 -0
  75. package/dist/integrations/afas-types.js +5 -0
  76. package/dist/integrations/afas.d.ts +234 -0
  77. package/dist/integrations/afas.js +290 -0
  78. package/dist/integrations/connections.d.ts +103 -0
  79. package/dist/integrations/connections.js +55 -0
  80. package/dist/integrations/esp.d.ts +313 -0
  81. package/dist/integrations/esp.js +169 -0
  82. package/dist/integrations/exact-online-types.d.ts +423 -0
  83. package/dist/integrations/exact-online-types.js +6 -0
  84. package/dist/integrations/exact-online.d.ts +248 -0
  85. package/dist/integrations/exact-online.js +376 -0
  86. package/dist/integrations/index.d.ts +40 -0
  87. package/dist/integrations/index.js +24 -0
  88. package/dist/integrations/pipeline-keys.d.ts +13 -0
  89. package/dist/integrations/pipeline-keys.js +22 -0
  90. package/dist/integrations/pipelines.d.ts +114 -0
  91. package/dist/integrations/pipelines.js +46 -0
  92. package/dist/integrations/types.d.ts +322 -0
  93. package/dist/integrations/types.js +8 -0
  94. package/dist/jobs/bulk-action-run.d.ts +11 -2
  95. package/dist/jobs/bulk-action-run.js +4 -5
  96. package/dist/locations/index.d.ts +66 -0
  97. package/dist/locations/index.js +31 -0
  98. package/dist/meta/index.d.ts +162 -0
  99. package/dist/orders/bulk.d.ts +75 -0
  100. package/dist/orders/bulk.js +150 -0
  101. package/dist/orders/cancel-with-money.d.ts +227 -0
  102. package/dist/orders/cancel-with-money.js +153 -0
  103. package/dist/orders/commit-edit.d.ts +7 -1
  104. package/dist/orders/commit-edit.js +5 -1
  105. package/dist/orders/deposit-policy.d.ts +103 -0
  106. package/dist/orders/deposit-policy.js +202 -0
  107. package/dist/orders/drafts.d.ts +800 -0
  108. package/dist/orders/drafts.js +771 -0
  109. package/dist/orders/fields.d.ts +245 -0
  110. package/dist/orders/fields.js +188 -0
  111. package/dist/orders/get.d.ts +29 -19
  112. package/dist/orders/get.js +17 -8
  113. package/dist/orders/index.d.ts +125 -5
  114. package/dist/orders/index.js +35 -2
  115. package/dist/orders/lifecycle.d.ts +128 -0
  116. package/dist/orders/lifecycle.js +158 -0
  117. package/dist/orders/line-price-preview.d.ts +7 -2
  118. package/dist/orders/list.d.ts +222 -0
  119. package/dist/orders/list.js +377 -0
  120. package/dist/orders/manual-discounts.d.ts +11 -2
  121. package/dist/orders/manual-discounts.js +2 -0
  122. package/dist/orders/manual-pricing.d.ts +5 -0
  123. package/dist/orders/order-entry.d.ts +20 -7
  124. package/dist/orders/plan-edit.d.ts +1 -1
  125. package/dist/orders/plan-edit.js +4 -1
  126. package/dist/orders/settings.d.ts +201 -0
  127. package/dist/orders/settings.js +325 -0
  128. package/dist/orders/status.d.ts +159 -13
  129. package/dist/orders/status.js +21 -0
  130. package/dist/orders/surcharges.d.ts +8 -1
  131. package/dist/orders/surcharges.js +3 -2
  132. package/dist/payments/account-credit.d.ts +30 -0
  133. package/dist/payments/account-credit.js +19 -0
  134. package/dist/payments/ar.d.ts +292 -0
  135. package/dist/payments/ar.js +223 -0
  136. package/dist/payments/connected-account.d.ts +47 -0
  137. package/dist/payments/connected-account.js +61 -0
  138. package/dist/payments/credit-noted-fields.d.ts +12 -0
  139. package/dist/payments/credit-noted-fields.js +37 -0
  140. package/dist/payments/index.d.ts +263 -10
  141. package/dist/payments/index.js +133 -1
  142. package/dist/payments/methods.d.ts +332 -0
  143. package/dist/payments/methods.js +363 -0
  144. package/dist/payments/mollie-methods.d.ts +159 -0
  145. package/dist/payments/mollie-methods.js +141 -0
  146. package/dist/payments/payment-links.d.ts +180 -0
  147. package/dist/payments/payment-links.js +97 -0
  148. package/dist/payments/provider-keys.d.ts +150 -0
  149. package/dist/payments/provider-keys.js +118 -0
  150. package/dist/payments/providers.d.ts +86 -11
  151. package/dist/payments/providers.js +29 -0
  152. package/dist/payments/requests.d.ts +144 -0
  153. package/dist/payments/requests.js +92 -0
  154. package/dist/payments/store-credit-fields.d.ts +15 -0
  155. package/dist/payments/store-credit-fields.js +51 -0
  156. package/dist/pickups/index.d.ts +104 -0
  157. package/dist/pickups/index.js +105 -0
  158. package/dist/platform/channels.d.ts +132 -0
  159. package/dist/platform/channels.js +128 -0
  160. package/dist/platform/geo.d.ts +123 -0
  161. package/dist/platform/geo.js +144 -0
  162. package/dist/platform/tax.d.ts +154 -0
  163. package/dist/platform/tax.js +139 -0
  164. package/dist/pos/anomalies.d.ts +158 -0
  165. package/dist/pos/anomalies.js +64 -0
  166. package/dist/pos/assisted-selling.d.ts +79 -0
  167. package/dist/pos/assisted-selling.js +38 -0
  168. package/dist/pos/exchanges.d.ts +103 -0
  169. package/dist/pos/exchanges.js +22 -0
  170. package/dist/pos/gift-cards.d.ts +135 -0
  171. package/dist/pos/gift-cards.js +47 -0
  172. package/dist/pos/index.d.ts +2125 -32
  173. package/dist/pos/index.js +742 -4
  174. package/dist/pos/no-receipt.d.ts +94 -0
  175. package/dist/pos/no-receipt.js +25 -0
  176. package/dist/pos/offline-sales.d.ts +187 -0
  177. package/dist/pos/offline-sales.js +116 -0
  178. package/dist/pos/pay-by-link.d.ts +143 -0
  179. package/dist/pos/pay-by-link.js +57 -0
  180. package/dist/pos/quick-keys.d.ts +103 -0
  181. package/dist/pos/quick-keys.js +45 -0
  182. package/dist/pos/reports.d.ts +360 -0
  183. package/dist/pos/reports.js +62 -0
  184. package/dist/pos/returns.d.ts +217 -0
  185. package/dist/pos/returns.js +53 -0
  186. package/dist/pricing/bulk-coupons.d.ts +139 -0
  187. package/dist/pricing/bulk-coupons.js +112 -0
  188. package/dist/pricing/index.d.ts +177 -4
  189. package/dist/pricing/index.js +176 -1
  190. package/dist/pricing/price-lists.d.ts +604 -0
  191. package/dist/pricing/price-lists.js +600 -0
  192. package/dist/pricing/vouchers.d.ts +103 -0
  193. package/dist/pricing/vouchers.js +69 -0
  194. package/dist/purchasing/alerts.d.ts +89 -0
  195. package/dist/purchasing/alerts.js +62 -0
  196. package/dist/purchasing/cost.d.ts +110 -0
  197. package/dist/purchasing/cost.js +86 -0
  198. package/dist/purchasing/index.d.ts +36 -0
  199. package/dist/purchasing/index.js +16 -0
  200. package/dist/purchasing/purchase-orders.d.ts +548 -0
  201. package/dist/purchasing/purchase-orders.js +491 -0
  202. package/dist/purchasing/replenishment.d.ts +281 -0
  203. package/dist/purchasing/replenishment.js +240 -0
  204. package/dist/purchasing/settings.d.ts +152 -0
  205. package/dist/purchasing/settings.js +181 -0
  206. package/dist/purchasing/suppliers.d.ts +476 -0
  207. package/dist/purchasing/suppliers.js +438 -0
  208. package/dist/quotes/index.d.ts +501 -0
  209. package/dist/quotes/index.js +439 -0
  210. package/dist/reports/index.d.ts +71 -8
  211. package/dist/reports/index.js +74 -11
  212. package/dist/returns/index.d.ts +818 -0
  213. package/dist/returns/index.js +844 -0
  214. package/dist/search/index.d.ts +174 -0
  215. package/dist/search/index.js +125 -0
  216. package/dist/shipping/definitions.d.ts +29 -0
  217. package/dist/shipping/definitions.js +47 -0
  218. package/dist/shipping/fulfillment-profiles.d.ts +174 -0
  219. package/dist/shipping/fulfillment-profiles.js +104 -0
  220. package/dist/shipping/hendriks.d.ts +97 -0
  221. package/dist/shipping/hendriks.js +50 -0
  222. package/dist/shipping/index.d.ts +48 -0
  223. package/dist/shipping/index.js +25 -0
  224. package/dist/shipping/methods.d.ts +198 -0
  225. package/dist/shipping/methods.js +240 -0
  226. package/dist/shipping/myparcel.d.ts +254 -0
  227. package/dist/shipping/myparcel.js +178 -0
  228. package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
  229. package/dist/shipping/parcel-rule.d.ts +6 -5
  230. package/dist/shipping/parcel-rule.js +21 -23
  231. package/dist/shipping/rate-tables.d.ts +179 -0
  232. package/dist/shipping/rate-tables.js +184 -0
  233. package/dist/stock/index.d.ts +10 -3
  234. package/dist/stock/index.js +3 -0
  235. package/dist/stock/locations.d.ts +144 -0
  236. package/dist/stock/locations.js +168 -0
  237. package/dist/stock/transfers.d.ts +216 -43
  238. package/dist/stock/transfers.js +140 -13
  239. package/dist/stored-value/index.d.ts +214 -4
  240. package/dist/stored-value/index.js +152 -0
  241. package/dist/subscriptions/index.d.ts +682 -0
  242. package/dist/subscriptions/index.js +815 -0
  243. package/dist/tax/index.d.ts +76 -1
  244. package/dist/tax/index.js +50 -0
  245. package/dist/tenant/email-style.d.ts +102 -0
  246. package/dist/tenant/email-style.js +72 -0
  247. package/dist/tenant/email-templates.d.ts +66 -0
  248. package/dist/tenant/email-templates.js +54 -0
  249. package/dist/tenant/notifications.d.ts +23 -17
  250. package/dist/tenant/settings-sources.d.ts +1 -1
  251. package/dist/tenant/time-zone.d.ts +17 -0
  252. package/dist/tenant/time-zone.js +11 -0
  253. package/dist/types.d.ts +51 -4
  254. package/dist/users/index.d.ts +3 -0
  255. package/dist/users/index.js +2 -0
  256. package/dist/users/warehouses.d.ts +50 -0
  257. package/dist/users/warehouses.js +51 -0
  258. package/package.json +2 -2
@@ -0,0 +1,227 @@
1
+ import type { Transport } from '@sixtyninecommerce/core';
2
+ import type { StoreCreditMove } from '../payments/account-credit.js';
3
+ import type { IssuedRefund, OrderPaymentPosition, PaidOrder } from '../payments/index.js';
4
+ import type { Call } from '../types.js';
5
+ import type { OrderOverpaymentChoice, OverpaymentOption } from './surcharges.js';
6
+ /** What happens to the money an order holds when it is cancelled. Pass one, or neither. */
7
+ export interface CancelWithMoneyCall extends Call {
8
+ /**
9
+ * Why the order is cancelled. REQUIRED with `retain`, where it is recorded in the order's
10
+ * history and the audit trail; otherwise written on the refunds and the account credit. At
11
+ * most 500 characters.
12
+ */
13
+ reason?: string;
14
+ /**
15
+ * The settled money goes back: `REFUND` to the payments it came from, or `ACCOUNT_CREDIT` to
16
+ * the customer's account (only where the store keeps the customer's balance itself). Ignored
17
+ * when the order holds no settled money.
18
+ */
19
+ overpayment?: OrderOverpaymentChoice;
20
+ /** The settled money stays on the cancelled order (with a `reason`). */
21
+ retain?: boolean;
22
+ }
23
+ /** What a cancel with a money decision did. */
24
+ /**
25
+ * How a refund's money reaches the customer: `PROVIDER` (the payment provider pays it back; the
26
+ * refund stays `Pending` until it confirms), `AUTOMATIC` (the platform puts it back itself: a
27
+ * stored-value refund credits the gift card or store credit it was paid with), `MANUAL` (an
28
+ * offline method: the refund is recorded and staff pay it out by hand). Only a `MANUAL` refund
29
+ * needs anyone to move money.
30
+ */
31
+ export type OrderCancelMoneyPayout = 'PROVIDER' | 'AUTOMATIC' | 'MANUAL';
32
+ /** How one refund a cancel made reaches the customer. */
33
+ export interface OrderCancelRefundPayout {
34
+ refundId: string;
35
+ paymentId: string;
36
+ payout: OrderCancelMoneyPayout;
37
+ }
38
+ export interface OrderCancellation {
39
+ /** The order as the cancel left it (`state: 'Cancelled'`). */
40
+ order: PaidOrder;
41
+ /**
42
+ * The refunds the cancel made: a card refund stays `Pending` until the payment provider
43
+ * confirms it; one recorded (an offline method, or stored value) is `Settled`. Which ones
44
+ * staff pay out by hand is `refundPayouts`.
45
+ */
46
+ refunds: IssuedRefund[];
47
+ /** Minor units the store kept on the cancelled order (`retain`); 0 otherwise. */
48
+ retained: number;
49
+ /** How each refund in `refunds` reaches the customer, by refund id. */
50
+ refundPayouts: OrderCancelRefundPayout[];
51
+ /** Minor units the cancel moved to the customer's account (`ACCOUNT_CREDIT`); 0 otherwise. */
52
+ creditedToAccount: number;
53
+ /**
54
+ * Minor units the cancel moved to the customer's store credit (`ACCOUNT_CREDIT` in a store
55
+ * whose book is store credit); 0 otherwise, and from an engine before it. Beside
56
+ * `creditedToAccount`, never part of it. Such a cancel also refunds its gift-card and
57
+ * store-credit payments to their own balances (`refunds`, payout `AUTOMATIC`).
58
+ */
59
+ creditedToStoreCredit: number;
60
+ /** The move to the customer's store-credit wallet; null otherwise. */
61
+ storeCredit: StoreCreditMove | null;
62
+ /** The card holds the cancel voided. */
63
+ voidedHolds: OrderCancelMoneyHold[];
64
+ /**
65
+ * The order's payment position after the cancel, with what of its money is now on the
66
+ * customer's account (`creditedToAccount`, already taken off `settled`).
67
+ */
68
+ position: OrderPaymentPosition & {
69
+ creditedToAccount: number;
70
+ };
71
+ }
72
+ /** A card hold `cancelWithMoney` voids, whatever is decided. Minor units. */
73
+ export interface OrderCancelMoneyHold {
74
+ paymentId: string;
75
+ method: string | null;
76
+ amount: number;
77
+ }
78
+ /** A refund `cancelWithMoney` makes on `REFUND`: everything one settled payment holds. */
79
+ export interface OrderCancelMoneyRefund {
80
+ paymentId: string;
81
+ method: string | null;
82
+ /** Minor units. */
83
+ amount: number;
84
+ /** How its money reaches the customer: only a `MANUAL` refund is paid out by hand. */
85
+ payout: OrderCancelMoneyPayout;
86
+ }
87
+ /**
88
+ * What `cancelWithMoney` would do with the money an order holds (`previewCancelWithMoney`), read
89
+ * now: each way of deciding, open or with the refusal the cancel would answer for it. Nothing was
90
+ * written and no lock was taken: the cancel judges it all again.
91
+ */
92
+ export interface OrderCancelMoneyPreview {
93
+ orderId: string;
94
+ currencyCode: string;
95
+ /**
96
+ * What the order's settled payments still hold, minor units: what `REFUND` gives back,
97
+ * `ACCOUNT_CREDIT` moves, or `retain` keeps. 0 when no decision is needed (a decision is then
98
+ * ignored).
99
+ */
100
+ settledHeld: number;
101
+ /**
102
+ * What gift cards sold on the order hold of its settled payments, minor units, beside
103
+ * `settledHeld` (never part of it): the value of a card already spent, which stays with the
104
+ * store, or of a card still live. No refund or account credit gives it back: only `retain` keeps
105
+ * it, with `settledHeld`, and while it is above 0 `REFUND` and `ACCOUNT_CREDIT` are closed
106
+ * (`REFUND_HELD_BY_GIFT_CARD`). A decision is needed when `settledHeld + giftCardHeld` is above 0;
107
+ * `retain` keeps that sum.
108
+ */
109
+ giftCardHeld: number;
110
+ /** The card holds the cancel voids, whatever is decided. */
111
+ holds: OrderCancelMoneyHold[];
112
+ /** The refunds `REFUND` would make, the recorded ones first. Empty while it is closed. */
113
+ refunds: OrderCancelMoneyRefund[];
114
+ /** `overpayment: 'REFUND'`: open, or the refusal choosing it would answer. */
115
+ refund: OverpaymentOption;
116
+ /**
117
+ * `overpayment: 'ACCOUNT_CREDIT'`: open only where the store keeps the customer's balance itself
118
+ * and the customer has a credit account there; otherwise the account's own refusal
119
+ * (`AR_LEDGER_NOT_ENABLED`, `AR_ACCOUNT_REQUIRED`, `AR_ACCOUNT_IN_ERP`, `ACCOUNT_CREDIT_*`, …).
120
+ */
121
+ accountCredit: OverpaymentOption;
122
+ /** `retain: true` (with a `reason`): open, or the refusal choosing it would answer. */
123
+ retain: OverpaymentOption;
124
+ /**
125
+ * The refusal the cancel answers whatever is decided (`ORDER_OVERPAYMENT_REFUND_UNRECONCILED`,
126
+ * `ORDER_CANCEL_HOLD_NOT_RELEASABLE`, `ORDER_CANCEL_SETTLEMENT_SPLIT` over two card holds,
127
+ * `REFUND_METHOD_UNAVAILABLE` for a hold), in the cancel's own words; null while a decision is
128
+ * open.
129
+ */
130
+ refusal: {
131
+ code: string;
132
+ message: string;
133
+ } | null;
134
+ /** The order's payment position, with what of its money is on the customer's account. */
135
+ position: OrderPaymentPosition & {
136
+ creditedToAccount: number;
137
+ };
138
+ }
139
+ /**
140
+ * Its own document, like the cancel's: on an engine without the query this call alone fails
141
+ * validation.
142
+ */
143
+ export declare const CANCEL_ORDER_WITH_MONEY_PREVIEW_QUERY = "\n query CancelOrderWithMoneyPreview($orderId: ID!) {\n cancelOrderWithMoneyPreview(orderId: $orderId) {\n orderId\n currencyCode\n settledHeld\n giftCardHeld\n holds {\n paymentId\n method\n amount\n }\n refunds {\n paymentId\n method\n amount\n payout\n }\n refund { \n available\n code\n message\n book\n }\n accountCredit { \n available\n code\n message\n book\n }\n retain { \n available\n code\n message\n book\n }\n refusal {\n code\n message\n }\n position {\n total\n covered\n settled\n authorized\n refunded\n creditedToAccount\n creditNoted\n owed\n outstanding\n overpaid\n availableToCharge\n }\n }\n }\n";
144
+ /**
145
+ * Its own document on purpose: `cancelOrderWithMoney` exists only on an engine that serves it,
146
+ * so on an older one this call alone fails validation and no other order call does.
147
+ */
148
+ export declare const CANCEL_ORDER_WITH_MONEY_MUTATION = "\n mutation CancelOrderWithMoney($input: CancelOrderWithMoneyInput!, $idempotencyKey: String) {\n cancelOrderWithMoney(input: $input, idempotencyKey: $idempotencyKey) {\n order {\n id\n code\n state\n currencyCode\n total\n totalWithTax\n }\n refunds {\n id\n total\n state\n method\n transactionId\n reason\n }\n retained\n refundPayouts {\n refundId\n paymentId\n payout\n }\n creditedToAccount\n creditedToStoreCredit\n storeCredit { accountId amount currencyCode entryIds }\n voidedHolds {\n paymentId\n method\n amount\n }\n position {\n total\n covered\n settled\n authorized\n refunded\n creditedToAccount\n creditNoted\n owed\n outstanding\n overpaid\n availableToCharge\n }\n }\n }\n";
149
+ export interface OrderCancelWithMoneyModule {
150
+ /**
151
+ * Cancel a whole order, its shipping included (a cancelled order bills nothing), and decide,
152
+ * in the same transaction, what happens to the money it holds. Needs `UpdateOrder`. The
153
+ * cancel's own rules are the order page's: a fulfillment
154
+ * holding a line refuses it, and a shopper's live cart is cancelled only when it carries a
155
+ * payment or a stock movement. It is the one way to cancel a `Parked` order: straight out of
156
+ * the park, its reserved stock released, with no `order.unparked`.
157
+ *
158
+ * Settled money goes back by `overpayment: 'REFUND'` (every payment that holds some, whole)
159
+ * or `'ACCOUNT_CREDIT'`, or stays with `retain: true` and a `reason`. A card hold on a gateway
160
+ * is voided whatever the choice; capture it first (`settlePayment`) to keep that money.
161
+ *
162
+ * A plain cancel (`cancelOrder` on the Admin API, or `orders.bulk` with `CANCEL`) of an order
163
+ * that has been placed or parked and still holds money is refused `ORDER_HOLDS_MONEY`
164
+ * (`BusinessRuleError`, 422), with `extensions.position` and `extensions.refundPosition`:
165
+ * cancel it here instead, or give the money back first (refund each settled payment with
166
+ * `payments.refund`, cancel a card hold's payment) and then cancel. What gift cards sold on the
167
+ * order hold (`giftCardHeld`) is never given back: only `retain` here keeps it.
168
+ *
169
+ * Refusals, with nothing written:
170
+ * - `ORDER_CANCEL_MONEY_CHOICE_REQUIRED` (422): settled money and no decision.
171
+ * - `CANCEL_RETAIN_REASON_REQUIRED` (422), `ORDER_CANCEL_MONEY_INPUT_INVALID`
172
+ * (`ValidationError`, 400: both a choice and `retain`, or a reason over 500 characters).
173
+ * - `ORDER_CANCEL_SETTLEMENT_SPLIT` (422): more than one card payment to refund or void. The
174
+ * cancel asks a payment provider at most once, as its last step: refund or void all but one
175
+ * first (`payments.refund`; release a card hold at the payment provider first where its
176
+ * payment method cannot), then cancel. A hold its method cannot release answers
177
+ * `ORDER_CANCEL_HOLD_NOT_RELEASABLE` instead, whatever else the order holds.
178
+ * - `ORDER_CANCEL_HOLD_NOT_RELEASABLE` (422, `extensions.paymentId`, `extensions.method`): a card
179
+ * hold whose payment method cannot void an authorization at its provider (cancelling it here
180
+ * would mark it cancelled while the provider keeps the money reserved). Release the hold at
181
+ * the payment provider first, then cancel that payment on the order, then cancel the order.
182
+ * - `ORDER_OVERPAYMENT_REFUND_UNRECONCILED` (422): a refund of unknown outcome is open; record
183
+ * the provider's answer first (`payments.reconcileRefund`).
184
+ * - `REFUND_HELD_BY_GIFT_CARD` (422, with `extensions.refundPosition`): `overpayment` while gift
185
+ * cards sold on the order hold part of its settled money (`giftCardHeld` on the preview).
186
+ * Neither way gives that back, and the cancel settles all of the money or none: refund the
187
+ * rest first (`payments.refund`), then cancel with `retain` and a `reason`, which keeps the
188
+ * gift cards' share on the cancelled order and records it.
189
+ * - `REFUND_METHOD_UNAVAILABLE`, the account's own refusals (`ACCOUNT_CREDIT_*`, `AR_*`), and
190
+ * the cancel's (`ORDER_HAS_ACTIVE_FULFILLMENT`, `ORDER_UNITS_SHIPPED`,
191
+ * `ORDER_CART_NOT_CANCELLABLE`, and `LOCATION_OUT_OF_SCOPE` for a credential restricted to
192
+ * stock locations while the order's stock is reserved outside them).
193
+ * - `ORDER_CANCEL_REFUSED`: the engine refused the cancel itself (an order already cancelled
194
+ * included), or the void of a card hold was not confirmed and recorded: the provider refused
195
+ * it, did not answer (an app's cancel hook that never answered included), or answered and the
196
+ * engine could not record it. NOTHING is cancelled either way, but the key differs: an engine
197
+ * refusal is stored and a repeat under the same key answers it again, so clear the condition
198
+ * and cancel again under a NEW key; a void that was not confirmed releases the key, so a retry
199
+ * under it asks the provider again. After a void, the hold may or may not still stand: check
200
+ * it at the provider (void or capture it there if it does), then cancel again.
201
+ * - `PAYMENT_CANCEL_CONFLICT` (`ConflictError`, 409, `extensions.state`): the engine refused the
202
+ * void before asking the provider: the payment moved since the cancel read it, or a capture
203
+ * of it may have reached its provider. Nothing was asked and NOTHING is cancelled; read the
204
+ * order again and act on it as it stands.
205
+ *
206
+ * `IDEMPOTENCY_OUTCOME_UNKNOWN` (`error.outcomeUnknown`, `extensions.movement`): the refund
207
+ * reached the payment provider and its answer never came. NOTHING is cancelled; the attempt is
208
+ * recorded and reserved on the order, and the key stays spent for 24 hours. Record the
209
+ * provider's answer (`payments.reconcileRefund`), then cancel again under a NEW key: a refund
210
+ * recorded as made is not made a second time.
211
+ *
212
+ * `idempotencyKey`: a repeat under it answers the first call's result, never a second cancel.
213
+ */
214
+ cancelWithMoney(orderId: string, options?: CancelWithMoneyCall): Promise<OrderCancellation>;
215
+ /**
216
+ * What {@link cancelWithMoney} would do with the money the order holds, before staff decide:
217
+ * what its settled payments hold (`settledHeld`, and beside it `giftCardHeld`, what gift cards
218
+ * sold on the order hold, which only `retain` keeps), the card holds it voids, the refunds
219
+ * `REFUND` would make,
220
+ * and for each way (`REFUND`, `ACCOUNT_CREDIT`, `retain`) whether it is open or the refusal
221
+ * the cancel would answer, in the cancel's own words. `refusal` is set when the cancel would
222
+ * be refused whatever is decided. Read now and without a lock: the cancel judges it again.
223
+ * Needs `UpdateOrder`, as the cancel does. Another store's order is a `NotFoundError`.
224
+ */
225
+ previewCancelWithMoney(orderId: string, options?: Call): Promise<OrderCancelMoneyPreview>;
226
+ }
227
+ export declare function createOrderCancelWithMoneyModule(transport: Transport): OrderCancelWithMoneyModule;
@@ -0,0 +1,153 @@
1
+ import { creditNotedAware } from '../payments/credit-noted-fields.js';
2
+ import { STORE_CREDIT_MOVE_FIELDS, storeCreditAware } from '../payments/store-credit-fields.js';
3
+ const OPTION_FIELDS = /* GraphQL */ `
4
+ available
5
+ code
6
+ message
7
+ book
8
+ `;
9
+ /**
10
+ * Its own document, like the cancel's: on an engine without the query this call alone fails
11
+ * validation.
12
+ */
13
+ export const CANCEL_ORDER_WITH_MONEY_PREVIEW_QUERY = /* GraphQL */ `
14
+ query CancelOrderWithMoneyPreview($orderId: ID!) {
15
+ cancelOrderWithMoneyPreview(orderId: $orderId) {
16
+ orderId
17
+ currencyCode
18
+ settledHeld
19
+ giftCardHeld
20
+ holds {
21
+ paymentId
22
+ method
23
+ amount
24
+ }
25
+ refunds {
26
+ paymentId
27
+ method
28
+ amount
29
+ payout
30
+ }
31
+ refund { ${OPTION_FIELDS} }
32
+ accountCredit { ${OPTION_FIELDS} }
33
+ retain { ${OPTION_FIELDS} }
34
+ refusal {
35
+ code
36
+ message
37
+ }
38
+ position {
39
+ total
40
+ covered
41
+ settled
42
+ authorized
43
+ refunded
44
+ creditedToAccount
45
+ creditNoted
46
+ owed
47
+ outstanding
48
+ overpaid
49
+ availableToCharge
50
+ }
51
+ }
52
+ }
53
+ `;
54
+ /**
55
+ * Its own document on purpose: `cancelOrderWithMoney` exists only on an engine that serves it,
56
+ * so on an older one this call alone fails validation and no other order call does.
57
+ */
58
+ export const CANCEL_ORDER_WITH_MONEY_MUTATION = /* GraphQL */ `
59
+ mutation CancelOrderWithMoney($input: CancelOrderWithMoneyInput!, $idempotencyKey: String) {
60
+ cancelOrderWithMoney(input: $input, idempotencyKey: $idempotencyKey) {
61
+ order {
62
+ id
63
+ code
64
+ state
65
+ currencyCode
66
+ total
67
+ totalWithTax
68
+ }
69
+ refunds {
70
+ id
71
+ total
72
+ state
73
+ method
74
+ transactionId
75
+ reason
76
+ }
77
+ retained
78
+ refundPayouts {
79
+ refundId
80
+ paymentId
81
+ payout
82
+ }
83
+ creditedToAccount
84
+ creditedToStoreCredit
85
+ storeCredit { ${STORE_CREDIT_MOVE_FIELDS} }
86
+ voidedHolds {
87
+ paymentId
88
+ method
89
+ amount
90
+ }
91
+ position {
92
+ total
93
+ covered
94
+ settled
95
+ authorized
96
+ refunded
97
+ creditedToAccount
98
+ creditNoted
99
+ owed
100
+ outstanding
101
+ overpaid
102
+ availableToCharge
103
+ }
104
+ }
105
+ }
106
+ `;
107
+ /** An option as the SDK types it: `code` and `message` are null when it is open. */
108
+ function toOption(raw) {
109
+ return {
110
+ available: raw.available,
111
+ code: raw.code ?? null,
112
+ message: raw.message ?? null,
113
+ book: raw.book ?? null,
114
+ };
115
+ }
116
+ export function createOrderCancelWithMoneyModule(transport) {
117
+ return {
118
+ async cancelWithMoney(orderId, options) {
119
+ const data = await storeCreditAware(creditNotedAware(transport)).graphql({
120
+ api: 'admin',
121
+ query: CANCEL_ORDER_WITH_MONEY_MUTATION,
122
+ // `undefined`, never an explicit null: `JSON.stringify` drops it, so an option left out
123
+ // stays off the wire rather than arriving as a value.
124
+ variables: {
125
+ input: {
126
+ orderId,
127
+ reason: options?.reason,
128
+ overpayment: options?.overpayment,
129
+ retain: options?.retain,
130
+ },
131
+ idempotencyKey: options?.idempotencyKey,
132
+ },
133
+ }, options);
134
+ const outcome = data.cancelOrderWithMoney;
135
+ return {
136
+ ...outcome,
137
+ creditedToStoreCredit: outcome.creditedToStoreCredit ?? 0,
138
+ storeCredit: outcome.storeCredit ?? null,
139
+ };
140
+ },
141
+ async previewCancelWithMoney(orderId, options) {
142
+ const data = await storeCreditAware(creditNotedAware(transport)).graphql({ api: 'admin', query: CANCEL_ORDER_WITH_MONEY_PREVIEW_QUERY, variables: { orderId } }, options);
143
+ const preview = data.cancelOrderWithMoneyPreview;
144
+ return {
145
+ ...preview,
146
+ refund: toOption(preview.refund),
147
+ accountCredit: toOption(preview.accountCredit),
148
+ retain: toOption(preview.retain),
149
+ refusal: preview.refusal ?? null,
150
+ };
151
+ },
152
+ };
153
+ }
@@ -1,4 +1,5 @@
1
1
  import { type Transport } from '@sixtyninecommerce/core';
2
+ import type { StoreCreditMove } from '../payments/account-credit.js';
2
3
  import type { Call } from '../types.js';
3
4
  import type { OrderEditDiff, OrderEditPlan } from './plan-edit.js';
4
5
  import type { OrderOverpaymentChoice } from './surcharges.js';
@@ -32,6 +33,11 @@ export interface OrderEditOverpaymentSettlement {
32
33
  currencyCode: string;
33
34
  /** For `ACCOUNT_CREDIT`: the receipts on the customer's account, one per payment it came from. */
34
35
  unappliedCashIds: string[];
36
+ /**
37
+ * For `ACCOUNT_CREDIT` in a store whose book is store credit: the move to the customer's
38
+ * wallet (`unappliedCashIds` is then empty). Null otherwise; absent from an engine before it.
39
+ */
40
+ storeCredit?: StoreCreditMove | null;
35
41
  }
36
42
  export interface OrderEditCommit {
37
43
  order: OrderEditCommittedOrder;
@@ -71,7 +77,7 @@ export interface CommitOrderEditCall extends Call {
71
77
  * Its own document on purpose: `commitOrderEdit` exists only on an engine with the order-edit
72
78
  * commit, so on an older one this call alone fails validation and no other order call does.
73
79
  */
74
- export declare const COMMIT_ORDER_EDIT_MUTATION = "\n mutation CommitOrderEdit(\n $orderId: ID!\n $diff: OrderEditDiffInput!\n $expectedPlanHash: String!\n $idempotencyKey: String!\n $overpaymentChoice: OrderOverpaymentChoice\n ) {\n commitOrderEdit(\n orderId: $orderId\n diff: $diff\n expectedPlanHash: $expectedPlanHash\n idempotencyKey: $idempotencyKey\n overpaymentChoice: $overpaymentChoice\n ) {\n order {\n id\n code\n state\n currencyCode\n totalWithTax\n }\n plan {\n orderId\n planHash\n orderVersion\n steps {\n kind\n input\n moneyEffect\n }\n refund {\n paymentId\n amount\n }\n overpayment {\n amount\n currencyCode\n surchargeIds\n refund {\n available\n code\n message\n }\n accountCredit {\n available\n code\n message\n }\n refundWhenChosen {\n paymentId\n amount\n }\n }\n returnState\n blockers {\n code\n message\n details\n }\n notices {\n code\n message\n details\n }\n payment {\n collected\n reason\n method\n }\n preview {\n currencyCode\n subTotal\n subTotalWithTax\n shipping\n shippingWithTax\n surcharges\n surchargesWithTax\n total\n totalWithTax\n taxSummary {\n description\n taxRate\n taxBase\n taxTotal\n }\n totalWithTaxBefore\n }\n }\n refund {\n id\n state\n total\n paymentId\n }\n overpayment {\n choice\n amount\n currencyCode\n unappliedCashIds\n }\n }\n }\n";
80
+ export declare const COMMIT_ORDER_EDIT_MUTATION = "\n mutation CommitOrderEdit(\n $orderId: ID!\n $diff: OrderEditDiffInput!\n $expectedPlanHash: String!\n $idempotencyKey: String!\n $overpaymentChoice: OrderOverpaymentChoice\n ) {\n commitOrderEdit(\n orderId: $orderId\n diff: $diff\n expectedPlanHash: $expectedPlanHash\n idempotencyKey: $idempotencyKey\n overpaymentChoice: $overpaymentChoice\n ) {\n order {\n id\n code\n state\n currencyCode\n totalWithTax\n }\n plan {\n orderId\n planHash\n orderVersion\n steps {\n kind\n input\n moneyEffect\n }\n refund {\n paymentId\n amount\n }\n overpayment {\n amount\n currencyCode\n surchargeIds\n refund {\n available\n code\n message\n book\n }\n accountCredit {\n available\n code\n message\n book\n }\n refundWhenChosen {\n paymentId\n amount\n }\n }\n returnState\n blockers {\n code\n message\n details\n }\n notices {\n code\n message\n details\n }\n payment {\n collected\n reason\n method\n }\n preview {\n currencyCode\n subTotal\n subTotalWithTax\n shipping\n shippingWithTax\n surcharges\n surchargesWithTax\n total\n totalWithTax\n taxSummary {\n description\n taxRate\n taxBase\n taxTotal\n }\n totalWithTaxBefore\n }\n }\n refund {\n id\n state\n total\n paymentId\n }\n overpayment {\n choice\n amount\n currencyCode\n unappliedCashIds\n storeCredit { accountId amount currencyCode entryIds }\n }\n }\n }\n";
75
81
  export interface OrderCommitEditModule {
76
82
  /**
77
83
  * Carry out an edit of a placed order as its plan (`planEdit`) states it, once. Needs
@@ -1,4 +1,5 @@
1
1
  import { idempotencyKey as mintIdempotencyKey } from '@sixtyninecommerce/core';
2
+ import { STORE_CREDIT_MOVE_FIELDS, storeCreditAware } from '../payments/store-credit-fields.js';
2
3
  /**
3
4
  * Its own document on purpose: `commitOrderEdit` exists only on an engine with the order-edit
4
5
  * commit, so on an older one this call alone fails validation and no other order call does.
@@ -46,11 +47,13 @@ export const COMMIT_ORDER_EDIT_MUTATION = /* GraphQL */ `
46
47
  available
47
48
  code
48
49
  message
50
+ book
49
51
  }
50
52
  accountCredit {
51
53
  available
52
54
  code
53
55
  message
56
+ book
54
57
  }
55
58
  refundWhenChosen {
56
59
  paymentId
@@ -103,6 +106,7 @@ export const COMMIT_ORDER_EDIT_MUTATION = /* GraphQL */ `
103
106
  amount
104
107
  currencyCode
105
108
  unappliedCashIds
109
+ storeCredit { ${STORE_CREDIT_MOVE_FIELDS} }
106
110
  }
107
111
  }
108
112
  }
@@ -112,7 +116,7 @@ export function createOrderCommitEditModule(transport) {
112
116
  async commitEdit(orderId, diff, options) {
113
117
  const key = options.idempotencyKey ?? mintIdempotencyKey();
114
118
  try {
115
- const data = await transport.graphql({
119
+ const data = await storeCreditAware(transport).graphql({
116
120
  api: 'admin',
117
121
  query: COMMIT_ORDER_EDIT_MUTATION,
118
122
  // The diff goes out as given, never normalised (see `planEdit`): left out, `null` and
@@ -0,0 +1,103 @@
1
+ import { type Transport } from '@sixtyninecommerce/core';
2
+ import type { Call } from '../types.js';
3
+ /** The fewest days `autoCancelAfterDays` may be; `null` means never. */
4
+ export declare const DEPOSIT_POLICY_AUTO_CANCEL_DAYS_MIN = 1;
5
+ /** The largest `storefront.minimumPercent`: a whole percentage of the order total. */
6
+ export declare const DEPOSIT_POLICY_MINIMUM_PERCENT_MAX = 100;
7
+ /** The most payment method codes `storefront.methods` may name. */
8
+ export declare const DEPOSIT_POLICY_STOREFRONT_METHODS_MAX = 50;
9
+ /** Deposits a SHOPPER pays online at checkout. Applies only while `enabled` is on as well. */
10
+ export interface StorefrontDepositPolicy {
11
+ /** The online switch. */
12
+ enabled: boolean;
13
+ /**
14
+ * Payment method CODES a shopper may pay a deposit with: offline methods and
15
+ * Mollie. Empty: none, so no shopper can pay a deposit online.
16
+ */
17
+ methods: string[];
18
+ /**
19
+ * The least an online deposit may be, as a whole percentage (0–100) of the
20
+ * order's total, judged in the order's currency. Beside `minimum`, not instead
21
+ * of it: the larger of the two applies.
22
+ */
23
+ minimumPercent: number;
24
+ }
25
+ /**
26
+ * The store's deposit policy (`Channel.customFields.orderDepositPolicy`): whether
27
+ * staff may take a deposit and park an order (`orders.park`), and whether a
28
+ * shopper may pay one at checkout. Every field present: this is what the engine
29
+ * APPLIES, absent and malformed fields read as their defaults.
30
+ */
31
+ export interface OrderDepositPolicy {
32
+ /**
33
+ * The store-wide switch. Off: a payment must cover the whole outstanding
34
+ * amount (`payments.record` refuses a part payment `DEPOSITS_NOT_ENABLED`) and
35
+ * no order can be parked.
36
+ */
37
+ enabled: boolean;
38
+ /**
39
+ * The least a deposit must be before an order can be parked, in minor units of
40
+ * the store's DEFAULT currency; 0 means any deposit will do. An order in another
41
+ * currency is held to it converted at the rate checkout charges with.
42
+ */
43
+ minimum: number;
44
+ /** Whether an order may be parked with nothing paid at all. */
45
+ allowZeroDepositPark: boolean;
46
+ /**
47
+ * Whether the storefront shows a parked order's reason to the shopper. Off by
48
+ * default: staff write that reason for staff.
49
+ */
50
+ showParkReasonToCustomer: boolean;
51
+ /**
52
+ * RESERVED: days after which a parked order is cancelled. Saved and read back,
53
+ * but nothing cancels a parked order automatically yet. `null`: never.
54
+ */
55
+ autoCancelAfterDays: number | null;
56
+ storefront: StorefrontDepositPolicy;
57
+ }
58
+ /**
59
+ * The policy of a store that never set one, and of every field that cannot be
60
+ * read: deposits off, no minimum, no zero-deposit park, the reason kept from the
61
+ * shopper, never auto-cancelled, no online deposits.
62
+ */
63
+ export declare const DEFAULT_ORDER_DEPOSIT_POLICY: Readonly<OrderDepositPolicy>;
64
+ /**
65
+ * The ACTIVE store's deposit policy (`admin.orders.depositPolicy`), stored as a
66
+ * Channel custom field and written through core `updateChannel`.
67
+ *
68
+ * Reading needs an authenticated administrator on the store; writing needs
69
+ * `UpdateChannel`.
70
+ */
71
+ export interface OrderDepositPolicyModule {
72
+ /**
73
+ * The policy the engine applies, read as tolerantly as the engine reads it: a
74
+ * store that never set one, a malformed column and a field of the wrong type
75
+ * all answer their defaults ({@link DEFAULT_ORDER_DEPOSIT_POLICY}), so this is
76
+ * what `orders.park` and `payments.record` will hold an order to.
77
+ */
78
+ get(options?: Call): Promise<OrderDepositPolicy>;
79
+ /**
80
+ * Replace the whole policy, and answer it as the engine now applies it.
81
+ *
82
+ * Every field is required: read it with {@link get}, change what you mean to,
83
+ * and send it back. Only the schema's fields are stored (anything else on the
84
+ * object is left out), and the method codes are stored as given.
85
+ *
86
+ * Refused before any request with `DEPOSIT_POLICY_INVALID` ({@link ValidationError},
87
+ * one `details[]` entry per failing field, named by its path such as
88
+ * `storefront.minimumPercent`): a non-boolean switch, a `minimum` that is not a
89
+ * whole number of 0 or more, an `autoCancelAfterDays` that is neither `null` nor
90
+ * a whole number of 1 or more, a `minimumPercent` outside 0–100, a blank or
91
+ * repeated method code, or more than 50 of them. The engine itself stores any
92
+ * JSON in the column and reads what it cannot use as the default, so this check
93
+ * is what keeps a bad value from silently turning deposits off.
94
+ *
95
+ * Absent and "set to the defaults" mean the same thing to the engine, and a
96
+ * store's column is never backfilled: write the policy when a merchant changed
97
+ * it, not as a side effect of saving something else.
98
+ */
99
+ set(policy: OrderDepositPolicy, options?: Call): Promise<OrderDepositPolicy>;
100
+ }
101
+ export declare const ORDER_DEPOSIT_POLICY_QUERY = "\n query OrderDepositPolicy {\n activeChannel { \n id\n customFields {\n orderDepositPolicy\n }\n }\n }\n";
102
+ export declare const SET_ORDER_DEPOSIT_POLICY_MUTATION = "\n mutation SetOrderDepositPolicy($input: UpdateChannelInput!) {\n updateChannel(input: $input) {\n ... on Channel { \n id\n customFields {\n orderDepositPolicy\n }\n }\n ... on ErrorResult { errorCode message }\n }\n }\n";
103
+ export declare function createOrderDepositPolicyModule(transport: Transport): OrderDepositPolicyModule;