@sixtyninecommerce/admin 0.10.0 → 0.12.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 (302) hide show
  1. package/README.md +5772 -118
  2. package/dist/auth/index.d.ts +7 -1
  3. package/dist/auth/index.js +8 -1
  4. package/dist/catalog/assets.d.ts +120 -8
  5. package/dist/catalog/assets.js +98 -12
  6. package/dist/catalog/collections.d.ts +279 -14
  7. package/dist/catalog/collections.js +246 -15
  8. package/dist/catalog/documents.d.ts +142 -0
  9. package/dist/catalog/documents.js +114 -0
  10. package/dist/catalog/index.d.ts +54 -6
  11. package/dist/catalog/index.js +10 -1
  12. package/dist/catalog/metadata.d.ts +244 -0
  13. package/dist/catalog/metadata.js +220 -0
  14. package/dist/catalog/products.d.ts +159 -19
  15. package/dist/catalog/products.js +88 -13
  16. package/dist/catalog/properties.d.ts +140 -14
  17. package/dist/catalog/properties.js +65 -1
  18. package/dist/catalog/recommendations.d.ts +288 -0
  19. package/dist/catalog/recommendations.js +237 -0
  20. package/dist/catalog/reviews.d.ts +381 -0
  21. package/dist/catalog/reviews.js +325 -0
  22. package/dist/catalog/types.d.ts +17 -1
  23. package/dist/catalog/types.js +10 -0
  24. package/dist/catalog/variant-find.d.ts +136 -0
  25. package/dist/catalog/variant-find.js +239 -0
  26. package/dist/catalog/variants.d.ts +293 -26
  27. package/dist/catalog/variants.js +164 -7
  28. package/dist/catalog/visibility.d.ts +38 -7
  29. package/dist/catalog/visibility.js +19 -1
  30. package/dist/client.d.ts +121 -9
  31. package/dist/client.js +53 -14
  32. package/dist/content/assets.d.ts +285 -0
  33. package/dist/content/assets.js +181 -0
  34. package/dist/content/forms.d.ts +332 -1
  35. package/dist/content/forms.js +140 -4
  36. package/dist/content/items.d.ts +292 -0
  37. package/dist/content/items.js +170 -0
  38. package/dist/content/menus.d.ts +254 -0
  39. package/dist/content/menus.js +70 -0
  40. package/dist/content/strings.d.ts +137 -0
  41. package/dist/content/strings.js +82 -0
  42. package/dist/content/types.d.ts +282 -0
  43. package/dist/content/types.js +100 -0
  44. package/dist/customers/age-verification.d.ts +66 -0
  45. package/dist/customers/age-verification.js +79 -0
  46. package/dist/customers/credit.d.ts +263 -0
  47. package/dist/customers/credit.js +244 -0
  48. package/dist/customers/delivery-preferences.d.ts +120 -0
  49. package/dist/customers/delivery-preferences.js +97 -0
  50. package/dist/customers/delivery-terms.d.ts +44 -0
  51. package/dist/customers/delivery-terms.js +32 -0
  52. package/dist/customers/groups.d.ts +207 -0
  53. package/dist/customers/groups.js +438 -0
  54. package/dist/customers/index.d.ts +462 -37
  55. package/dist/customers/index.js +317 -40
  56. package/dist/customers/invitation-status.d.ts +57 -0
  57. package/dist/customers/invitation-status.js +21 -0
  58. package/dist/customers/notes.d.ts +67 -0
  59. package/dist/customers/notes.js +51 -0
  60. package/dist/customers/notification-recipients.d.ts +97 -0
  61. package/dist/customers/notification-recipients.js +84 -0
  62. package/dist/customers/saved-lists.d.ts +42 -0
  63. package/dist/customers/saved-lists.js +61 -0
  64. package/dist/customers/vat.d.ts +83 -0
  65. package/dist/customers/vat.js +46 -0
  66. package/dist/customers/wire.d.ts +20 -0
  67. package/dist/customers/wire.js +35 -0
  68. package/dist/documents/ar.d.ts +307 -0
  69. package/dist/documents/ar.js +254 -0
  70. package/dist/documents/emails.d.ts +150 -0
  71. package/dist/documents/emails.js +220 -0
  72. package/dist/documents/index.d.ts +744 -21
  73. package/dist/documents/index.js +438 -24
  74. package/dist/documents/pdf.d.ts +2 -0
  75. package/dist/documents/pdf.js +11 -0
  76. package/dist/fulfillments/create.d.ts +167 -0
  77. package/dist/fulfillments/create.js +216 -0
  78. package/dist/fulfillments/index.d.ts +163 -11
  79. package/dist/fulfillments/index.js +135 -6
  80. package/dist/fulfillments/payment-policy.d.ts +64 -0
  81. package/dist/fulfillments/payment-policy.js +140 -0
  82. package/dist/fulfillments/warehouse.d.ts +724 -0
  83. package/dist/fulfillments/warehouse.js +914 -0
  84. package/dist/geo/index.d.ts +119 -0
  85. package/dist/geo/index.js +107 -0
  86. package/dist/index.d.ts +147 -39
  87. package/dist/index.js +51 -12
  88. package/dist/integrations/afas-actions.d.ts +234 -0
  89. package/dist/integrations/afas-actions.js +310 -0
  90. package/dist/integrations/afas-types.d.ts +483 -0
  91. package/dist/integrations/afas-types.js +5 -0
  92. package/dist/integrations/afas.d.ts +234 -0
  93. package/dist/integrations/afas.js +290 -0
  94. package/dist/integrations/connections.d.ts +103 -0
  95. package/dist/integrations/connections.js +55 -0
  96. package/dist/integrations/esp.d.ts +313 -0
  97. package/dist/integrations/esp.js +169 -0
  98. package/dist/integrations/exact-online-types.d.ts +965 -0
  99. package/dist/integrations/exact-online-types.js +6 -0
  100. package/dist/integrations/exact-online.d.ts +784 -0
  101. package/dist/integrations/exact-online.js +1089 -0
  102. package/dist/integrations/index.d.ts +44 -3
  103. package/dist/integrations/index.js +23 -3
  104. package/dist/integrations/pipeline-discoveries.d.ts +65 -0
  105. package/dist/integrations/pipeline-discoveries.js +65 -0
  106. package/dist/integrations/pipeline-keys.d.ts +13 -0
  107. package/dist/integrations/pipeline-keys.js +22 -0
  108. package/dist/integrations/pipeline-runs.d.ts +119 -0
  109. package/dist/integrations/pipeline-runs.js +87 -0
  110. package/dist/integrations/pipelines.d.ts +87 -15
  111. package/dist/integrations/pipelines.js +41 -22
  112. package/dist/integrations/price-import.d.ts +223 -0
  113. package/dist/integrations/price-import.js +124 -0
  114. package/dist/integrations/types.d.ts +367 -3
  115. package/dist/integrations/types.js +4 -3
  116. package/dist/locations/index.d.ts +66 -0
  117. package/dist/locations/index.js +31 -0
  118. package/dist/meta/index.d.ts +172 -0
  119. package/dist/metafields/index.d.ts +8 -1
  120. package/dist/metafields/index.js +10 -0
  121. package/dist/orders/cancel-with-money.d.ts +237 -0
  122. package/dist/orders/cancel-with-money.js +155 -0
  123. package/dist/orders/commit-edit.d.ts +23 -1
  124. package/dist/orders/commit-edit.js +19 -2
  125. package/dist/orders/deposit-policy.d.ts +3 -1
  126. package/dist/orders/drafts.d.ts +800 -0
  127. package/dist/orders/drafts.js +771 -0
  128. package/dist/orders/fields.d.ts +245 -0
  129. package/dist/orders/fields.js +188 -0
  130. package/dist/orders/get.d.ts +29 -19
  131. package/dist/orders/get.js +17 -8
  132. package/dist/orders/index.d.ts +66 -15
  133. package/dist/orders/index.js +25 -2
  134. package/dist/orders/lifecycle.d.ts +128 -0
  135. package/dist/orders/lifecycle.js +158 -0
  136. package/dist/orders/line-price-preview.d.ts +7 -2
  137. package/dist/orders/list.d.ts +243 -0
  138. package/dist/orders/list.js +487 -0
  139. package/dist/orders/manual-discounts.d.ts +13 -5
  140. package/dist/orders/manual-pricing.d.ts +5 -0
  141. package/dist/orders/money-view.d.ts +149 -0
  142. package/dist/orders/money-view.js +99 -0
  143. package/dist/orders/order-entry.d.ts +20 -7
  144. package/dist/orders/plan-edit.d.ts +34 -2
  145. package/dist/orders/plan-edit.js +112 -11
  146. package/dist/orders/settings.d.ts +201 -0
  147. package/dist/orders/settings.js +325 -0
  148. package/dist/orders/status.d.ts +159 -13
  149. package/dist/orders/status.js +21 -0
  150. package/dist/orders/surcharges.d.ts +20 -1
  151. package/dist/orders/surcharges.js +37 -11
  152. package/dist/payments/account-credit.d.ts +46 -0
  153. package/dist/payments/account-credit.js +42 -0
  154. package/dist/payments/ar.d.ts +292 -0
  155. package/dist/payments/ar.js +223 -0
  156. package/dist/payments/connected-account.d.ts +47 -0
  157. package/dist/payments/connected-account.js +61 -0
  158. package/dist/payments/credit-noted-fields.d.ts +19 -0
  159. package/dist/payments/credit-noted-fields.js +69 -0
  160. package/dist/payments/customer-consent.d.ts +30 -0
  161. package/dist/payments/customer-consent.js +49 -0
  162. package/dist/payments/index.d.ts +340 -19
  163. package/dist/payments/index.js +151 -1
  164. package/dist/payments/methods.d.ts +303 -8
  165. package/dist/payments/methods.js +337 -7
  166. package/dist/payments/mollie-methods.d.ts +159 -0
  167. package/dist/payments/mollie-methods.js +141 -0
  168. package/dist/payments/payment-links.d.ts +180 -0
  169. package/dist/payments/payment-links.js +97 -0
  170. package/dist/payments/provider-keys.d.ts +150 -0
  171. package/dist/payments/provider-keys.js +118 -0
  172. package/dist/payments/providers.d.ts +86 -11
  173. package/dist/payments/providers.js +29 -0
  174. package/dist/payments/requests.d.ts +147 -0
  175. package/dist/payments/requests.js +93 -0
  176. package/dist/payments/store-credit-fields.d.ts +15 -0
  177. package/dist/payments/store-credit-fields.js +51 -0
  178. package/dist/pickups/index.d.ts +106 -0
  179. package/dist/pickups/index.js +108 -0
  180. package/dist/platform/channels.d.ts +132 -0
  181. package/dist/platform/channels.js +128 -0
  182. package/dist/platform/email-gateways.d.ts +165 -0
  183. package/dist/platform/email-gateways.js +78 -0
  184. package/dist/platform/geo.d.ts +123 -0
  185. package/dist/platform/geo.js +144 -0
  186. package/dist/platform/tax.d.ts +162 -0
  187. package/dist/platform/tax.js +169 -0
  188. package/dist/pos/anomalies.d.ts +158 -0
  189. package/dist/pos/anomalies.js +64 -0
  190. package/dist/pos/assisted-selling.d.ts +79 -0
  191. package/dist/pos/assisted-selling.js +38 -0
  192. package/dist/pos/exchanges.d.ts +108 -0
  193. package/dist/pos/exchanges.js +22 -0
  194. package/dist/pos/gift-cards.d.ts +135 -0
  195. package/dist/pos/gift-cards.js +47 -0
  196. package/dist/pos/index.d.ts +2370 -58
  197. package/dist/pos/index.js +854 -7
  198. package/dist/pos/no-receipt.d.ts +94 -0
  199. package/dist/pos/no-receipt.js +25 -0
  200. package/dist/pos/offline-sales.d.ts +228 -0
  201. package/dist/pos/offline-sales.js +170 -0
  202. package/dist/pos/pay-by-link.d.ts +143 -0
  203. package/dist/pos/pay-by-link.js +57 -0
  204. package/dist/pos/quick-keys.d.ts +103 -0
  205. package/dist/pos/quick-keys.js +45 -0
  206. package/dist/pos/reports.d.ts +360 -0
  207. package/dist/pos/reports.js +62 -0
  208. package/dist/pos/returns.d.ts +244 -0
  209. package/dist/pos/returns.js +83 -0
  210. package/dist/pricing/bulk-coupons.d.ts +139 -0
  211. package/dist/pricing/bulk-coupons.js +112 -0
  212. package/dist/pricing/index.d.ts +174 -4
  213. package/dist/pricing/index.js +174 -1
  214. package/dist/pricing/price-lists.d.ts +606 -0
  215. package/dist/pricing/price-lists.js +600 -0
  216. package/dist/purchasing/alerts.d.ts +104 -0
  217. package/dist/purchasing/alerts.js +88 -0
  218. package/dist/purchasing/backorders.d.ts +61 -0
  219. package/dist/purchasing/backorders.js +92 -0
  220. package/dist/purchasing/cost.d.ts +110 -0
  221. package/dist/purchasing/cost.js +86 -0
  222. package/dist/purchasing/index.d.ts +54 -0
  223. package/dist/purchasing/index.js +24 -0
  224. package/dist/purchasing/links.d.ts +263 -0
  225. package/dist/purchasing/links.js +192 -0
  226. package/dist/purchasing/purchase-orders.d.ts +551 -0
  227. package/dist/purchasing/purchase-orders.js +491 -0
  228. package/dist/purchasing/receipts.d.ts +396 -0
  229. package/dist/purchasing/receipts.js +287 -0
  230. package/dist/purchasing/replenishment.d.ts +281 -0
  231. package/dist/purchasing/replenishment.js +240 -0
  232. package/dist/purchasing/returns.d.ts +273 -0
  233. package/dist/purchasing/returns.js +229 -0
  234. package/dist/purchasing/settings.d.ts +152 -0
  235. package/dist/purchasing/settings.js +181 -0
  236. package/dist/purchasing/suppliers.d.ts +476 -0
  237. package/dist/purchasing/suppliers.js +438 -0
  238. package/dist/quotes/index.d.ts +518 -0
  239. package/dist/quotes/index.js +439 -0
  240. package/dist/reports/index.d.ts +71 -8
  241. package/dist/reports/index.js +74 -11
  242. package/dist/returns/index.d.ts +675 -21
  243. package/dist/returns/index.js +756 -11
  244. package/dist/search/index.d.ts +76 -1
  245. package/dist/search/index.js +63 -0
  246. package/dist/seo/config.d.ts +128 -0
  247. package/dist/seo/config.js +95 -0
  248. package/dist/seo/redirects.d.ts +125 -0
  249. package/dist/seo/redirects.js +60 -1
  250. package/dist/seo/settings.d.ts +147 -0
  251. package/dist/seo/settings.js +209 -0
  252. package/dist/shipping/definitions.d.ts +29 -0
  253. package/dist/shipping/definitions.js +47 -0
  254. package/dist/shipping/fulfillment-profiles.d.ts +174 -0
  255. package/dist/shipping/fulfillment-profiles.js +104 -0
  256. package/dist/shipping/hendriks.d.ts +97 -0
  257. package/dist/shipping/hendriks.js +50 -0
  258. package/dist/shipping/index.d.ts +54 -0
  259. package/dist/shipping/index.js +27 -0
  260. package/dist/shipping/methods.d.ts +205 -0
  261. package/dist/shipping/methods.js +240 -0
  262. package/dist/shipping/myparcel.d.ts +668 -0
  263. package/dist/shipping/myparcel.js +466 -0
  264. package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
  265. package/dist/shipping/parcel-rule.d.ts +6 -5
  266. package/dist/shipping/parcel-rule.js +21 -23
  267. package/dist/shipping/rate-tables.d.ts +324 -0
  268. package/dist/shipping/rate-tables.js +390 -0
  269. package/dist/shipping/ship-to-countries.d.ts +75 -0
  270. package/dist/shipping/ship-to-countries.js +47 -0
  271. package/dist/stock/by-location.d.ts +86 -0
  272. package/dist/stock/by-location.js +94 -0
  273. package/dist/stock/index.d.ts +18 -4
  274. package/dist/stock/index.js +7 -0
  275. package/dist/stock/locations.d.ts +144 -0
  276. package/dist/stock/locations.js +168 -0
  277. package/dist/stock/settings.d.ts +106 -0
  278. package/dist/stock/settings.js +103 -0
  279. package/dist/stock/transfers.d.ts +386 -52
  280. package/dist/stock/transfers.js +222 -17
  281. package/dist/stored-value/index.d.ts +312 -11
  282. package/dist/stored-value/index.js +223 -4
  283. package/dist/subscriptions/index.d.ts +682 -0
  284. package/dist/subscriptions/index.js +815 -0
  285. package/dist/tax/display-policy.d.ts +105 -0
  286. package/dist/tax/display-policy.js +84 -0
  287. package/dist/tax/index.d.ts +79 -1
  288. package/dist/tax/index.js +52 -0
  289. package/dist/tenant/email-style.d.ts +102 -0
  290. package/dist/tenant/email-style.js +72 -0
  291. package/dist/tenant/email-templates.d.ts +287 -0
  292. package/dist/tenant/email-templates.js +271 -0
  293. package/dist/tenant/notifications.d.ts +23 -17
  294. package/dist/tenant/settings-sources.d.ts +1 -1
  295. package/dist/tenant/time-zone.d.ts +17 -0
  296. package/dist/tenant/time-zone.js +11 -0
  297. package/dist/types.d.ts +50 -3
  298. package/dist/users/index.d.ts +3 -0
  299. package/dist/users/index.js +2 -0
  300. package/dist/users/warehouses.d.ts +50 -0
  301. package/dist/users/warehouses.js +51 -0
  302. package/package.json +2 -2
@@ -0,0 +1,245 @@
1
+ /**
2
+ * The order page's own fields (headless spec §9.2 `orders` "notes", "fulfilments"; W10-26): the
3
+ * order's notes, its purchase-order number, its customer, its goodwill rounding, and the
4
+ * correction of what a fulfilment shipped.
5
+ *
6
+ * Whether an order still takes a goodwill rounding or a fulfilment correction is
7
+ * `orders.status(orderId).actions` (`APPLY_GOODWILL_ROUNDING` to apply one,
8
+ * `SET_GOODWILL_ROUNDING` to clear it, `CORRECT_FULFILLMENT`): ask it before offering one.
9
+ */
10
+ import { type Transport } from '@sixtyninecommerce/core';
11
+ import type { Call } from '../types.js';
12
+ /** A staff note on an order. Listed with the order's history (`orders.get`, type `ORDER_NOTE`). */
13
+ export interface OrderNote {
14
+ id: string;
15
+ note: string;
16
+ /** Whether the customer sees it (the storefront's order history). */
17
+ isPublic: boolean;
18
+ /** ISO-8601 with offset. */
19
+ createdAt: string;
20
+ /** ISO-8601 with offset. */
21
+ updatedAt: string;
22
+ }
23
+ export interface OrderNoteInput {
24
+ note: string;
25
+ /** Whether the customer sees it. Default false: a note is for staff unless you say otherwise. */
26
+ isPublic?: boolean;
27
+ }
28
+ export interface OrderNotesModule {
29
+ /**
30
+ * Add a note to the order's history. Needs `UpdateOrder`. A locked, completed or cancelled
31
+ * order still takes notes.
32
+ *
33
+ * It resolves with nothing: the engine answers the order, not the note. The note's id (for
34
+ * `update` and `delete`) is on `orders.get(orderId).history`, newest first, type `ORDER_NOTE`.
35
+ * An order this store does not hold is a `NotFoundError` (`ENTITY_NOT_FOUND`).
36
+ *
37
+ * @effect write
38
+ */
39
+ add(orderId: string, input: OrderNoteInput, options?: Call): Promise<void>;
40
+ /**
41
+ * Change a note's text, who sees it, or both; what is left out is kept. Needs `UpdateOrder`.
42
+ * An id that is not a note of this store is a `NotFoundError` (`ENTITY_NOT_FOUND`), the same
43
+ * as a missing one.
44
+ *
45
+ * @effect write
46
+ */
47
+ update(noteId: string, input: {
48
+ note?: string;
49
+ isPublic?: boolean;
50
+ }, options?: Call): Promise<OrderNote>;
51
+ /**
52
+ * Delete a note for good. Needs `UpdateOrder`.
53
+ *
54
+ * Refused `ORDER_NOTE_NOT_DELETED` (`ConflictError`, 409, as every `*_NOT_DELETED` of this
55
+ * SDK) with the engine's own reason: a note this store does not have, or a history entry that
56
+ * records a decision about the order (a payment coverage override, money kept on a cancelled
57
+ * order), which stays on its history.
58
+ *
59
+ * @effect destructive
60
+ */
61
+ delete(noteId: string, options?: Call): Promise<void>;
62
+ }
63
+ /** The order's purchase-order number as a write leaves it. */
64
+ export interface OrderPurchaseOrderNumber {
65
+ orderId: string;
66
+ /** Null when the order carries none. */
67
+ purchaseOrderNumber: string | null;
68
+ }
69
+ /** The order's customer as `setCustomer` leaves it. */
70
+ export interface OrderCustomerAssignment {
71
+ orderId: string;
72
+ customer: {
73
+ id: string;
74
+ firstName: string;
75
+ lastName: string;
76
+ emailAddress: string;
77
+ } | null;
78
+ }
79
+ /** The order's total and its goodwill rounding as a write leaves them. */
80
+ export interface OrderGoodwillRounding {
81
+ orderId: string;
82
+ code: string;
83
+ currencyCode: string;
84
+ /** The order's gross total in minor units, BEFORE the rounding. */
85
+ totalWithTax: number;
86
+ /**
87
+ * The rounding in minor units: negative while one is applied (`-87` takes 0.87 off), null
88
+ * when there is none. What the order bills is `totalWithTax` plus this.
89
+ */
90
+ goodwillRoundingMinor: number | null;
91
+ }
92
+ /** Where the units taken out of a fulfilment went. There is no default. */
93
+ export type FulfillmentUnitDisposition = 'RETURN_TO_STOCK' | 'WRITE_OFF';
94
+ export interface FulfillmentQuantityCorrectionLine {
95
+ orderLineId: string;
96
+ /** What actually shipped: 0 up to the line's quantity in the fulfilment. It never rises. */
97
+ quantity: number;
98
+ /**
99
+ * Also lower the ORDERED quantity by the same amount, so the customer is billed for what
100
+ * shipped. Leave it out when the balance follows in a later fulfilment.
101
+ */
102
+ reduceOrderLine?: boolean;
103
+ }
104
+ export interface FulfillmentQuantityCorrectionInput {
105
+ fulfillmentId: string;
106
+ /** The lines that change. A line left at its quantity may be left out. */
107
+ lines: readonly FulfillmentQuantityCorrectionLine[];
108
+ /**
109
+ * `RETURN_TO_STOCK`: the units are back on the shelf and sellable. `WRITE_OFF`: they are gone
110
+ * (miscounted, broken, lost) and stock on hand does not rise.
111
+ */
112
+ disposition: FulfillmentUnitDisposition | (string & {});
113
+ /** Why, for the order's history. */
114
+ reason?: string | null;
115
+ }
116
+ /** The fulfilment as a correction leaves it. */
117
+ export interface FulfillmentQuantityCorrection {
118
+ fulfillmentId: string;
119
+ state: string;
120
+ lines: Array<{
121
+ orderLineId: string;
122
+ quantity: number;
123
+ }>;
124
+ }
125
+ export interface OrderFieldsModule {
126
+ /** The order's staff notes: add, change, delete. */
127
+ notes: OrderNotesModule;
128
+ /**
129
+ * Set the order's purchase-order number (the buyer's own reference, printed on the invoice's
130
+ * "Reference" row), or clear it with `null` or an empty string. Needs `UpdateOrder`. An
131
+ * invoiced order still takes it: it prints on the NEXT invoice.
132
+ *
133
+ * Refused `ORDER_PO_NUMBER_INVALID` (`ValidationError`, 400) for a value over 255 characters;
134
+ * `error.details[0].field` is `/input/customFields/poNumber`. An order this store does not
135
+ * hold is a `NotFoundError` (`ENTITY_NOT_FOUND`). An engine older than the code answers the
136
+ * same refusal as `USER_INPUT_ERROR` (also a `ValidationError`), with no `details`.
137
+ *
138
+ * @effect write
139
+ */
140
+ setPurchaseOrderNumber(orderId: string, value: string | null, options?: Call): Promise<OrderPurchaseOrderNumber>;
141
+ /**
142
+ * Move the order to another customer of the store. Needs `UpdateOrder`. `options.note` is
143
+ * kept with the change on the order's history. Naming the customer the order already has
144
+ * changes nothing.
145
+ *
146
+ * Refused with the engine's sentence (`ValidationError`, `USER_INPUT_ERROR`, 400) while the
147
+ * order's content no longer changes (an invoice bills it, or it is completed or cancelled:
148
+ * `orders.status(orderId).editBlock`), and once delivery terms were accepted for it. An
149
+ * order or a customer this store does not hold is a `NotFoundError` (`ENTITY_NOT_FOUND`).
150
+ *
151
+ * @effect write
152
+ */
153
+ setCustomer(orderId: string, customerId: string, options?: Call & {
154
+ note?: string;
155
+ }): Promise<OrderCustomerAssignment>;
156
+ /**
157
+ * Round the order's payable total DOWN to a whole currency unit as a courtesy (`apply:
158
+ * true`), or take the rounding off again (`false`). Needs `UpdateOrder`.
159
+ *
160
+ * **It changes what the order bills.** The engine computes the amount from the order's own
161
+ * gross total: this method takes none. The rounding is stored beside the total (the
162
+ * order's lines and `totalWithTax` do not change), and the order's invoice, its payment
163
+ * position (`orders.paymentPosition`) and the accounts-receivable ledger all bill
164
+ * `totalWithTax + goodwillRoundingMinor`. It moves no payment and issues no refund. Applied
165
+ * again after the total changed, it is recomputed.
166
+ *
167
+ * Refused, with nothing changed:
168
+ * - `GOODWILL_ROUNDING_LOCKED` (422), either way, once the order's total no longer moves: an
169
+ * invoice bills it, it is completed or cancelled, or it is settled or invoiced in the
170
+ * store's ERP. `orders.status` answers the same rule (`SET_GOODWILL_ROUNDING`:
171
+ * `INVOICE_LOCKED`, `COMPLETED`, `CANCELLED`, `ERP_LOCKED`);
172
+ * - `GOODWILL_ROUNDING_NOT_APPLICABLE` (422), applying only: the order has more than one VAT
173
+ * rate (the rounding is booked at a single rate), or its total is already whole;
174
+ * - `GOODWILL_ROUNDING_LEAVES_MONEY_OVER` (422), applying only: the order is paid, and its
175
+ * payments would hold more than the rounded total. The rounding refunds nothing, so that
176
+ * money would stay over: refund the customer instead. `orders.status` answers it
177
+ * (`APPLY_GOODWILL_ROUNDING`: `LEAVES_MONEY_OVER`);
178
+ * - `ORDER_MONEY_ACTION_IN_PROGRESS` (409, retryable), either way: a return's settlement or an
179
+ * invoice correction of the order held its money turn past the wait. Try again.
180
+ *
181
+ * An order this store does not hold is a `NotFoundError` (`ENTITY_NOT_FOUND`). An engine
182
+ * older than these codes answers the same refusals with their sentence and no code (a 500).
183
+ *
184
+ * @effect money
185
+ */
186
+ setGoodwillRounding(orderId: string, apply: boolean, options?: Call): Promise<OrderGoodwillRounding>;
187
+ /**
188
+ * Record what a fulfilment ACTUALLY shipped after a short pick: lower its line quantities,
189
+ * move the stock the `disposition` implies, and, per line, optionally lower what the customer
190
+ * is billed for (`reduceOrderLine`), all in one step. Needs `UpdateOrder`. It notes the
191
+ * correction on the order's history and tells no carrier.
192
+ *
193
+ * **`reduceOrderLine` changes what the order bills, and it issues NO refund.** It is refused
194
+ * once the order's payment holds money (see below): correct the fulfilment without it, then
195
+ * give the money back through an order edit. Without `reduceOrderLine` the order keeps asking
196
+ * for the units, as a split shipment needs.
197
+ *
198
+ * **This is the order page's door.** The warehouse workspace has its own
199
+ * (`correctFulfillmentQuantities`, for a caller holding `UpdateFulfillment`, scoped to the
200
+ * warehouses they are assigned to, and never billing down): `orders.status` explains both
201
+ * under `CORRECT_FULFILLMENT`. Whether THIS fulfilment can still be corrected is its own
202
+ * stage (Pending or Picking, or Packed with no carrier booking).
203
+ *
204
+ * **Idempotency.** With `options.idempotencyKey`, repeating the same correction answers the
205
+ * first one's fulfilment instead of removing the units a second time; another correction
206
+ * under that key is `IDEMPOTENCY_CONFLICT` (409). Without a key a repeat is a second
207
+ * correction.
208
+ *
209
+ * Refused, with nothing changed:
210
+ * - `FULFILLMENT_QUANTITY_INPUT_INVALID` (`ValidationError`, 400): no lines, a line named
211
+ * twice or not in the fulfilment, a quantity that is not a whole number of 0 or more or
212
+ * that rises, or a correction that changes nothing;
213
+ * - `FULFILLMENT_QUANTITY_NOT_CORRECTABLE` (422): the fulfilment has shipped, a carrier
214
+ * booking fixes its contents, or the correction would empty it (cancel it instead);
215
+ * - `FULFILLMENT_QUANTITY_ORDER_LOCKED` (422): an invoice bills the order, or it is
216
+ * completed or cancelled (`orders.status(orderId).fulfillmentCorrection`);
217
+ * - `FULFILLMENT_QUANTITY_BILL_DOWN_REFUSED` (422), `reduceOrderLine` only: the order's
218
+ * payment is settled or held by a payment provider, or its method is no longer on the
219
+ * store so it cannot be shown to hold no money;
220
+ * - `ORDER_BILLING_LOCKED` (422), `reduceOrderLine` only: the order was sent to an ERP that
221
+ * takes no later change;
222
+ * - `FULFILLMENT_QUANTITY_CONFLICT` (`ConflictError`, 409): the fulfilment or the order
223
+ * changed meanwhile. Read the order again and correct what it shows now;
224
+ * - `FULFILLMENT_CHANGED` (retryable): another change to the fulfilment was in progress;
225
+ * - `LOCATION_OUT_OF_SCOPE` (422), for a credential restricted to stock locations (an API
226
+ * token or app installation with `locationIds`) only: the fulfilment does not ship from one
227
+ * of them (one with no recorded warehouse included). It reads like a missing fulfilment, and
228
+ * the key is not spent on it.
229
+ *
230
+ * A fulfilment this store does not hold is a `NotFoundError` (`ENTITY_NOT_FOUND`). Platform
231
+ * releases before this method do not take the key and refuse the call as `ValidationError`
232
+ * `GRAPHQL_VALIDATION_FAILED` (400): deploy the engine first.
233
+ *
234
+ * @effect money
235
+ */
236
+ correctFulfillmentQuantities(input: FulfillmentQuantityCorrectionInput, options?: Call): Promise<FulfillmentQuantityCorrection>;
237
+ }
238
+ export declare const ADD_ORDER_NOTE_MUTATION = "\n mutation AddNoteToOrder($input: AddNoteToOrderInput!) {\n addNoteToOrder(input: $input) {\n id\n }\n }\n";
239
+ export declare const UPDATE_ORDER_NOTE_MUTATION = "\n mutation UpdateOrderNote($input: UpdateOrderNoteInput!) {\n updateOrderNote(input: $input) {\n id\n isPublic\n data\n createdAt\n updatedAt\n }\n }\n";
240
+ export declare const DELETE_ORDER_NOTE_MUTATION = "\n mutation DeleteOrderNote($id: ID!) {\n deleteOrderNote(id: $id) {\n result\n message\n }\n }\n";
241
+ export declare const SET_ORDER_PURCHASE_ORDER_NUMBER_MUTATION = "\n mutation SetOrderPurchaseOrderNumber($input: UpdateOrderInput!) {\n setOrderCustomFields(input: $input) {\n id\n customFields {\n poNumber\n }\n }\n }\n";
242
+ export declare const SET_ORDER_CUSTOMER_MUTATION = "\n mutation SetOrderCustomer($input: SetOrderCustomerInput!) {\n setOrderCustomer(input: $input) {\n id\n customer {\n id\n firstName\n lastName\n emailAddress\n }\n }\n }\n";
243
+ export declare const SET_ORDER_GOODWILL_ROUNDING_MUTATION = "\n mutation SetOrderGoodwillRounding($orderId: ID!, $apply: Boolean!) {\n setOrderGoodwillRounding(orderId: $orderId, apply: $apply) {\n id\n code\n currencyCode\n totalWithTax\n customFields {\n goodwillRoundingMinor\n }\n }\n }\n";
244
+ export declare const CORRECT_FULFILLMENT_QUANTITIES_MUTATION = "\n mutation UpdateFulfillmentLineQuantities(\n $fulfillmentId: ID!\n $lines: [UpdateFulfillmentLineQuantityInput!]!\n $disposition: FulfillmentUnitDisposition!\n $reason: String\n $idempotencyKey: String\n ) {\n updateFulfillmentLineQuantities(\n fulfillmentId: $fulfillmentId\n lines: $lines\n disposition: $disposition\n reason: $reason\n idempotencyKey: $idempotencyKey\n ) {\n id\n state\n lines {\n orderLineId\n quantity\n }\n }\n }\n";
245
+ export declare function createOrderFieldsModule(transport: Transport): OrderFieldsModule;
@@ -0,0 +1,188 @@
1
+ /**
2
+ * The order page's own fields (headless spec §9.2 `orders` "notes", "fulfilments"; W10-26): the
3
+ * order's notes, its purchase-order number, its customer, its goodwill rounding, and the
4
+ * correction of what a fulfilment shipped.
5
+ *
6
+ * Whether an order still takes a goodwill rounding or a fulfilment correction is
7
+ * `orders.status(orderId).actions` (`APPLY_GOODWILL_ROUNDING` to apply one,
8
+ * `SET_GOODWILL_ROUNDING` to clear it, `CORRECT_FULFILLMENT`): ask it before offering one.
9
+ */
10
+ import { NotFoundError } from '@sixtyninecommerce/core';
11
+ import { assertDeleted, fieldOf } from '../catalog/types.js';
12
+ export const ADD_ORDER_NOTE_MUTATION = /* GraphQL */ `
13
+ mutation AddNoteToOrder($input: AddNoteToOrderInput!) {
14
+ addNoteToOrder(input: $input) {
15
+ id
16
+ }
17
+ }
18
+ `;
19
+ export const UPDATE_ORDER_NOTE_MUTATION = /* GraphQL */ `
20
+ mutation UpdateOrderNote($input: UpdateOrderNoteInput!) {
21
+ updateOrderNote(input: $input) {
22
+ id
23
+ isPublic
24
+ data
25
+ createdAt
26
+ updatedAt
27
+ }
28
+ }
29
+ `;
30
+ export const DELETE_ORDER_NOTE_MUTATION = /* GraphQL */ `
31
+ mutation DeleteOrderNote($id: ID!) {
32
+ deleteOrderNote(id: $id) {
33
+ result
34
+ message
35
+ }
36
+ }
37
+ `;
38
+ export const SET_ORDER_PURCHASE_ORDER_NUMBER_MUTATION = /* GraphQL */ `
39
+ mutation SetOrderPurchaseOrderNumber($input: UpdateOrderInput!) {
40
+ setOrderCustomFields(input: $input) {
41
+ id
42
+ customFields {
43
+ poNumber
44
+ }
45
+ }
46
+ }
47
+ `;
48
+ export const SET_ORDER_CUSTOMER_MUTATION = /* GraphQL */ `
49
+ mutation SetOrderCustomer($input: SetOrderCustomerInput!) {
50
+ setOrderCustomer(input: $input) {
51
+ id
52
+ customer {
53
+ id
54
+ firstName
55
+ lastName
56
+ emailAddress
57
+ }
58
+ }
59
+ }
60
+ `;
61
+ export const SET_ORDER_GOODWILL_ROUNDING_MUTATION = /* GraphQL */ `
62
+ mutation SetOrderGoodwillRounding($orderId: ID!, $apply: Boolean!) {
63
+ setOrderGoodwillRounding(orderId: $orderId, apply: $apply) {
64
+ id
65
+ code
66
+ currencyCode
67
+ totalWithTax
68
+ customFields {
69
+ goodwillRoundingMinor
70
+ }
71
+ }
72
+ }
73
+ `;
74
+ export const CORRECT_FULFILLMENT_QUANTITIES_MUTATION = /* GraphQL */ `
75
+ mutation UpdateFulfillmentLineQuantities(
76
+ $fulfillmentId: ID!
77
+ $lines: [UpdateFulfillmentLineQuantityInput!]!
78
+ $disposition: FulfillmentUnitDisposition!
79
+ $reason: String
80
+ $idempotencyKey: String
81
+ ) {
82
+ updateFulfillmentLineQuantities(
83
+ fulfillmentId: $fulfillmentId
84
+ lines: $lines
85
+ disposition: $disposition
86
+ reason: $reason
87
+ idempotencyKey: $idempotencyKey
88
+ ) {
89
+ id
90
+ state
91
+ lines {
92
+ orderLineId
93
+ quantity
94
+ }
95
+ }
96
+ }
97
+ `;
98
+ function noteOf(entry) {
99
+ const text = entry.data?.note;
100
+ return {
101
+ id: entry.id,
102
+ note: typeof text === 'string' ? text : '',
103
+ isPublic: entry.isPublic,
104
+ createdAt: entry.createdAt,
105
+ updatedAt: entry.updatedAt,
106
+ };
107
+ }
108
+ /** The engine answers these two fields `null` for an order it could not return. */
109
+ function orderOrNotFound(order, orderId) {
110
+ if (order !== null && order !== undefined)
111
+ return order;
112
+ throw new NotFoundError({
113
+ code: 'ORDER_NOT_FOUND',
114
+ message: `This store has no order ${orderId}.`,
115
+ status: 404,
116
+ service: 'vendure',
117
+ });
118
+ }
119
+ export function createOrderFieldsModule(transport) {
120
+ return {
121
+ notes: {
122
+ async add(orderId, input, options) {
123
+ await fieldOf(transport, ADD_ORDER_NOTE_MUTATION, 'addNoteToOrder', { input: { id: orderId, note: input.note, isPublic: input.isPublic ?? false } }, options);
124
+ },
125
+ async update(noteId, input, options) {
126
+ const entry = await fieldOf(transport, UPDATE_ORDER_NOTE_MUTATION, 'updateOrderNote',
127
+ // `undefined`, never an explicit null: what is left out stays off the wire, and kept.
128
+ { input: { noteId, note: input.note, isPublic: input.isPublic } }, options);
129
+ return noteOf(entry);
130
+ },
131
+ async delete(noteId, options) {
132
+ assertDeleted('ORDER_NOTE_NOT_DELETED', [
133
+ await fieldOf(transport, DELETE_ORDER_NOTE_MUTATION, 'deleteOrderNote', { id: noteId }, options),
134
+ ]);
135
+ },
136
+ },
137
+ async setPurchaseOrderNumber(orderId, value, options) {
138
+ const order = await fieldOf(transport, SET_ORDER_PURCHASE_ORDER_NUMBER_MUTATION, 'setOrderCustomFields',
139
+ // An empty string and null both clear it; the engine stores null.
140
+ { input: { id: orderId, customFields: { poNumber: value === '' ? null : value } } }, options);
141
+ const found = orderOrNotFound(order, orderId);
142
+ const stored = found.customFields?.poNumber;
143
+ return {
144
+ orderId: found.id,
145
+ purchaseOrderNumber: typeof stored === 'string' && stored !== '' ? stored : null,
146
+ };
147
+ },
148
+ async setCustomer(orderId, customerId, options) {
149
+ const order = await fieldOf(transport, SET_ORDER_CUSTOMER_MUTATION, 'setOrderCustomer',
150
+ // `undefined`, never an explicit null: an omitted note stays off the wire.
151
+ { input: { orderId, customerId, note: options?.note } }, options);
152
+ const found = orderOrNotFound(order, orderId);
153
+ return { orderId: found.id, customer: found.customer ?? null };
154
+ },
155
+ async setGoodwillRounding(orderId, apply, options) {
156
+ const order = await fieldOf(transport, SET_ORDER_GOODWILL_ROUNDING_MUTATION, 'setOrderGoodwillRounding', { orderId, apply }, options);
157
+ return {
158
+ orderId: order.id,
159
+ code: order.code,
160
+ currencyCode: order.currencyCode,
161
+ totalWithTax: order.totalWithTax,
162
+ goodwillRoundingMinor: order.customFields?.goodwillRoundingMinor ?? null,
163
+ };
164
+ },
165
+ async correctFulfillmentQuantities(input, options) {
166
+ const fulfillment = await fieldOf(transport, CORRECT_FULFILLMENT_QUANTITIES_MUTATION, 'updateFulfillmentLineQuantities', {
167
+ fulfillmentId: input.fulfillmentId,
168
+ lines: input.lines.map((line) => ({
169
+ orderLineId: line.orderLineId,
170
+ quantity: line.quantity,
171
+ reduceOrderLine: line.reduceOrderLine === true,
172
+ })),
173
+ disposition: input.disposition,
174
+ reason: input.reason ?? null,
175
+ // `undefined`, never an explicit null: an omitted key stays off the wire.
176
+ idempotencyKey: options?.idempotencyKey,
177
+ }, options);
178
+ return {
179
+ fulfillmentId: fulfillment.id,
180
+ state: fulfillment.state,
181
+ lines: fulfillment.lines.map((line) => ({
182
+ orderLineId: line.orderLineId,
183
+ quantity: line.quantity,
184
+ })),
185
+ };
186
+ },
187
+ };
188
+ }
@@ -9,15 +9,15 @@
9
9
  * in `include`, so a caller reads only what it uses, and the core document
10
10
  * names no field an engine without that plugin lacks.
11
11
  *
12
- * Money is an integer in minor units of the order's currency, with three
13
- * exceptions that are NOT converted to it: a line's `productVariant.price` and
14
- * `priceWithTax` (the catalogue price in the currency of the request, which is
15
- * the store's default unless the call names another), and a line's
16
- * `customFields.cost` (the store's default currency). An instant is an ISO-8601
17
- * string with its offset.
12
+ * Money is an integer in minor units of the order's currency, with two
13
+ * exceptions that are NOT converted to it: a line's `productVariant.storePrice`
14
+ * (the catalogue price in the currency of the request, which is the store's
15
+ * default unless the call names another; its own `currencyCode` says which),
16
+ * and a line's `customFields.cost` (the store's default currency). An instant is
17
+ * an ISO-8601 string with its offset.
18
18
  */
19
19
  import { type Transport } from '@sixtyninecommerce/core';
20
- import type { InventoryFlag } from '../catalog/variants.js';
20
+ import type { InventoryFlag, VariantStorePrice } from '../catalog/variants.js';
21
21
  import type { OrderDiscount } from '../pricing/index.js';
22
22
  import type { Call } from '../types.js';
23
23
  /**
@@ -140,15 +140,15 @@ export interface OrderLineVariant {
140
140
  sku: string;
141
141
  /**
142
142
  * The catalogue unit price today, net and gross: the retail price, before any
143
- * price list or override, unlike the line's own `unitPrice`.
143
+ * price list or override, unlike the line's own `unitPrice`. Null when the
144
+ * store has no price for the variant any more; the line keeps its own prices.
144
145
  *
145
- * NOT in the order's currency. It is in the currency of the request: the
146
- * store's default, unless the call names another (`tenant.currency`). On an
147
- * order in another currency, never subtract it from or compare it with the
148
- * line's own prices.
146
+ * NOT in the order's currency. It is in the currency of the request
147
+ * (`storePrice.currencyCode`): the store's default, unless the call names
148
+ * another (`tenant.currency`). On an order in another currency, never
149
+ * subtract it from or compare it with the line's own prices.
149
150
  */
150
- price: number;
151
- priceWithTax: number;
151
+ storePrice: VariantStorePrice | null;
152
152
  stockOnHand: number;
153
153
  stockAllocated: number;
154
154
  /** How the variant tracks stock: its own setting, or the store's (`INHERIT`). */
@@ -570,16 +570,24 @@ export type Order<I extends OrderInclude = never> = {
570
570
  * Every promotion's discount on the order, one entry per promotion, amounts
571
571
  * negative: the line promotions and the order promotions' shares of the lines
572
572
  * and of shipping, added up per promotion. A line's own discounts are already
573
- * in its `discountedLinePrice`, so do not add the two. The read selects these
574
- * three fields of the pricing module's `OrderDiscount`;
575
- * `pricing.discounts(orderId)` answers the rest.
573
+ * in its `discountedLinePrice`, and a promotion's share of shipping is already
574
+ * in `shipping` (that share is on `shippingLines[].discounts`, under the same
575
+ * `adjustmentSource`), so do not add the two. The read selects these four
576
+ * fields of the pricing module's `OrderDiscount`; `pricing.discounts(orderId)`
577
+ * answers the rest.
576
578
  */
577
- discounts: Array<Pick<OrderDiscount, 'description' | 'amount' | 'amountWithTax'>>;
579
+ discounts: Array<Pick<OrderDiscount, 'adjustmentSource' | 'description' | 'amount' | 'amountWithTax'>>;
578
580
  shippingLines: Array<{
579
581
  shippingMethod: {
580
582
  id: string;
581
583
  name: string;
582
584
  };
585
+ /**
586
+ * The promotions' discounts on this shipping line, amounts negative, already
587
+ * in `shipping`. Each is part of the `discounts` entry of the same
588
+ * `adjustmentSource`.
589
+ */
590
+ discounts: Array<Pick<OrderDiscount, 'adjustmentSource' | 'amount' | 'amountWithTax'>>;
583
591
  }>;
584
592
  payments: OrderPayment[] | null;
585
593
  fulfillments: OrderFulfillment<I>[] | null;
@@ -640,7 +648,7 @@ export type Order<I extends OrderInclude = never> = {
640
648
  * the named blocks is included: an object whose every field belongs to a block
641
649
  * (an empty selection is not valid GraphQL).
642
650
  */
643
- export declare const ORDER_QUERY_EVERY_BLOCK = "\n query Order($id: ID!) {\n order(id: $id) {\n id\n code\n state\n active\n total\n totalWithTax\n subTotal\n subTotalWithTax\n shipping\n shippingWithTax\n currencyCode\n orderPlacedAt\n #[paymentTerms\n paymentTerms {\n source\n managedExternally\n status\n conditionCode\n conditionDescription\n summary\n classification\n paymentDays\n paymentEndOfMonths\n paymentMethod\n percentage\n discountPaymentDays\n discountPercentage\n paymentDiscountType\n stale\n syncedAt\n error\n resolvedAt\n remoteConditionCode\n remoteConfirmedAt\n remoteMismatch\n }\n #]\n #[deliveryTerms\n deliveryTerms {\n source\n sourceScope\n governingCustomerId\n sourceCustomerId\n managedExternally\n status\n shippingMethodStatus\n policyStatus\n summary\n selectionSource\n selectedShippingMethodId\n selectedShippingMethodCode\n selectedShippingMethodName\n platformShippingMethodCode\n platformShippingMethodName\n platformShippingMethodDescription\n platformShippingPrice\n platformShippingPriceWithTax\n preferredShippingMethodId\n incotermStatus\n incotermCode\n incotermVersion\n incotermAddress\n incotermDescription\n shippingLeadDays\n deliveryAdvice\n stale\n syncedAt\n warning\n resolvedAt\n remoteShippingMethodCode\n remoteShippingMethodName\n remoteIncotermCode\n remoteIncotermVersion\n remoteIncotermAddress\n remoteDeliveryDate\n remoteConfirmedAt\n remoteMismatch\n }\n #]\n couponCodes\n customer {\n id\n firstName\n lastName\n emailAddress\n phoneNumber\n #[vatValidation|afas|parasut\n customFields {\n #[vatValidation\n vatNumber\n vatValidationStatus\n #]\n #[afas\n afasVrId\n afasOrgId\n afasContactId\n afasPersId\n #]\n #[parasut\n parasutContactId\n #]\n }\n #]\n addresses {\n id\n fullName\n company\n streetLine1\n streetLine2\n city\n postalCode\n country {\n code\n }\n defaultShippingAddress\n defaultBillingAddress\n #[afas\n customFields {\n afasAddressId\n }\n #]\n }\n }\n lines {\n id\n quantity\n unitPrice\n unitPriceWithTax\n listPriceIncludesTax\n discountedUnitPrice\n discountedUnitPriceWithTax\n linePrice\n linePriceWithTax\n discountedLinePrice\n discountedLinePriceWithTax\n proratedLinePrice\n proratedLinePriceWithTax\n taxRate\n productVariant {\n id\n name\n sku\n price\n priceWithTax\n stockOnHand\n stockAllocated\n trackInventory\n outOfStockThreshold\n useGlobalOutOfStockThreshold\n stockLevels {\n stockLocationId\n stockOnHand\n stockAllocated\n stockLocation {\n id\n name\n }\n }\n product {\n id\n name\n featuredAsset {\n id\n preview\n }\n }\n }\n featuredAsset {\n id\n preview\n }\n #[lineAllocations\n allocations {\n id\n stockLocation {\n id\n name\n }\n quantity\n }\n #]\n outstandingAllocatedQuantity\n outstandingAllocations {\n stockLocationId\n stockLocationName\n quantity\n }\n customFields {\n unitPriceOverride\n priceOverrideReason\n unitPriceImported\n priceListId\n priceListName\n retailPrice\n priceListPrice\n priceListDiscountType\n priceListDiscountValue\n priceListDiscountChain\n cost\n preferredStockLocationId\n backorderedQuantity\n }\n }\n surcharges {\n id\n description\n sku\n price\n priceWithTax\n taxRate\n }\n discounts {\n description\n amount\n amountWithTax\n }\n shippingLines {\n shippingMethod {\n id\n name\n }\n }\n payments {\n id\n state\n method\n amount\n transactionId\n createdAt\n refunds {\n id\n state\n total\n reason\n }\n }\n fulfillments {\n id\n state\n nextStates\n method\n trackingCode\n lines {\n orderLineId\n quantity\n }\n #[fulfillmentDetails\n handlerCode\n handlerName\n handlerDetails {\n label\n value\n }\n packingSlips {\n id\n packingSlipNumber\n fulfillmentId\n languageCode\n storageKey\n createdAt\n }\n #]\n stockLocationName\n linkedOrders {\n id\n code\n }\n customFields {\n #[myparcel\n myparcelShipmentId\n myparcelLabelStatus\n myparcelLabelFormat\n myparcelLabelUrlA4\n myparcelLabelUrlA6\n myparcelLabelLastError\n myparcelLabelHandoff\n #]\n bookingStatus\n }\n createdAt\n }\n shippingAddress {\n fullName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n country\n countryCode\n phoneNumber\n }\n billingAddress {\n fullName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n country\n countryCode\n phoneNumber\n }\n history(options: { take: 50, sort: { createdAt: DESC } }) {\n items {\n id\n type\n data\n createdAt\n isPublic\n administrator {\n id\n firstName\n lastName\n }\n }\n }\n taxSummary {\n description\n taxRate\n taxBase\n taxTotal\n }\n nextStates\n createdAt\n updatedAt\n customFields {\n isLocked\n externalOrderId\n externalPlatform\n sourceFulfillmentHandedOff\n originalPlacedAt\n sourceWarehouse\n pickupLocation\n allocationExpiresAt\n goodwillRoundingMinor\n removeTax\n isGift\n giftNote\n hidePricesOnPackingSlip\n poNumber\n requestedDeliveryDate\n orderNotes\n customerShippingAddressId\n customerBillingAddressId\n shippingAddressIsTemporary\n billingAddressIsTemporary\n paymentStatus\n fulfillmentStatus\n returnStatus\n lifecycleStatus\n #[paymentTerms\n paymentTermsDays\n paymentConditionCode\n #]\n #[afas\n afasSalesOrderId\n afasDirectInvoiceOrNu\n afasInvoiceNumber\n afasInvoiceDate\n afasLocked\n afasLockReason\n afasLastSyncAt\n #]\n #[parasut\n parasutInvoiceId\n parasutEInvoiceStatus\n parasutEInvoiceUuid\n parasutLastError\n #]\n }\n fulfillmentHold {\n reason\n note\n heldAt\n heldByUserId\n heldBy\n }\n #[priceList\n priceList {\n id\n name\n description\n defaultDiscountBps\n defaultDiscountAmount\n entries {\n id\n variantId\n discountType\n discountValue\n }\n }\n #]\n }\n }\n";
651
+ export declare const ORDER_QUERY_EVERY_BLOCK = "\n query Order($id: ID!) {\n order(id: $id) {\n id\n code\n state\n active\n total\n totalWithTax\n subTotal\n subTotalWithTax\n shipping\n shippingWithTax\n currencyCode\n orderPlacedAt\n #[paymentTerms\n paymentTerms {\n source\n managedExternally\n status\n conditionCode\n conditionDescription\n summary\n classification\n paymentDays\n paymentEndOfMonths\n paymentMethod\n percentage\n discountPaymentDays\n discountPercentage\n paymentDiscountType\n stale\n syncedAt\n error\n resolvedAt\n remoteConditionCode\n remoteConfirmedAt\n remoteMismatch\n }\n #]\n #[deliveryTerms\n deliveryTerms {\n source\n sourceScope\n governingCustomerId\n sourceCustomerId\n managedExternally\n status\n shippingMethodStatus\n policyStatus\n summary\n selectionSource\n selectedShippingMethodId\n selectedShippingMethodCode\n selectedShippingMethodName\n platformShippingMethodCode\n platformShippingMethodName\n platformShippingMethodDescription\n platformShippingPrice\n platformShippingPriceWithTax\n preferredShippingMethodId\n incotermStatus\n incotermCode\n incotermVersion\n incotermAddress\n incotermDescription\n shippingLeadDays\n deliveryAdvice\n stale\n syncedAt\n warning\n resolvedAt\n remoteShippingMethodCode\n remoteShippingMethodName\n remoteIncotermCode\n remoteIncotermVersion\n remoteIncotermAddress\n remoteDeliveryDate\n remoteConfirmedAt\n remoteMismatch\n }\n #]\n couponCodes\n customer {\n id\n firstName\n lastName\n emailAddress\n phoneNumber\n #[vatValidation|afas|parasut\n customFields {\n #[vatValidation\n vatNumber\n vatValidationStatus\n #]\n #[afas\n afasVrId\n afasOrgId\n afasContactId\n afasPersId\n #]\n #[parasut\n parasutContactId\n #]\n }\n #]\n addresses {\n id\n fullName\n company\n streetLine1\n streetLine2\n city\n postalCode\n country {\n code\n }\n defaultShippingAddress\n defaultBillingAddress\n #[afas\n customFields {\n afasAddressId\n }\n #]\n }\n }\n lines {\n id\n quantity\n unitPrice\n unitPriceWithTax\n listPriceIncludesTax\n discountedUnitPrice\n discountedUnitPriceWithTax\n linePrice\n linePriceWithTax\n discountedLinePrice\n discountedLinePriceWithTax\n proratedLinePrice\n proratedLinePriceWithTax\n taxRate\n productVariant {\n id\n name\n sku\n storePrice {\n price\n priceWithTax\n currencyCode\n }\n stockOnHand\n stockAllocated\n trackInventory\n outOfStockThreshold\n useGlobalOutOfStockThreshold\n stockLevels {\n stockLocationId\n stockOnHand\n stockAllocated\n stockLocation {\n id\n name\n }\n }\n product {\n id\n name\n featuredAsset {\n id\n preview\n }\n }\n }\n featuredAsset {\n id\n preview\n }\n #[lineAllocations\n allocations {\n id\n stockLocation {\n id\n name\n }\n quantity\n }\n #]\n outstandingAllocatedQuantity\n outstandingAllocations {\n stockLocationId\n stockLocationName\n quantity\n }\n customFields {\n unitPriceOverride\n priceOverrideReason\n unitPriceImported\n priceListId\n priceListName\n retailPrice\n priceListPrice\n priceListDiscountType\n priceListDiscountValue\n priceListDiscountChain\n cost\n preferredStockLocationId\n backorderedQuantity\n }\n }\n surcharges {\n id\n description\n sku\n price\n priceWithTax\n taxRate\n }\n discounts {\n adjustmentSource\n description\n amount\n amountWithTax\n }\n shippingLines {\n shippingMethod {\n id\n name\n }\n discounts {\n adjustmentSource\n amount\n amountWithTax\n }\n }\n payments {\n id\n state\n method\n amount\n transactionId\n createdAt\n refunds {\n id\n state\n total\n reason\n }\n }\n fulfillments {\n id\n state\n nextStates\n method\n trackingCode\n lines {\n orderLineId\n quantity\n }\n #[fulfillmentDetails\n handlerCode\n handlerName\n handlerDetails {\n label\n value\n }\n packingSlips {\n id\n packingSlipNumber\n fulfillmentId\n languageCode\n storageKey\n createdAt\n }\n #]\n stockLocationName\n linkedOrders {\n id\n code\n }\n customFields {\n #[myparcel\n myparcelShipmentId\n myparcelLabelStatus\n myparcelLabelFormat\n myparcelLabelUrlA4\n myparcelLabelUrlA6\n myparcelLabelLastError\n myparcelLabelHandoff\n #]\n bookingStatus\n }\n createdAt\n }\n shippingAddress {\n fullName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n country\n countryCode\n phoneNumber\n }\n billingAddress {\n fullName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n country\n countryCode\n phoneNumber\n }\n history(options: { take: 50, sort: { createdAt: DESC } }) {\n items {\n id\n type\n data\n createdAt\n isPublic\n administrator {\n id\n firstName\n lastName\n }\n }\n }\n taxSummary {\n description\n taxRate\n taxBase\n taxTotal\n }\n nextStates\n createdAt\n updatedAt\n customFields {\n isLocked\n externalOrderId\n externalPlatform\n sourceFulfillmentHandedOff\n originalPlacedAt\n sourceWarehouse\n pickupLocation\n allocationExpiresAt\n goodwillRoundingMinor\n removeTax\n isGift\n giftNote\n hidePricesOnPackingSlip\n poNumber\n requestedDeliveryDate\n orderNotes\n customerShippingAddressId\n customerBillingAddressId\n shippingAddressIsTemporary\n billingAddressIsTemporary\n paymentStatus\n fulfillmentStatus\n returnStatus\n lifecycleStatus\n #[paymentTerms\n paymentTermsDays\n paymentConditionCode\n #]\n #[afas\n afasSalesOrderId\n afasDirectInvoiceOrNu\n afasInvoiceNumber\n afasInvoiceDate\n afasLocked\n afasLockReason\n afasLastSyncAt\n #]\n #[parasut\n parasutInvoiceId\n parasutEInvoiceStatus\n parasutEInvoiceUuid\n parasutLastError\n #]\n }\n fulfillmentHold {\n reason\n note\n heldAt\n heldByUserId\n heldBy\n }\n #[priceList\n priceList {\n id\n name\n description\n defaultDiscountBps\n defaultDiscountAmount\n entries {\n id\n variantId\n discountType\n discountValue\n }\n }\n #]\n }\n }\n";
644
652
  /**
645
653
  * The document `get` sends for a set of blocks: {@link ORDER_QUERY_EVERY_BLOCK}
646
654
  * without the blocks the call did not include, and without the marker lines.
@@ -714,6 +722,8 @@ export interface OrderGetModule {
714
722
  *
715
723
  * Why the order is the way it is (its lock, what may be done to it) is
716
724
  * {@link OrderStatusModule.status}, not a field here.
725
+ *
726
+ * @effect read
717
727
  */
718
728
  get(orderId: string): Promise<Order | null>;
719
729
  get<const O extends OrderGetOptions | undefined>(orderId: string, options: O): Promise<OrderGetAnswer<O> | null>;
@@ -9,12 +9,12 @@
9
9
  * in `include`, so a caller reads only what it uses, and the core document
10
10
  * names no field an engine without that plugin lacks.
11
11
  *
12
- * Money is an integer in minor units of the order's currency, with three
13
- * exceptions that are NOT converted to it: a line's `productVariant.price` and
14
- * `priceWithTax` (the catalogue price in the currency of the request, which is
15
- * the store's default unless the call names another), and a line's
16
- * `customFields.cost` (the store's default currency). An instant is an ISO-8601
17
- * string with its offset.
12
+ * Money is an integer in minor units of the order's currency, with two
13
+ * exceptions that are NOT converted to it: a line's `productVariant.storePrice`
14
+ * (the catalogue price in the currency of the request, which is the store's
15
+ * default unless the call names another; its own `currencyCode` says which),
16
+ * and a line's `customFields.cost` (the store's default currency). An instant is
17
+ * an ISO-8601 string with its offset.
18
18
  */
19
19
  import { ValidationError } from '@sixtyninecommerce/core';
20
20
  import { redactionWatcher } from '../customer-data-redaction.js';
@@ -210,8 +210,11 @@ export const ORDER_QUERY_EVERY_BLOCK = /* GraphQL */ `
210
210
  id
211
211
  name
212
212
  sku
213
- price
214
- priceWithTax
213
+ storePrice {
214
+ price
215
+ priceWithTax
216
+ currencyCode
217
+ }
215
218
  stockOnHand
216
219
  stockAllocated
217
220
  trackInventory
@@ -280,6 +283,7 @@ export const ORDER_QUERY_EVERY_BLOCK = /* GraphQL */ `
280
283
  taxRate
281
284
  }
282
285
  discounts {
286
+ adjustmentSource
283
287
  description
284
288
  amount
285
289
  amountWithTax
@@ -289,6 +293,11 @@ export const ORDER_QUERY_EVERY_BLOCK = /* GraphQL */ `
289
293
  id
290
294
  name
291
295
  }
296
+ discounts {
297
+ adjustmentSource
298
+ amount
299
+ amountWithTax
300
+ }
292
301
  }
293
302
  payments {
294
303
  id