@tallyui/core 3.20.0 → 4.0.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-XF3RD6GX.js +515 -0
- package/dist/index.d.ts +41 -47
- package/dist/index.js +119 -101
- package/dist/server/index.cjs +1923 -0
- package/dist/server/index.d.cts +1039 -0
- package/dist/server/index.d.ts +46 -48
- package/dist/server/index.js +516 -206
- package/dist/{command-result-E_nH57WD.d.ts → tax-rate-DCJhfJbZ.d.ts} +442 -26
- package/package.json +10 -5
- package/src/commands.ts +12 -0
- package/src/context/money-format-context.tsx +50 -0
- package/src/coupons/woocommerce/to-coupon-configs.ts +5 -8
- package/src/fnv1a32.ts +14 -0
- package/src/index.ts +18 -5
- package/src/known-warnings.ts +23 -0
- package/src/money.ts +85 -2
- package/src/server/batch.ts +63 -27
- package/src/server/command-result.ts +28 -1
- package/src/server/display-signalling/contract.ts +203 -78
- package/src/server/display-signalling/memory-server.ts +71 -23
- package/src/server/fiscal-figures.ts +1 -1
- package/src/server/index.ts +5 -1
- package/src/server/money.ts +4 -1
- package/src/server/order-payload-shape.ts +96 -5
- package/src/server/refund-payload-shape.ts +5 -11
- package/src/server/register-payload-shape.ts +6 -12
- package/src/server/rejection-codes.ts +4 -4
- package/src/server/reopen-payload-shape.ts +25 -0
- package/src/server/shape-errors.ts +17 -0
- package/src/server/tax-rate.ts +13 -0
- package/src/server/update-payload-shape.ts +51 -0
- package/src/server/versions.ts +9 -2
- package/src/types/closures.ts +34 -0
- package/src/types/commands.ts +93 -8
- package/src/types/connector.ts +37 -4
- package/src/types/display-signalling.ts +30 -14
- package/src/types/index.ts +6 -3
- package/src/types/orders.ts +25 -3
- package/src/types/payment-methods.ts +17 -0
- package/src/types/stock.ts +2 -0
- package/src/types/store-settings.ts +7 -0
- package/src/types/traits/product.ts +19 -0
- package/dist/chunk-27L7XLTT.js +0 -235
package/src/server/versions.ts
CHANGED
|
@@ -5,10 +5,17 @@
|
|
|
5
5
|
* advertises it only once it handles it.
|
|
6
6
|
* 5 (ADR-075) adds fees, shipping and custom lines; 6 (ADR-077) adds coupons, regular prices, line
|
|
7
7
|
* attributes and Any picks (#495); a plugin advertises each only once it handles it.
|
|
8
|
-
* 7 (ADR-083) adds the sale note; 8 (#722) adds `taxAddress` and the customer's addresses.
|
|
8
|
+
* 7 (ADR-083) adds the sale note; 8 (#722) adds `taxAddress` and the customer's addresses; 9 (#790) adds each coupon's per-line amounts.
|
|
9
|
+
* 10 adds each payment's methodId (ruling A, 2026-11-18).
|
|
10
|
+
* 11 is 10 plus the customer's billing and shipping on a sale not taxed by address (ADR-086 d2 as amended 2026-11-19).
|
|
11
|
+
* 12 is 11 plus the customer's tax ids, a catalogue line's edited SKU and order meta, as informational fields (ADR-092).
|
|
9
12
|
*/
|
|
10
|
-
export const SUPPORTED_ORDER_CREATE_VERSIONS: readonly number[] = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
13
|
+
export const SUPPORTED_ORDER_CREATE_VERSIONS: readonly number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
|
11
14
|
/** The till's capability for the contract versions shared by all five register commands; a server passes its own. */
|
|
12
15
|
export const SUPPORTED_REGISTER_VERSIONS: readonly number[] = [1]
|
|
13
16
|
/** The till's capability for order.refund versions (ADR-080); a server passes its own. */
|
|
14
17
|
export const SUPPORTED_ORDER_REFUND_VERSIONS: readonly number[] = [1]
|
|
18
|
+
/** The till's capability for order.reopen versions (ADR-090); a server passes its own. */
|
|
19
|
+
export const SUPPORTED_ORDER_REOPEN_VERSIONS: readonly number[] = [1]
|
|
20
|
+
/** The till's capability for order.update versions (ADR-090); a server passes its own. */
|
|
21
|
+
export const SUPPORTED_ORDER_UPDATE_VERSIONS: readonly number[] = [1]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SyncContext } from './connector';
|
|
2
|
+
|
|
3
|
+
/** A manager's sign-in for one approval (ADR-082, ADR-093): sent straight to the store; never logged, kept or put in an error. */
|
|
4
|
+
export interface ApproverCredentials { username: string; password: string }
|
|
5
|
+
|
|
6
|
+
/** A correction the store appended to a closure (ADR-032, ADR-093), money in integer minor units. */
|
|
7
|
+
export type Correction = {
|
|
8
|
+
id: number; type: 'late_sale' | 'late_refund' | 'late_movement' | 'recount'; created_at: string;
|
|
9
|
+
actor: { id: string; name: string }; approver: { id: string; name: string } | null; reason: string;
|
|
10
|
+
figures: { expected_delta?: Record<string, number>; cash_delta?: number; sales_delta?: number; refunds_delta?: number;
|
|
11
|
+
counted?: Record<string, number>; variance?: Record<string, number> };
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** A Z closure as the store holds it (ADR-093), money in minor units. A figure the store withholds from this user is absent, never 0. */
|
|
15
|
+
export interface StoreClosure {
|
|
16
|
+
id: string; number: number; registerId: string; sessionId: string; storeId?: string; reason: string; businessDay?: string;
|
|
17
|
+
openedAt: string; closedAt: string; printedAt?: string; printCount: number; lastPrintedAt?: string;
|
|
18
|
+
expected?: Record<string, number>; tillExpected?: Record<string, number>; counted?: Record<string, number>; variance?: Record<string, number>;
|
|
19
|
+
periodSalesTotalMinor?: number; periodRefundsTotalMinor?: number; perpetualSalesTotalMinor?: number; perpetualRefundsTotalMinor?: number;
|
|
20
|
+
unsyncedCount: number; unsyncedTotalMinor?: number; correctionsCount?: number; corrections?: Correction[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The store's Z closures (ADR-093): online, read-through. Reads reject with `ConnectorUnauthorizedError` for a 401 or 403. */
|
|
24
|
+
export interface ClosureReads {
|
|
25
|
+
/** Newest first. `hasMore` is true when the page came back full. */
|
|
26
|
+
list(context: SyncContext, query?: { registerId?: string; after?: string; before?: string; page?: number; perPage?: number }): Promise<{ items: StoreClosure[]; hasMore: boolean }>;
|
|
27
|
+
/** One closure with its `corrections`; `null` when the store has none by that id. */
|
|
28
|
+
get(context: SyncContext, id: string): Promise<StoreClosure | null>;
|
|
29
|
+
last(context: SyncContext, registerId: string): Promise<StoreClosure | null>;
|
|
30
|
+
/** Appends a recount (`counted` names every tender, `cash` included). Replay-safe by `correctionId`. `closure` is absent when this user may not read closures. */
|
|
31
|
+
recount(context: SyncContext, id: string, input: { correctionId: string; counted: Record<string, number>; reason: string; approval?: ApproverCredentials }): Promise<{ closure?: StoreClosure } | { refused: 'approval_required' | 'approval_invalid' | 'approval_forbidden' | 'not_found' }>;
|
|
32
|
+
/** Records one print and returns the closure; `forbidden` when this user may not print closures. */
|
|
33
|
+
markPrinted(context: SyncContext, id: string): Promise<StoreClosure | { refused: 'forbidden' | 'not_found' }>;
|
|
34
|
+
}
|
package/src/types/commands.ts
CHANGED
|
@@ -8,9 +8,13 @@ export interface CommandEnvelope<P = unknown> {
|
|
|
8
8
|
/** 3 when the order carries ADR-065's `display` and `taxByRate` (the store accepts 3), else 2 when discounted, else 1;
|
|
9
9
|
* 4 is 3 with every `discountMinor` tax-exclusive, built only when capped at 4 or more (#286).
|
|
10
10
|
* 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
11
|
+
* 6 is 5 plus coupons, regular prices, line attributes and Any picks (ADR-077, #495), sent only for an order that has one.
|
|
11
12
|
* 7 is 6 plus the sale's `note` (ADR-083), sent only for an order that has one.
|
|
12
|
-
* 8 is 7 plus `taxAddress` and the customer's addresses (#722), sent only for a sale taxed on the customer's address.
|
|
13
|
-
|
|
13
|
+
* 8 is 7 plus `taxAddress` and the customer's addresses (#722), sent only for a sale taxed on the customer's address.
|
|
14
|
+
* 9 is 8 plus each coupon's per-line amounts (`coupons[].lines`, #790), sent only when every coupon carries them; it needs no `taxAddress`.
|
|
15
|
+
* 11 is 10 plus the customer's addresses on a sale with no taxAddress, as informational fields (ADR-086 d2 amended).
|
|
16
|
+
* 12 is 11 plus the customer's tax ids, a catalogue line's edited SKU and order meta, as informational fields (ADR-092). */
|
|
17
|
+
version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
14
18
|
payload: P;
|
|
15
19
|
createdAt: string; // ISO 8601, client clock
|
|
16
20
|
deviceId: string;
|
|
@@ -24,7 +28,7 @@ export type RegisterCommandType = 'register.session.open' | 'register.session.tr
|
|
|
24
28
|
export type RegisterCommandEnvelope<P = Record<string, unknown>> =
|
|
25
29
|
Omit<CommandEnvelope<P>, 'type' | 'version'> & { type: RegisterCommandType; version: number };
|
|
26
30
|
/** Any command a transport can carry. */
|
|
27
|
-
export type AnyCommandEnvelope = CommandEnvelope<unknown> | RegisterCommandEnvelope<unknown> | OrderRefundEnvelope<unknown>;
|
|
31
|
+
export type AnyCommandEnvelope = CommandEnvelope<unknown> | RegisterCommandEnvelope<unknown> | OrderRefundEnvelope<unknown> | OrderReopenEnvelope<unknown> | OrderUpdateEnvelope<unknown>;
|
|
28
32
|
|
|
29
33
|
/** A line's refunded quantity and restock choice (ADR-080). */
|
|
30
34
|
export interface OrderRefundLine { orderLineId: string; quantity: number; restock: boolean }
|
|
@@ -56,9 +60,52 @@ export interface OrderRefundOrderStateData { state: string }
|
|
|
56
60
|
/** The session that is not open on the refunding register (ADR-080). */
|
|
57
61
|
export interface OrderRefundNoOpenSessionData { sessionId: string }
|
|
58
62
|
|
|
63
|
+
/** An online reopen against a store order, attributed to the cashier and register (ADR-090). */
|
|
64
|
+
export interface OrderReopenPayload {
|
|
65
|
+
orderId: string; clientOrderId?: string; baseRevision?: string;
|
|
66
|
+
cashierRef: string; registerId: string; storeId?: string; createdAt: string;
|
|
67
|
+
}
|
|
68
|
+
/** An order.reopen v1 command with the shared idempotency envelope (ADR-090). */
|
|
69
|
+
export type OrderReopenEnvelope<P = OrderReopenPayload> =
|
|
70
|
+
Omit<CommandEnvelope<P>, 'type' | 'version'> & { type: 'order.reopen'; version: 1 };
|
|
71
|
+
/** The reopened order's server identity, status and revision (ADR-090). */
|
|
72
|
+
export interface OrderReopenResult { orderId: string; status: string; revision?: string }
|
|
73
|
+
/** Per-command reopen refusals (ADR-090). */
|
|
74
|
+
export type OrderReopenRejectionCode = 'payment_in_motion' | 'order_state' | 'revision_conflict' | 'forbidden';
|
|
75
|
+
/** The payment or attempt preventing a reopen (ADR-090). */
|
|
76
|
+
export interface OrderReopenPaymentInMotionData { paymentId?: string; attemptId?: string }
|
|
77
|
+
/** The order state preventing a reopen and the store's refusal code (ADR-090). */
|
|
78
|
+
export interface OrderReopenOrderStateData { state: string; storeCode?: string }
|
|
79
|
+
|
|
80
|
+
/** A kept line's store order-item id, absent on a new line (ADR-090). */
|
|
81
|
+
export type OrderUpdateLine = OrderCreateLine & { storeLineId?: string };
|
|
82
|
+
/** A kept fee's store order-item id, absent on a new fee (ADR-090). */
|
|
83
|
+
export type OrderUpdateFee = OrderCreateFee & { storeLineId?: string };
|
|
84
|
+
/** A kept shipping charge's store order-item id, absent on a new charge (ADR-090). */
|
|
85
|
+
export type OrderUpdateShipping = OrderCreateShipping & { storeLineId?: string };
|
|
86
|
+
/** A payment already on the order carries its store id and is never re-taken (ADR-090). */
|
|
87
|
+
export type OrderUpdatePayment = OrderCreatePayment & { paymentId?: string };
|
|
88
|
+
/** The reopened sale's whole new state, checked by its named order.create version (ADR-090). */
|
|
89
|
+
export interface OrderUpdatePayload extends Omit<OrderCreatePayload, 'lines' | 'payments' | 'fees' | 'shipping'> {
|
|
90
|
+
orderId: string; baseRevision?: string; createVersion: OrderCreateEnvelope['version'];
|
|
91
|
+
lines: OrderUpdateLine[]; payments: OrderUpdatePayment[];
|
|
92
|
+
fees?: OrderUpdateFee[]; shipping?: OrderUpdateShipping[];
|
|
93
|
+
}
|
|
94
|
+
/** An order.update v1 command with the shared idempotency envelope (ADR-090). */
|
|
95
|
+
export type OrderUpdateEnvelope<P = OrderUpdatePayload> =
|
|
96
|
+
Omit<CommandEnvelope<P>, 'type' | 'version'> & { type: 'order.update'; version: 1 };
|
|
97
|
+
/** Per-command update refusals; payment_in_motion reuses OrderReopenPaymentInMotionData (ADR-090). */
|
|
98
|
+
export type OrderUpdateRejectionCode = 'payment_in_motion' | 'reopen_required' | 'revision_conflict';
|
|
99
|
+
/** The order status preventing an update until it is reopened (ADR-090). */
|
|
100
|
+
export interface OrderUpdateReopenRequiredData { orderStatus: string }
|
|
101
|
+
|
|
59
102
|
/** An order.create envelope: 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
60
|
-
*
|
|
61
|
-
|
|
103
|
+
* 6 is 5 plus coupons, regular prices, line attributes and Any picks (ADR-077, #495).
|
|
104
|
+
* 7 is 6 plus the sale's note (ADR-083). 8 is 7 plus `taxAddress` and the customer's addresses (#722).
|
|
105
|
+
* 9 is 8 plus each coupon's per-line amounts (`coupons[].lines`, #790), sent only when every coupon carries them; it needs no `taxAddress`.
|
|
106
|
+
* 11 is 10 plus the customer's addresses on a sale with no taxAddress, as informational fields (ADR-086 d2 amended).
|
|
107
|
+
* 12 is 11 plus the customer's tax ids, a catalogue line's edited SKU and order meta, as informational fields (ADR-092). */
|
|
108
|
+
export type OrderCreateEnvelope = CommandEnvelope<OrderCreatePayload> & { type: 'order.create'; version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 };
|
|
62
109
|
|
|
63
110
|
/** Outcome of processing a command. */
|
|
64
111
|
export type CommandStatus = 'applied' | 'duplicate' | 'rejected';
|
|
@@ -121,6 +168,16 @@ export type CommandWarning =
|
|
|
121
168
|
| {
|
|
122
169
|
code: 'figures_mismatch';
|
|
123
170
|
fields: Array<{ field: 'subtotalMinor' | 'taxMinor' | 'discountMinor' | (string & {}); tillMinor: number; serverMinor: number }>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* One warning per sale, never a refusal: each line figure that differs from the server's own computation,
|
|
174
|
+
* once per (line, figure), with both values. `lineId` is the line's order.create `clientLineId`.
|
|
175
|
+
* `figures_mismatch` stays the order-level one. `parseCommandResult` refuses a `field` it doesn't know;
|
|
176
|
+
* `knownWarnings` keeps it (a newer store's figure).
|
|
177
|
+
*/
|
|
178
|
+
| {
|
|
179
|
+
code: 'line_figures_mismatch';
|
|
180
|
+
lines: Array<{ lineId: string; field: 'subtotalMinor' | 'taxMinor' | 'discountMinor' | 'totalMinor' | (string & {}); tillMinor: number; serverMinor: number }>;
|
|
124
181
|
};
|
|
125
182
|
|
|
126
183
|
/** Error reported when a command is rejected. */
|
|
@@ -155,6 +212,7 @@ export interface CommandResult {
|
|
|
155
212
|
error?: CommandError;
|
|
156
213
|
register?: RegisterCommandResult;
|
|
157
214
|
refund?: OrderRefundResult;
|
|
215
|
+
reopen?: OrderReopenResult;
|
|
158
216
|
}
|
|
159
217
|
|
|
160
218
|
/** A register command's server figures (registers c2b applies them). */
|
|
@@ -242,6 +300,8 @@ export interface OrderCreateLine {
|
|
|
242
300
|
taxStatus: 'taxable' | 'none';
|
|
243
301
|
};
|
|
244
302
|
title?: string;
|
|
303
|
+
/** Version 12 (ADR-092): a catalogue line's SKU as the cashier edited it, 1–100 characters; a custom line uses `custom.sku`. */
|
|
304
|
+
sku?: string;
|
|
245
305
|
quantity: number;
|
|
246
306
|
unitPriceMinor: number;
|
|
247
307
|
/** 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. */
|
|
@@ -275,6 +335,18 @@ export interface OrderCreateCoupon {
|
|
|
275
335
|
discountMinor: number;
|
|
276
336
|
/** The tax on that discount, integer >= 0. */
|
|
277
337
|
discountTaxMinor: number;
|
|
338
|
+
/** Version 9 (#790): this coupon's share of each line it reduced; present on every coupon at 9, never below. */
|
|
339
|
+
lines?: OrderCreateCouponLine[];
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** Version 9 (#790): one coupon's share of one line, in integer minor units; see docs/contract/order-create-v9.md. */
|
|
343
|
+
export interface OrderCreateCouponLine {
|
|
344
|
+
/** A `payload.lines[].clientLineId`. */
|
|
345
|
+
clientLineId: string;
|
|
346
|
+
/** This coupon's discount on that line, tax-exclusive, integer >= 0. */
|
|
347
|
+
discountMinor: number;
|
|
348
|
+
/** The tax on it, integer >= 0. */
|
|
349
|
+
discountTaxMinor: number;
|
|
278
350
|
}
|
|
279
351
|
|
|
280
352
|
/** Version 5: a fee, never discounted (ADR-075). */
|
|
@@ -312,6 +384,8 @@ export interface OrderCreatePayment {
|
|
|
312
384
|
tenderedMinor?: number;
|
|
313
385
|
changeMinor?: number;
|
|
314
386
|
reference?: string;
|
|
387
|
+
/** Version 10: the payment method's own id on the platform (a Woo gateway id, a Medusa provider id, a Vendure PaymentMethod code), 1–64 characters, no NUL. Informational: `method` still decides cash; core refuses no value by meaning. */
|
|
388
|
+
methodId?: string;
|
|
315
389
|
}
|
|
316
390
|
|
|
317
391
|
/** Version 3 (ADR-065): the receipt's display figures, integer minor units of `currency` at `exponent`. */
|
|
@@ -389,12 +463,14 @@ export interface OrderCreatePayload {
|
|
|
389
463
|
email?: string;
|
|
390
464
|
/** 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. */
|
|
391
465
|
customerId?: string;
|
|
392
|
-
/** Version 8 (#722): the customer's billing address, sent
|
|
466
|
+
/** Version 8 (#722): the customer's billing address, sent at 8+ with `taxAddress` and at 11 without it. */
|
|
393
467
|
billing?: OrderAddress;
|
|
394
|
-
/** Version 8 (#722): the customer's shipping address, sent
|
|
468
|
+
/** Version 8 (#722): the customer's shipping address, sent at 8+ with `taxAddress` and at 11 without it. */
|
|
395
469
|
shipping?: OrderAddress;
|
|
470
|
+
/** Version 12 (ADR-092): the customer's tax ids on this sale, at most ORDER_TAX_IDS_MAX (10). */
|
|
471
|
+
taxIds?: OrderCreateTaxId[];
|
|
396
472
|
} | null;
|
|
397
|
-
/** Version 8 (#722): the customer address the till taxed the sale on; always present at 8, and that address has a
|
|
473
|
+
/** Version 8 (#722): the customer address the till taxed the sale on; always present at 8; optional at 9, and that address has a
|
|
398
474
|
* non-empty `country`. Absent: the store's base address. */
|
|
399
475
|
taxAddress?: 'billing' | 'shipping';
|
|
400
476
|
registerId?: string;
|
|
@@ -404,8 +480,17 @@ export interface OrderCreatePayload {
|
|
|
404
480
|
sessionId?: string;
|
|
405
481
|
/** Version 7 (ADR-083): the sale's note, 1 to ORDER_NOTE_MAX UTF-16 units; omitted when the sale has none. */
|
|
406
482
|
note?: string;
|
|
483
|
+
/** Version 12 (ADR-092): the order's custom fields, at most ORDER_META_MAX (50), keys unique; omitted when none. */
|
|
484
|
+
meta?: OrderCreateMeta[];
|
|
407
485
|
}
|
|
408
486
|
|
|
487
|
+
/** A customer tax id on order.create 12 (ADR-092): `type` 1–32 UTF-16 units (the connector's scheme id), `value` 1–64,
|
|
488
|
+
* `country` an ISO 3166-1 alpha-2 code. */
|
|
489
|
+
export interface OrderCreateTaxId { type: string; value: string; country?: string }
|
|
490
|
+
|
|
491
|
+
/** An order custom field on order.create 12 (ADR-092): `key` 1–255 UTF-16 units, not starting with `_`; `value` 0–ORDER_NOTE_MAX. */
|
|
492
|
+
export interface OrderCreateMeta { key: string; value: string }
|
|
493
|
+
|
|
409
494
|
/** A customer's address on order.create v8 (#722): each field a string of at most 255 UTF-16 units; no email, which
|
|
410
495
|
* `customer.email` carries. */
|
|
411
496
|
export interface OrderAddress {
|
package/src/types/connector.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { ListOrdersQuery, OrderFilterField, StoreOrder, StoreOrderPage } fr
|
|
|
10
10
|
import type { PaymentMethodDescriptor } from './payment-methods';
|
|
11
11
|
import type { ReceiptTemplate, ReceiptTemplateKind } from './receipt-templates';
|
|
12
12
|
import type { RegisterInfo } from './registers';
|
|
13
|
+
import type { ClosureReads } from './closures';
|
|
13
14
|
import type { Cashier } from './cashier';
|
|
14
15
|
import type { FailureClass } from '../connectivity';
|
|
15
16
|
import type { DisplayAdvertisement, DisplaySignalling } from './display-signalling';
|
|
@@ -51,6 +52,10 @@ export interface ServerCapabilities {
|
|
|
51
52
|
register?: number;
|
|
52
53
|
/** The highest `order.refund` version; absent or 0 means the store takes no refunds and the app hides the action (ADR-080). */
|
|
53
54
|
orderRefund?: number;
|
|
55
|
+
/** The highest `order.reopen` version; absent or 0 means the store cannot reopen orders and the app hides the action (ADR-090). */
|
|
56
|
+
orderReopen?: number;
|
|
57
|
+
/** The highest `order.update` version; a store that lists `order.reopen` lists it (ADR-090). */
|
|
58
|
+
orderUpdate?: number;
|
|
54
59
|
/** How the store rounds tax (#287). Absent: an older server, per_order + half_away_from_zero. */
|
|
55
60
|
taxRounding?: TaxRounding;
|
|
56
61
|
/** Whether one order may carry several payments. Absent means it may: order.create's `payments` has always been a
|
|
@@ -79,6 +84,11 @@ export interface ServerCapabilities {
|
|
|
79
84
|
* `customerDisplay`. Absent means no second-device display.
|
|
80
85
|
*/
|
|
81
86
|
customerDisplay?: DisplayAdvertisement;
|
|
87
|
+
/** The receipt-email version a store's `/tally/v1/info` advertises as `receiptEmail: { v: n }` (vendurepos gap 12.1b).
|
|
88
|
+
* Absent means the store does not email receipts. */
|
|
89
|
+
receiptEmail?: number;
|
|
90
|
+
/** The platform plugin's own contract version, from `/tally/v1/info`'s top-level `pluginContract` (#1114). Absent when not sent or malformed; each connector says what a version adds. */
|
|
91
|
+
pluginContract?: number;
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
/** #287, ADR-071. `custom`: the till computes as when absent; that server never emits `figures_mismatch` for subtotal or tax. */
|
|
@@ -124,6 +134,7 @@ export function parseTaxRounding(value: unknown, warn?: (reason: string) => void
|
|
|
124
134
|
return undefined;
|
|
125
135
|
}
|
|
126
136
|
|
|
137
|
+
/** Reads an info response's lineTax capability: { none, classes } as two booleans, or undefined when absent or malformed (with warn only when malformed). */
|
|
127
138
|
export function parseLineTax(value: unknown, warn?: (reason: string) => void): { none: boolean; classes: boolean } | undefined {
|
|
128
139
|
if (value === undefined) return undefined;
|
|
129
140
|
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
@@ -144,6 +155,14 @@ function parseRegisterApproval(value: unknown, warn?: (reason: string) => void):
|
|
|
144
155
|
return undefined;
|
|
145
156
|
}
|
|
146
157
|
|
|
158
|
+
function parseReceiptEmail(value: unknown, warn?: (reason: string) => void): number | undefined {
|
|
159
|
+
if (value === undefined) return undefined;
|
|
160
|
+
const v = typeof value === 'object' && value !== null && !Array.isArray(value) ? (value as { v?: unknown }).v : undefined;
|
|
161
|
+
if (typeof v === 'number' && Number.isSafeInteger(v) && v > 0) return v;
|
|
162
|
+
warn?.('ignoring a malformed receiptEmail');
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
|
|
147
166
|
const maxVersion = (list: unknown): number | undefined => {
|
|
148
167
|
const valid = Array.isArray(list) ? list.filter((v): v is number => typeof v === 'number' && Number.isSafeInteger(v) && v > 0) : [];
|
|
149
168
|
return valid.length > 0 ? Math.max(...valid) : undefined;
|
|
@@ -153,9 +172,13 @@ const maxVersion = (list: unknown): number | undefined => {
|
|
|
153
172
|
* Reads a 2xx body of `GET /tally/v1/info` (ADR-062): `orderCreate` is the max of
|
|
154
173
|
* `contracts["order.create"]`, or 1 when it's missing or malformed; `register` is the max of
|
|
155
174
|
* `contracts.register` when valid; `taxRounding` is the top-level sibling of `contracts` (#287); malformed `lineTax` is ignored.
|
|
156
|
-
* malformed `registerApproval` is ignored (ADR-082). `coupons` is true only when the body says `coupons: true` (#709).
|
|
175
|
+
* A malformed `registerApproval` is ignored (ADR-082). `coupons` is true only when the body says `coupons: true` (#709).
|
|
157
176
|
* `orderRefund` is the max of `contracts["order.refund"]` when valid, otherwise absent (ADR-080).
|
|
177
|
+
* `orderReopen` is the max of `contracts["order.reopen"]` when valid, otherwise absent (ADR-090).
|
|
178
|
+
* `orderUpdate` is the max of `contracts["order.update"]` when valid, otherwise absent (ADR-090).
|
|
158
179
|
* `customerDisplay` is present only when `parseDisplayAdvertisement` accepts it; a malformed one warns (ADR-085).
|
|
180
|
+
* `receiptEmail` is `v` of `receiptEmail: { v }` when `v` is a safe integer above 0; a malformed one is left out and warns.
|
|
181
|
+
* `pluginContract` is the top-level `pluginContract` when it is a safe integer of 1 or more; a malformed one is left out and warns (#1114).
|
|
159
182
|
* Absent `taxRounding` uses the default; a present malformed value is unknown, so settings wait.
|
|
160
183
|
* A non-object body is also unknown, not a statement of the store's defaults.
|
|
161
184
|
*/
|
|
@@ -164,9 +187,11 @@ export function parseInfoCapabilities(body: unknown, warn?: (reason: string) =>
|
|
|
164
187
|
warn?.('non-object info body: capabilities unknown');
|
|
165
188
|
return undefined;
|
|
166
189
|
}
|
|
167
|
-
const { contracts, taxRounding, lineTax, registerApproval, coupons, customerDisplay } = body as { contracts?: Record<string, unknown> | null; taxRounding?: unknown; lineTax?: unknown; registerApproval?: unknown; coupons?: unknown; customerDisplay?: unknown };
|
|
190
|
+
const { contracts, taxRounding, lineTax, registerApproval, coupons, customerDisplay, receiptEmail, pluginContract } = body as { contracts?: Record<string, unknown> | null; taxRounding?: unknown; lineTax?: unknown; registerApproval?: unknown; coupons?: unknown; customerDisplay?: unknown; receiptEmail?: unknown; pluginContract?: unknown };
|
|
168
191
|
const register = maxVersion(contracts?.register);
|
|
169
192
|
const orderRefund = maxVersion(contracts?.['order.refund']);
|
|
193
|
+
const orderReopen = maxVersion(contracts?.['order.reopen']);
|
|
194
|
+
const orderUpdate = maxVersion(contracts?.['order.update']);
|
|
170
195
|
const rounding = parseTaxRounding(taxRounding);
|
|
171
196
|
if (taxRounding !== undefined && rounding === undefined) {
|
|
172
197
|
warn?.(`malformed taxRounding: rounding is unknown, so settings wait: ${JSON.stringify(taxRounding)}`);
|
|
@@ -175,12 +200,18 @@ export function parseInfoCapabilities(body: unknown, warn?: (reason: string) =>
|
|
|
175
200
|
const parsedLineTax = parseLineTax(lineTax, warn);
|
|
176
201
|
const parsed = parseRegisterApproval(registerApproval, warn);
|
|
177
202
|
const display = parseDisplayAdvertisement(customerDisplay, warn);
|
|
203
|
+
const emailVersion = parseReceiptEmail(receiptEmail, warn);
|
|
204
|
+
const contractOk = typeof pluginContract === 'number' && Number.isSafeInteger(pluginContract) && pluginContract >= 1;
|
|
205
|
+
if (pluginContract !== undefined && !contractOk) warn?.(`malformed pluginContract: ${JSON.stringify(pluginContract)}`);
|
|
178
206
|
return { orderCreate: maxVersion(contracts?.['order.create']) ?? 1,
|
|
179
207
|
...(orderRefund !== undefined ? { orderRefund } : {}),
|
|
208
|
+
...(orderReopen !== undefined ? { orderReopen } : {}),
|
|
209
|
+
...(orderUpdate !== undefined ? { orderUpdate } : {}),
|
|
180
210
|
...(register !== undefined ? { register } : {}), ...(rounding ? { taxRounding: rounding } : {}),
|
|
181
211
|
...(parsedLineTax ? { lineTax: parsedLineTax } : {}),
|
|
182
212
|
...(parsed ? { registerApproval: parsed } : {}), ...(coupons === true ? { coupons: true } : {}),
|
|
183
|
-
...(display ? { customerDisplay: display } : {}) }
|
|
213
|
+
...(display ? { customerDisplay: display } : {}), ...(emailVersion !== undefined ? { receiptEmail: emailVersion } : {}),
|
|
214
|
+
...(contractOk ? { pluginContract } : {}) };
|
|
184
215
|
}
|
|
185
216
|
|
|
186
217
|
export interface AuthField {
|
|
@@ -247,7 +278,7 @@ export interface SyncContext {
|
|
|
247
278
|
*/
|
|
248
279
|
export interface ConnectorSchemas {
|
|
249
280
|
products: RxJsonSchema<any>;
|
|
250
|
-
//
|
|
281
|
+
// Any other collection's schema, keyed by the collection's name.
|
|
251
282
|
[key: string]: RxJsonSchema<any>;
|
|
252
283
|
}
|
|
253
284
|
|
|
@@ -396,6 +427,8 @@ export interface TallyConnector {
|
|
|
396
427
|
* for credentials; a connector's own errors otherwise. `undefined` when the connector has no register directory.
|
|
397
428
|
*/
|
|
398
429
|
listRegisters?: (context: SyncContext) => Promise<RegisterInfo[]>;
|
|
430
|
+
/** The store's Z closures (ADR-093): online only. `undefined` when the connector has none: the app hides its server-closure features. */
|
|
431
|
+
closures?: ClosureReads;
|
|
399
432
|
/**
|
|
400
433
|
* The signed-in cashier and their neutral POS permissions (v2 parity A12), mapped from the platform's own roles or
|
|
401
434
|
* capabilities. Read-only. `null` when the connector has no cashier to describe; `undefined` (no method) when the
|
|
@@ -25,6 +25,8 @@ export type DisplaySignallingErrorCode =
|
|
|
25
25
|
| 'collect_refused'
|
|
26
26
|
/** Till side: an id this device does not own, or one that is unknown or expired. */
|
|
27
27
|
| 'not_found'
|
|
28
|
+
/** Till side: a missing, wrong or unknown device key, or `registerDevice` for an id that already holds a key or has already adopted. One code for all of them. */
|
|
29
|
+
| 'device_refused'
|
|
28
30
|
/** Display side: a token that is unknown, forgotten or pruned. */
|
|
29
31
|
| 'token_refused'
|
|
30
32
|
/** A snapshot whose JSON is over 200 KiB. */
|
|
@@ -69,6 +71,9 @@ export interface DisplayRecord {
|
|
|
69
71
|
connected: boolean;
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
/** The till's credential on every till-side call: its device id and the key `registerDevice` issued for it. Core treats `deviceKey` as opaque. */
|
|
75
|
+
export interface TillDevice { deviceId: string; deviceKey: string }
|
|
76
|
+
|
|
72
77
|
/** One WebRTC signalling message; `payload` is opaque to the server. */
|
|
73
78
|
export interface SignalMessage { type: 'offer' | 'answer' | 'ice'; payload: string }
|
|
74
79
|
|
|
@@ -76,37 +81,48 @@ export interface SignalMessage { type: 'offer' | 'answer' | 'ice'; payload: stri
|
|
|
76
81
|
* The platform-neutral signalling seam for a second-device customer display (ADR-085 d2). Each backend's plugin
|
|
77
82
|
* implements the routes its own way; every implementation meets this floor (d4–d6, d8, #705), which
|
|
78
83
|
* `displaySignallingContract` in `@tallyui/core/server` tests. A plugin may be stricter.
|
|
79
|
-
* Till side: every call takes a cashier session and the till's
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* `DisplaySignallingError`.
|
|
84
|
+
* Till side: every call takes a cashier session and the till's `TillDevice`; the refusal order is `forbidden` (a
|
|
85
|
+
* session without `customer_display.pair`), then `device_refused` (the device key), then `not_found` (an id this device
|
|
86
|
+
* does not own), and a refused call has no effect. Display side: no login; calls are gated by the display's token
|
|
87
|
+
* (`token_refused`), and each successful token call updates `lastSeenAt`. Every refusal is a `DisplaySignallingError`.
|
|
88
|
+
* The device key is the till's credential (TallyUI#754). An implementation compares key hashes in constant time, never
|
|
89
|
+
* logs the key, never puts it in an error or a response body, and never returns it after issue. The device id is an
|
|
90
|
+
* identifier, not a credential, anywhere, including the device id in order data (`order.create`).
|
|
83
91
|
*/
|
|
84
92
|
export interface DisplaySignalling {
|
|
93
|
+
/**
|
|
94
|
+
* Issues the device key for `deviceId`, needing `customer_display.pair`: 128 bits, base64url, stored only as SHA-256
|
|
95
|
+
* hex, and returned once, by this call only. An id that already holds a key gives `device_refused`. A pre-migration id
|
|
96
|
+
* (rows from before device keys, no key hash) adopts them once, logged with the cashier id. An admin reset deletes the
|
|
97
|
+
* device record with every display, code and pending pairing it owns, so the id registers as new; a reset never returns
|
|
98
|
+
* an id to the keyless pre-migration state.
|
|
99
|
+
*/
|
|
100
|
+
registerDevice(ctx: SyncContext, deviceId: string): Promise<{ deviceKey: string }>;
|
|
85
101
|
/** A pairing code: 6+ digits from `crypto.getRandomValues`, single use, live at most 10 minutes; a 6th unspent code per device gives `limit`. */
|
|
86
|
-
mint(ctx: SyncContext,
|
|
102
|
+
mint(ctx: SyncContext, device: TillDevice): Promise<{ code: string; expiresAt: string }>;
|
|
87
103
|
/** The live claims on codes this device minted, each with its check code. */
|
|
88
|
-
pending(ctx: SyncContext,
|
|
104
|
+
pending(ctx: SyncContext, device: TillDevice): Promise<PendingPairing[]>;
|
|
89
105
|
/**
|
|
90
106
|
* Confirms a claim on a code this device minted, recording the display as owned by this device and cashier. The
|
|
91
107
|
* display then collects its token: 128 bits, base64url, stored only as SHA-256 hex. A claim that carried a valid
|
|
92
108
|
* token moves that display: its old row, token and snapshot go in the same step, and this device owns the same id.
|
|
93
109
|
*/
|
|
94
|
-
confirm(ctx: SyncContext,
|
|
110
|
+
confirm(ctx: SyncContext, device: TillDevice, claimId: string): Promise<void>;
|
|
95
111
|
/** Declines a claim on a code this device minted: the pending pairing is deleted, and nothing is issued. */
|
|
96
|
-
decline(ctx: SyncContext,
|
|
112
|
+
decline(ctx: SyncContext, device: TillDevice, claimId: string): Promise<void>;
|
|
97
113
|
/** The displays this device owns. A display unseen for 30 days is pruned with its token and snapshot. */
|
|
98
|
-
list(ctx: SyncContext,
|
|
114
|
+
list(ctx: SyncContext, device: TillDevice): Promise<DisplayRecord[]>;
|
|
99
115
|
/** Deletes the display's row, token hash and snapshot at once; the token is refused on its next call. */
|
|
100
|
-
forget(ctx: SyncContext,
|
|
116
|
+
forget(ctx: SyncContext, device: TillDevice, displayId: string): Promise<void>;
|
|
101
117
|
/** Queues a message in an owned display's inbox. */
|
|
102
|
-
sendSignal(ctx: SyncContext,
|
|
118
|
+
sendSignal(ctx: SyncContext, device: TillDevice, displayId: string, message: SignalMessage): Promise<void>;
|
|
103
119
|
/** Drains this device's inbox: each message once, in send order, only from displays it owns. */
|
|
104
|
-
receiveSignals(ctx: SyncContext,
|
|
120
|
+
receiveSignals(ctx: SyncContext, device: TillDevice): Promise<Array<SignalMessage & { displayId: string }>>;
|
|
105
121
|
/** Keeps `body` as the display's only snapshot for at most 60 s; over 204 800 UTF-8 bytes of JSON gives `too_large` and keeps the old one. */
|
|
106
|
-
postSnapshot(ctx: SyncContext,
|
|
122
|
+
postSnapshot(ctx: SyncContext, device: TillDevice, displayId: string, body: unknown): Promise<void>;
|
|
107
123
|
/**
|
|
108
124
|
* Claims a live code: the first claim spends it and records a pending pairing with `displayName` and a fresh 4-digit
|
|
109
|
-
* check code, unique among live pending pairings, and returns a claim secret (128 bits, base64url, stored only as a
|
|
125
|
+
* check code, unique among that till's live pending pairings, and returns a claim secret (128 bits, base64url, stored only as a
|
|
110
126
|
* hash); no token. `token` is the display's current token, if any, so a confirm moves it. A claim naming no live code
|
|
111
127
|
* fails and spends nothing. Failed claims are limited per source (10 a minute, IPv6 by /64 via `rateLimitSource`) and
|
|
112
128
|
* store-wide (100 per 10 minutes); over either, every claim is refused and spends nothing. Every refusal is `claim_refused`.
|
package/src/types/index.ts
CHANGED
|
@@ -13,14 +13,14 @@ export type { ReplicationAdapter } from './replication';
|
|
|
13
13
|
|
|
14
14
|
export type {
|
|
15
15
|
DisplaySignalling, DisplaySignallingContext, DisplaySignallingErrorCode, DisplayAdvertisement, IceServer,
|
|
16
|
-
PendingPairing, DisplayRecord, SignalMessage,
|
|
16
|
+
PendingPairing, DisplayRecord, SignalMessage, TillDevice,
|
|
17
17
|
} from './display-signalling';
|
|
18
18
|
|
|
19
19
|
export type { FingerprintReconcileAdapter, IdReconcileAdapter, StockReconcileAdapter } from './reconcile';
|
|
20
20
|
|
|
21
21
|
export type { StoreSettings, StoreSettingsChoice, StoreTaxClass, StoreTaxRate, StoreTaxRateLocation } from './store-settings';
|
|
22
22
|
|
|
23
|
-
export type { ProductTraits, TraitContext, VariantSummary, VariantOptionGroup, ProductCategory } from './traits/product';
|
|
23
|
+
export type { ProductTraits, TraitContext, VariantSummary, VariantOptionGroup, ProductCategory, ProductTerm } from './traits/product';
|
|
24
24
|
|
|
25
25
|
export type { Money, ProductPrice, ResolvedPrice } from './money';
|
|
26
26
|
|
|
@@ -33,7 +33,10 @@ export type {
|
|
|
33
33
|
RegisterCommandType, RegisterCommandEnvelope, AnyCommandEnvelope,
|
|
34
34
|
OrderRefundLine, OrderRefundPayload, OrderRefundEnvelope, OrderRefundResult, OrderRefundRejectionCode,
|
|
35
35
|
OrderRefundQuantityExceedsData, OrderRefundAmountMismatchData, OrderRefundOrderStateData, OrderRefundNoOpenSessionData,
|
|
36
|
-
|
|
36
|
+
OrderReopenPayload, OrderReopenEnvelope, OrderReopenResult, OrderReopenRejectionCode,
|
|
37
|
+
OrderReopenPaymentInMotionData, OrderReopenOrderStateData,
|
|
38
|
+
OrderUpdateLine, OrderUpdateFee, OrderUpdateShipping, OrderUpdatePayment, OrderUpdatePayload, OrderUpdateEnvelope, OrderUpdateRejectionCode, OrderUpdateReopenRequiredData,
|
|
39
|
+
CommandWarning, CommandError, CommandResult, OrderCreateLine, OrderCreateTaxId, OrderCreateMeta,
|
|
37
40
|
PaymentMethodKind, OrderCreatePayment, OrderCreatePayload, OrderCreateEnvelope,
|
|
38
41
|
OrderCreateDisplay, OrderCreateTaxRate,
|
|
39
42
|
OrderCreateCoupon, OrderCreateCouponInvalidData, OrderCreateTotalMismatchData,
|
package/src/types/orders.ts
CHANGED
|
@@ -24,9 +24,23 @@ export interface StoreOrderLine {
|
|
|
24
24
|
|
|
25
25
|
/** A fee or shipping line: excluding tax, the tax beside it. A fee may be negative.
|
|
26
26
|
* `taxMinor` is such that `totalMinor + taxMinor` is the gross rounded once. */
|
|
27
|
-
export interface StoreOrderCharge {
|
|
27
|
+
export interface StoreOrderCharge {
|
|
28
|
+
/** The store's order-item id, which `OrderUpdateFee.storeLineId` / `OrderUpdateShipping.storeLineId` names; absent when the store gives none. */
|
|
29
|
+
id?: string;
|
|
30
|
+
name: string;
|
|
31
|
+
totalMinor: number;
|
|
32
|
+
taxMinor: number;
|
|
33
|
+
/** The tax status the store recorded on the fee or shipping line; absent when the store's response carries none. */
|
|
34
|
+
taxStatus?: 'taxable' | 'none';
|
|
35
|
+
/** A fee's recorded tax class; absent means the standard class. Shipping lines carry none. */
|
|
36
|
+
taxClass?: string;
|
|
37
|
+
/** A shipping line's recorded method id. */
|
|
38
|
+
methodId?: string;
|
|
39
|
+
}
|
|
28
40
|
|
|
29
41
|
export interface StoreOrderPayment {
|
|
42
|
+
/** The store's payment record id, which `OrderUpdatePayment.paymentId` names; absent when the store keeps no per-payment record. */
|
|
43
|
+
id?: string;
|
|
30
44
|
/** The store's own method id, e.g. WooCommerce's `pos_cash`. */
|
|
31
45
|
method: string;
|
|
32
46
|
/** The store's name for it, e.g. "Cash". */
|
|
@@ -45,8 +59,10 @@ export interface StoreOrder {
|
|
|
45
59
|
id: string;
|
|
46
60
|
/** The number the store shows (`CommandServerRefs.displayId`). */
|
|
47
61
|
reference: string;
|
|
48
|
-
/** The till's `PosOrder.id` when a till created the order; absent otherwise. */
|
|
62
|
+
/** The till's `PosOrder.id` when a till created the order; absent otherwise. It is also what an `order.reopen` sends as `clientOrderId`. */
|
|
49
63
|
clientOrderId?: string;
|
|
64
|
+
/** The store's current revision of the order, which `OrderReopenPayload.baseRevision` and `OrderUpdatePayload.baseRevision` carry; absent when the store has none. */
|
|
65
|
+
revision?: string;
|
|
50
66
|
/** The platform's own status word (WooCommerce: `completed`, `refunded`, …); the app labels it. */
|
|
51
67
|
status: string;
|
|
52
68
|
/** ISO 8601, UTC. */
|
|
@@ -66,6 +82,10 @@ export interface StoreOrder {
|
|
|
66
82
|
taxMinor: number;
|
|
67
83
|
totalMinor: number;
|
|
68
84
|
payments: StoreOrderPayment[];
|
|
85
|
+
/** The store keeps a per-payment record for this order in a shape the connector cannot read
|
|
86
|
+
* (WooCommerce: a WCPOS payment ledger of another schema); `payments` is then the order's paid-state
|
|
87
|
+
* fallback, and a reopen must refuse the order. Absent otherwise. */
|
|
88
|
+
paymentRecordUnreadable?: true;
|
|
69
89
|
refunds: StoreOrderRefund[];
|
|
70
90
|
}
|
|
71
91
|
|
|
@@ -105,6 +125,8 @@ export interface ListOrdersQuery {
|
|
|
105
125
|
export interface StoreOrderPage {
|
|
106
126
|
orders: StoreOrder[];
|
|
107
127
|
hasMore: boolean;
|
|
108
|
-
/**
|
|
128
|
+
/** Orders on this page the connector could not read and left out; absent when every order read. */
|
|
129
|
+
unreadable?: number;
|
|
130
|
+
/** Every order the query matches across all pages; undefined when the store gives no count. It still counts orders left out as `unreadable`. */
|
|
109
131
|
total?: number;
|
|
110
132
|
}
|
|
@@ -101,3 +101,20 @@ export function paymentMethodOf(kind: PaymentMethodKind): PaymentMethodDescripto
|
|
|
101
101
|
export function defaultPaymentMethods(): PaymentMethodDescriptor[] {
|
|
102
102
|
return [paymentMethodOf('cash'), paymentMethodOf('external')];
|
|
103
103
|
}
|
|
104
|
+
|
|
105
|
+
/** The descriptor kinds whose wire method is 'cash'. */
|
|
106
|
+
const CASH_KINDS: readonly string[] = ['cash'];
|
|
107
|
+
/** The order's wire method for a descriptor (ruling A, 2026-11-18): a cash-kind method is 'cash', every other kind 'external'. The one kind→method rule. */
|
|
108
|
+
export function wireMethodOf(descriptor: Pick<PaymentMethodDescriptor, 'kind'>): PaymentMethodKind {
|
|
109
|
+
return CASH_KINDS.includes(descriptor.kind) ? 'cash' : 'external';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* A leg's takings key, for labels, takings and report rows: its wire `method` when it has no `methodId` or the id is the
|
|
114
|
+
* method itself (exactly the key before methodId), else `${method}:${methodId}`. Kind plus id, so that a non-cash method
|
|
115
|
+
* whose platform id happens to be `cash` (`{ method: 'external', methodId: 'cash' }`) never merges with cash. Never for
|
|
116
|
+
* cash decisions or register rows: those read `method`.
|
|
117
|
+
*/
|
|
118
|
+
export function legMethodId(leg: { method: string; methodId?: string }): string {
|
|
119
|
+
return leg.methodId === undefined || leg.methodId === leg.method ? leg.method : `${leg.method}:${leg.methodId}`;
|
|
120
|
+
}
|
package/src/types/stock.ts
CHANGED
|
@@ -15,4 +15,6 @@ export interface StockLevel {
|
|
|
15
15
|
status: StockStatus;
|
|
16
16
|
/** Units on hand, when tracked. May be negative on backorder. */
|
|
17
17
|
quantity?: number;
|
|
18
|
+
/** Whether the backend takes orders beyond `quantity` (WooCommerce's `backorders`): `no` refuses, `notify` takes them and tells the customer, `yes` takes them. Absent: the backend did not say. */
|
|
19
|
+
backorders?: 'no' | 'notify' | 'yes';
|
|
18
20
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MoneyFormat } from '../money';
|
|
1
2
|
import type { TaxRounding } from './connector';
|
|
2
3
|
import type { TaxAddress, TaxBasedOn } from '../tax/woocommerce/tax-location';
|
|
3
4
|
import type { WooTaxRate } from '../tax/woocommerce/types';
|
|
@@ -27,6 +28,10 @@ export interface StoreSettings {
|
|
|
27
28
|
taxRoundAtSubtotal?: boolean;
|
|
28
29
|
/** WooCommerce's calculate coupon discounts sequentially setting. */
|
|
29
30
|
calcDiscountsSequentially?: boolean;
|
|
31
|
+
/** WCPOS's "prevent overselling" store setting: WCPOS v2's stock guard runs only when it is on. Absent: the connector did not read it; treat it as off. */
|
|
32
|
+
preventOverselling?: boolean;
|
|
33
|
+
/** The store's own money format, for `@tallyui/pos`'s `CurrencyProvider` `format`, and how typed amounts are read (#672); rounding and orders never read it. Absent: the connector did not read one; money reads through Intl as before. */
|
|
34
|
+
moneyFormat?: MoneyFormat;
|
|
30
35
|
shippingTaxClass?: string;
|
|
31
36
|
taxClassSlugs?: string[];
|
|
32
37
|
/** The tax classes with their display names, in the store's order. Display only. Absent when the connector did not read them. */
|
|
@@ -70,6 +75,8 @@ export interface StoreTaxRate {
|
|
|
70
75
|
compound?: boolean;
|
|
71
76
|
/** Whether the rate also applies to shipping. */
|
|
72
77
|
shipping?: boolean;
|
|
78
|
+
/** The backend's conditions for an override rate (Medusa: a rate that applies only to the listed records), as `reference` (the kind, e.g. `product_type`) and `referenceId`. Absent for a rate with none, and from a backend without rules. */
|
|
79
|
+
rules?: { reference: string; referenceId: string }[];
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
/**
|
|
@@ -5,6 +5,19 @@ import type { StockLevel } from '../stock';
|
|
|
5
5
|
export interface ProductCategory {
|
|
6
6
|
id: string;
|
|
7
7
|
name: string;
|
|
8
|
+
/** The category's picture (absolute URL); a browse tile shows it, else the name's initial on a tint. */
|
|
9
|
+
imageUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** A label a product carries, grouped (a Vendure facet value, a WooCommerce tag or brand). Ids are the backend's, as strings. */
|
|
13
|
+
export interface ProductTerm {
|
|
14
|
+
/** The group's id, unique per backend (e.g. the facet's id, or 'tag'). */
|
|
15
|
+
group: string;
|
|
16
|
+
/** The group's label, e.g. "Brand". */
|
|
17
|
+
groupName: string;
|
|
18
|
+
/** The term's id, unique within its group. */
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
/** One purchasable variant of a product, in backend-neutral terms. */
|
|
@@ -148,6 +161,12 @@ export interface ProductTraits<Doc = any> {
|
|
|
148
161
|
*/
|
|
149
162
|
getCategories?: (doc: Doc) => ProductCategory[];
|
|
150
163
|
|
|
164
|
+
/**
|
|
165
|
+
* The product's terms (facet values, tags, brands), each in its group.
|
|
166
|
+
* Optional: without it a product has no terms, and Catalogue shows no term pills.
|
|
167
|
+
*/
|
|
168
|
+
getTerms?: (doc: Doc) => ProductTerm[];
|
|
169
|
+
|
|
151
170
|
/** The connector-specific unique ID (as string for consistency) */
|
|
152
171
|
getId: (doc: Doc) => string;
|
|
153
172
|
}
|