@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.
- package/README.md +5772 -118
- package/dist/auth/index.d.ts +7 -1
- package/dist/auth/index.js +8 -1
- package/dist/catalog/assets.d.ts +120 -8
- package/dist/catalog/assets.js +98 -12
- package/dist/catalog/collections.d.ts +279 -14
- package/dist/catalog/collections.js +246 -15
- package/dist/catalog/documents.d.ts +142 -0
- package/dist/catalog/documents.js +114 -0
- package/dist/catalog/index.d.ts +54 -6
- package/dist/catalog/index.js +10 -1
- package/dist/catalog/metadata.d.ts +244 -0
- package/dist/catalog/metadata.js +220 -0
- package/dist/catalog/products.d.ts +159 -19
- package/dist/catalog/products.js +88 -13
- package/dist/catalog/properties.d.ts +140 -14
- package/dist/catalog/properties.js +65 -1
- package/dist/catalog/recommendations.d.ts +288 -0
- package/dist/catalog/recommendations.js +237 -0
- package/dist/catalog/reviews.d.ts +381 -0
- package/dist/catalog/reviews.js +325 -0
- package/dist/catalog/types.d.ts +17 -1
- package/dist/catalog/types.js +10 -0
- package/dist/catalog/variant-find.d.ts +136 -0
- package/dist/catalog/variant-find.js +239 -0
- package/dist/catalog/variants.d.ts +293 -26
- package/dist/catalog/variants.js +164 -7
- package/dist/catalog/visibility.d.ts +38 -7
- package/dist/catalog/visibility.js +19 -1
- package/dist/client.d.ts +121 -9
- package/dist/client.js +53 -14
- package/dist/content/assets.d.ts +285 -0
- package/dist/content/assets.js +181 -0
- package/dist/content/forms.d.ts +332 -1
- package/dist/content/forms.js +140 -4
- package/dist/content/items.d.ts +292 -0
- package/dist/content/items.js +170 -0
- package/dist/content/menus.d.ts +254 -0
- package/dist/content/menus.js +70 -0
- package/dist/content/strings.d.ts +137 -0
- package/dist/content/strings.js +82 -0
- package/dist/content/types.d.ts +282 -0
- package/dist/content/types.js +100 -0
- package/dist/customers/age-verification.d.ts +66 -0
- package/dist/customers/age-verification.js +79 -0
- package/dist/customers/credit.d.ts +263 -0
- package/dist/customers/credit.js +244 -0
- package/dist/customers/delivery-preferences.d.ts +120 -0
- package/dist/customers/delivery-preferences.js +97 -0
- package/dist/customers/delivery-terms.d.ts +44 -0
- package/dist/customers/delivery-terms.js +32 -0
- package/dist/customers/groups.d.ts +207 -0
- package/dist/customers/groups.js +438 -0
- package/dist/customers/index.d.ts +462 -37
- package/dist/customers/index.js +317 -40
- package/dist/customers/invitation-status.d.ts +57 -0
- package/dist/customers/invitation-status.js +21 -0
- package/dist/customers/notes.d.ts +67 -0
- package/dist/customers/notes.js +51 -0
- package/dist/customers/notification-recipients.d.ts +97 -0
- package/dist/customers/notification-recipients.js +84 -0
- package/dist/customers/saved-lists.d.ts +42 -0
- package/dist/customers/saved-lists.js +61 -0
- package/dist/customers/vat.d.ts +83 -0
- package/dist/customers/vat.js +46 -0
- package/dist/customers/wire.d.ts +20 -0
- package/dist/customers/wire.js +35 -0
- package/dist/documents/ar.d.ts +307 -0
- package/dist/documents/ar.js +254 -0
- package/dist/documents/emails.d.ts +150 -0
- package/dist/documents/emails.js +220 -0
- package/dist/documents/index.d.ts +744 -21
- package/dist/documents/index.js +438 -24
- package/dist/documents/pdf.d.ts +2 -0
- package/dist/documents/pdf.js +11 -0
- package/dist/fulfillments/create.d.ts +167 -0
- package/dist/fulfillments/create.js +216 -0
- package/dist/fulfillments/index.d.ts +163 -11
- package/dist/fulfillments/index.js +135 -6
- package/dist/fulfillments/payment-policy.d.ts +64 -0
- package/dist/fulfillments/payment-policy.js +140 -0
- package/dist/fulfillments/warehouse.d.ts +724 -0
- package/dist/fulfillments/warehouse.js +914 -0
- package/dist/geo/index.d.ts +119 -0
- package/dist/geo/index.js +107 -0
- package/dist/index.d.ts +147 -39
- package/dist/index.js +51 -12
- package/dist/integrations/afas-actions.d.ts +234 -0
- package/dist/integrations/afas-actions.js +310 -0
- package/dist/integrations/afas-types.d.ts +483 -0
- package/dist/integrations/afas-types.js +5 -0
- package/dist/integrations/afas.d.ts +234 -0
- package/dist/integrations/afas.js +290 -0
- package/dist/integrations/connections.d.ts +103 -0
- package/dist/integrations/connections.js +55 -0
- package/dist/integrations/esp.d.ts +313 -0
- package/dist/integrations/esp.js +169 -0
- package/dist/integrations/exact-online-types.d.ts +965 -0
- package/dist/integrations/exact-online-types.js +6 -0
- package/dist/integrations/exact-online.d.ts +784 -0
- package/dist/integrations/exact-online.js +1089 -0
- package/dist/integrations/index.d.ts +44 -3
- package/dist/integrations/index.js +23 -3
- package/dist/integrations/pipeline-discoveries.d.ts +65 -0
- package/dist/integrations/pipeline-discoveries.js +65 -0
- package/dist/integrations/pipeline-keys.d.ts +13 -0
- package/dist/integrations/pipeline-keys.js +22 -0
- package/dist/integrations/pipeline-runs.d.ts +119 -0
- package/dist/integrations/pipeline-runs.js +87 -0
- package/dist/integrations/pipelines.d.ts +87 -15
- package/dist/integrations/pipelines.js +41 -22
- package/dist/integrations/price-import.d.ts +223 -0
- package/dist/integrations/price-import.js +124 -0
- package/dist/integrations/types.d.ts +367 -3
- package/dist/integrations/types.js +4 -3
- package/dist/locations/index.d.ts +66 -0
- package/dist/locations/index.js +31 -0
- package/dist/meta/index.d.ts +172 -0
- package/dist/metafields/index.d.ts +8 -1
- package/dist/metafields/index.js +10 -0
- package/dist/orders/cancel-with-money.d.ts +237 -0
- package/dist/orders/cancel-with-money.js +155 -0
- package/dist/orders/commit-edit.d.ts +23 -1
- package/dist/orders/commit-edit.js +19 -2
- package/dist/orders/deposit-policy.d.ts +3 -1
- package/dist/orders/drafts.d.ts +800 -0
- package/dist/orders/drafts.js +771 -0
- package/dist/orders/fields.d.ts +245 -0
- package/dist/orders/fields.js +188 -0
- package/dist/orders/get.d.ts +29 -19
- package/dist/orders/get.js +17 -8
- package/dist/orders/index.d.ts +66 -15
- package/dist/orders/index.js +25 -2
- package/dist/orders/lifecycle.d.ts +128 -0
- package/dist/orders/lifecycle.js +158 -0
- package/dist/orders/line-price-preview.d.ts +7 -2
- package/dist/orders/list.d.ts +243 -0
- package/dist/orders/list.js +487 -0
- package/dist/orders/manual-discounts.d.ts +13 -5
- package/dist/orders/manual-pricing.d.ts +5 -0
- package/dist/orders/money-view.d.ts +149 -0
- package/dist/orders/money-view.js +99 -0
- package/dist/orders/order-entry.d.ts +20 -7
- package/dist/orders/plan-edit.d.ts +34 -2
- package/dist/orders/plan-edit.js +112 -11
- package/dist/orders/settings.d.ts +201 -0
- package/dist/orders/settings.js +325 -0
- package/dist/orders/status.d.ts +159 -13
- package/dist/orders/status.js +21 -0
- package/dist/orders/surcharges.d.ts +20 -1
- package/dist/orders/surcharges.js +37 -11
- package/dist/payments/account-credit.d.ts +46 -0
- package/dist/payments/account-credit.js +42 -0
- package/dist/payments/ar.d.ts +292 -0
- package/dist/payments/ar.js +223 -0
- package/dist/payments/connected-account.d.ts +47 -0
- package/dist/payments/connected-account.js +61 -0
- package/dist/payments/credit-noted-fields.d.ts +19 -0
- package/dist/payments/credit-noted-fields.js +69 -0
- package/dist/payments/customer-consent.d.ts +30 -0
- package/dist/payments/customer-consent.js +49 -0
- package/dist/payments/index.d.ts +340 -19
- package/dist/payments/index.js +151 -1
- package/dist/payments/methods.d.ts +303 -8
- package/dist/payments/methods.js +337 -7
- package/dist/payments/mollie-methods.d.ts +159 -0
- package/dist/payments/mollie-methods.js +141 -0
- package/dist/payments/payment-links.d.ts +180 -0
- package/dist/payments/payment-links.js +97 -0
- package/dist/payments/provider-keys.d.ts +150 -0
- package/dist/payments/provider-keys.js +118 -0
- package/dist/payments/providers.d.ts +86 -11
- package/dist/payments/providers.js +29 -0
- package/dist/payments/requests.d.ts +147 -0
- package/dist/payments/requests.js +93 -0
- package/dist/payments/store-credit-fields.d.ts +15 -0
- package/dist/payments/store-credit-fields.js +51 -0
- package/dist/pickups/index.d.ts +106 -0
- package/dist/pickups/index.js +108 -0
- package/dist/platform/channels.d.ts +132 -0
- package/dist/platform/channels.js +128 -0
- package/dist/platform/email-gateways.d.ts +165 -0
- package/dist/platform/email-gateways.js +78 -0
- package/dist/platform/geo.d.ts +123 -0
- package/dist/platform/geo.js +144 -0
- package/dist/platform/tax.d.ts +162 -0
- package/dist/platform/tax.js +169 -0
- package/dist/pos/anomalies.d.ts +158 -0
- package/dist/pos/anomalies.js +64 -0
- package/dist/pos/assisted-selling.d.ts +79 -0
- package/dist/pos/assisted-selling.js +38 -0
- package/dist/pos/exchanges.d.ts +108 -0
- package/dist/pos/exchanges.js +22 -0
- package/dist/pos/gift-cards.d.ts +135 -0
- package/dist/pos/gift-cards.js +47 -0
- package/dist/pos/index.d.ts +2370 -58
- package/dist/pos/index.js +854 -7
- package/dist/pos/no-receipt.d.ts +94 -0
- package/dist/pos/no-receipt.js +25 -0
- package/dist/pos/offline-sales.d.ts +228 -0
- package/dist/pos/offline-sales.js +170 -0
- package/dist/pos/pay-by-link.d.ts +143 -0
- package/dist/pos/pay-by-link.js +57 -0
- package/dist/pos/quick-keys.d.ts +103 -0
- package/dist/pos/quick-keys.js +45 -0
- package/dist/pos/reports.d.ts +360 -0
- package/dist/pos/reports.js +62 -0
- package/dist/pos/returns.d.ts +244 -0
- package/dist/pos/returns.js +83 -0
- package/dist/pricing/bulk-coupons.d.ts +139 -0
- package/dist/pricing/bulk-coupons.js +112 -0
- package/dist/pricing/index.d.ts +174 -4
- package/dist/pricing/index.js +174 -1
- package/dist/pricing/price-lists.d.ts +606 -0
- package/dist/pricing/price-lists.js +600 -0
- package/dist/purchasing/alerts.d.ts +104 -0
- package/dist/purchasing/alerts.js +88 -0
- package/dist/purchasing/backorders.d.ts +61 -0
- package/dist/purchasing/backorders.js +92 -0
- package/dist/purchasing/cost.d.ts +110 -0
- package/dist/purchasing/cost.js +86 -0
- package/dist/purchasing/index.d.ts +54 -0
- package/dist/purchasing/index.js +24 -0
- package/dist/purchasing/links.d.ts +263 -0
- package/dist/purchasing/links.js +192 -0
- package/dist/purchasing/purchase-orders.d.ts +551 -0
- package/dist/purchasing/purchase-orders.js +491 -0
- package/dist/purchasing/receipts.d.ts +396 -0
- package/dist/purchasing/receipts.js +287 -0
- package/dist/purchasing/replenishment.d.ts +281 -0
- package/dist/purchasing/replenishment.js +240 -0
- package/dist/purchasing/returns.d.ts +273 -0
- package/dist/purchasing/returns.js +229 -0
- package/dist/purchasing/settings.d.ts +152 -0
- package/dist/purchasing/settings.js +181 -0
- package/dist/purchasing/suppliers.d.ts +476 -0
- package/dist/purchasing/suppliers.js +438 -0
- package/dist/quotes/index.d.ts +518 -0
- package/dist/quotes/index.js +439 -0
- package/dist/reports/index.d.ts +71 -8
- package/dist/reports/index.js +74 -11
- package/dist/returns/index.d.ts +675 -21
- package/dist/returns/index.js +756 -11
- package/dist/search/index.d.ts +76 -1
- package/dist/search/index.js +63 -0
- package/dist/seo/config.d.ts +128 -0
- package/dist/seo/config.js +95 -0
- package/dist/seo/redirects.d.ts +125 -0
- package/dist/seo/redirects.js +60 -1
- package/dist/seo/settings.d.ts +147 -0
- package/dist/seo/settings.js +209 -0
- package/dist/shipping/definitions.d.ts +29 -0
- package/dist/shipping/definitions.js +47 -0
- package/dist/shipping/fulfillment-profiles.d.ts +174 -0
- package/dist/shipping/fulfillment-profiles.js +104 -0
- package/dist/shipping/hendriks.d.ts +97 -0
- package/dist/shipping/hendriks.js +50 -0
- package/dist/shipping/index.d.ts +54 -0
- package/dist/shipping/index.js +27 -0
- package/dist/shipping/methods.d.ts +205 -0
- package/dist/shipping/methods.js +240 -0
- package/dist/shipping/myparcel.d.ts +668 -0
- package/dist/shipping/myparcel.js +466 -0
- package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
- package/dist/shipping/parcel-rule.d.ts +6 -5
- package/dist/shipping/parcel-rule.js +21 -23
- package/dist/shipping/rate-tables.d.ts +324 -0
- package/dist/shipping/rate-tables.js +390 -0
- package/dist/shipping/ship-to-countries.d.ts +75 -0
- package/dist/shipping/ship-to-countries.js +47 -0
- package/dist/stock/by-location.d.ts +86 -0
- package/dist/stock/by-location.js +94 -0
- package/dist/stock/index.d.ts +18 -4
- package/dist/stock/index.js +7 -0
- package/dist/stock/locations.d.ts +144 -0
- package/dist/stock/locations.js +168 -0
- package/dist/stock/settings.d.ts +106 -0
- package/dist/stock/settings.js +103 -0
- package/dist/stock/transfers.d.ts +386 -52
- package/dist/stock/transfers.js +222 -17
- package/dist/stored-value/index.d.ts +312 -11
- package/dist/stored-value/index.js +223 -4
- package/dist/subscriptions/index.d.ts +682 -0
- package/dist/subscriptions/index.js +815 -0
- package/dist/tax/display-policy.d.ts +105 -0
- package/dist/tax/display-policy.js +84 -0
- package/dist/tax/index.d.ts +79 -1
- package/dist/tax/index.js +52 -0
- package/dist/tenant/email-style.d.ts +102 -0
- package/dist/tenant/email-style.js +72 -0
- package/dist/tenant/email-templates.d.ts +287 -0
- package/dist/tenant/email-templates.js +271 -0
- package/dist/tenant/notifications.d.ts +23 -17
- package/dist/tenant/settings-sources.d.ts +1 -1
- package/dist/tenant/time-zone.d.ts +17 -0
- package/dist/tenant/time-zone.js +11 -0
- package/dist/types.d.ts +50 -3
- package/dist/users/index.d.ts +3 -0
- package/dist/users/index.js +2 -0
- package/dist/users/warehouses.d.ts +50 -0
- package/dist/users/warehouses.js +51 -0
- package/package.json +2 -2
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Till returns and voids (POS engine sprint 20): goods of a completed till sale back, refunded to
|
|
5
|
+
* the sale's own payments, or the whole sale voided. A headless till (a machine principal with
|
|
6
|
+
* `x-location`) is a supported caller: its CREDENTIAL is the manager gate, so no staff or approval
|
|
7
|
+
* token is sent. Money is integer minor units of the order's currency.
|
|
8
|
+
*
|
|
9
|
+
* `quote` is a read: what the units would refund, to which payments, and why it cannot be done now
|
|
10
|
+
* (`blockedBy`, never thrown). `create` and `void` re-compute under the order's money turn and
|
|
11
|
+
* refuse a total other than `expectedTotal` (`POS_RETURN_AMOUNT_CHANGED`, another return was made
|
|
12
|
+
* meanwhile). Refusals that mean NOTHING moved: `POS_RETURN_INVALID` (`extensions.reason`),
|
|
13
|
+
* `POS_RETURN_AMOUNT_CHANGED`, `POS_RETURN_WINDOW_ENDED` (send `overrideWindow`),
|
|
14
|
+
* `POS_RETURN_REFUND_UNKNOWN`, `POS_RETURN_SPLIT_CARD`, `POS_RETURN_EXCEEDS_REFUNDABLE`,
|
|
15
|
+
* `POS_RETURN_SALE_NOT_COMPLETED`, `POS_VOID_NOT_ALLOWED` (`extensions.reason`),
|
|
16
|
+
* `POS_RETURNS_UNAVAILABLE`, `POS_SESSION_REQUIRED` (a cash refund needs an open drawer),
|
|
17
|
+
* `REFUND_REFUSED`, `REFUND_METHOD_UNAVAILABLE`, `LIVE_CONNECTION_REFUSED`.
|
|
18
|
+
* `IDEMPOTENCY_OUTCOME_UNKNOWN` is neither: a card refund reached the provider and the outcome is
|
|
19
|
+
* unknown; never retry under a new key. A card refund the provider did not confirm answers
|
|
20
|
+
* `complete: false` with that refund's `outcome: 'unknown'`; a repeat under the SAME key answers
|
|
21
|
+
* `complete: true` once it was reconciled as made.
|
|
22
|
+
*
|
|
23
|
+
* `payout: 'STORED_VALUE'` (engine C6b) pays a return out to the sale's OWN customer's store credit
|
|
24
|
+
* instead of refunding it: no refund, no provider, no drawer; `quote(...).storedValuePayout` says
|
|
25
|
+
* whether it can (`reason` `no_customer`, `no_method`, `not_entitled` when not), and `create`
|
|
26
|
+
* refuses `POS_RETURN_STORE_CREDIT_UNAVAILABLE` (`extensions.reason`) when it cannot, nothing moved.
|
|
27
|
+
* `quote` and `create` need an engine with C6b (an older one refuses their documents); `void`
|
|
28
|
+
* keeps its sprint-20 selection and reads on any engine.
|
|
29
|
+
*
|
|
30
|
+
* The customer's consent to store credit (owner ruling Q4, EU consumer law CRD art. 13(1)): a
|
|
31
|
+
* store-credit payout asks whether the customer expressly agreed to store credit instead of a
|
|
32
|
+
* refund to their payment when `quote(...).storedValuePayout.asksConsent` says so, and `create`
|
|
33
|
+
* sends the answer as `customerAgreed`. The engine records it on the store credit; never a
|
|
34
|
+
* condition. `quote` reads `asksConsent` on an engine before it too (the document without it,
|
|
35
|
+
* `false`: such an engine takes no answer).
|
|
36
|
+
*/
|
|
37
|
+
export type PosReturnKind = 'RETURN' | 'VOID';
|
|
38
|
+
/** Where a return's value goes (C6b): REFUND (the default) or the customer's store credit. */
|
|
39
|
+
export type PosReturnPayout = 'REFUND' | 'STORED_VALUE';
|
|
40
|
+
export interface PosReturnQuoteInput {
|
|
41
|
+
orderId: string;
|
|
42
|
+
/** RETURN when omitted; VOID ignores lines. */
|
|
43
|
+
kind?: PosReturnKind;
|
|
44
|
+
lines?: Array<{
|
|
45
|
+
orderLineId: string;
|
|
46
|
+
quantity: number;
|
|
47
|
+
}>;
|
|
48
|
+
cashFirst?: boolean;
|
|
49
|
+
/** REFUND when omitted (C6b). */
|
|
50
|
+
payout?: PosReturnPayout;
|
|
51
|
+
}
|
|
52
|
+
/** Whether a sale's return can go to its customer's store credit (C6b). */
|
|
53
|
+
export interface PosReturnStoredValuePayout {
|
|
54
|
+
available: boolean;
|
|
55
|
+
/** no_customer, no_method or not_entitled when it cannot. More may come. */
|
|
56
|
+
reason: string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Ask the customer whether they expressly agreed to store credit before this payout, and send
|
|
59
|
+
* the answer as `PosReturnCreateInput.customerAgreed` (owner ruling Q4): true exactly when the
|
|
60
|
+
* payout is available. `false` from an engine before the field, which takes no answer, and on a
|
|
61
|
+
* webshop order's quote, which never pays out to store credit.
|
|
62
|
+
*/
|
|
63
|
+
asksConsent: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** The store credit a return was paid out to (C6b). */
|
|
66
|
+
export interface PosReturnStoredValueCredit {
|
|
67
|
+
accountId: string;
|
|
68
|
+
entryId: string;
|
|
69
|
+
amount: number;
|
|
70
|
+
}
|
|
71
|
+
export interface PosReturnQuoteLine {
|
|
72
|
+
orderLineId: string;
|
|
73
|
+
name: string;
|
|
74
|
+
sku: string | null;
|
|
75
|
+
customItem: boolean;
|
|
76
|
+
restockable: boolean;
|
|
77
|
+
soldQuantity: number;
|
|
78
|
+
returnedQuantity: number;
|
|
79
|
+
returnableQuantity: number;
|
|
80
|
+
quantity: number;
|
|
81
|
+
refundAmount: number;
|
|
82
|
+
}
|
|
83
|
+
export interface PosReturnLeg {
|
|
84
|
+
paymentId: string;
|
|
85
|
+
/** cash, card or other. More may come. */
|
|
86
|
+
kind: string;
|
|
87
|
+
method: string;
|
|
88
|
+
amount: number;
|
|
89
|
+
}
|
|
90
|
+
export interface PosReturnQuote {
|
|
91
|
+
orderId: string;
|
|
92
|
+
kind: PosReturnKind;
|
|
93
|
+
currencyCode: string;
|
|
94
|
+
receiptNumber: string | null;
|
|
95
|
+
lines: PosReturnQuoteLine[];
|
|
96
|
+
total: number;
|
|
97
|
+
legs: PosReturnLeg[];
|
|
98
|
+
cashPaidOut: number;
|
|
99
|
+
returnWindowEndsAt: string | null;
|
|
100
|
+
outsideWindow: boolean;
|
|
101
|
+
refundedOutsideReturns: number;
|
|
102
|
+
restockLocationName: string | null;
|
|
103
|
+
/** A POS_RETURN_* / POS_VOID_NOT_ALLOWED / REFUND_METHOD_UNAVAILABLE code, or null. More may come. */
|
|
104
|
+
blockedBy: string | null;
|
|
105
|
+
blockedReason: string | null;
|
|
106
|
+
/** Whether the return can go to the customer's store credit (C6b). */
|
|
107
|
+
storedValuePayout: PosReturnStoredValuePayout;
|
|
108
|
+
}
|
|
109
|
+
export interface PosReturnLineInput {
|
|
110
|
+
orderLineId: string;
|
|
111
|
+
quantity: number;
|
|
112
|
+
/** damaged, defective, wrong_item, not_as_described, arrived_late, no_longer_needed, order_error, other. */
|
|
113
|
+
reasonCode: string;
|
|
114
|
+
restock: boolean;
|
|
115
|
+
}
|
|
116
|
+
export interface PosReturnCreateInput {
|
|
117
|
+
orderId: string;
|
|
118
|
+
lines: PosReturnLineInput[];
|
|
119
|
+
/** `quote(...).total` as shown. */
|
|
120
|
+
expectedTotal: number;
|
|
121
|
+
overrideWindow?: boolean;
|
|
122
|
+
cashFirst?: boolean;
|
|
123
|
+
/** REFUND when omitted (C6b). STORED_VALUE: the whole return to the sale's customer's store credit. */
|
|
124
|
+
payout?: PosReturnPayout;
|
|
125
|
+
/**
|
|
126
|
+
* A STORED_VALUE payout whose quote said `asksConsent`: whether the customer expressly agreed to
|
|
127
|
+
* store credit instead of a refund to their payment (EU consumer law, CRD art. 13(1)), as staff
|
|
128
|
+
* asked them. The engine records it on the store credit with who stated it
|
|
129
|
+
* (`StoredValueEntry.customerAgreed`); never a condition, nothing is refused for it. Part of the
|
|
130
|
+
* request: a repeat under the same key sends the same answer, another answer is
|
|
131
|
+
* `IDEMPOTENCY_CONFLICT`. Sent only when given (true or false): left out or null, the request is
|
|
132
|
+
* what it always was. An engine before the field refuses a call that gives it, and that refusal
|
|
133
|
+
* is surfaced, never retried without the answer.
|
|
134
|
+
*/
|
|
135
|
+
customerAgreed?: boolean | null;
|
|
136
|
+
}
|
|
137
|
+
export interface PosVoidInput {
|
|
138
|
+
orderId: string;
|
|
139
|
+
/** `quote({ orderId, kind: 'VOID' }).total` as shown. */
|
|
140
|
+
expectedTotal: number;
|
|
141
|
+
}
|
|
142
|
+
export interface PosReturnRefund {
|
|
143
|
+
paymentId: string;
|
|
144
|
+
kind: string;
|
|
145
|
+
method: string;
|
|
146
|
+
amount: number;
|
|
147
|
+
refundId: string;
|
|
148
|
+
/** made, or unknown. More may come. */
|
|
149
|
+
outcome: string;
|
|
150
|
+
}
|
|
151
|
+
export interface PosReturnResult {
|
|
152
|
+
orderId: string;
|
|
153
|
+
returnId: string;
|
|
154
|
+
/** The return's RMA code. */
|
|
155
|
+
returnCode: string;
|
|
156
|
+
kind: PosReturnKind;
|
|
157
|
+
total: number;
|
|
158
|
+
refunds: PosReturnRefund[];
|
|
159
|
+
cashPaidOut: number;
|
|
160
|
+
complete: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* What a STORED_VALUE payout credited (C6b); null for a refund. Absent on `void`, which never
|
|
163
|
+
* pays out to store credit and keeps the sprint-20 selection (it reads on an engine before C6b).
|
|
164
|
+
*/
|
|
165
|
+
storedValueCredit?: PosReturnStoredValueCredit | null;
|
|
166
|
+
}
|
|
167
|
+
/** A webshop order by its code AND its customer's email (engine C3/34). */
|
|
168
|
+
export interface PosOnlineOrderRef {
|
|
169
|
+
orderCode: string;
|
|
170
|
+
emailAddress: string;
|
|
171
|
+
}
|
|
172
|
+
/** What a till may know of a webshop order before a return (engine C3/34). */
|
|
173
|
+
export interface PosOnlineOrder {
|
|
174
|
+
orderId: string;
|
|
175
|
+
orderCode: string;
|
|
176
|
+
placedAt: string | null;
|
|
177
|
+
state: string;
|
|
178
|
+
currencyCode: string;
|
|
179
|
+
totalWithTax: number;
|
|
180
|
+
customerName: string | null;
|
|
181
|
+
/** The payment a return goes back to (its method's name); null when none can. */
|
|
182
|
+
refundMethodName: string | null;
|
|
183
|
+
returnableUnits: number;
|
|
184
|
+
/** POS_ONLINE_RETURN_BACK_OFFICE / POS_ONLINE_RETURN_NOTHING_RETURNABLE, or null. More may come. */
|
|
185
|
+
blockedBy: string | null;
|
|
186
|
+
blockedReason: string | null;
|
|
187
|
+
}
|
|
188
|
+
/** An online return's quote: the till quote plus what it refunds of delivery (engine C3/34). */
|
|
189
|
+
export interface PosOnlineReturnQuote extends PosReturnQuote {
|
|
190
|
+
/** Delivery refunded: only when the return brings the whole order back inside the window. */
|
|
191
|
+
shippingRefund: number;
|
|
192
|
+
/** `online`. More may come. */
|
|
193
|
+
source: string;
|
|
194
|
+
}
|
|
195
|
+
export interface PosOnlineReturnInput {
|
|
196
|
+
order: PosOnlineOrderRef;
|
|
197
|
+
lines: PosReturnLineInput[];
|
|
198
|
+
/** `onlineQuote(...).total` as shown, delivery included. */
|
|
199
|
+
expectedTotal: number;
|
|
200
|
+
overrideWindow?: boolean;
|
|
201
|
+
}
|
|
202
|
+
export interface PosReturnsModule {
|
|
203
|
+
/** What a return (or a void) would do now. Writes nothing. */
|
|
204
|
+
quote(input: PosReturnQuoteInput, options?: Call): Promise<PosReturnQuote>;
|
|
205
|
+
/** Return items: the key is REQUIRED (`options.idempotencyKey`). */
|
|
206
|
+
create(input: PosReturnCreateInput, options: Call & {
|
|
207
|
+
idempotencyKey: string;
|
|
208
|
+
}): Promise<PosReturnResult>;
|
|
209
|
+
/** Void a sale: the key is REQUIRED (`options.idempotencyKey`). */
|
|
210
|
+
void(input: PosVoidInput, options: Call & {
|
|
211
|
+
idempotencyKey: string;
|
|
212
|
+
}): Promise<PosReturnResult>;
|
|
213
|
+
/**
|
|
214
|
+
* A webshop order of this store by its code AND its customer's email (engine C3/34), re-verified
|
|
215
|
+
* on every call. An unknown code, a wrong email or another store's order is ONE refusal,
|
|
216
|
+
* `POS_ONLINE_ORDER_NOT_FOUND`; a till sale `POS_ONLINE_ORDER_IS_TILL_SALE`.
|
|
217
|
+
*/
|
|
218
|
+
findOnlineOrder(ref: PosOnlineOrderRef, options?: Call): Promise<PosOnlineOrder>;
|
|
219
|
+
/** What returning these units of the webshop order would refund now (engine C3/34). */
|
|
220
|
+
onlineQuote(input: {
|
|
221
|
+
order: PosOnlineOrderRef;
|
|
222
|
+
lines?: Array<{
|
|
223
|
+
orderLineId: string;
|
|
224
|
+
quantity: number;
|
|
225
|
+
}>;
|
|
226
|
+
}, options?: Call): Promise<PosOnlineReturnQuote>;
|
|
227
|
+
/**
|
|
228
|
+
* Return a webshop order's items at the credential's location, refunded to ONE online payment
|
|
229
|
+
* (engine C3/34). The key is REQUIRED. A provider that answers later or never confirms answers
|
|
230
|
+
* `complete: false` with the refund's `outcome` `pending` / `unknown` (do not refund again).
|
|
231
|
+
*/
|
|
232
|
+
onlineReturn(input: PosOnlineReturnInput, options: Call & {
|
|
233
|
+
idempotencyKey: string;
|
|
234
|
+
}): Promise<PosReturnResult>;
|
|
235
|
+
}
|
|
236
|
+
export declare const POS_RETURN_QUOTE_QUERY = "query PosReturnQuote($input: PosReturnQuoteInput!) { posReturnQuote(input: $input) { orderId kind currencyCode receiptNumber lines { orderLineId name sku customItem restockable soldQuantity returnedQuantity returnableQuantity quantity refundAmount } total legs { paymentId kind method amount } cashPaidOut returnWindowEndsAt outsideWindow refundedOutsideReturns restockLocationName blockedBy blockedReason storedValuePayout { available reason asksConsent } } }";
|
|
237
|
+
/** The quote for an engine before the till's consent (owner ruling Q4): no `asksConsent`. */
|
|
238
|
+
export declare const POS_RETURN_QUOTE_QUERY_BEFORE_CONSENT = "query PosReturnQuote($input: PosReturnQuoteInput!) { posReturnQuote(input: $input) { orderId kind currencyCode receiptNumber lines { orderLineId name sku customItem restockable soldQuantity returnedQuantity returnableQuantity quantity refundAmount } total legs { paymentId kind method amount } cashPaidOut returnWindowEndsAt outsideWindow refundedOutsideReturns restockLocationName blockedBy blockedReason storedValuePayout { available reason } } }";
|
|
239
|
+
export declare const POS_RETURN_MUTATION = "mutation PosReturn($input: PosReturnInput!) { posReturn(input: $input) { orderId returnId returnCode kind total refunds { paymentId kind method amount refundId outcome } cashPaidOut complete storedValueCredit { accountId entryId amount } } }";
|
|
240
|
+
export declare const POS_VOID_SALE_MUTATION = "mutation PosVoidSale($input: PosVoidSaleInput!) { posVoidSale(input: $input) { orderId returnId returnCode kind total refunds { paymentId kind method amount refundId outcome } cashPaidOut complete } }";
|
|
241
|
+
export declare const POS_ONLINE_ORDER_QUERY = "query PosOnlineOrder($input: PosOnlineOrderRefInput!) { posOnlineOrder(input: $input) { orderId orderCode placedAt state currencyCode totalWithTax customerName refundMethodName returnableUnits blockedBy blockedReason } }";
|
|
242
|
+
export declare const POS_ONLINE_RETURN_QUOTE_QUERY = "query PosOnlineReturnQuote($input: PosOnlineReturnQuoteInput!) { posOnlineReturnQuote(input: $input) { orderId kind currencyCode receiptNumber lines { orderLineId name sku customItem restockable soldQuantity returnedQuantity returnableQuantity quantity refundAmount } total legs { paymentId kind method amount } cashPaidOut returnWindowEndsAt outsideWindow refundedOutsideReturns restockLocationName blockedBy blockedReason storedValuePayout { available reason } shippingRefund source } }";
|
|
243
|
+
export declare const POS_ONLINE_RETURN_MUTATION = "mutation PosOnlineReturn($input: PosOnlineReturnInput!) { posOnlineReturn(input: $input) { orderId returnId returnCode kind total refunds { paymentId kind method amount refundId outcome } cashPaidOut complete } }";
|
|
244
|
+
export declare function createPosReturnsModule(transport: Transport): PosReturnsModule;
|