@sixtyninecommerce/admin 0.10.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 (247) hide show
  1. package/README.md +4347 -171
  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 +159 -19
  9. package/dist/catalog/products.js +88 -13
  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 +233 -26
  21. package/dist/catalog/variants.js +125 -7
  22. package/dist/catalog/visibility.d.ts +20 -5
  23. package/dist/catalog/visibility.js +19 -1
  24. package/dist/client.d.ts +95 -9
  25. package/dist/client.js +35 -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 +44 -10
  63. package/dist/fulfillments/index.js +11 -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 +123 -35
  71. package/dist/index.js +45 -12
  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 +29 -3
  87. package/dist/integrations/index.js +18 -3
  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 +15 -14
  91. package/dist/integrations/pipelines.js +6 -22
  92. package/dist/integrations/types.d.ts +146 -0
  93. package/dist/locations/index.d.ts +66 -0
  94. package/dist/locations/index.js +31 -0
  95. package/dist/meta/index.d.ts +162 -0
  96. package/dist/orders/cancel-with-money.d.ts +227 -0
  97. package/dist/orders/cancel-with-money.js +153 -0
  98. package/dist/orders/commit-edit.d.ts +7 -1
  99. package/dist/orders/commit-edit.js +5 -1
  100. package/dist/orders/drafts.d.ts +800 -0
  101. package/dist/orders/drafts.js +771 -0
  102. package/dist/orders/fields.d.ts +245 -0
  103. package/dist/orders/fields.js +188 -0
  104. package/dist/orders/get.d.ts +29 -19
  105. package/dist/orders/get.js +17 -8
  106. package/dist/orders/index.d.ts +49 -9
  107. package/dist/orders/index.js +22 -2
  108. package/dist/orders/lifecycle.d.ts +128 -0
  109. package/dist/orders/lifecycle.js +158 -0
  110. package/dist/orders/line-price-preview.d.ts +7 -2
  111. package/dist/orders/list.d.ts +222 -0
  112. package/dist/orders/list.js +377 -0
  113. package/dist/orders/manual-pricing.d.ts +5 -0
  114. package/dist/orders/order-entry.d.ts +20 -7
  115. package/dist/orders/plan-edit.d.ts +1 -1
  116. package/dist/orders/plan-edit.js +4 -1
  117. package/dist/orders/settings.d.ts +201 -0
  118. package/dist/orders/settings.js +325 -0
  119. package/dist/orders/status.d.ts +159 -13
  120. package/dist/orders/status.js +21 -0
  121. package/dist/orders/surcharges.d.ts +8 -1
  122. package/dist/orders/surcharges.js +3 -2
  123. package/dist/payments/account-credit.d.ts +30 -0
  124. package/dist/payments/account-credit.js +19 -0
  125. package/dist/payments/ar.d.ts +292 -0
  126. package/dist/payments/ar.js +223 -0
  127. package/dist/payments/connected-account.d.ts +47 -0
  128. package/dist/payments/connected-account.js +61 -0
  129. package/dist/payments/credit-noted-fields.d.ts +12 -0
  130. package/dist/payments/credit-noted-fields.js +37 -0
  131. package/dist/payments/index.d.ts +257 -11
  132. package/dist/payments/index.js +131 -1
  133. package/dist/payments/methods.d.ts +303 -8
  134. package/dist/payments/methods.js +337 -7
  135. package/dist/payments/mollie-methods.d.ts +159 -0
  136. package/dist/payments/mollie-methods.js +141 -0
  137. package/dist/payments/payment-links.d.ts +180 -0
  138. package/dist/payments/payment-links.js +97 -0
  139. package/dist/payments/provider-keys.d.ts +150 -0
  140. package/dist/payments/provider-keys.js +118 -0
  141. package/dist/payments/providers.d.ts +86 -11
  142. package/dist/payments/providers.js +29 -0
  143. package/dist/payments/requests.d.ts +144 -0
  144. package/dist/payments/requests.js +92 -0
  145. package/dist/payments/store-credit-fields.d.ts +15 -0
  146. package/dist/payments/store-credit-fields.js +51 -0
  147. package/dist/pickups/index.d.ts +104 -0
  148. package/dist/pickups/index.js +105 -0
  149. package/dist/platform/channels.d.ts +132 -0
  150. package/dist/platform/channels.js +128 -0
  151. package/dist/platform/geo.d.ts +123 -0
  152. package/dist/platform/geo.js +144 -0
  153. package/dist/platform/tax.d.ts +154 -0
  154. package/dist/platform/tax.js +139 -0
  155. package/dist/pos/anomalies.d.ts +158 -0
  156. package/dist/pos/anomalies.js +64 -0
  157. package/dist/pos/assisted-selling.d.ts +79 -0
  158. package/dist/pos/assisted-selling.js +38 -0
  159. package/dist/pos/exchanges.d.ts +103 -0
  160. package/dist/pos/exchanges.js +22 -0
  161. package/dist/pos/gift-cards.d.ts +135 -0
  162. package/dist/pos/gift-cards.js +47 -0
  163. package/dist/pos/index.d.ts +2125 -32
  164. package/dist/pos/index.js +742 -4
  165. package/dist/pos/no-receipt.d.ts +94 -0
  166. package/dist/pos/no-receipt.js +25 -0
  167. package/dist/pos/offline-sales.d.ts +187 -0
  168. package/dist/pos/offline-sales.js +116 -0
  169. package/dist/pos/pay-by-link.d.ts +143 -0
  170. package/dist/pos/pay-by-link.js +57 -0
  171. package/dist/pos/quick-keys.d.ts +103 -0
  172. package/dist/pos/quick-keys.js +45 -0
  173. package/dist/pos/reports.d.ts +360 -0
  174. package/dist/pos/reports.js +62 -0
  175. package/dist/pos/returns.d.ts +217 -0
  176. package/dist/pos/returns.js +53 -0
  177. package/dist/pricing/bulk-coupons.d.ts +139 -0
  178. package/dist/pricing/bulk-coupons.js +112 -0
  179. package/dist/pricing/index.d.ts +174 -4
  180. package/dist/pricing/index.js +174 -1
  181. package/dist/pricing/price-lists.d.ts +604 -0
  182. package/dist/pricing/price-lists.js +600 -0
  183. package/dist/purchasing/alerts.d.ts +89 -0
  184. package/dist/purchasing/alerts.js +62 -0
  185. package/dist/purchasing/cost.d.ts +110 -0
  186. package/dist/purchasing/cost.js +86 -0
  187. package/dist/purchasing/index.d.ts +36 -0
  188. package/dist/purchasing/index.js +16 -0
  189. package/dist/purchasing/purchase-orders.d.ts +548 -0
  190. package/dist/purchasing/purchase-orders.js +491 -0
  191. package/dist/purchasing/replenishment.d.ts +281 -0
  192. package/dist/purchasing/replenishment.js +240 -0
  193. package/dist/purchasing/settings.d.ts +152 -0
  194. package/dist/purchasing/settings.js +181 -0
  195. package/dist/purchasing/suppliers.d.ts +476 -0
  196. package/dist/purchasing/suppliers.js +438 -0
  197. package/dist/quotes/index.d.ts +501 -0
  198. package/dist/quotes/index.js +439 -0
  199. package/dist/reports/index.d.ts +71 -8
  200. package/dist/reports/index.js +74 -11
  201. package/dist/returns/index.d.ts +614 -21
  202. package/dist/returns/index.js +695 -11
  203. package/dist/search/index.d.ts +76 -1
  204. package/dist/search/index.js +63 -0
  205. package/dist/shipping/definitions.d.ts +29 -0
  206. package/dist/shipping/definitions.js +47 -0
  207. package/dist/shipping/fulfillment-profiles.d.ts +174 -0
  208. package/dist/shipping/fulfillment-profiles.js +104 -0
  209. package/dist/shipping/hendriks.d.ts +97 -0
  210. package/dist/shipping/hendriks.js +50 -0
  211. package/dist/shipping/index.d.ts +48 -0
  212. package/dist/shipping/index.js +25 -0
  213. package/dist/shipping/methods.d.ts +198 -0
  214. package/dist/shipping/methods.js +240 -0
  215. package/dist/shipping/myparcel.d.ts +254 -0
  216. package/dist/shipping/myparcel.js +178 -0
  217. package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
  218. package/dist/shipping/parcel-rule.d.ts +6 -5
  219. package/dist/shipping/parcel-rule.js +21 -23
  220. package/dist/shipping/rate-tables.d.ts +179 -0
  221. package/dist/shipping/rate-tables.js +184 -0
  222. package/dist/stock/index.d.ts +10 -3
  223. package/dist/stock/index.js +3 -0
  224. package/dist/stock/locations.d.ts +144 -0
  225. package/dist/stock/locations.js +168 -0
  226. package/dist/stock/transfers.d.ts +216 -43
  227. package/dist/stock/transfers.js +140 -13
  228. package/dist/stored-value/index.d.ts +214 -4
  229. package/dist/stored-value/index.js +152 -0
  230. package/dist/subscriptions/index.d.ts +682 -0
  231. package/dist/subscriptions/index.js +815 -0
  232. package/dist/tax/index.d.ts +76 -1
  233. package/dist/tax/index.js +50 -0
  234. package/dist/tenant/email-style.d.ts +102 -0
  235. package/dist/tenant/email-style.js +72 -0
  236. package/dist/tenant/email-templates.d.ts +66 -0
  237. package/dist/tenant/email-templates.js +54 -0
  238. package/dist/tenant/notifications.d.ts +23 -17
  239. package/dist/tenant/settings-sources.d.ts +1 -1
  240. package/dist/tenant/time-zone.d.ts +17 -0
  241. package/dist/tenant/time-zone.js +11 -0
  242. package/dist/types.d.ts +50 -3
  243. package/dist/users/index.d.ts +3 -0
  244. package/dist/users/index.js +2 -0
  245. package/dist/users/warehouses.d.ts +50 -0
  246. package/dist/users/warehouses.js +51 -0
  247. package/package.json +2 -2
@@ -0,0 +1,103 @@
1
+ import type { Transport } from '@sixtyninecommerce/core';
2
+ import type { Call } from '../types.js';
3
+ /**
4
+ * A store's quick keys (POS sprint 13): the till's favourite-product buttons, on named, coloured
5
+ * pages, one layout per store, shown on every till of the store. The limits and the palette are
6
+ * the engine's (`vendure-plugin-pos` `services/quick-key-layout.ts`), pinned by
7
+ * `pos-quick-keys.spec.ts`.
8
+ */
9
+ /** The quick key palette; anything else is refused `POS_QUICK_KEYS_INVALID`. */
10
+ export declare const POS_QUICK_KEY_COLORS: readonly ["slate", "red", "orange", "amber", "green", "teal", "sky", "blue", "violet", "pink"];
11
+ export type PosQuickKeyColor = (typeof POS_QUICK_KEY_COLORS)[number];
12
+ /** At most 10 pages of at most 40 keys; a page name of 1-20 and a label of up to 30 characters. */
13
+ export declare const POS_QUICK_KEY_LIMITS: {
14
+ readonly pages: 10;
15
+ readonly keysPerPage: 40;
16
+ readonly pageNameLength: 20;
17
+ readonly labelLength: 30;
18
+ };
19
+ /** Whether the till shows a key; only `available` keys are on the till. More may come. */
20
+ export type PosQuickKeyState = 'available' | 'product_disabled' | 'product_gone' | 'variant_disabled' | 'variant_gone' | 'no_sellable_variant' | (string & {});
21
+ export interface PosQuickKey {
22
+ /** Send it back to keep the key, also when it moves to another page. */
23
+ id: string;
24
+ productId: string;
25
+ /** The one variant the key adds; null for a product key (one variant adds, several open the picker). */
26
+ variantId: string | null;
27
+ /** The store's button text; null shows the product's (or the variant's) own name. */
28
+ label: string | null;
29
+ /** A palette colour, or a newer engine's; null for none. */
30
+ color: string | null;
31
+ state: PosQuickKeyState;
32
+ /** The catalogue's name now (the variant's for a variant key); null when it is gone. */
33
+ name: string | null;
34
+ /** The variant's SKU for a variant key; null otherwise. */
35
+ sku: string | null;
36
+ featuredAsset: {
37
+ id: string;
38
+ preview: string;
39
+ } | null;
40
+ }
41
+ export interface PosQuickKeyPage {
42
+ /** Send it back to keep the page. */
43
+ id: string;
44
+ name: string;
45
+ color: string | null;
46
+ keys: PosQuickKey[];
47
+ }
48
+ export interface PosQuickKeyLayout {
49
+ /** Raised by every save that changes the layout; 0 before the first. Send it as `expectedVersion`. */
50
+ version: number;
51
+ /** When a save last changed the layout (ISO-8601); null before the first. */
52
+ updatedAt: string | null;
53
+ pages: PosQuickKeyPage[];
54
+ }
55
+ export interface PosQuickKeyInput {
56
+ /** A stored key's id keeps the key; omit it for a new key. */
57
+ id?: string;
58
+ productId: string;
59
+ /** Pin the key to one variant of the product; omit for the product. */
60
+ variantId?: string | null;
61
+ /** Blank shows the product's (or the variant's) own name. */
62
+ label?: string | null;
63
+ /**
64
+ * A palette colour, or null for none. A colour this SDK does not list is sent as read (sprint
65
+ * 27: a back office keeps an engine colour it does not know); the engine refuses one IT does not
66
+ * know (`POS_QUICK_KEYS_INVALID`, `color_unknown`).
67
+ */
68
+ color?: PosQuickKeyColor | (string & {}) | null;
69
+ }
70
+ export interface PosQuickKeyPageInput {
71
+ /** A stored page's id keeps the page; omit it for a new page. */
72
+ id?: string;
73
+ name: string;
74
+ /**
75
+ * A palette colour, or null for none. A colour this SDK does not list is sent as read (sprint
76
+ * 27: a back office keeps an engine colour it does not know); the engine refuses one IT does not
77
+ * know (`POS_QUICK_KEYS_INVALID`, `color_unknown`).
78
+ */
79
+ color?: PosQuickKeyColor | (string & {}) | null;
80
+ keys: PosQuickKeyInput[];
81
+ }
82
+ export interface SetPosQuickKeyLayoutInput {
83
+ /** The `version` the editor read. */
84
+ expectedVersion: number;
85
+ pages: PosQuickKeyPageInput[];
86
+ }
87
+ /** Read needs UpdateSettings or ManagePosDevices; set needs UpdateSettings. */
88
+ export interface PosQuickKeysModule {
89
+ /** The store's quick keys, every page and key in order, each key's `state` saying whether the till shows it. */
90
+ get(options?: Call): Promise<PosQuickKeyLayout>;
91
+ /**
92
+ * Replace them (the whole layout). Refusals: `POS_QUICK_KEYS_CONFLICT` (`ConflictError`, 409:
93
+ * changed since `expectedVersion`; read again), `POS_QUICK_KEYS_INVALID` (`ValidationError`, 400;
94
+ * `error.details[0].field` is a JSON Pointer into the input), `POS_QUICK_KEYS_PRODUCT_NOT_FOUND`
95
+ * (`NotFoundError`, 404), `POS_QUICK_KEYS_FORMAT_UNSUPPORTED` (`BusinessRuleError`, 422),
96
+ * `ORGANIZATION_WORKSPACE_NOT_A_STORE`. Sending what is stored again is never refused, whatever
97
+ * `expectedVersion` says.
98
+ */
99
+ set(input: SetPosQuickKeyLayoutInput, options?: Call): Promise<PosQuickKeyLayout>;
100
+ }
101
+ export declare const POS_QUICK_KEY_LAYOUT_QUERY = "query PosQuickKeyLayout { posQuickKeyLayout { version updatedAt pages { id name color keys { id productId variantId label color state name sku featuredAsset { id preview } } } } }";
102
+ export declare const SET_POS_QUICK_KEY_LAYOUT_MUTATION = "mutation SetPosQuickKeyLayout($input: SetPosQuickKeyLayoutInput!) { setPosQuickKeyLayout(input: $input) { version updatedAt pages { id name color keys { id productId variantId label color state name sku featuredAsset { id preview } } } } }";
103
+ export declare function createPosQuickKeysModule(transport: Transport): PosQuickKeysModule;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * A store's quick keys (POS sprint 13): the till's favourite-product buttons, on named, coloured
3
+ * pages, one layout per store, shown on every till of the store. The limits and the palette are
4
+ * the engine's (`vendure-plugin-pos` `services/quick-key-layout.ts`), pinned by
5
+ * `pos-quick-keys.spec.ts`.
6
+ */
7
+ /** The quick key palette; anything else is refused `POS_QUICK_KEYS_INVALID`. */
8
+ export const POS_QUICK_KEY_COLORS = [
9
+ 'slate',
10
+ 'red',
11
+ 'orange',
12
+ 'amber',
13
+ 'green',
14
+ 'teal',
15
+ 'sky',
16
+ 'blue',
17
+ 'violet',
18
+ 'pink',
19
+ ];
20
+ /** At most 10 pages of at most 40 keys; a page name of 1-20 and a label of up to 30 characters. */
21
+ export const POS_QUICK_KEY_LIMITS = {
22
+ pages: 10,
23
+ keysPerPage: 40,
24
+ pageNameLength: 20,
25
+ labelLength: 30,
26
+ };
27
+ const LAYOUT_FIELDS = 'version updatedAt pages { id name color keys { id productId variantId label color state name sku featuredAsset { id preview } } }';
28
+ export const POS_QUICK_KEY_LAYOUT_QUERY = `query PosQuickKeyLayout { posQuickKeyLayout { ${LAYOUT_FIELDS} } }`;
29
+ export const SET_POS_QUICK_KEY_LAYOUT_MUTATION = `mutation SetPosQuickKeyLayout($input: SetPosQuickKeyLayoutInput!) { setPosQuickKeyLayout(input: $input) { ${LAYOUT_FIELDS} } }`;
30
+ export function createPosQuickKeysModule(transport) {
31
+ const gql = async (query, variables, options) => transport.graphql({ api: 'admin', query, variables }, options);
32
+ return {
33
+ async get(options) {
34
+ const data = await gql(POS_QUICK_KEY_LAYOUT_QUERY, {}, options);
35
+ return data.posQuickKeyLayout;
36
+ },
37
+ async set(input, options) {
38
+ if (!Number.isInteger(input.expectedVersion) || input.expectedVersion < 0) {
39
+ throw new TypeError('quickKeys.set needs expectedVersion: the whole-number version the layout was read at (0 before the first save).');
40
+ }
41
+ const data = await gql(SET_POS_QUICK_KEY_LAYOUT_MUTATION, { input }, options);
42
+ return data.setPosQuickKeyLayout;
43
+ },
44
+ };
45
+ }
@@ -0,0 +1,360 @@
1
+ import { type Page, type Transport } from '@sixtyninecommerce/core';
2
+ import type { Call, ListOptions } from '../types.js';
3
+ /**
4
+ * The back office's POS reports (engine sprint 28): every figure computed by the engine from the
5
+ * drawers' records, never summed by the caller. One read, `posReport(input)`, whose sections are
6
+ * fields; each method here selects ONE section (plus the report's header), so a page reads only
7
+ * what it shows.
8
+ *
9
+ * - Days are BUSINESS days: the label each drawer was stamped with when it opened, in its
10
+ * location's zone (a bar's 01:30 sale is the day before's). `fromDay`/`toDay` are inclusive
11
+ * `YYYY-MM-DD`, both today in the store's zone when omitted, at most 31 days apart.
12
+ * - Every day reconciles to its Z reports: `net = inZ + notInZ + unexplained + live −
13
+ * refundsAfterClose` (`PosReportZCheck`). A card refund made after its sale's drawer closed is
14
+ * in no Z: it counts on the day it was made. Open drawers are in, live (`openDrawerCount`).
15
+ * - A sale is credited to the cashier who completed it; who rang each line is not recorded.
16
+ * - Money is integer minor units of the drawer currency (the store's default); a sale in another
17
+ * currency is in no figure (`otherCurrencySaleCount`). Exchange credit and returns without a
18
+ * receipt are memos, never money.
19
+ *
20
+ * Needs `UpdateSettings` or `ManagePosDevices`; a location-restricted caller names one of its
21
+ * locations (`LOCATION_NOT_ALLOWED`). Refused `POS_LIST_RANGE_INVALID` (`extensions.reason`),
22
+ * `POS_REGISTER_NOT_FOUND`, `POS_REPORT_TIMED_OUT` (narrow the days or pick a location). Each
23
+ * method is its own document: an engine before 28 refuses it at validation, nothing else.
24
+ */
25
+ export interface PosReportInput {
26
+ fromDay?: string;
27
+ toDay?: string;
28
+ /** One stock location; every location of the store when omitted. */
29
+ stockLocationId?: string;
30
+ /** One register (standing at `stockLocationId` when both are given). */
31
+ registerId?: string;
32
+ }
33
+ /** What every section answers beside it: the window and the drawers it covers. */
34
+ export interface PosReportHeader {
35
+ fromDay: string;
36
+ toDay: string;
37
+ currencyCode: string;
38
+ stockLocationId: string | null;
39
+ registerId: string | null;
40
+ generatedAt: string;
41
+ drawerCount: number;
42
+ /** Drawers still open: their figures can still change. */
43
+ openDrawerCount: number;
44
+ /** Completed sales in another currency than the drawer's: in no figure. */
45
+ otherCurrencySaleCount: number;
46
+ }
47
+ export interface PosReportFigures {
48
+ saleCount: number;
49
+ itemCount: number;
50
+ salesTotal: number;
51
+ cash: number;
52
+ card: number;
53
+ other: number;
54
+ cashRefunds: number;
55
+ cardRefunds: number;
56
+ otherRefunds: number;
57
+ /** Card and other refunds made after their sale's drawer had closed (in no Z). */
58
+ refundsAfterClose: number;
59
+ net: number;
60
+ /** Signed; never part of `net`. */
61
+ cashRounding: number;
62
+ /** Not money: never in a tender or in `net`. */
63
+ exchangeCredit: number;
64
+ /** Returns without a receipt, both payouts; their cash is also in `cashRefunds`. */
65
+ noReceiptReturns: number;
66
+ /** Of which gift cards sold: a memo already inside cash, card and other; never taken off net. */
67
+ giftCardsSold: number;
68
+ giftCardsSoldCount: number;
69
+ /** Store credit issued on returns instead of a refund: a memo, in no refund and not in net. */
70
+ storeCreditIssued: number;
71
+ storeCreditIssuedCount: number;
72
+ }
73
+ export interface PosReportZCheck {
74
+ inZ: number;
75
+ notInZ: number;
76
+ live: number;
77
+ refundsAfterClose: number;
78
+ /** 0 unless a closed drawer's cash changed. */
79
+ unexplained: number;
80
+ recomputedZCount: number;
81
+ }
82
+ export interface PosReportDay {
83
+ businessDay: string;
84
+ drawerCount: number;
85
+ openDrawerCount: number;
86
+ uncountedDrawerCount: number;
87
+ figures: PosReportFigures;
88
+ zCheck: PosReportZCheck;
89
+ /** With one location: `open`, `closed` or `reopened` (more may come); null otherwise. */
90
+ storeDayStatus: string | null;
91
+ storeDayMismatch: boolean;
92
+ }
93
+ export interface PosReportReconciliation {
94
+ salesTotal: number;
95
+ paymentsBySale: number;
96
+ uncompletedCartPayments: number;
97
+ cashElsewhere: number;
98
+ }
99
+ export interface PosReportSummary extends PosReportHeader {
100
+ totals: PosReportFigures;
101
+ totalsCheck: PosReportZCheck;
102
+ days: PosReportDay[];
103
+ reconciliation: PosReportReconciliation;
104
+ }
105
+ export interface PosReportTenderRow {
106
+ /** `cash`, `card` or `other`. */
107
+ kind: string;
108
+ method: string;
109
+ methodName: string;
110
+ /** The store's stored-value method: part of other. */
111
+ storedValue: boolean;
112
+ paymentCount: number;
113
+ payments: number;
114
+ refunds: number;
115
+ refundsAfterClose: number;
116
+ net: number;
117
+ }
118
+ export interface PosReportDrawer {
119
+ openingFloats: number;
120
+ cashSales: number;
121
+ cashRefunds: number;
122
+ cashRounding: number;
123
+ paidIn: number;
124
+ paidOut: number;
125
+ safeDrops: number;
126
+ floatAdjustments: number;
127
+ noSaleCount: number;
128
+ expectedCash: number;
129
+ countedDrawerCount: number;
130
+ countedCash: number;
131
+ variance: number;
132
+ uncountedDrawerCount: number;
133
+ pendingApprovalCount: number;
134
+ }
135
+ export interface PosReportTenders extends PosReportHeader {
136
+ tenders: {
137
+ rows: PosReportTenderRow[];
138
+ drawer: PosReportDrawer;
139
+ };
140
+ }
141
+ export interface PosReportRegister {
142
+ registerId: string;
143
+ registerName: string | null;
144
+ drawerCount: number;
145
+ openDrawerCount: number;
146
+ uncountedDrawerCount: number;
147
+ figures: PosReportFigures;
148
+ variance: number;
149
+ }
150
+ export interface PosReportLocation {
151
+ stockLocationId: string | null;
152
+ name: string | null;
153
+ figures: PosReportFigures;
154
+ variance: number;
155
+ registers: PosReportRegister[];
156
+ }
157
+ export interface PosReportLocations extends PosReportHeader {
158
+ locations: PosReportLocation[];
159
+ }
160
+ export interface PosReportHour {
161
+ /** 0-23 in each drawer's own time zone. */
162
+ hour: number;
163
+ saleCount: number;
164
+ itemCount: number;
165
+ salesTotal: number;
166
+ }
167
+ export interface PosReportHours extends PosReportHeader {
168
+ hours: PosReportHour[];
169
+ }
170
+ export interface PosReportCashier extends PosReportCashierActivity {
171
+ staffId: string | null;
172
+ name: string | null;
173
+ /** A connected system's own reference for the person, as it gave it. */
174
+ externalRef: string | null;
175
+ saleCount: number;
176
+ itemCount: number;
177
+ salesTotal: number;
178
+ cashRefundCount: number;
179
+ cashRefunds: number;
180
+ }
181
+ export interface PosReportCashiers extends PosReportHeader {
182
+ cashiers: {
183
+ rows: PosReportCashier[];
184
+ refundsNotAttributed: number;
185
+ };
186
+ }
187
+ export interface PosReportCashierActivity {
188
+ /** Returns, voids and exchanges processed (returns without a receipt included). */
189
+ returnCount: number;
190
+ returnGross: number;
191
+ /** Returns approved as the manager. */
192
+ returnApprovalCount: number;
193
+ /** Till discounts the store's discount log names this staff member for. */
194
+ tillDiscountCount: number;
195
+ tillDiscountGross: number;
196
+ }
197
+ /** How a product page is sorted, each descending. */
198
+ export type PosReportProductSort = 'NET_GROSS' | 'QUANTITY' | 'RETURNED';
199
+ export interface PosReportProductOptions extends ListOptions {
200
+ sort?: PosReportProductSort;
201
+ }
202
+ export interface PosReportProduct {
203
+ productVariantId: string;
204
+ productId: string | null;
205
+ /** "Custom items" for the custom item carrier. */
206
+ name: string;
207
+ sku: string | null;
208
+ customItems: boolean;
209
+ soldQuantity: number;
210
+ returnedQuantity: number;
211
+ netQuantity: number;
212
+ listGross: number;
213
+ /** Promotions, coupons and till discounts on the sold lines. */
214
+ discounts: number;
215
+ salesGross: number;
216
+ returnedGross: number;
217
+ netGross: number;
218
+ netOfTax: number;
219
+ tax: number;
220
+ }
221
+ export interface PosReportProductTotals {
222
+ soldQuantity: number;
223
+ returnedQuantity: number;
224
+ listGross: number;
225
+ discounts: number;
226
+ salesGross: number;
227
+ returnedGross: number;
228
+ netGross: number;
229
+ netOfTax: number;
230
+ tax: number;
231
+ }
232
+ /** A page of product rows, with the report's header and the totals over every row. */
233
+ export interface PosReportProductsPage extends Page<PosReportProduct> {
234
+ report: PosReportHeader;
235
+ totals: PosReportProductTotals;
236
+ }
237
+ export interface PosReportTaxRow {
238
+ description: string;
239
+ taxRate: number;
240
+ pricesIncludeTax: boolean | null;
241
+ salesGross: number;
242
+ salesNet: number;
243
+ salesTax: number;
244
+ returnsGross: number;
245
+ returnsNet: number;
246
+ returnsTax: number;
247
+ /** Money-only refunds, apportioned over the refunded sale's rates. */
248
+ apportionedRefundsGross: number;
249
+ apportionedRefundsNet: number;
250
+ apportionedRefundsTax: number;
251
+ netGross: number;
252
+ netNet: number;
253
+ /** The tax to file: Σ per receipt. */
254
+ netTax: number;
255
+ taxOnTotal: number | null;
256
+ rounding: number | null;
257
+ }
258
+ export interface PosReportTax extends PosReportHeader {
259
+ tax: {
260
+ rows: PosReportTaxRow[];
261
+ days: Array<{
262
+ businessDay: string;
263
+ rows: PosReportTaxRow[];
264
+ }>;
265
+ lineAllocationRounding: number;
266
+ };
267
+ }
268
+ export interface PosReportReturns extends PosReportHeader {
269
+ returns: {
270
+ /** False: the store keeps no returns record (only returns without a receipt count). */
271
+ available: boolean;
272
+ /** `return`, `void`, `exchange`, `back_office`, `no_receipt`; more may come. */
273
+ kinds: Array<{
274
+ kind: string;
275
+ returnCount: number;
276
+ gross: number;
277
+ }>;
278
+ reasons: Array<{
279
+ reasonCode: string;
280
+ lineCount: number;
281
+ quantity: number;
282
+ gross: number;
283
+ }>;
284
+ restockedQuantity: number;
285
+ writtenOffQuantity: number;
286
+ gross: number;
287
+ awaitingSettlementCount: number;
288
+ awaitingSettlementGross: number;
289
+ noReceiptCount: number;
290
+ noReceiptGross: number;
291
+ noReceiptCashGross: number;
292
+ noReceiptStoreCreditGross: number;
293
+ };
294
+ }
295
+ export interface PosReportDiscounts extends PosReportHeader {
296
+ discounts: {
297
+ tillGross: number;
298
+ tillNet: number;
299
+ tillSaleCount: number;
300
+ /** False: the store keeps no discount log. */
301
+ reasonsAvailable: boolean;
302
+ reasons: Array<{
303
+ reasonCode: string | null;
304
+ reasonName: string | null;
305
+ count: number;
306
+ gross: number;
307
+ net: number;
308
+ }>;
309
+ /** Till discounts no log row names. */
310
+ notLoggedGross: number;
311
+ promotions: Array<{
312
+ description: string;
313
+ lineCount: number;
314
+ gross: number;
315
+ net: number;
316
+ }>;
317
+ promotionsGross: number;
318
+ };
319
+ }
320
+ export interface PosReportsModule {
321
+ /** By business day, reconciled to the Zs, with the range's totals and reconciliation. */
322
+ summary(input?: PosReportInput, options?: Call): Promise<PosReportSummary>;
323
+ /** By tender (each payment method), and the drawers' cash. */
324
+ tenders(input?: PosReportInput, options?: Call): Promise<PosReportTenders>;
325
+ /** By location, each register under it. */
326
+ locations(input?: PosReportInput, options?: Call): Promise<PosReportLocations>;
327
+ /** 24 rows, each drawer's sales in its own zone's hour. */
328
+ hours(input?: PosReportInput, options?: Call): Promise<PosReportHours>;
329
+ /** By the cashier who completed each sale. */
330
+ cashiers(input?: PosReportInput, options?: Call): Promise<PosReportCashiers>;
331
+ /**
332
+ * By product and variant, returns netted, a page at a time (`limit` 1-200, 50 by default;
333
+ * `after` an offset cursor), with the totals over every row. `POS_REPORT_TOO_LARGE` above
334
+ * 250,000 sold lines: choose fewer days or one location.
335
+ */
336
+ products(input?: PosReportInput, options?: PosReportProductOptions): Promise<PosReportProductsPage>;
337
+ /** By tax rate, per business day and for the window (`POS_REPORT_TOO_LARGE` as products). */
338
+ tax(input?: PosReportInput, options?: Call): Promise<PosReportTax>;
339
+ /** Returns and voids, returns without a receipt. */
340
+ returns(input?: PosReportInput, options?: Call): Promise<PosReportReturns>;
341
+ /** Till discounts by reason, promotions by description (`POS_REPORT_TOO_LARGE` as products). */
342
+ discounts(input?: PosReportInput, options?: Call): Promise<PosReportDiscounts>;
343
+ }
344
+ export declare const POS_REPORT_FIGURES_FIELDS = "saleCount itemCount salesTotal cash card other cashRefunds cardRefunds otherRefunds refundsAfterClose net cashRounding exchangeCredit noReceiptReturns giftCardsSold giftCardsSoldCount storeCreditIssued storeCreditIssuedCount";
345
+ export declare const POS_REPORT_SUMMARY_QUERY: string;
346
+ export declare const POS_REPORT_TENDERS_QUERY: string;
347
+ export declare const POS_REPORT_LOCATIONS_QUERY: string;
348
+ export declare const POS_REPORT_HOURS_QUERY: string;
349
+ export declare const POS_REPORT_CASHIERS_QUERY: string;
350
+ export declare const POS_REPORT_PRODUCTS_QUERY = "query PosReportProducts($input: PosReportInput, $products: PosReportProductsInput) { posReport(input: $input) { fromDay toDay currencyCode stockLocationId registerId generatedAt drawerCount openDrawerCount otherCurrencySaleCount products(input: $products) { items { productVariantId productId name sku customItems netQuantity soldQuantity returnedQuantity listGross discounts salesGross returnedGross netGross netOfTax tax } totalItems totals { soldQuantity returnedQuantity listGross discounts salesGross returnedGross netGross netOfTax tax } } } }";
351
+ export declare const POS_REPORT_TAX_QUERY: string;
352
+ export declare const POS_REPORT_RETURNS_QUERY: string;
353
+ export declare const POS_REPORT_DISCOUNTS_QUERY: string;
354
+ /** A product page: at most this many rows. */
355
+ export declare const POS_REPORT_PRODUCTS_MAX_PAGE = 200;
356
+ /** ... and this many when `limit` is omitted. */
357
+ export declare const POS_REPORT_PRODUCTS_DEFAULT_PAGE = 50;
358
+ /** `{ input }` when there is one, else nothing: the engine's defaults apply to an absent input. */
359
+ export declare function reportVariables(input: PosReportInput | undefined): Record<string, unknown>;
360
+ export declare function createPosReportsModule(transport: Transport): PosReportsModule;
@@ -0,0 +1,62 @@
1
+ import { pageFromVendureList, readOffsetCursor, } from '@sixtyninecommerce/core';
2
+ const HEADER = 'fromDay toDay currencyCode stockLocationId registerId generatedAt drawerCount openDrawerCount otherCurrencySaleCount';
3
+ export const POS_REPORT_FIGURES_FIELDS = 'saleCount itemCount salesTotal cash card other cashRefunds cardRefunds otherRefunds refundsAfterClose net cashRounding exchangeCredit noReceiptReturns giftCardsSold giftCardsSoldCount storeCreditIssued storeCreditIssuedCount';
4
+ const ZCHECK = 'inZ notInZ live refundsAfterClose unexplained recomputedZCount';
5
+ function reportQuery(name, section) {
6
+ return `query ${name}($input: PosReportInput) { posReport(input: $input) { ${HEADER} ${section} } }`;
7
+ }
8
+ export const POS_REPORT_SUMMARY_QUERY = reportQuery('PosReportSummary', `totals { ${POS_REPORT_FIGURES_FIELDS} } totalsCheck { ${ZCHECK} } days { businessDay drawerCount openDrawerCount uncountedDrawerCount figures { ${POS_REPORT_FIGURES_FIELDS} } zCheck { ${ZCHECK} } storeDayStatus storeDayMismatch } reconciliation { salesTotal paymentsBySale uncompletedCartPayments cashElsewhere }`);
9
+ export const POS_REPORT_TENDERS_QUERY = reportQuery('PosReportTenders', 'tenders { rows { kind method methodName storedValue paymentCount payments refunds refundsAfterClose net } drawer { openingFloats cashSales cashRefunds cashRounding paidIn paidOut safeDrops floatAdjustments noSaleCount expectedCash countedDrawerCount countedCash variance uncountedDrawerCount pendingApprovalCount } }');
10
+ export const POS_REPORT_LOCATIONS_QUERY = reportQuery('PosReportLocations', `locations { stockLocationId name figures { ${POS_REPORT_FIGURES_FIELDS} } variance registers { registerId registerName drawerCount openDrawerCount uncountedDrawerCount figures { ${POS_REPORT_FIGURES_FIELDS} } variance } }`);
11
+ export const POS_REPORT_HOURS_QUERY = reportQuery('PosReportHours', 'hours { hour saleCount itemCount salesTotal }');
12
+ export const POS_REPORT_CASHIERS_QUERY = reportQuery('PosReportCashiers', 'cashiers { rows { staffId name externalRef saleCount itemCount salesTotal cashRefundCount cashRefunds returnCount returnGross returnApprovalCount tillDiscountCount tillDiscountGross } refundsNotAttributed }');
13
+ const PRODUCT_FIGURES = 'soldQuantity returnedQuantity listGross discounts salesGross returnedGross netGross netOfTax tax';
14
+ export const POS_REPORT_PRODUCTS_QUERY = `query PosReportProducts($input: PosReportInput, $products: PosReportProductsInput) { posReport(input: $input) { ${HEADER} products(input: $products) { items { productVariantId productId name sku customItems netQuantity ${PRODUCT_FIGURES} } totalItems totals { ${PRODUCT_FIGURES} } } } }`;
15
+ const TAX_ROW = 'description taxRate pricesIncludeTax salesGross salesNet salesTax returnsGross returnsNet returnsTax apportionedRefundsGross apportionedRefundsNet apportionedRefundsTax netGross netNet netTax taxOnTotal rounding';
16
+ export const POS_REPORT_TAX_QUERY = reportQuery('PosReportTax', `tax { rows { ${TAX_ROW} } days { businessDay rows { ${TAX_ROW} } } lineAllocationRounding }`);
17
+ export const POS_REPORT_RETURNS_QUERY = reportQuery('PosReportReturns', 'returns { available kinds { kind returnCount gross } reasons { reasonCode lineCount quantity gross } restockedQuantity writtenOffQuantity gross awaitingSettlementCount awaitingSettlementGross noReceiptCount noReceiptGross noReceiptCashGross noReceiptStoreCreditGross }');
18
+ export const POS_REPORT_DISCOUNTS_QUERY = reportQuery('PosReportDiscounts', 'discounts { tillGross tillNet tillSaleCount reasonsAvailable reasons { reasonCode reasonName count gross net } notLoggedGross promotions { description lineCount gross net } promotionsGross }');
19
+ /** A product page: at most this many rows. */
20
+ export const POS_REPORT_PRODUCTS_MAX_PAGE = 200;
21
+ /** ... and this many when `limit` is omitted. */
22
+ export const POS_REPORT_PRODUCTS_DEFAULT_PAGE = 50;
23
+ /** `{ input }` when there is one, else nothing: the engine's defaults apply to an absent input. */
24
+ export function reportVariables(input) {
25
+ if (!input)
26
+ return {};
27
+ const sent = Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined && value !== ''));
28
+ return Object.keys(sent).length === 0 ? {} : { input: sent };
29
+ }
30
+ export function createPosReportsModule(transport) {
31
+ const read = async (query, input, options) => {
32
+ const data = await transport.graphql({ api: 'admin', query, variables: reportVariables(input) }, options);
33
+ return data.posReport;
34
+ };
35
+ return {
36
+ summary: (input, options) => read(POS_REPORT_SUMMARY_QUERY, input, options),
37
+ tenders: (input, options) => read(POS_REPORT_TENDERS_QUERY, input, options),
38
+ locations: (input, options) => read(POS_REPORT_LOCATIONS_QUERY, input, options),
39
+ hours: (input, options) => read(POS_REPORT_HOURS_QUERY, input, options),
40
+ cashiers: (input, options) => read(POS_REPORT_CASHIERS_QUERY, input, options),
41
+ tax: (input, options) => read(POS_REPORT_TAX_QUERY, input, options),
42
+ returns: (input, options) => read(POS_REPORT_RETURNS_QUERY, input, options),
43
+ discounts: (input, options) => read(POS_REPORT_DISCOUNTS_QUERY, input, options),
44
+ products: (input, options) => {
45
+ const take = Math.min(Math.max(Math.trunc(options?.limit ?? POS_REPORT_PRODUCTS_DEFAULT_PAGE), 1), POS_REPORT_PRODUCTS_MAX_PAGE);
46
+ const page = async (skip) => {
47
+ const data = await transport.graphql({
48
+ api: 'admin',
49
+ query: POS_REPORT_PRODUCTS_QUERY,
50
+ variables: {
51
+ ...reportVariables(input),
52
+ products: { skip, take, ...(options?.sort ? { sort: options.sort } : {}) },
53
+ },
54
+ }, options);
55
+ const { products, ...report } = data.posReport;
56
+ const listed = pageFromVendureList(products, skip, take, (cursor) => page(readOffsetCursor(cursor)));
57
+ return Object.assign(listed, { report, totals: products.totals });
58
+ };
59
+ return page(options?.after === undefined ? 0 : readOffsetCursor(options.after));
60
+ },
61
+ };
62
+ }