@tallyui/core 3.20.1 → 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
|
@@ -53,12 +53,26 @@ interface StockLevel {
|
|
|
53
53
|
status: StockStatus;
|
|
54
54
|
/** Units on hand, when tracked. May be negative on backorder. */
|
|
55
55
|
quantity?: number;
|
|
56
|
+
/** 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. */
|
|
57
|
+
backorders?: 'no' | 'notify' | 'yes';
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/** A flat product category: `id` is the backend's id as a string (unique per backend), `name` its label. */
|
|
59
61
|
interface ProductCategory {
|
|
60
62
|
id: string;
|
|
61
63
|
name: string;
|
|
64
|
+
/** The category's picture (absolute URL); a browse tile shows it, else the name's initial on a tint. */
|
|
65
|
+
imageUrl?: string;
|
|
66
|
+
}
|
|
67
|
+
/** A label a product carries, grouped (a Vendure facet value, a WooCommerce tag or brand). Ids are the backend's, as strings. */
|
|
68
|
+
interface ProductTerm {
|
|
69
|
+
/** The group's id, unique per backend (e.g. the facet's id, or 'tag'). */
|
|
70
|
+
group: string;
|
|
71
|
+
/** The group's label, e.g. "Brand". */
|
|
72
|
+
groupName: string;
|
|
73
|
+
/** The term's id, unique within its group. */
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
62
76
|
}
|
|
63
77
|
/** One purchasable variant of a product, in backend-neutral terms. */
|
|
64
78
|
interface VariantSummary {
|
|
@@ -174,6 +188,11 @@ interface ProductTraits<Doc = any> {
|
|
|
174
188
|
* Optional: without it, the pos category helpers use `getCategoryNames` with each name as its id.
|
|
175
189
|
*/
|
|
176
190
|
getCategories?: (doc: Doc) => ProductCategory[];
|
|
191
|
+
/**
|
|
192
|
+
* The product's terms (facet values, tags, brands), each in its group.
|
|
193
|
+
* Optional: without it a product has no terms, and Catalogue shows no term pills.
|
|
194
|
+
*/
|
|
195
|
+
getTerms?: (doc: Doc) => ProductTerm[];
|
|
177
196
|
/** The connector-specific unique ID (as string for consistency) */
|
|
178
197
|
getId: (doc: Doc) => string;
|
|
179
198
|
}
|
|
@@ -356,6 +375,59 @@ interface CatalogueReconcileAdapter<Doc = any, Cursor = unknown> {
|
|
|
356
375
|
refetchBatchSize?: number;
|
|
357
376
|
}
|
|
358
377
|
|
|
378
|
+
/** Number of minor-unit digits for an ISO 4217 code (2 for EUR, 0 for JPY). */
|
|
379
|
+
declare function minorUnitDigits(currency: string): number;
|
|
380
|
+
/** The currency's symbol for a plain-English label ('€' for EUR, '$' for USD), not a full amount. */
|
|
381
|
+
declare function currencySymbol(currency: string, locale?: string): string;
|
|
382
|
+
/**
|
|
383
|
+
* Converts a major-unit amount ('12.50', 12.5) into Money.
|
|
384
|
+
* Returns undefined for empty or non-numeric input.
|
|
385
|
+
*/
|
|
386
|
+
declare function moneyFromMajor(value: string | number | null | undefined, currency: string): Money | undefined;
|
|
387
|
+
/** Parses trimmed decimal text into safe integer minor units, without rounding. */
|
|
388
|
+
declare function moneyFromDecimalString(text: string, currency: string): Money | undefined;
|
|
389
|
+
/**
|
|
390
|
+
* Converts Money back to a major-unit number, e.g. for Intl formatting.
|
|
391
|
+
* @deprecated Use `minorToMajor(money.amount, minorUnitDigits(money.currency))`, which returns an exact decimal string instead of a float.
|
|
392
|
+
*/
|
|
393
|
+
declare function moneyToMajor(money: Money): number;
|
|
394
|
+
/** A store's own money format (WCPOS v2 General settings); a field left out keeps the locale's. */
|
|
395
|
+
interface MoneyFormat {
|
|
396
|
+
position?: 'left' | 'right' | 'left_space' | 'right_space';
|
|
397
|
+
thousandSeparator?: string;
|
|
398
|
+
decimalSeparator?: string;
|
|
399
|
+
decimals?: number;
|
|
400
|
+
/** The store's currency symbol as plain text (e.g. WooCommerce's `currency_symbol` with HTML entities decoded); Intl's symbol for the currency and locale when unset. */
|
|
401
|
+
symbol?: string;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Formats Money for display with Intl, e.g. '€12.50' or '¥1,200'.
|
|
405
|
+
* Returns undefined for 'XXX' (currency unknown), so callers can fall back.
|
|
406
|
+
*/
|
|
407
|
+
declare function formatMoney(money: Money, locale?: string, format?: MoneyFormat): string | undefined;
|
|
408
|
+
/**
|
|
409
|
+
* A typed amount in the store's separators as plain decimal text ('1.234,50' → '1234.50'); ported from WCPOS v2 typed-field.tsx parseNumber.
|
|
410
|
+
* Without a format the text is untouched; it never rounds, so too many places stay the caller's refusal (#672).
|
|
411
|
+
*/
|
|
412
|
+
declare function normalizeMoneyText(text: string, format?: MoneyFormat): string;
|
|
413
|
+
/**
|
|
414
|
+
* Picks the price to charge from a price list, in `currency` if given, else in
|
|
415
|
+
* the first currency listed. A sale entry wins over the base entry.
|
|
416
|
+
*/
|
|
417
|
+
declare function resolvePrice(prices: ProductPrice[], currency?: string): ResolvedPrice | undefined;
|
|
418
|
+
/**
|
|
419
|
+
* The lowest and highest price to charge across variants, in `currency` if
|
|
420
|
+
* given, else each variant's first currency; undefined when no variant
|
|
421
|
+
* resolves. Only amounts in the first resolved variant's currency are
|
|
422
|
+
* compared; a variant that resolves to another currency is skipped.
|
|
423
|
+
*/
|
|
424
|
+
declare function resolvePriceRange(variants: Array<{
|
|
425
|
+
prices: ProductPrice[];
|
|
426
|
+
}>, currency?: string): {
|
|
427
|
+
min: Money;
|
|
428
|
+
max: Money;
|
|
429
|
+
} | undefined;
|
|
430
|
+
|
|
359
431
|
/** WooCommerce's "Calculate tax based on" (`woocommerce_tax_based_on`). */
|
|
360
432
|
type TaxBasedOn = 'base' | 'billing' | 'shipping';
|
|
361
433
|
/** The address WooCommerce matches tax rates against. */
|
|
@@ -471,6 +543,10 @@ interface StoreSettings {
|
|
|
471
543
|
taxRoundAtSubtotal?: boolean;
|
|
472
544
|
/** WooCommerce's calculate coupon discounts sequentially setting. */
|
|
473
545
|
calcDiscountsSequentially?: boolean;
|
|
546
|
+
/** 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. */
|
|
547
|
+
preventOverselling?: boolean;
|
|
548
|
+
/** 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. */
|
|
549
|
+
moneyFormat?: MoneyFormat;
|
|
474
550
|
shippingTaxClass?: string;
|
|
475
551
|
taxClassSlugs?: string[];
|
|
476
552
|
/** The tax classes with their display names, in the store's order. Display only. Absent when the connector did not read them. */
|
|
@@ -514,6 +590,11 @@ interface StoreTaxRate {
|
|
|
514
590
|
compound?: boolean;
|
|
515
591
|
/** Whether the rate also applies to shipping. */
|
|
516
592
|
shipping?: boolean;
|
|
593
|
+
/** 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. */
|
|
594
|
+
rules?: {
|
|
595
|
+
reference: string;
|
|
596
|
+
referenceId: string;
|
|
597
|
+
}[];
|
|
517
598
|
}
|
|
518
599
|
/**
|
|
519
600
|
* Picks among several regions, countries or sales channels when the store has more than one.
|
|
@@ -610,9 +691,13 @@ interface CommandEnvelope<P = unknown> {
|
|
|
610
691
|
/** 3 when the order carries ADR-065's `display` and `taxByRate` (the store accepts 3), else 2 when discounted, else 1;
|
|
611
692
|
* 4 is 3 with every `discountMinor` tax-exclusive, built only when capped at 4 or more (#286).
|
|
612
693
|
* 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
694
|
+
* 6 is 5 plus coupons, regular prices, line attributes and Any picks (ADR-077, #495), sent only for an order that has one.
|
|
613
695
|
* 7 is 6 plus the sale's `note` (ADR-083), sent only for an order that has one.
|
|
614
|
-
* 8 is 7 plus `taxAddress` and the customer's addresses (#722), sent only for a sale taxed on the customer's address.
|
|
615
|
-
|
|
696
|
+
* 8 is 7 plus `taxAddress` and the customer's addresses (#722), sent only for a sale taxed on the customer's address.
|
|
697
|
+
* 9 is 8 plus each coupon's per-line amounts (`coupons[].lines`, #790), sent only when every coupon carries them; it needs no `taxAddress`.
|
|
698
|
+
* 11 is 10 plus the customer's addresses on a sale with no taxAddress, as informational fields (ADR-086 d2 amended).
|
|
699
|
+
* 12 is 11 plus the customer's tax ids, a catalogue line's edited SKU and order meta, as informational fields (ADR-092). */
|
|
700
|
+
version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
616
701
|
payload: P;
|
|
617
702
|
createdAt: string;
|
|
618
703
|
deviceId: string;
|
|
@@ -626,7 +711,7 @@ type RegisterCommandEnvelope<P = Record<string, unknown>> = Omit<CommandEnvelope
|
|
|
626
711
|
version: number;
|
|
627
712
|
};
|
|
628
713
|
/** Any command a transport can carry. */
|
|
629
|
-
type AnyCommandEnvelope = CommandEnvelope<unknown> | RegisterCommandEnvelope<unknown> | OrderRefundEnvelope<unknown>;
|
|
714
|
+
type AnyCommandEnvelope = CommandEnvelope<unknown> | RegisterCommandEnvelope<unknown> | OrderRefundEnvelope<unknown> | OrderReopenEnvelope<unknown> | OrderUpdateEnvelope<unknown>;
|
|
630
715
|
/** A line's refunded quantity and restock choice (ADR-080). */
|
|
631
716
|
interface OrderRefundLine {
|
|
632
717
|
orderLineId: string;
|
|
@@ -688,11 +773,85 @@ interface OrderRefundOrderStateData {
|
|
|
688
773
|
interface OrderRefundNoOpenSessionData {
|
|
689
774
|
sessionId: string;
|
|
690
775
|
}
|
|
776
|
+
/** An online reopen against a store order, attributed to the cashier and register (ADR-090). */
|
|
777
|
+
interface OrderReopenPayload {
|
|
778
|
+
orderId: string;
|
|
779
|
+
clientOrderId?: string;
|
|
780
|
+
baseRevision?: string;
|
|
781
|
+
cashierRef: string;
|
|
782
|
+
registerId: string;
|
|
783
|
+
storeId?: string;
|
|
784
|
+
createdAt: string;
|
|
785
|
+
}
|
|
786
|
+
/** An order.reopen v1 command with the shared idempotency envelope (ADR-090). */
|
|
787
|
+
type OrderReopenEnvelope<P = OrderReopenPayload> = Omit<CommandEnvelope<P>, 'type' | 'version'> & {
|
|
788
|
+
type: 'order.reopen';
|
|
789
|
+
version: 1;
|
|
790
|
+
};
|
|
791
|
+
/** The reopened order's server identity, status and revision (ADR-090). */
|
|
792
|
+
interface OrderReopenResult {
|
|
793
|
+
orderId: string;
|
|
794
|
+
status: string;
|
|
795
|
+
revision?: string;
|
|
796
|
+
}
|
|
797
|
+
/** Per-command reopen refusals (ADR-090). */
|
|
798
|
+
type OrderReopenRejectionCode = 'payment_in_motion' | 'order_state' | 'revision_conflict' | 'forbidden';
|
|
799
|
+
/** The payment or attempt preventing a reopen (ADR-090). */
|
|
800
|
+
interface OrderReopenPaymentInMotionData {
|
|
801
|
+
paymentId?: string;
|
|
802
|
+
attemptId?: string;
|
|
803
|
+
}
|
|
804
|
+
/** The order state preventing a reopen and the store's refusal code (ADR-090). */
|
|
805
|
+
interface OrderReopenOrderStateData {
|
|
806
|
+
state: string;
|
|
807
|
+
storeCode?: string;
|
|
808
|
+
}
|
|
809
|
+
/** A kept line's store order-item id, absent on a new line (ADR-090). */
|
|
810
|
+
type OrderUpdateLine = OrderCreateLine & {
|
|
811
|
+
storeLineId?: string;
|
|
812
|
+
};
|
|
813
|
+
/** A kept fee's store order-item id, absent on a new fee (ADR-090). */
|
|
814
|
+
type OrderUpdateFee = OrderCreateFee & {
|
|
815
|
+
storeLineId?: string;
|
|
816
|
+
};
|
|
817
|
+
/** A kept shipping charge's store order-item id, absent on a new charge (ADR-090). */
|
|
818
|
+
type OrderUpdateShipping = OrderCreateShipping & {
|
|
819
|
+
storeLineId?: string;
|
|
820
|
+
};
|
|
821
|
+
/** A payment already on the order carries its store id and is never re-taken (ADR-090). */
|
|
822
|
+
type OrderUpdatePayment = OrderCreatePayment & {
|
|
823
|
+
paymentId?: string;
|
|
824
|
+
};
|
|
825
|
+
/** The reopened sale's whole new state, checked by its named order.create version (ADR-090). */
|
|
826
|
+
interface OrderUpdatePayload extends Omit<OrderCreatePayload, 'lines' | 'payments' | 'fees' | 'shipping'> {
|
|
827
|
+
orderId: string;
|
|
828
|
+
baseRevision?: string;
|
|
829
|
+
createVersion: OrderCreateEnvelope['version'];
|
|
830
|
+
lines: OrderUpdateLine[];
|
|
831
|
+
payments: OrderUpdatePayment[];
|
|
832
|
+
fees?: OrderUpdateFee[];
|
|
833
|
+
shipping?: OrderUpdateShipping[];
|
|
834
|
+
}
|
|
835
|
+
/** An order.update v1 command with the shared idempotency envelope (ADR-090). */
|
|
836
|
+
type OrderUpdateEnvelope<P = OrderUpdatePayload> = Omit<CommandEnvelope<P>, 'type' | 'version'> & {
|
|
837
|
+
type: 'order.update';
|
|
838
|
+
version: 1;
|
|
839
|
+
};
|
|
840
|
+
/** Per-command update refusals; payment_in_motion reuses OrderReopenPaymentInMotionData (ADR-090). */
|
|
841
|
+
type OrderUpdateRejectionCode = 'payment_in_motion' | 'reopen_required' | 'revision_conflict';
|
|
842
|
+
/** The order status preventing an update until it is reopened (ADR-090). */
|
|
843
|
+
interface OrderUpdateReopenRequiredData {
|
|
844
|
+
orderStatus: string;
|
|
845
|
+
}
|
|
691
846
|
/** An order.create envelope: 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
692
|
-
*
|
|
847
|
+
* 6 is 5 plus coupons, regular prices, line attributes and Any picks (ADR-077, #495).
|
|
848
|
+
* 7 is 6 plus the sale's note (ADR-083). 8 is 7 plus `taxAddress` and the customer's addresses (#722).
|
|
849
|
+
* 9 is 8 plus each coupon's per-line amounts (`coupons[].lines`, #790), sent only when every coupon carries them; it needs no `taxAddress`.
|
|
850
|
+
* 11 is 10 plus the customer's addresses on a sale with no taxAddress, as informational fields (ADR-086 d2 amended).
|
|
851
|
+
* 12 is 11 plus the customer's tax ids, a catalogue line's edited SKU and order meta, as informational fields (ADR-092). */
|
|
693
852
|
type OrderCreateEnvelope = CommandEnvelope<OrderCreatePayload> & {
|
|
694
853
|
type: 'order.create';
|
|
695
|
-
version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
854
|
+
version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
696
855
|
};
|
|
697
856
|
/** Outcome of processing a command. */
|
|
698
857
|
type CommandStatus = 'applied' | 'duplicate' | 'rejected';
|
|
@@ -767,6 +926,21 @@ type CommandWarning = {
|
|
|
767
926
|
tillMinor: number;
|
|
768
927
|
serverMinor: number;
|
|
769
928
|
}>;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* One warning per sale, never a refusal: each line figure that differs from the server's own computation,
|
|
932
|
+
* once per (line, figure), with both values. `lineId` is the line's order.create `clientLineId`.
|
|
933
|
+
* `figures_mismatch` stays the order-level one. `parseCommandResult` refuses a `field` it doesn't know;
|
|
934
|
+
* `knownWarnings` keeps it (a newer store's figure).
|
|
935
|
+
*/
|
|
936
|
+
| {
|
|
937
|
+
code: 'line_figures_mismatch';
|
|
938
|
+
lines: Array<{
|
|
939
|
+
lineId: string;
|
|
940
|
+
field: 'subtotalMinor' | 'taxMinor' | 'discountMinor' | 'totalMinor' | (string & {});
|
|
941
|
+
tillMinor: number;
|
|
942
|
+
serverMinor: number;
|
|
943
|
+
}>;
|
|
770
944
|
};
|
|
771
945
|
/** Error reported when a command is rejected. */
|
|
772
946
|
interface CommandError {
|
|
@@ -802,6 +976,7 @@ interface CommandResult {
|
|
|
802
976
|
error?: CommandError;
|
|
803
977
|
register?: RegisterCommandResult;
|
|
804
978
|
refund?: OrderRefundResult;
|
|
979
|
+
reopen?: OrderReopenResult;
|
|
805
980
|
}
|
|
806
981
|
/** A register command's server figures (registers c2b applies them). */
|
|
807
982
|
interface RegisterCommandResult {
|
|
@@ -949,6 +1124,8 @@ interface OrderCreateLine {
|
|
|
949
1124
|
taxStatus: 'taxable' | 'none';
|
|
950
1125
|
};
|
|
951
1126
|
title?: string;
|
|
1127
|
+
/** Version 12 (ADR-092): a catalogue line's SKU as the cashier edited it, 1–100 characters; a custom line uses `custom.sku`. */
|
|
1128
|
+
sku?: string;
|
|
952
1129
|
quantity: number;
|
|
953
1130
|
unitPriceMinor: number;
|
|
954
1131
|
/** 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. */
|
|
@@ -981,6 +1158,17 @@ interface OrderCreateCoupon {
|
|
|
981
1158
|
discountMinor: number;
|
|
982
1159
|
/** The tax on that discount, integer >= 0. */
|
|
983
1160
|
discountTaxMinor: number;
|
|
1161
|
+
/** Version 9 (#790): this coupon's share of each line it reduced; present on every coupon at 9, never below. */
|
|
1162
|
+
lines?: OrderCreateCouponLine[];
|
|
1163
|
+
}
|
|
1164
|
+
/** Version 9 (#790): one coupon's share of one line, in integer minor units; see docs/contract/order-create-v9.md. */
|
|
1165
|
+
interface OrderCreateCouponLine {
|
|
1166
|
+
/** A `payload.lines[].clientLineId`. */
|
|
1167
|
+
clientLineId: string;
|
|
1168
|
+
/** This coupon's discount on that line, tax-exclusive, integer >= 0. */
|
|
1169
|
+
discountMinor: number;
|
|
1170
|
+
/** The tax on it, integer >= 0. */
|
|
1171
|
+
discountTaxMinor: number;
|
|
984
1172
|
}
|
|
985
1173
|
/** Version 5: a fee, never discounted (ADR-075). */
|
|
986
1174
|
interface OrderCreateFee {
|
|
@@ -1014,6 +1202,8 @@ interface OrderCreatePayment {
|
|
|
1014
1202
|
tenderedMinor?: number;
|
|
1015
1203
|
changeMinor?: number;
|
|
1016
1204
|
reference?: string;
|
|
1205
|
+
/** 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. */
|
|
1206
|
+
methodId?: string;
|
|
1017
1207
|
}
|
|
1018
1208
|
/** Version 3 (ADR-065): the receipt's display figures, integer minor units of `currency` at `exponent`. */
|
|
1019
1209
|
interface OrderCreateDisplay {
|
|
@@ -1095,12 +1285,14 @@ interface OrderCreatePayload {
|
|
|
1095
1285
|
email?: string;
|
|
1096
1286
|
/** 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. */
|
|
1097
1287
|
customerId?: string;
|
|
1098
|
-
/** Version 8 (#722): the customer's billing address, sent
|
|
1288
|
+
/** Version 8 (#722): the customer's billing address, sent at 8+ with `taxAddress` and at 11 without it. */
|
|
1099
1289
|
billing?: OrderAddress;
|
|
1100
|
-
/** Version 8 (#722): the customer's shipping address, sent
|
|
1290
|
+
/** Version 8 (#722): the customer's shipping address, sent at 8+ with `taxAddress` and at 11 without it. */
|
|
1101
1291
|
shipping?: OrderAddress;
|
|
1292
|
+
/** Version 12 (ADR-092): the customer's tax ids on this sale, at most ORDER_TAX_IDS_MAX (10). */
|
|
1293
|
+
taxIds?: OrderCreateTaxId[];
|
|
1102
1294
|
} | null;
|
|
1103
|
-
/** Version 8 (#722): the customer address the till taxed the sale on; always present at 8, and that address has a
|
|
1295
|
+
/** Version 8 (#722): the customer address the till taxed the sale on; always present at 8; optional at 9, and that address has a
|
|
1104
1296
|
* non-empty `country`. Absent: the store's base address. */
|
|
1105
1297
|
taxAddress?: 'billing' | 'shipping';
|
|
1106
1298
|
registerId?: string;
|
|
@@ -1110,6 +1302,20 @@ interface OrderCreatePayload {
|
|
|
1110
1302
|
sessionId?: string;
|
|
1111
1303
|
/** Version 7 (ADR-083): the sale's note, 1 to ORDER_NOTE_MAX UTF-16 units; omitted when the sale has none. */
|
|
1112
1304
|
note?: string;
|
|
1305
|
+
/** Version 12 (ADR-092): the order's custom fields, at most ORDER_META_MAX (50), keys unique; omitted when none. */
|
|
1306
|
+
meta?: OrderCreateMeta[];
|
|
1307
|
+
}
|
|
1308
|
+
/** A customer tax id on order.create 12 (ADR-092): `type` 1–32 UTF-16 units (the connector's scheme id), `value` 1–64,
|
|
1309
|
+
* `country` an ISO 3166-1 alpha-2 code. */
|
|
1310
|
+
interface OrderCreateTaxId {
|
|
1311
|
+
type: string;
|
|
1312
|
+
value: string;
|
|
1313
|
+
country?: string;
|
|
1314
|
+
}
|
|
1315
|
+
/** An order custom field on order.create 12 (ADR-092): `key` 1–255 UTF-16 units, not starting with `_`; `value` 0–ORDER_NOTE_MAX. */
|
|
1316
|
+
interface OrderCreateMeta {
|
|
1317
|
+
key: string;
|
|
1318
|
+
value: string;
|
|
1113
1319
|
}
|
|
1114
1320
|
/** A customer's address on order.create v8 (#722): each field a string of at most 255 UTF-16 units; no email, which
|
|
1115
1321
|
* `customer.email` carries. */
|
|
@@ -1164,11 +1370,21 @@ interface StoreOrderLine {
|
|
|
1164
1370
|
/** A fee or shipping line: excluding tax, the tax beside it. A fee may be negative.
|
|
1165
1371
|
* `taxMinor` is such that `totalMinor + taxMinor` is the gross rounded once. */
|
|
1166
1372
|
interface StoreOrderCharge {
|
|
1373
|
+
/** The store's order-item id, which `OrderUpdateFee.storeLineId` / `OrderUpdateShipping.storeLineId` names; absent when the store gives none. */
|
|
1374
|
+
id?: string;
|
|
1167
1375
|
name: string;
|
|
1168
1376
|
totalMinor: number;
|
|
1169
1377
|
taxMinor: number;
|
|
1378
|
+
/** The tax status the store recorded on the fee or shipping line; absent when the store's response carries none. */
|
|
1379
|
+
taxStatus?: 'taxable' | 'none';
|
|
1380
|
+
/** A fee's recorded tax class; absent means the standard class. Shipping lines carry none. */
|
|
1381
|
+
taxClass?: string;
|
|
1382
|
+
/** A shipping line's recorded method id. */
|
|
1383
|
+
methodId?: string;
|
|
1170
1384
|
}
|
|
1171
1385
|
interface StoreOrderPayment {
|
|
1386
|
+
/** The store's payment record id, which `OrderUpdatePayment.paymentId` names; absent when the store keeps no per-payment record. */
|
|
1387
|
+
id?: string;
|
|
1172
1388
|
/** The store's own method id, e.g. WooCommerce's `pos_cash`. */
|
|
1173
1389
|
method: string;
|
|
1174
1390
|
/** The store's name for it, e.g. "Cash". */
|
|
@@ -1189,8 +1405,10 @@ interface StoreOrder {
|
|
|
1189
1405
|
id: string;
|
|
1190
1406
|
/** The number the store shows (`CommandServerRefs.displayId`). */
|
|
1191
1407
|
reference: string;
|
|
1192
|
-
/** The till's `PosOrder.id` when a till created the order; absent otherwise. */
|
|
1408
|
+
/** The till's `PosOrder.id` when a till created the order; absent otherwise. It is also what an `order.reopen` sends as `clientOrderId`. */
|
|
1193
1409
|
clientOrderId?: string;
|
|
1410
|
+
/** The store's current revision of the order, which `OrderReopenPayload.baseRevision` and `OrderUpdatePayload.baseRevision` carry; absent when the store has none. */
|
|
1411
|
+
revision?: string;
|
|
1194
1412
|
/** The platform's own status word (WooCommerce: `completed`, `refunded`, …); the app labels it. */
|
|
1195
1413
|
status: string;
|
|
1196
1414
|
/** ISO 8601, UTC. */
|
|
@@ -1223,6 +1441,10 @@ interface StoreOrder {
|
|
|
1223
1441
|
taxMinor: number;
|
|
1224
1442
|
totalMinor: number;
|
|
1225
1443
|
payments: StoreOrderPayment[];
|
|
1444
|
+
/** The store keeps a per-payment record for this order in a shape the connector cannot read
|
|
1445
|
+
* (WooCommerce: a WCPOS payment ledger of another schema); `payments` is then the order's paid-state
|
|
1446
|
+
* fallback, and a reopen must refuse the order. Absent otherwise. */
|
|
1447
|
+
paymentRecordUnreadable?: true;
|
|
1226
1448
|
refunds: StoreOrderRefund[];
|
|
1227
1449
|
}
|
|
1228
1450
|
/** The filter fields a connector may support on listOrders. */
|
|
@@ -1261,7 +1483,9 @@ interface ListOrdersQuery {
|
|
|
1261
1483
|
interface StoreOrderPage {
|
|
1262
1484
|
orders: StoreOrder[];
|
|
1263
1485
|
hasMore: boolean;
|
|
1264
|
-
/**
|
|
1486
|
+
/** Orders on this page the connector could not read and left out; absent when every order read. */
|
|
1487
|
+
unreadable?: number;
|
|
1488
|
+
/** Every order the query matches across all pages; undefined when the store gives no count. It still counts orders left out as `unreadable`. */
|
|
1265
1489
|
total?: number;
|
|
1266
1490
|
}
|
|
1267
1491
|
|
|
@@ -1353,6 +1577,18 @@ interface PaymentMethodDescriptor {
|
|
|
1353
1577
|
declare function paymentMethodOf(kind: PaymentMethodKind): PaymentMethodDescriptor;
|
|
1354
1578
|
/** Today's two methods, cash then the card terminal: what the till offers when the connector has no `paymentMethods`. */
|
|
1355
1579
|
declare function defaultPaymentMethods(): PaymentMethodDescriptor[];
|
|
1580
|
+
/** 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. */
|
|
1581
|
+
declare function wireMethodOf(descriptor: Pick<PaymentMethodDescriptor, 'kind'>): PaymentMethodKind;
|
|
1582
|
+
/**
|
|
1583
|
+
* A leg's takings key, for labels, takings and report rows: its wire `method` when it has no `methodId` or the id is the
|
|
1584
|
+
* method itself (exactly the key before methodId), else `${method}:${methodId}`. Kind plus id, so that a non-cash method
|
|
1585
|
+
* whose platform id happens to be `cash` (`{ method: 'external', methodId: 'cash' }`) never merges with cash. Never for
|
|
1586
|
+
* cash decisions or register rows: those read `method`.
|
|
1587
|
+
*/
|
|
1588
|
+
declare function legMethodId(leg: {
|
|
1589
|
+
method: string;
|
|
1590
|
+
methodId?: string;
|
|
1591
|
+
}): string;
|
|
1356
1592
|
|
|
1357
1593
|
/** What a template prints: a sale's receipt, a report, or a register closure. */
|
|
1358
1594
|
type ReceiptTemplateKind = 'receipt' | 'report' | 'closure';
|
|
@@ -1396,6 +1632,94 @@ interface RegisterInfo {
|
|
|
1396
1632
|
expectedCloseTime?: string;
|
|
1397
1633
|
}
|
|
1398
1634
|
|
|
1635
|
+
/** 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. */
|
|
1636
|
+
interface ApproverCredentials {
|
|
1637
|
+
username: string;
|
|
1638
|
+
password: string;
|
|
1639
|
+
}
|
|
1640
|
+
/** A correction the store appended to a closure (ADR-032, ADR-093), money in integer minor units. */
|
|
1641
|
+
type Correction = {
|
|
1642
|
+
id: number;
|
|
1643
|
+
type: 'late_sale' | 'late_refund' | 'late_movement' | 'recount';
|
|
1644
|
+
created_at: string;
|
|
1645
|
+
actor: {
|
|
1646
|
+
id: string;
|
|
1647
|
+
name: string;
|
|
1648
|
+
};
|
|
1649
|
+
approver: {
|
|
1650
|
+
id: string;
|
|
1651
|
+
name: string;
|
|
1652
|
+
} | null;
|
|
1653
|
+
reason: string;
|
|
1654
|
+
figures: {
|
|
1655
|
+
expected_delta?: Record<string, number>;
|
|
1656
|
+
cash_delta?: number;
|
|
1657
|
+
sales_delta?: number;
|
|
1658
|
+
refunds_delta?: number;
|
|
1659
|
+
counted?: Record<string, number>;
|
|
1660
|
+
variance?: Record<string, number>;
|
|
1661
|
+
};
|
|
1662
|
+
};
|
|
1663
|
+
/** 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. */
|
|
1664
|
+
interface StoreClosure {
|
|
1665
|
+
id: string;
|
|
1666
|
+
number: number;
|
|
1667
|
+
registerId: string;
|
|
1668
|
+
sessionId: string;
|
|
1669
|
+
storeId?: string;
|
|
1670
|
+
reason: string;
|
|
1671
|
+
businessDay?: string;
|
|
1672
|
+
openedAt: string;
|
|
1673
|
+
closedAt: string;
|
|
1674
|
+
printedAt?: string;
|
|
1675
|
+
printCount: number;
|
|
1676
|
+
lastPrintedAt?: string;
|
|
1677
|
+
expected?: Record<string, number>;
|
|
1678
|
+
tillExpected?: Record<string, number>;
|
|
1679
|
+
counted?: Record<string, number>;
|
|
1680
|
+
variance?: Record<string, number>;
|
|
1681
|
+
periodSalesTotalMinor?: number;
|
|
1682
|
+
periodRefundsTotalMinor?: number;
|
|
1683
|
+
perpetualSalesTotalMinor?: number;
|
|
1684
|
+
perpetualRefundsTotalMinor?: number;
|
|
1685
|
+
unsyncedCount: number;
|
|
1686
|
+
unsyncedTotalMinor?: number;
|
|
1687
|
+
correctionsCount?: number;
|
|
1688
|
+
corrections?: Correction[];
|
|
1689
|
+
}
|
|
1690
|
+
/** The store's Z closures (ADR-093): online, read-through. Reads reject with `ConnectorUnauthorizedError` for a 401 or 403. */
|
|
1691
|
+
interface ClosureReads {
|
|
1692
|
+
/** Newest first. `hasMore` is true when the page came back full. */
|
|
1693
|
+
list(context: SyncContext, query?: {
|
|
1694
|
+
registerId?: string;
|
|
1695
|
+
after?: string;
|
|
1696
|
+
before?: string;
|
|
1697
|
+
page?: number;
|
|
1698
|
+
perPage?: number;
|
|
1699
|
+
}): Promise<{
|
|
1700
|
+
items: StoreClosure[];
|
|
1701
|
+
hasMore: boolean;
|
|
1702
|
+
}>;
|
|
1703
|
+
/** One closure with its `corrections`; `null` when the store has none by that id. */
|
|
1704
|
+
get(context: SyncContext, id: string): Promise<StoreClosure | null>;
|
|
1705
|
+
last(context: SyncContext, registerId: string): Promise<StoreClosure | null>;
|
|
1706
|
+
/** Appends a recount (`counted` names every tender, `cash` included). Replay-safe by `correctionId`. `closure` is absent when this user may not read closures. */
|
|
1707
|
+
recount(context: SyncContext, id: string, input: {
|
|
1708
|
+
correctionId: string;
|
|
1709
|
+
counted: Record<string, number>;
|
|
1710
|
+
reason: string;
|
|
1711
|
+
approval?: ApproverCredentials;
|
|
1712
|
+
}): Promise<{
|
|
1713
|
+
closure?: StoreClosure;
|
|
1714
|
+
} | {
|
|
1715
|
+
refused: 'approval_required' | 'approval_invalid' | 'approval_forbidden' | 'not_found';
|
|
1716
|
+
}>;
|
|
1717
|
+
/** Records one print and returns the closure; `forbidden` when this user may not print closures. */
|
|
1718
|
+
markPrinted(context: SyncContext, id: string): Promise<StoreClosure | {
|
|
1719
|
+
refused: 'forbidden' | 'not_found';
|
|
1720
|
+
}>;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1399
1723
|
/**
|
|
1400
1724
|
* The neutral POS permissions a connector resolves from its own model (v2 parity A12):
|
|
1401
1725
|
* - `viewReports`: Reports, and a count that shows the expected figures (not blind);
|
|
@@ -1485,6 +1809,8 @@ type DisplaySignallingErrorCode =
|
|
|
1485
1809
|
| 'collect_refused'
|
|
1486
1810
|
/** Till side: an id this device does not own, or one that is unknown or expired. */
|
|
1487
1811
|
| 'not_found'
|
|
1812
|
+
/** 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. */
|
|
1813
|
+
| 'device_refused'
|
|
1488
1814
|
/** Display side: a token that is unknown, forgotten or pruned. */
|
|
1489
1815
|
| 'token_refused'
|
|
1490
1816
|
/** A snapshot whose JSON is over 200 KiB. */
|
|
@@ -1523,6 +1849,11 @@ interface DisplayRecord {
|
|
|
1523
1849
|
/** Whether the display was seen recently (the reference server: within the last 30 s). */
|
|
1524
1850
|
connected: boolean;
|
|
1525
1851
|
}
|
|
1852
|
+
/** The till's credential on every till-side call: its device id and the key `registerDevice` issued for it. Core treats `deviceKey` as opaque. */
|
|
1853
|
+
interface TillDevice {
|
|
1854
|
+
deviceId: string;
|
|
1855
|
+
deviceKey: string;
|
|
1856
|
+
}
|
|
1526
1857
|
/** One WebRTC signalling message; `payload` is opaque to the server. */
|
|
1527
1858
|
interface SignalMessage {
|
|
1528
1859
|
type: 'offer' | 'answer' | 'ice';
|
|
@@ -1532,42 +1863,55 @@ interface SignalMessage {
|
|
|
1532
1863
|
* The platform-neutral signalling seam for a second-device customer display (ADR-085 d2). Each backend's plugin
|
|
1533
1864
|
* implements the routes its own way; every implementation meets this floor (d4–d6, d8, #705), which
|
|
1534
1865
|
* `displaySignallingContract` in `@tallyui/core/server` tests. A plugin may be stricter.
|
|
1535
|
-
* Till side: every call takes a cashier session and the till's
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
1538
|
-
* `DisplaySignallingError`.
|
|
1866
|
+
* Till side: every call takes a cashier session and the till's `TillDevice`; the refusal order is `forbidden` (a
|
|
1867
|
+
* session without `customer_display.pair`), then `device_refused` (the device key), then `not_found` (an id this device
|
|
1868
|
+
* does not own), and a refused call has no effect. Display side: no login; calls are gated by the display's token
|
|
1869
|
+
* (`token_refused`), and each successful token call updates `lastSeenAt`. Every refusal is a `DisplaySignallingError`.
|
|
1870
|
+
* The device key is the till's credential (TallyUI#754). An implementation compares key hashes in constant time, never
|
|
1871
|
+
* logs the key, never puts it in an error or a response body, and never returns it after issue. The device id is an
|
|
1872
|
+
* identifier, not a credential, anywhere, including the device id in order data (`order.create`).
|
|
1539
1873
|
*/
|
|
1540
1874
|
interface DisplaySignalling {
|
|
1875
|
+
/**
|
|
1876
|
+
* Issues the device key for `deviceId`, needing `customer_display.pair`: 128 bits, base64url, stored only as SHA-256
|
|
1877
|
+
* hex, and returned once, by this call only. An id that already holds a key gives `device_refused`. A pre-migration id
|
|
1878
|
+
* (rows from before device keys, no key hash) adopts them once, logged with the cashier id. An admin reset deletes the
|
|
1879
|
+
* device record with every display, code and pending pairing it owns, so the id registers as new; a reset never returns
|
|
1880
|
+
* an id to the keyless pre-migration state.
|
|
1881
|
+
*/
|
|
1882
|
+
registerDevice(ctx: SyncContext, deviceId: string): Promise<{
|
|
1883
|
+
deviceKey: string;
|
|
1884
|
+
}>;
|
|
1541
1885
|
/** A pairing code: 6+ digits from `crypto.getRandomValues`, single use, live at most 10 minutes; a 6th unspent code per device gives `limit`. */
|
|
1542
|
-
mint(ctx: SyncContext,
|
|
1886
|
+
mint(ctx: SyncContext, device: TillDevice): Promise<{
|
|
1543
1887
|
code: string;
|
|
1544
1888
|
expiresAt: string;
|
|
1545
1889
|
}>;
|
|
1546
1890
|
/** The live claims on codes this device minted, each with its check code. */
|
|
1547
|
-
pending(ctx: SyncContext,
|
|
1891
|
+
pending(ctx: SyncContext, device: TillDevice): Promise<PendingPairing[]>;
|
|
1548
1892
|
/**
|
|
1549
1893
|
* Confirms a claim on a code this device minted, recording the display as owned by this device and cashier. The
|
|
1550
1894
|
* display then collects its token: 128 bits, base64url, stored only as SHA-256 hex. A claim that carried a valid
|
|
1551
1895
|
* token moves that display: its old row, token and snapshot go in the same step, and this device owns the same id.
|
|
1552
1896
|
*/
|
|
1553
|
-
confirm(ctx: SyncContext,
|
|
1897
|
+
confirm(ctx: SyncContext, device: TillDevice, claimId: string): Promise<void>;
|
|
1554
1898
|
/** Declines a claim on a code this device minted: the pending pairing is deleted, and nothing is issued. */
|
|
1555
|
-
decline(ctx: SyncContext,
|
|
1899
|
+
decline(ctx: SyncContext, device: TillDevice, claimId: string): Promise<void>;
|
|
1556
1900
|
/** The displays this device owns. A display unseen for 30 days is pruned with its token and snapshot. */
|
|
1557
|
-
list(ctx: SyncContext,
|
|
1901
|
+
list(ctx: SyncContext, device: TillDevice): Promise<DisplayRecord[]>;
|
|
1558
1902
|
/** Deletes the display's row, token hash and snapshot at once; the token is refused on its next call. */
|
|
1559
|
-
forget(ctx: SyncContext,
|
|
1903
|
+
forget(ctx: SyncContext, device: TillDevice, displayId: string): Promise<void>;
|
|
1560
1904
|
/** Queues a message in an owned display's inbox. */
|
|
1561
|
-
sendSignal(ctx: SyncContext,
|
|
1905
|
+
sendSignal(ctx: SyncContext, device: TillDevice, displayId: string, message: SignalMessage): Promise<void>;
|
|
1562
1906
|
/** Drains this device's inbox: each message once, in send order, only from displays it owns. */
|
|
1563
|
-
receiveSignals(ctx: SyncContext,
|
|
1907
|
+
receiveSignals(ctx: SyncContext, device: TillDevice): Promise<Array<SignalMessage & {
|
|
1564
1908
|
displayId: string;
|
|
1565
1909
|
}>>;
|
|
1566
1910
|
/** 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. */
|
|
1567
|
-
postSnapshot(ctx: SyncContext,
|
|
1911
|
+
postSnapshot(ctx: SyncContext, device: TillDevice, displayId: string, body: unknown): Promise<void>;
|
|
1568
1912
|
/**
|
|
1569
1913
|
* Claims a live code: the first claim spends it and records a pending pairing with `displayName` and a fresh 4-digit
|
|
1570
|
-
* check code, unique among live pending pairings, and returns a claim secret (128 bits, base64url, stored only as a
|
|
1914
|
+
* check code, unique among that till's live pending pairings, and returns a claim secret (128 bits, base64url, stored only as a
|
|
1571
1915
|
* hash); no token. `token` is the display's current token, if any, so a confirm moves it. A claim naming no live code
|
|
1572
1916
|
* fails and spends nothing. Failed claims are limited per source (10 a minute, IPv6 by /64 via `rateLimitSource`) and
|
|
1573
1917
|
* store-wide (100 per 10 minutes); over either, every claim is refused and spends nothing. Every refusal is `claim_refused`.
|
|
@@ -1637,6 +1981,10 @@ interface ServerCapabilities {
|
|
|
1637
1981
|
register?: number;
|
|
1638
1982
|
/** The highest `order.refund` version; absent or 0 means the store takes no refunds and the app hides the action (ADR-080). */
|
|
1639
1983
|
orderRefund?: number;
|
|
1984
|
+
/** The highest `order.reopen` version; absent or 0 means the store cannot reopen orders and the app hides the action (ADR-090). */
|
|
1985
|
+
orderReopen?: number;
|
|
1986
|
+
/** The highest `order.update` version; a store that lists `order.reopen` lists it (ADR-090). */
|
|
1987
|
+
orderUpdate?: number;
|
|
1640
1988
|
/** How the store rounds tax (#287). Absent: an older server, per_order + half_away_from_zero. */
|
|
1641
1989
|
taxRounding?: TaxRounding;
|
|
1642
1990
|
/** Whether one order may carry several payments. Absent means it may: order.create's `payments` has always been a
|
|
@@ -1670,6 +2018,11 @@ interface ServerCapabilities {
|
|
|
1670
2018
|
* `customerDisplay`. Absent means no second-device display.
|
|
1671
2019
|
*/
|
|
1672
2020
|
customerDisplay?: DisplayAdvertisement;
|
|
2021
|
+
/** The receipt-email version a store's `/tally/v1/info` advertises as `receiptEmail: { v: n }` (vendurepos gap 12.1b).
|
|
2022
|
+
* Absent means the store does not email receipts. */
|
|
2023
|
+
receiptEmail?: number;
|
|
2024
|
+
/** 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. */
|
|
2025
|
+
pluginContract?: number;
|
|
1673
2026
|
}
|
|
1674
2027
|
/** #287, ADR-071. `custom`: the till computes as when absent; that server never emits `figures_mismatch` for subtotal or tax. */
|
|
1675
2028
|
type TaxRounding = {
|
|
@@ -1696,6 +2049,7 @@ declare function resolveCapabilities(fresh: ServerCapabilities | undefined, stor
|
|
|
1696
2049
|
* no logger, so a malformed value gives `undefined` and one reason to `warn` for the caller to log.
|
|
1697
2050
|
*/
|
|
1698
2051
|
declare function parseTaxRounding(value: unknown, warn?: (reason: string) => void): TaxRounding | undefined;
|
|
2052
|
+
/** Reads an info response's lineTax capability: { none, classes } as two booleans, or undefined when absent or malformed (with warn only when malformed). */
|
|
1699
2053
|
declare function parseLineTax(value: unknown, warn?: (reason: string) => void): {
|
|
1700
2054
|
none: boolean;
|
|
1701
2055
|
classes: boolean;
|
|
@@ -1704,9 +2058,13 @@ declare function parseLineTax(value: unknown, warn?: (reason: string) => void):
|
|
|
1704
2058
|
* Reads a 2xx body of `GET /tally/v1/info` (ADR-062): `orderCreate` is the max of
|
|
1705
2059
|
* `contracts["order.create"]`, or 1 when it's missing or malformed; `register` is the max of
|
|
1706
2060
|
* `contracts.register` when valid; `taxRounding` is the top-level sibling of `contracts` (#287); malformed `lineTax` is ignored.
|
|
1707
|
-
* malformed `registerApproval` is ignored (ADR-082). `coupons` is true only when the body says `coupons: true` (#709).
|
|
2061
|
+
* A malformed `registerApproval` is ignored (ADR-082). `coupons` is true only when the body says `coupons: true` (#709).
|
|
1708
2062
|
* `orderRefund` is the max of `contracts["order.refund"]` when valid, otherwise absent (ADR-080).
|
|
2063
|
+
* `orderReopen` is the max of `contracts["order.reopen"]` when valid, otherwise absent (ADR-090).
|
|
2064
|
+
* `orderUpdate` is the max of `contracts["order.update"]` when valid, otherwise absent (ADR-090).
|
|
1709
2065
|
* `customerDisplay` is present only when `parseDisplayAdvertisement` accepts it; a malformed one warns (ADR-085).
|
|
2066
|
+
* `receiptEmail` is `v` of `receiptEmail: { v }` when `v` is a safe integer above 0; a malformed one is left out and warns.
|
|
2067
|
+
* `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).
|
|
1710
2068
|
* Absent `taxRounding` uses the default; a present malformed value is unknown, so settings wait.
|
|
1711
2069
|
* A non-object body is also unknown, not a statement of the store's defaults.
|
|
1712
2070
|
*/
|
|
@@ -1916,6 +2274,8 @@ interface TallyConnector {
|
|
|
1916
2274
|
* for credentials; a connector's own errors otherwise. `undefined` when the connector has no register directory.
|
|
1917
2275
|
*/
|
|
1918
2276
|
listRegisters?: (context: SyncContext) => Promise<RegisterInfo[]>;
|
|
2277
|
+
/** The store's Z closures (ADR-093): online only. `undefined` when the connector has none: the app hides its server-closure features. */
|
|
2278
|
+
closures?: ClosureReads;
|
|
1919
2279
|
/**
|
|
1920
2280
|
* The signed-in cashier and their neutral POS permissions (v2 parity A12), mapped from the platform's own roles or
|
|
1921
2281
|
* capabilities. Read-only. `null` when the connector has no cashier to describe; `undefined` (no method) when the
|
|
@@ -1947,6 +2307,18 @@ declare const PROTOCOL_VERSION = 1;
|
|
|
1947
2307
|
declare const MAX_COMMANDS_PER_BATCH = 50;
|
|
1948
2308
|
/** 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. */
|
|
1949
2309
|
declare const ORDER_NOTE_MAX = 1000;
|
|
2310
|
+
/** The most tax ids order.create 12 carries in `customer.taxIds` (ADR-092). */
|
|
2311
|
+
declare const ORDER_TAX_IDS_MAX = 10;
|
|
2312
|
+
/** The longest order.create 12 tax id `type` (the connector's scheme id), in UTF-16 code units (ADR-092). */
|
|
2313
|
+
declare const ORDER_TAX_ID_TYPE_MAX = 32;
|
|
2314
|
+
/** The longest order.create 12 tax id `value`, in UTF-16 code units (ADR-092). */
|
|
2315
|
+
declare const ORDER_TAX_ID_VALUE_MAX = 64;
|
|
2316
|
+
/** The most entries order.create 12 carries in `meta`; a meta value's bound is ORDER_NOTE_MAX (ADR-092). */
|
|
2317
|
+
declare const ORDER_META_MAX = 50;
|
|
2318
|
+
/** The longest order.create 12 meta `key`, in UTF-16 code units (ADR-092). */
|
|
2319
|
+
declare const ORDER_META_KEY_MAX = 255;
|
|
2320
|
+
/** The longest order.create 12 catalogue line `sku`, in UTF-16 code units; WooCommerce's product lookup table holds 100 (ADR-092). */
|
|
2321
|
+
declare const ORDER_LINE_SKU_MAX = 100;
|
|
1950
2322
|
/**
|
|
1951
2323
|
* True if `value` has the shape of a CommandBatchResponse: an object with a
|
|
1952
2324
|
* `results` array whose every entry has a string `id` and a `status` of
|
|
@@ -1954,6 +2326,16 @@ declare const ORDER_NOTE_MAX = 1000;
|
|
|
1954
2326
|
*/
|
|
1955
2327
|
declare function isCommandBatchResponse(value: unknown): value is CommandBatchResponse;
|
|
1956
2328
|
|
|
2329
|
+
/**
|
|
2330
|
+
* ISO 4217 minor-unit exponent as resolved by Intl (which rejects malformed codes); depends on the runtime's ICU data.
|
|
2331
|
+
* @deprecated Use `minorUnitDigits` (exported here and from `@tallyui/core`). It returns 2 for a code Intl rejects, where this throws.
|
|
2332
|
+
*/
|
|
2333
|
+
declare function currencyDecimals(currency: string): number;
|
|
2334
|
+
/** Converts a safe integer minor amount to an exact major-unit decimal string. */
|
|
2335
|
+
declare function minorToMajor(minor: number, decimals: number): string;
|
|
2336
|
+
/** Rounds a major-unit decimal to minor units, half away from zero, without float scaling. */
|
|
2337
|
+
declare function majorToMinor(value: string | number, decimals: number): number;
|
|
2338
|
+
|
|
1957
2339
|
/** parseCommandResult's refusal; its message names the first bad field. A plugin maps it
|
|
1958
2340
|
* to its own invalid-data error (e.g. Medusa's MedusaError INVALID_DATA). */
|
|
1959
2341
|
declare class CommandResultError extends Error {
|
|
@@ -1963,4 +2345,38 @@ declare class CommandResultError extends Error {
|
|
|
1963
2345
|
* CommandResultError naming the first bad field. */
|
|
1964
2346
|
declare function parseCommandResult(value: unknown): CommandResult;
|
|
1965
2347
|
|
|
1966
|
-
|
|
2348
|
+
/**
|
|
2349
|
+
* A session's expected figures per method: the counted float in cash, plus each order's payments, plus paid_in
|
|
2350
|
+
* and minus paid_out movements that are not voided. The plugin chooses which orders count (for Medusa: completed,
|
|
2351
|
+
* archived and cancelled POS orders, so a received sale stays counted after an admin archives or cancels it) and
|
|
2352
|
+
* passes each order's recorded POS payments; this function only sums. Refunds made in the session (by the refund's
|
|
2353
|
+
* own sessionId, ADR-080) lower expected per method.
|
|
2354
|
+
*/
|
|
2355
|
+
declare function deriveSessionFigures(input: {
|
|
2356
|
+
countedFloatMinor: number;
|
|
2357
|
+
orders: {
|
|
2358
|
+
payments: {
|
|
2359
|
+
method: string;
|
|
2360
|
+
amountMinor: number;
|
|
2361
|
+
}[];
|
|
2362
|
+
}[];
|
|
2363
|
+
movements: {
|
|
2364
|
+
id: string;
|
|
2365
|
+
type: 'paid_in' | 'paid_out' | 'no_sale' | 'void';
|
|
2366
|
+
amountMinor: number;
|
|
2367
|
+
voids: string | null;
|
|
2368
|
+
}[];
|
|
2369
|
+
refunds?: {
|
|
2370
|
+
byMethod: Record<string, number>;
|
|
2371
|
+
}[];
|
|
2372
|
+
}): {
|
|
2373
|
+
expected: Record<string, number>;
|
|
2374
|
+
salesCount: number;
|
|
2375
|
+
refundsTotalMinor?: number;
|
|
2376
|
+
};
|
|
2377
|
+
declare function deriveVariance(counted: Record<string, number>, expected: Record<string, number>): Record<string, number>;
|
|
2378
|
+
|
|
2379
|
+
/** Converts a plain decimal percentage with at most four fractional digits to safe integer ppm. */
|
|
2380
|
+
declare function ratePpmFromPercent(percent: number | string): number;
|
|
2381
|
+
|
|
2382
|
+
export { type ConnectorTraits as $, type AnyCommandEnvelope as A, type BatchTooLargeBody as B, type CommandWarning as C, type DisplayAdvertisement as D, type CollectionSync as E, type CommandBatchRequest as F, type CommandBatchResponse as G, type CommandEnvelope as H, type IceServer as I, type CommandError as J, type CommandResult as K, type ListOrdersQuery as L, type MoneyFormat as M, CommandResultError as N, type OrderFilterField as O, type ProductTraits as P, type CommandServerRefs as Q, type ReplicationAdapter as R, type StockReconcileAdapter as S, type TallyConnector as T, type CommandStatus as U, type VariantSummary as V, type WooTaxRate as W, type CommandType as X, type ConnectivityState as Y, type ConnectorAuth as Z, type ConnectorSchemas as _, type StockLevel as a, type PaymentHardware as a$, type Correction as a0, type Customer as a1, type CustomerAddress as a2, type CustomerInput as a3, type CustomerPage as a4, type CustomerPatch as a5, CustomerServiceError as a6, type CustomerTaxId as a7, DISPLAY_PAIR_CAPABILITY as a8, type DisplayRecord as a9, type OrderCreateTaxRate as aA, type OrderCreateTotalMismatchData as aB, type OrderRefundAmountMismatchData as aC, type OrderRefundEnvelope as aD, type OrderRefundLine as aE, type OrderRefundNoOpenSessionData as aF, type OrderRefundOrderStateData as aG, type OrderRefundPayload as aH, type OrderRefundQuantityExceedsData as aI, type OrderRefundRejectionCode as aJ, type OrderRefundResult as aK, type OrderReopenEnvelope as aL, type OrderReopenOrderStateData as aM, type OrderReopenPayload as aN, type OrderReopenPaymentInMotionData as aO, type OrderReopenRejectionCode as aP, type OrderReopenResult as aQ, type OrderUpdateEnvelope as aR, type OrderUpdateFee as aS, type OrderUpdateLine as aT, type OrderUpdatePayload as aU, type OrderUpdatePayment as aV, type OrderUpdateRejectionCode as aW, type OrderUpdateReopenRequiredData as aX, type OrderUpdateShipping as aY, PROTOCOL_HEADER as aZ, PROTOCOL_VERSION as a_, type DisplaySignalling as aa, type DisplaySignallingContext as ab, DisplaySignallingError as ac, type DisplaySignallingErrorCode as ad, type FailureClass as ae, type FingerprintReconcileAdapter as af, type IdReconcileAdapter as ag, MAX_COMMANDS_PER_BATCH as ah, ORDER_LINE_SKU_MAX as ai, ORDER_META_KEY_MAX as aj, ORDER_META_MAX as ak, ORDER_NOTE_MAX as al, ORDER_TAX_IDS_MAX as am, ORDER_TAX_ID_TYPE_MAX as an, ORDER_TAX_ID_VALUE_MAX as ao, type OrderAddress as ap, type OrderCreateCoupon as aq, type OrderCreateCouponInvalidData as ar, type OrderCreateCouponLine as as, type OrderCreateDisplay as at, type OrderCreateEnvelope as au, type OrderCreateLine as av, type OrderCreateMeta as aw, type OrderCreatePayload as ax, type OrderCreatePayment as ay, type OrderCreateTaxId as az, type SyncContext as b, moneyToMajor as b$, type PaymentKind as b0, type PaymentMethodDescriptor as b1, type PaymentMethodKind as b2, type PaymentOfflineMode as b3, type PaymentRounding as b4, type PaymentTipsMode as b5, type PaymentTransport as b6, type PendingPairing as b7, type ProductCategory as b8, type ProductPrice as b9, type StoreOrderPage as bA, type StoreOrderPayment as bB, type StoreOrderRefund as bC, type StoreSettings as bD, type StoreSettingsChoice as bE, type StoreTaxClass as bF, type StoreTaxRate as bG, type StoreTaxRateLocation as bH, type TaxRounding as bI, type TillDevice as bJ, type UpdateRequired as bK, type VariantOptionGroup as bL, cashierPermissions as bM, classifyFailure as bN, currencySymbol as bO, customerTraits as bP, defaultPaymentMethods as bQ, deriveSessionFigures as bR, deriveVariance as bS, formatMoney as bT, isCashierPermission as bU, isCommandBatchResponse as bV, legMethodId as bW, minorToMajor as bX, minorUnitDigits as bY, moneyFromDecimalString as bZ, moneyFromMajor as b_, type ProductTerm as ba, type ReceiptTemplate as bb, type ReceiptTemplateKind as bc, type RegisterApprovalInvalidData as bd, type RegisterApprovalRequiredData as be, type RegisterClosureSubmitPayload as bf, type RegisterCommandEnvelope as bg, type RegisterCommandResult as bh, type RegisterCommandType as bi, type RegisterInfo as bj, type RegisterMovementRecordPayload as bk, type RegisterMovementVoidPayload as bl, type RegisterSessionAlreadyOpenData as bm, type RegisterSessionOpenPayload as bn, type RegisterSessionSupersededData as bo, type RegisterSessionTransitionPayload as bp, type RemoteIdEntry as bq, type ResolvedPrice as br, type ServerCapabilities as bs, type SignInResult as bt, type SignalMessage as bu, type StockStatus as bv, type StoreClosure as bw, type StoreOrder as bx, type StoreOrderCharge as by, type StoreOrderLine as bz, type TraitContext as c, neutralFailureClass as c0, noResponse as c1, normalizeMoneyText as c2, parseCommandResult as c3, parseInfoCapabilities as c4, parseLineTax as c5, parseTaxRounding as c6, paymentMethodOf as c7, ratePpmFromPercent as c8, resolveCapabilities as c9, resolvePrice as ca, resolvePriceRange as cb, wireMethodOf as cc, currencyDecimals as cd, majorToMinor as ce, type CustomerTraits as d, type Money as e, type CalculateTaxesInput as f, type CalculateTaxesResult as g, type ItemizedTax as h, type ResolvedTaxLocation as i, TAX_BASED_ON_META_KEY as j, type TaxAddress as k, type TaxBasedOn as l, type TaxLocationOrder as m, normalizeTaxBasedOn as n, orderTaxLocation as o, type ApproverCredentials as p, type AuthField as q, CASHIER_PERMISSIONS as r, COMMANDS_PATH as s, type CaptureMode as t, type CaptureModeEntry as u, type Cashier as v, type CashierPermission as w, type CatalogueReconcileAdapter as x, type CatalogueReconcileEntry as y, type ClosureReads as z };
|