@tallyui/core 3.17.0 → 3.19.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/dist/{chunk-CSXNXRBA.js → chunk-27L7XLTT.js} +48 -0
- package/dist/command-result-BZd1YFMP.d.ts +1956 -0
- package/dist/index.d.ts +51 -1085
- package/dist/index.js +145 -9
- package/dist/server/index.d.ts +46 -5
- package/dist/server/index.js +594 -114
- package/package.json +1 -1
- package/src/customer-display/advertisement.ts +57 -0
- package/src/customer-display/index.ts +2 -0
- package/src/customer-display/rate-limit-source.ts +40 -0
- package/src/index.ts +13 -2
- package/src/order-filters.ts +58 -0
- package/src/server/batch.ts +4 -0
- package/src/server/display-signalling/contract.ts +254 -0
- package/src/server/display-signalling/index.ts +3 -0
- package/src/server/display-signalling/memory-server.ts +250 -0
- package/src/server/index.ts +2 -0
- package/src/server/order-payload-shape.ts +25 -1
- package/src/server/versions.ts +2 -2
- package/src/tax/woocommerce/index.ts +2 -0
- package/src/tax/woocommerce/tax-location.ts +59 -0
- package/src/types/commands.ts +27 -4
- package/src/types/connector.ts +41 -7
- package/src/types/customers.ts +9 -0
- package/src/types/display-signalling.ts +123 -0
- package/src/types/index.ts +6 -1
- package/src/types/orders.ts +23 -0
- package/src/types/receipt-templates.ts +26 -0
- package/src/types/store-settings.ts +42 -1
- package/dist/command-result-CoCa8PXJ.d.ts +0 -544
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
/** Supported command operation. */
|
|
2
|
-
type CommandType = 'order.create';
|
|
3
|
-
/** Client command with a stable idempotency key and typed payload. */
|
|
4
|
-
interface CommandEnvelope<P = unknown> {
|
|
5
|
-
id: string;
|
|
6
|
-
type: CommandType;
|
|
7
|
-
/** 3 when the order carries ADR-065's `display` and `taxByRate` (the store accepts 3), else 2 when discounted, else 1;
|
|
8
|
-
* 4 is 3 with every `discountMinor` tax-exclusive, built only when capped at 4 or more (#286).
|
|
9
|
-
* 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
10
|
-
* 7 is 6 plus the sale's `note` (ADR-083), sent only for an order that has one. */
|
|
11
|
-
version: 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
12
|
-
payload: P;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
deviceId: string;
|
|
15
|
-
attempt: number;
|
|
16
|
-
}
|
|
17
|
-
/** The register commands (ADR-068); each versions on its own, from 1. */
|
|
18
|
-
type RegisterCommandType = 'register.session.open' | 'register.session.transition' | 'register.movement.record' | 'register.movement.void' | 'register.closure.submit';
|
|
19
|
-
/** A register command's envelope: the same fields as CommandEnvelope, with its own type and a numeric version. */
|
|
20
|
-
type RegisterCommandEnvelope<P = Record<string, unknown>> = Omit<CommandEnvelope<P>, 'type' | 'version'> & {
|
|
21
|
-
type: RegisterCommandType;
|
|
22
|
-
version: number;
|
|
23
|
-
};
|
|
24
|
-
/** Any command a transport can carry. */
|
|
25
|
-
type AnyCommandEnvelope = CommandEnvelope<unknown> | RegisterCommandEnvelope<unknown> | OrderRefundEnvelope<unknown>;
|
|
26
|
-
/** A line's refunded quantity and restock choice (ADR-080). */
|
|
27
|
-
interface OrderRefundLine {
|
|
28
|
-
orderLineId: string;
|
|
29
|
-
quantity: number;
|
|
30
|
-
restock: boolean;
|
|
31
|
-
}
|
|
32
|
-
/** An online refund against an order, attributed to the refunding session (ADR-080). */
|
|
33
|
-
interface OrderRefundPayload {
|
|
34
|
-
clientRefundId: string;
|
|
35
|
-
orderId: string;
|
|
36
|
-
clientOrderId?: string;
|
|
37
|
-
lines: OrderRefundLine[];
|
|
38
|
-
shippingMinor: number;
|
|
39
|
-
adjustmentMinor: number;
|
|
40
|
-
totalMinor: number;
|
|
41
|
-
destination: 'original_method' | 'cash';
|
|
42
|
-
reason: string;
|
|
43
|
-
registerId: string;
|
|
44
|
-
sessionId: string;
|
|
45
|
-
cashierRef?: string;
|
|
46
|
-
createdAt: string;
|
|
47
|
-
}
|
|
48
|
-
/** An order.refund v1 command with the shared idempotency envelope (ADR-080). */
|
|
49
|
-
type OrderRefundEnvelope<P = OrderRefundPayload> = Omit<CommandEnvelope<P>, 'type' | 'version'> & {
|
|
50
|
-
type: 'order.refund';
|
|
51
|
-
version: 1;
|
|
52
|
-
};
|
|
53
|
-
/** The server's refund total, tender attribution and platform refunds (ADR-080). */
|
|
54
|
-
interface OrderRefundResult {
|
|
55
|
-
totalMinor: number;
|
|
56
|
-
byMethod: Record<string, number>;
|
|
57
|
-
refunds: Array<{
|
|
58
|
-
id: string;
|
|
59
|
-
paymentId: string;
|
|
60
|
-
totalMinor: number;
|
|
61
|
-
state: string;
|
|
62
|
-
}>;
|
|
63
|
-
}
|
|
64
|
-
/** Per-command refund refusals (ADR-080 decision 5). */
|
|
65
|
-
type OrderRefundRejectionCode = 'nothing_to_refund' | 'quantity_exceeds' | 'amount_mismatch' | 'order_state' | 'not_till_order' | 'forbidden' | 'no_open_session';
|
|
66
|
-
/** Lines exceeding the server's refundable quantities (ADR-080). */
|
|
67
|
-
interface OrderRefundQuantityExceedsData {
|
|
68
|
-
lines: Array<{
|
|
69
|
-
orderLineId: string;
|
|
70
|
-
quantity: number;
|
|
71
|
-
refundableQuantity: number;
|
|
72
|
-
}>;
|
|
73
|
-
}
|
|
74
|
-
/** The till's expected refund and the server's computed amount (ADR-080). */
|
|
75
|
-
interface OrderRefundAmountMismatchData {
|
|
76
|
-
expectedMinor: number;
|
|
77
|
-
serverMinor: number;
|
|
78
|
-
}
|
|
79
|
-
/** The order state preventing a refund (ADR-080). */
|
|
80
|
-
interface OrderRefundOrderStateData {
|
|
81
|
-
state: string;
|
|
82
|
-
}
|
|
83
|
-
/** The session that is not open on the refunding register (ADR-080). */
|
|
84
|
-
interface OrderRefundNoOpenSessionData {
|
|
85
|
-
sessionId: string;
|
|
86
|
-
}
|
|
87
|
-
/** An order.create envelope: 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
88
|
-
* 7 is 6 plus the sale's note (ADR-083). */
|
|
89
|
-
type OrderCreateEnvelope = CommandEnvelope<OrderCreatePayload> & {
|
|
90
|
-
type: 'order.create';
|
|
91
|
-
version: 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
92
|
-
};
|
|
93
|
-
/** Outcome of processing a command. */
|
|
94
|
-
type CommandStatus = 'applied' | 'duplicate' | 'rejected';
|
|
95
|
-
/** Server order identifiers and authoritative total. */
|
|
96
|
-
interface CommandServerRefs {
|
|
97
|
-
orderId: string;
|
|
98
|
-
displayId?: string;
|
|
99
|
-
totalMinor: number;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Non-fatal discrepancies reported while processing a command. A server may send codes not
|
|
103
|
-
* listed here (a newer contract); readers go through `knownWarnings`, which drops them, and a
|
|
104
|
-
* warning never rejects a sale.
|
|
105
|
-
*/
|
|
106
|
-
type CommandWarning = {
|
|
107
|
-
code: 'total_mismatch';
|
|
108
|
-
expectedMinor: number;
|
|
109
|
-
serverMinor: number;
|
|
110
|
-
/**
|
|
111
|
-
* Present if and only if the server added an untaxed rounding surcharge so its total
|
|
112
|
-
* matches the till's; signed, in minor units, `expectedMinor - serverMinor`, where
|
|
113
|
-
* `serverMinor` is the platform's total before the bridge.
|
|
114
|
-
*/
|
|
115
|
-
bridgeMinor?: number;
|
|
116
|
-
} | {
|
|
117
|
-
/**
|
|
118
|
-
* One per variant this sale took below zero stock. `quantity` is the units of this sale that
|
|
119
|
-
* stock did not cover (medusapos plugin 0.2.0 and later); older servers sent the variant's
|
|
120
|
-
* whole shortfall under the same field.
|
|
121
|
-
*/
|
|
122
|
-
code: 'insufficient_stock';
|
|
123
|
-
variantId: string;
|
|
124
|
-
quantity: number;
|
|
125
|
-
} | {
|
|
126
|
-
/**
|
|
127
|
-
* One warning per tax rate whose tax differs by more than the server's rounding tolerance
|
|
128
|
-
* (order.create v3 only); `expectedMinor` is the till's `taxByRate[].taxMinor` for that
|
|
129
|
-
* rate and `serverMinor` the platform's tax for it.
|
|
130
|
-
*/
|
|
131
|
-
code: 'tax_rate_mismatch';
|
|
132
|
-
ratePpm: number;
|
|
133
|
-
expectedMinor: number;
|
|
134
|
-
serverMinor: number;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* The sale's `customerId` (1 to 64 characters) was unknown, deleted or in another channel, so
|
|
138
|
-
* the sale was kept as a guest sale rather than held (ADR-070).
|
|
139
|
-
*/
|
|
140
|
-
| {
|
|
141
|
-
code: 'customer_ignored';
|
|
142
|
-
customerId: string;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* The order named a session the store did not hold when it applied the order (register v2).
|
|
146
|
-
* The store keeps the id on the order, and an open or alias that arrives later counts it.
|
|
147
|
-
* It does not mean the session was abandoned.
|
|
148
|
-
*/
|
|
149
|
-
| {
|
|
150
|
-
code: 'register_session_unknown';
|
|
151
|
-
sessionId: string;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* One warning per sale, never a refusal: each of the till's figures that differs from the
|
|
155
|
-
* server's own computation, once, with both values (#257). `total_mismatch` stays separate.
|
|
156
|
-
* `parseCommandResult` refuses a `field` it doesn't know; `knownWarnings` keeps it (a newer
|
|
157
|
-
* store's figure), so the type admits any non-empty string besides the three names.
|
|
158
|
-
*/
|
|
159
|
-
| {
|
|
160
|
-
code: 'figures_mismatch';
|
|
161
|
-
fields: Array<{
|
|
162
|
-
field: 'subtotalMinor' | 'taxMinor' | 'discountMinor' | (string & {});
|
|
163
|
-
tillMinor: number;
|
|
164
|
-
serverMinor: number;
|
|
165
|
-
}>;
|
|
166
|
-
};
|
|
167
|
-
/** Error reported when a command is rejected. */
|
|
168
|
-
interface CommandError {
|
|
169
|
-
code: string;
|
|
170
|
-
message: string;
|
|
171
|
-
/** A refusal's details, e.g. the server's supported version. */
|
|
172
|
-
data?: Record<string, unknown>;
|
|
173
|
-
}
|
|
174
|
-
/** `coupon_invalid` (order.create v6, ADR-077 d4): the store would not apply one of the order's coupons. */
|
|
175
|
-
interface OrderCreateCouponInvalidData {
|
|
176
|
-
/** The payload coupon's code, when the store can tell which one. */
|
|
177
|
-
couponCode?: string;
|
|
178
|
-
/** The store's own error code, e.g. WooCommerce's, for the log; never shown as the cashier's message. */
|
|
179
|
-
storeCode?: string;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* `total_mismatch` as a refusal (order.create v6, ADR-077 R4): the store would accept the order but computes a
|
|
183
|
-
* different total from the envelope, so it made no order. The store's own figures, as `figures_mismatch` names them.
|
|
184
|
-
*/
|
|
185
|
-
interface OrderCreateTotalMismatchData {
|
|
186
|
-
fields: Array<{
|
|
187
|
-
field: 'subtotalMinor' | 'taxMinor' | 'discountMinor' | 'totalMinor' | (string & {});
|
|
188
|
-
tillMinor: number;
|
|
189
|
-
serverMinor: number;
|
|
190
|
-
}>;
|
|
191
|
-
}
|
|
192
|
-
/** Server result for a single command. */
|
|
193
|
-
interface CommandResult {
|
|
194
|
-
id: string;
|
|
195
|
-
status: CommandStatus;
|
|
196
|
-
serverRefs?: CommandServerRefs;
|
|
197
|
-
warnings?: CommandWarning[];
|
|
198
|
-
error?: CommandError;
|
|
199
|
-
register?: RegisterCommandResult;
|
|
200
|
-
refund?: OrderRefundResult;
|
|
201
|
-
}
|
|
202
|
-
/** A register command's server figures (registers c2b applies them). */
|
|
203
|
-
interface RegisterCommandResult {
|
|
204
|
-
/** The session's server state after this command. `expected` is absent when the server redacts it (blind). */
|
|
205
|
-
session?: {
|
|
206
|
-
id: string;
|
|
207
|
-
status: 'open' | 'counting' | 'closed' | 'superseded';
|
|
208
|
-
expected?: Record<string, number>;
|
|
209
|
-
salesCount?: number;
|
|
210
|
-
/** Sent on a resume (register v2): the store session's opening time. */
|
|
211
|
-
openedAt?: string;
|
|
212
|
-
/** Sent on a resume (register v2): the store session's counted opening float. */
|
|
213
|
-
openingFloatMinor?: number;
|
|
214
|
-
};
|
|
215
|
-
/** The open was this device's own live session (register v2); the store keeps fromSessionId as a permanent alias of session.id. */
|
|
216
|
-
resumed?: {
|
|
217
|
-
fromSessionId: string;
|
|
218
|
-
};
|
|
219
|
-
/** The session this open took over (register v2). */
|
|
220
|
-
superseded?: {
|
|
221
|
-
sessionId: string;
|
|
222
|
-
openedAt?: string;
|
|
223
|
-
deviceId?: string;
|
|
224
|
-
deviceName?: string;
|
|
225
|
-
};
|
|
226
|
-
/** The register's counters: a floor for the till's own, never lowered. */
|
|
227
|
-
counters?: {
|
|
228
|
-
lastClosureNumber: number;
|
|
229
|
-
perpetualSalesTotalMinor: number;
|
|
230
|
-
perpetualRefundsTotalMinor: number;
|
|
231
|
-
};
|
|
232
|
-
/** `register.closure.submit` only. */
|
|
233
|
-
closure?: {
|
|
234
|
-
serverClosureId: string;
|
|
235
|
-
number: number;
|
|
236
|
-
expected?: Record<string, number>;
|
|
237
|
-
variance?: Record<string, number>;
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
interface RegisterSessionOpenPayload {
|
|
241
|
-
sessionId: string;
|
|
242
|
-
registerId: string;
|
|
243
|
-
storeKey?: string;
|
|
244
|
-
businessDay?: string;
|
|
245
|
-
openedAt: string;
|
|
246
|
-
openedBy?: string;
|
|
247
|
-
expectedFloatMinor?: number;
|
|
248
|
-
countedFloatMinor: number;
|
|
249
|
-
openingVarianceMinor?: number;
|
|
250
|
-
/** Register v2 only (ADR-078): the till's name on another till's take-over sheet, 1 to 64 characters after trim. */
|
|
251
|
-
deviceName?: string;
|
|
252
|
-
/** Register v2 only (ADR-078): the live session this open takes over, a compare-and-set. */
|
|
253
|
-
supersedes?: string;
|
|
254
|
-
}
|
|
255
|
-
/** error.data for register_session_already_open. */
|
|
256
|
-
interface RegisterSessionAlreadyOpenData {
|
|
257
|
-
sessionId: string;
|
|
258
|
-
registerId?: string;
|
|
259
|
-
openedAt?: string;
|
|
260
|
-
openedBy?: string;
|
|
261
|
-
deviceId?: string;
|
|
262
|
-
deviceName?: string;
|
|
263
|
-
status?: 'open' | 'counting';
|
|
264
|
-
}
|
|
265
|
-
/** error.data for register_session_superseded. */
|
|
266
|
-
interface RegisterSessionSupersededData {
|
|
267
|
-
sessionId: string;
|
|
268
|
-
supersededAt?: string;
|
|
269
|
-
supersededBy?: string;
|
|
270
|
-
deviceId?: string;
|
|
271
|
-
deviceName?: string;
|
|
272
|
-
newSessionId?: string;
|
|
273
|
-
}
|
|
274
|
-
/** error.data for register_approval_required (ADR-082 d6): variance is counted − tillExpected for each key of counted. */
|
|
275
|
-
interface RegisterApprovalRequiredData {
|
|
276
|
-
sessionId: string;
|
|
277
|
-
thresholdMinor: number;
|
|
278
|
-
variance: Record<string, number>;
|
|
279
|
-
}
|
|
280
|
-
/** error.data for register_approval_invalid (ADR-082 d6). */
|
|
281
|
-
interface RegisterApprovalInvalidData {
|
|
282
|
-
reason: 'unknown' | 'expired' | 'used' | 'session_mismatch' | 'variance_mismatch';
|
|
283
|
-
}
|
|
284
|
-
interface RegisterSessionTransitionPayload {
|
|
285
|
-
sessionId: string;
|
|
286
|
-
status: 'open' | 'counting' | 'closed';
|
|
287
|
-
at: string;
|
|
288
|
-
/** Closing only. */ counted?: Record<string, number>;
|
|
289
|
-
closedBy?: string;
|
|
290
|
-
approvedBy?: string;
|
|
291
|
-
}
|
|
292
|
-
interface RegisterMovementRecordPayload {
|
|
293
|
-
movementId: string;
|
|
294
|
-
sessionId: string;
|
|
295
|
-
type: 'paid_in' | 'paid_out' | 'no_sale';
|
|
296
|
-
amountMinor: number;
|
|
297
|
-
reason: string;
|
|
298
|
-
createdAt: string;
|
|
299
|
-
createdBy?: string;
|
|
300
|
-
}
|
|
301
|
-
interface RegisterMovementVoidPayload {
|
|
302
|
-
movementId: string;
|
|
303
|
-
sessionId: string;
|
|
304
|
-
voids: string;
|
|
305
|
-
createdAt: string;
|
|
306
|
-
createdBy?: string;
|
|
307
|
-
}
|
|
308
|
-
interface RegisterClosureSubmitPayload {
|
|
309
|
-
closureId: string;
|
|
310
|
-
sessionId: string;
|
|
311
|
-
registerId: string;
|
|
312
|
-
number: number;
|
|
313
|
-
businessDay?: string;
|
|
314
|
-
openedAt: string;
|
|
315
|
-
closedAt: string;
|
|
316
|
-
closedBy?: string;
|
|
317
|
-
approvedBy?: string;
|
|
318
|
-
/** Register v3 only (ADR-082): the store's approval proof, opaque; never parsed, logged or stored in the Z. */ approval?: string;
|
|
319
|
-
tillExpected: Record<string, number>;
|
|
320
|
-
counted: Record<string, number>;
|
|
321
|
-
periodSalesTotalMinor: number;
|
|
322
|
-
periodRefundsTotalMinor: number;
|
|
323
|
-
perpetualSalesTotalMinor: number;
|
|
324
|
-
perpetualRefundsTotalMinor: number;
|
|
325
|
-
unsyncedCount: number;
|
|
326
|
-
unsyncedTotalMinor: number;
|
|
327
|
-
softwareVersion: string;
|
|
328
|
-
orderIds: string[];
|
|
329
|
-
movementIds: string[];
|
|
330
|
-
}
|
|
331
|
-
/** Order line with client identity and price in minor units. */
|
|
332
|
-
interface OrderCreateLine {
|
|
333
|
-
clientLineId: string;
|
|
334
|
-
/** Required unless `custom` is set (version 5). */
|
|
335
|
-
variantId?: string;
|
|
336
|
-
/** Version 5 instruction: a non-catalogue line, without variantId; takes line and order discounts. */
|
|
337
|
-
custom?: {
|
|
338
|
-
/** Recorded title, 1–255 characters. */
|
|
339
|
-
name: string;
|
|
340
|
-
/** Recorded SKU, at most 64 characters when present. */
|
|
341
|
-
sku?: string;
|
|
342
|
-
/** Instruction, at most 64 characters; absent means the standard class. */
|
|
343
|
-
taxClass?: string;
|
|
344
|
-
/** Instruction: `none` means no tax on this line. */
|
|
345
|
-
taxStatus: 'taxable' | 'none';
|
|
346
|
-
};
|
|
347
|
-
title?: string;
|
|
348
|
-
quantity: number;
|
|
349
|
-
unitPriceMinor: number;
|
|
350
|
-
/** Version 6 recorded figure: the product's regular (not sale) unit price, in the line's tax mode and integer minor units, when the till knew it. */
|
|
351
|
-
regularUnitPriceMinor?: number;
|
|
352
|
-
/** Version 6 recorded: the variant's attribute names and values (#495), each at most 255 characters. */
|
|
353
|
-
attributes?: Record<string, string>;
|
|
354
|
-
/** Version 6: the names in attributes the cashier picked for the variant's "Any" option groups (#495 c/d). */
|
|
355
|
-
anyAttributes?: string[];
|
|
356
|
-
/**
|
|
357
|
-
* This line's own tax mode, when it differs from the order's `pricesIncludeTax`
|
|
358
|
-
* (a price that carries its own flag, D2c). Absent means the order's flag, so
|
|
359
|
-
* older clients and single-mode orders are unchanged.
|
|
360
|
-
*/
|
|
361
|
-
taxInclusive?: boolean;
|
|
362
|
-
/**
|
|
363
|
-
* Version 2 (ADR-062): this line's total discount, its own line discounts plus its allocated share of
|
|
364
|
-
* the order discount, in the line's own tax mode and integer minor units. The line is taxed on
|
|
365
|
-
* `unitPriceMinor × quantity − discountMinor`. Present only when above 0.
|
|
366
|
-
* Version 4+ (#286): tax-exclusive (net) in every mode; an inclusive line's is `net(A) − net(A − D)`.
|
|
367
|
-
*/
|
|
368
|
-
discountMinor?: number;
|
|
369
|
-
}
|
|
370
|
-
/** Version 6 (ADR-077): a coupon the till applied. Recorded figures, in integer minor units of the order's currency. */
|
|
371
|
-
interface OrderCreateCoupon {
|
|
372
|
-
/** The coupon code as the store knows it, 1–255 characters. */
|
|
373
|
-
code: string;
|
|
374
|
-
/** The store's id for the coupon, 1–64 characters. */
|
|
375
|
-
couponId: string;
|
|
376
|
-
/** The discount it gave, tax-exclusive, integer >= 0. */
|
|
377
|
-
discountMinor: number;
|
|
378
|
-
/** The tax on that discount, integer >= 0. */
|
|
379
|
-
discountTaxMinor: number;
|
|
380
|
-
}
|
|
381
|
-
/** Version 5: a fee, never discounted (ADR-075). */
|
|
382
|
-
interface OrderCreateFee {
|
|
383
|
-
/** Identity: UUID, stable for the order's life, at most 36 characters. */
|
|
384
|
-
clientFeeId: string;
|
|
385
|
-
/** Recorded fee title, 1–255 characters. */
|
|
386
|
-
name: string;
|
|
387
|
-
/** Instruction: integer >= 0, gross when pricesIncludeTax, net otherwise; never discounted. */
|
|
388
|
-
amountMinor: number;
|
|
389
|
-
/** Instruction: `none` means no tax on this fee. */
|
|
390
|
-
taxStatus: 'taxable' | 'none';
|
|
391
|
-
/** Instruction, at most 64 characters; absent means the standard class. */
|
|
392
|
-
taxClass?: string;
|
|
393
|
-
/** Informational till tax, integer >= 0; a server difference is total_mismatch, not a refusal. */
|
|
394
|
-
taxMinor: number;
|
|
395
|
-
}
|
|
396
|
-
/** Version 5: the same instructions and recorded/informational fields as a fee, never discounted. */
|
|
397
|
-
interface OrderCreateShipping extends Omit<OrderCreateFee, 'clientFeeId'> {
|
|
398
|
-
/** Identity: UUID, stable for the order's life, at most 36 characters. */
|
|
399
|
-
clientShippingId: string;
|
|
400
|
-
/** Recorded shipping method id, at most 64 characters; absent means a POS-entered charge. */
|
|
401
|
-
methodId?: string;
|
|
402
|
-
}
|
|
403
|
-
/** Supported order payment method. */
|
|
404
|
-
type PaymentMethodKind = 'cash' | 'external';
|
|
405
|
-
/** Order payment with client identity and amounts in minor units. */
|
|
406
|
-
interface OrderCreatePayment {
|
|
407
|
-
clientPaymentId: string;
|
|
408
|
-
method: PaymentMethodKind;
|
|
409
|
-
amountMinor: number;
|
|
410
|
-
tenderedMinor?: number;
|
|
411
|
-
changeMinor?: number;
|
|
412
|
-
reference?: string;
|
|
413
|
-
}
|
|
414
|
-
/** Version 3 (ADR-065): the receipt's display figures, integer minor units of `currency` at `exponent`. */
|
|
415
|
-
interface OrderCreateDisplay {
|
|
416
|
-
currency: string;
|
|
417
|
-
exponent: number;
|
|
418
|
-
taxInclusive: boolean;
|
|
419
|
-
subtotalMinor: number;
|
|
420
|
-
discountMinor: number;
|
|
421
|
-
taxMinor: number;
|
|
422
|
-
totalMinor: number;
|
|
423
|
-
orderDiscountMinor: number;
|
|
424
|
-
lines: Array<{
|
|
425
|
-
clientLineId: string;
|
|
426
|
-
amountMinor: number;
|
|
427
|
-
discounts: Array<{
|
|
428
|
-
discountId: string;
|
|
429
|
-
label?: string;
|
|
430
|
-
amountMinor: number;
|
|
431
|
-
}>;
|
|
432
|
-
}>;
|
|
433
|
-
/** Version 5 recorded figures: one row per payload fee, in the display tax mode. */
|
|
434
|
-
fees?: Array<{
|
|
435
|
-
/** Identity: the payload fee's clientFeeId. */
|
|
436
|
-
clientFeeId: string;
|
|
437
|
-
/** Recorded integer minor units, equal to the payload fee amount. */
|
|
438
|
-
amountMinor: number;
|
|
439
|
-
}>;
|
|
440
|
-
/** Version 5 recorded figures: one row per payload shipping charge, in the display tax mode. */
|
|
441
|
-
shipping?: Array<{
|
|
442
|
-
/** Identity: the payload shipping charge's clientShippingId. */
|
|
443
|
-
clientShippingId: string;
|
|
444
|
-
/** Recorded integer minor units, equal to the payload shipping amount. */
|
|
445
|
-
amountMinor: number;
|
|
446
|
-
}>;
|
|
447
|
-
/** Version 6 recorded figures: one row per payload coupon, its discount in the display tax mode. */
|
|
448
|
-
coupons?: Array<{
|
|
449
|
-
code: string;
|
|
450
|
-
amountMinor: number;
|
|
451
|
-
}>;
|
|
452
|
-
}
|
|
453
|
-
/** Version 3 (ADR-065): one tax rate's net, tax and gross, as the receipt's tax summary splits them. */
|
|
454
|
-
interface OrderCreateTaxRate {
|
|
455
|
-
ratePpm: number;
|
|
456
|
-
code?: string;
|
|
457
|
-
netMinor: number;
|
|
458
|
-
taxMinor: number;
|
|
459
|
-
grossMinor: number;
|
|
460
|
-
}
|
|
461
|
-
/** Client order data submitted by an order.create command. */
|
|
462
|
-
interface OrderCreatePayload {
|
|
463
|
-
clientOrderId: string;
|
|
464
|
-
createdAt: string;
|
|
465
|
-
currency: string;
|
|
466
|
-
pricesIncludeTax: boolean;
|
|
467
|
-
lines: OrderCreateLine[];
|
|
468
|
-
/** Version 5 instructions: fees in the order's tax mode; omitted when none. */
|
|
469
|
-
fees?: OrderCreateFee[];
|
|
470
|
-
/** Version 5 instructions: shipping in the order's tax mode; omitted when none. */
|
|
471
|
-
shipping?: OrderCreateShipping[];
|
|
472
|
-
/** Version 6 (ADR-077): the coupons the till applied, in the order it applied them; omitted when none.
|
|
473
|
-
* The store re-applies them by `code` and refuses the order with `coupon_invalid` if one no longer applies. */
|
|
474
|
-
coupons?: OrderCreateCoupon[];
|
|
475
|
-
/** Version 6: net of the coupons' `discountMinor`, as `taxMinor` is of their `discountTaxMinor`; coupons are not part of `discountMinor`. */
|
|
476
|
-
subtotalMinor: number;
|
|
477
|
-
/**
|
|
478
|
-
* Version 2 (ADR-062): the order's total discount, equal to Σ `lines[].discountMinor`. Present only when above 0.
|
|
479
|
-
* Version 4+ (#286) means every `discountMinor`, this and each line's, is tax-exclusive, so the sum still holds.
|
|
480
|
-
* Version 6: coupons are not included; their amounts are in `coupons[].discountMinor`.
|
|
481
|
-
*/
|
|
482
|
-
discountMinor?: number;
|
|
483
|
-
taxMinor: number;
|
|
484
|
-
totalMinor: number;
|
|
485
|
-
payments: OrderCreatePayment[];
|
|
486
|
-
/** Version 3+; both or neither. */
|
|
487
|
-
display?: OrderCreateDisplay;
|
|
488
|
-
/** Version 3+; both or neither. */
|
|
489
|
-
taxByRate?: OrderCreateTaxRate[];
|
|
490
|
-
customer?: {
|
|
491
|
-
email?: string;
|
|
492
|
-
/** Version 3+: the platform's id for the customer picked at the till, a soft reference of at most 64 characters. Absent for a guest sale, or when no customer was picked. */
|
|
493
|
-
customerId?: string;
|
|
494
|
-
} | null;
|
|
495
|
-
registerId?: string;
|
|
496
|
-
cashierRef?: string;
|
|
497
|
-
locationId?: string;
|
|
498
|
-
/** Version 3+: the register session the sale was taken for, stamped or late (ADR-032). A late sale names the session that refused its stamp; the server tells the two apart by the session's closure `orderIds`. Absent when the sale had no session. */
|
|
499
|
-
sessionId?: string;
|
|
500
|
-
/** Version 7 (ADR-083): the sale's note, 1 to ORDER_NOTE_MAX UTF-16 units; omitted when the sale has none. */
|
|
501
|
-
note?: string;
|
|
502
|
-
}
|
|
503
|
-
/** Batch of commands submitted to the server. */
|
|
504
|
-
interface CommandBatchRequest<E extends AnyCommandEnvelope = CommandEnvelope> {
|
|
505
|
-
commands: E[];
|
|
506
|
-
}
|
|
507
|
-
/** Results returned by the server for a command batch. */
|
|
508
|
-
interface CommandBatchResponse {
|
|
509
|
-
results: CommandResult[];
|
|
510
|
-
}
|
|
511
|
-
/** The `413` body for a batch over the limit (ADR-038; Front desk ruling 18). */
|
|
512
|
-
type BatchTooLargeBody = {
|
|
513
|
-
code: 'batch_too_large';
|
|
514
|
-
maxCommands: number;
|
|
515
|
-
message: string;
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
/** Path of the command endpoint, relative to the backend's base URL. */
|
|
519
|
-
declare const COMMANDS_PATH = "/tally/v1/commands";
|
|
520
|
-
/** Header carrying the protocol version. */
|
|
521
|
-
declare const PROTOCOL_HEADER = "X-Tally-Protocol";
|
|
522
|
-
/** Current protocol version. */
|
|
523
|
-
declare const PROTOCOL_VERSION = 1;
|
|
524
|
-
/** The ADR-038 batch limit; a server answers more with 413 and a BatchTooLargeBody. */
|
|
525
|
-
declare const MAX_COMMANDS_PER_BATCH = 50;
|
|
526
|
-
/** The longest order.create `note` (version 7, ADR-083), in UTF-16 code units. WCPOS v2's order note has no cap; this bounds the wire. */
|
|
527
|
-
declare const ORDER_NOTE_MAX = 1000;
|
|
528
|
-
/**
|
|
529
|
-
* True if `value` has the shape of a CommandBatchResponse: an object with a
|
|
530
|
-
* `results` array whose every entry has a string `id` and a `status` of
|
|
531
|
-
* 'applied' | 'duplicate' | 'rejected'. Optional fields are not deep-checked.
|
|
532
|
-
*/
|
|
533
|
-
declare function isCommandBatchResponse(value: unknown): value is CommandBatchResponse;
|
|
534
|
-
|
|
535
|
-
/** parseCommandResult's refusal; its message names the first bad field. A plugin maps it
|
|
536
|
-
* to its own invalid-data error (e.g. Medusa's MedusaError INVALID_DATA). */
|
|
537
|
-
declare class CommandResultError extends Error {
|
|
538
|
-
constructor(message: string);
|
|
539
|
-
}
|
|
540
|
-
/** Validates a CommandResult (e.g. one read back from the ledger). Throws
|
|
541
|
-
* CommandResultError naming the first bad field. */
|
|
542
|
-
declare function parseCommandResult(value: unknown): CommandResult;
|
|
543
|
-
|
|
544
|
-
export { type AnyCommandEnvelope as A, type BatchTooLargeBody as B, type CommandWarning as C, type OrderRefundRejectionCode as D, type OrderRefundResult as E, PROTOCOL_HEADER as F, PROTOCOL_VERSION as G, type RegisterApprovalRequiredData as H, type RegisterClosureSubmitPayload as I, type RegisterCommandEnvelope as J, type RegisterCommandResult as K, type RegisterCommandType as L, MAX_COMMANDS_PER_BATCH as M, type RegisterMovementRecordPayload as N, ORDER_NOTE_MAX as O, type PaymentMethodKind as P, type RegisterMovementVoidPayload as Q, type RegisterApprovalInvalidData as R, type RegisterSessionAlreadyOpenData as S, type RegisterSessionOpenPayload as T, type RegisterSessionSupersededData as U, type RegisterSessionTransitionPayload as V, isCommandBatchResponse as W, parseCommandResult as X, COMMANDS_PATH as a, type CommandBatchRequest as b, type CommandBatchResponse as c, type CommandEnvelope as d, type CommandError as e, type CommandResult as f, CommandResultError as g, type CommandServerRefs as h, type CommandStatus as i, type CommandType as j, type OrderCreateCoupon as k, type OrderCreateCouponInvalidData as l, type OrderCreateDisplay as m, type OrderCreateEnvelope as n, type OrderCreateLine as o, type OrderCreatePayload as p, type OrderCreatePayment as q, type OrderCreateTaxRate as r, type OrderCreateTotalMismatchData as s, type OrderRefundAmountMismatchData as t, type OrderRefundEnvelope as u, type OrderRefundLine as v, type OrderRefundNoOpenSessionData as w, type OrderRefundOrderStateData as x, type OrderRefundPayload as y, type OrderRefundQuantityExceedsData as z };
|