@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/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IceServer, D as DisplayAdvertisement, O as OrderFilterField, L as ListOrdersQuery,
|
|
2
|
-
export { A as AnyCommandEnvelope, q as AuthField, B as BatchTooLargeBody, r as CASHIER_PERMISSIONS, s as COMMANDS_PATH, t as CaptureMode, u as CaptureModeEntry, v as Cashier, w as CashierPermission, x as CatalogueReconcileAdapter, y as CatalogueReconcileEntry, z as
|
|
1
|
+
import { I as IceServer, D as DisplayAdvertisement, O as OrderFilterField, L as ListOrdersQuery, V as VariantSummary, C as CommandWarning, P as ProductTraits, S as StockReconcileAdapter, a as StockLevel, R as ReplicationAdapter, b as SyncContext, T as TallyConnector, c as TraitContext, d as CustomerTraits, M as MoneyFormat, e as Money, f as CalculateTaxesInput, g as CalculateTaxesResult, W as WooTaxRate, h as ItemizedTax, i as ResolvedTaxLocation, j as TAX_BASED_ON_META_KEY, k as TaxAddress, l as TaxBasedOn, m as TaxLocationOrder, n as normalizeTaxBasedOn, o as orderTaxLocation } from './tax-rate-DCJhfJbZ.js';
|
|
2
|
+
export { A as AnyCommandEnvelope, p as ApproverCredentials, q as AuthField, B as BatchTooLargeBody, r as CASHIER_PERMISSIONS, s as COMMANDS_PATH, t as CaptureMode, u as CaptureModeEntry, v as Cashier, w as CashierPermission, x as CatalogueReconcileAdapter, y as CatalogueReconcileEntry, z as ClosureReads, E as CollectionSync, F as CommandBatchRequest, G as CommandBatchResponse, H as CommandEnvelope, J as CommandError, K as CommandResult, N as CommandResultError, Q as CommandServerRefs, U as CommandStatus, X as CommandType, Y as ConnectivityState, Z as ConnectorAuth, _ as ConnectorSchemas, $ as ConnectorTraits, a0 as Correction, a1 as Customer, a2 as CustomerAddress, a3 as CustomerInput, a4 as CustomerPage, a5 as CustomerPatch, a6 as CustomerServiceError, a7 as CustomerTaxId, a8 as DISPLAY_PAIR_CAPABILITY, a9 as DisplayRecord, aa as DisplaySignalling, ab as DisplaySignallingContext, ac as DisplaySignallingError, ad as DisplaySignallingErrorCode, ae as FailureClass, af as FingerprintReconcileAdapter, ag as IdReconcileAdapter, ah as MAX_COMMANDS_PER_BATCH, ai as ORDER_LINE_SKU_MAX, aj as ORDER_META_KEY_MAX, ak as ORDER_META_MAX, al as ORDER_NOTE_MAX, am as ORDER_TAX_IDS_MAX, an as ORDER_TAX_ID_TYPE_MAX, ao as ORDER_TAX_ID_VALUE_MAX, ap as OrderAddress, aq as OrderCreateCoupon, ar as OrderCreateCouponInvalidData, as as OrderCreateCouponLine, at as OrderCreateDisplay, au as OrderCreateEnvelope, av as OrderCreateLine, aw as OrderCreateMeta, ax as OrderCreatePayload, ay as OrderCreatePayment, az as OrderCreateTaxId, aA as OrderCreateTaxRate, aB as OrderCreateTotalMismatchData, aC as OrderRefundAmountMismatchData, aD as OrderRefundEnvelope, aE as OrderRefundLine, aF as OrderRefundNoOpenSessionData, aG as OrderRefundOrderStateData, aH as OrderRefundPayload, aI as OrderRefundQuantityExceedsData, aJ as OrderRefundRejectionCode, aK as OrderRefundResult, aL as OrderReopenEnvelope, aM as OrderReopenOrderStateData, aN as OrderReopenPayload, aO as OrderReopenPaymentInMotionData, aP as OrderReopenRejectionCode, aQ as OrderReopenResult, aR as OrderUpdateEnvelope, aS as OrderUpdateFee, aT as OrderUpdateLine, aU as OrderUpdatePayload, aV as OrderUpdatePayment, aW as OrderUpdateRejectionCode, aX as OrderUpdateReopenRequiredData, aY as OrderUpdateShipping, aZ as PROTOCOL_HEADER, a_ as PROTOCOL_VERSION, a$ as PaymentHardware, b0 as PaymentKind, b1 as PaymentMethodDescriptor, b2 as PaymentMethodKind, b3 as PaymentOfflineMode, b4 as PaymentRounding, b5 as PaymentTipsMode, b6 as PaymentTransport, b7 as PendingPairing, b8 as ProductCategory, b9 as ProductPrice, ba as ProductTerm, bb as ReceiptTemplate, bc as ReceiptTemplateKind, bd as RegisterApprovalInvalidData, be as RegisterApprovalRequiredData, bf as RegisterClosureSubmitPayload, bg as RegisterCommandEnvelope, bh as RegisterCommandResult, bi as RegisterCommandType, bj as RegisterInfo, bk as RegisterMovementRecordPayload, bl as RegisterMovementVoidPayload, bm as RegisterSessionAlreadyOpenData, bn as RegisterSessionOpenPayload, bo as RegisterSessionSupersededData, bp as RegisterSessionTransitionPayload, bq as RemoteIdEntry, br as ResolvedPrice, bs as ServerCapabilities, bt as SignInResult, bu as SignalMessage, bv as StockStatus, bw as StoreClosure, bx as StoreOrder, by as StoreOrderCharge, bz as StoreOrderLine, bA as StoreOrderPage, bB as StoreOrderPayment, bC as StoreOrderRefund, bD as StoreSettings, bE as StoreSettingsChoice, bF as StoreTaxClass, bG as StoreTaxRate, bH as StoreTaxRateLocation, bI as TaxRounding, bJ as TillDevice, bK as UpdateRequired, bL as VariantOptionGroup, bM as cashierPermissions, bN as classifyFailure, bO as currencySymbol, bP as customerTraits, bQ as defaultPaymentMethods, bR as deriveSessionFigures, bS as deriveVariance, bT as formatMoney, bU as isCashierPermission, bV as isCommandBatchResponse, bW as legMethodId, bX as minorToMajor, bY as minorUnitDigits, bZ as moneyFromDecimalString, b_ as moneyFromMajor, b$ as moneyToMajor, c0 as neutralFailureClass, c1 as noResponse, c2 as normalizeMoneyText, c3 as parseCommandResult, c4 as parseInfoCapabilities, c5 as parseLineTax, c6 as parseTaxRounding, c7 as paymentMethodOf, c8 as ratePpmFromPercent, c9 as resolveCapabilities, ca as resolvePrice, cb as resolvePriceRange, cc as wireMethodOf } from './tax-rate-DCJhfJbZ.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import 'rxdb';
|
|
@@ -135,42 +135,6 @@ declare function assertOrderFiltersSupported(query: ListOrdersQuery | undefined,
|
|
|
135
135
|
*/
|
|
136
136
|
declare function assertOrderDateRange(range: ListOrdersQuery['dateRange']): void;
|
|
137
137
|
|
|
138
|
-
/** Number of minor-unit digits for an ISO 4217 code (2 for EUR, 0 for JPY). */
|
|
139
|
-
declare function minorUnitDigits(currency: string): number;
|
|
140
|
-
/** The currency's symbol for a plain-English label ('€' for EUR, '$' for USD), not a full amount. */
|
|
141
|
-
declare function currencySymbol(currency: string, locale?: string): string;
|
|
142
|
-
/**
|
|
143
|
-
* Converts a major-unit amount ('12.50', 12.5) into Money.
|
|
144
|
-
* Returns undefined for empty or non-numeric input.
|
|
145
|
-
*/
|
|
146
|
-
declare function moneyFromMajor(value: string | number | null | undefined, currency: string): Money | undefined;
|
|
147
|
-
/** Parses trimmed decimal text into safe integer minor units, without rounding. */
|
|
148
|
-
declare function moneyFromDecimalString(text: string, currency: string): Money | undefined;
|
|
149
|
-
/** Converts Money back to a major-unit number, e.g. for Intl formatting. */
|
|
150
|
-
declare function moneyToMajor(money: Money): number;
|
|
151
|
-
/**
|
|
152
|
-
* Formats Money for display with Intl, e.g. '€12.50' or '¥1,200'.
|
|
153
|
-
* Returns undefined for 'XXX' (currency unknown), so callers can fall back.
|
|
154
|
-
*/
|
|
155
|
-
declare function formatMoney(money: Money, locale?: string): string | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* Picks the price to charge from a price list, in `currency` if given, else in
|
|
158
|
-
* the first currency listed. A sale entry wins over the base entry.
|
|
159
|
-
*/
|
|
160
|
-
declare function resolvePrice(prices: ProductPrice[], currency?: string): ResolvedPrice | undefined;
|
|
161
|
-
/**
|
|
162
|
-
* The lowest and highest price to charge across variants, in `currency` if
|
|
163
|
-
* given, else each variant's first currency; undefined when no variant
|
|
164
|
-
* resolves. Only amounts in the first resolved variant's currency are
|
|
165
|
-
* compared; a variant that resolves to another currency is skipped.
|
|
166
|
-
*/
|
|
167
|
-
declare function resolvePriceRange(variants: Array<{
|
|
168
|
-
prices: ProductPrice[];
|
|
169
|
-
}>, currency?: string): {
|
|
170
|
-
min: Money;
|
|
171
|
-
max: Money;
|
|
172
|
-
} | undefined;
|
|
173
|
-
|
|
174
138
|
/**
|
|
175
139
|
* The variant whose barcode or SKU equals `code`, compared after trimming
|
|
176
140
|
* both sides and ignoring case. A barcode match wins over a SKU match. When
|
|
@@ -189,12 +153,23 @@ declare function findVariantByCode(variants: VariantSummary[], code: string): Va
|
|
|
189
153
|
* A `figures_mismatch` is dropped entirely unless `fields` is non-empty and each entry names a
|
|
190
154
|
* different figure with two differing safe integers; each entry is rebuilt from its known keys.
|
|
191
155
|
* A figure name it doesn't know (any non-empty string) is kept, since a newer store may send one.
|
|
156
|
+
* A `line_figures_mismatch` is dropped entirely unless `lines` is non-empty and each entry has a `lineId` of 1 to 64
|
|
157
|
+
* characters, a non-empty `field` (kept when unknown), two differing safe integers, and a `lineId` and `field` pair of its own.
|
|
192
158
|
*/
|
|
193
159
|
declare function knownWarnings(warnings: unknown): CommandWarning[];
|
|
194
160
|
|
|
195
161
|
/** Orders backend ids: numerically when both are integer strings (Vendure '9' < '10', compared with BigInt so long ids stay exact), with ties in numeric value (e.g. '01' vs '1') broken by plain string order; an integer id always sorts before a non-integer one; otherwise (neither is an integer string) by plain string order (not `localeCompare`, which is locale-dependent). This is a total order, so sorting is consistent regardless of input order. */
|
|
196
162
|
declare function compareIds(a: string | number, b: string | number): number;
|
|
197
163
|
|
|
164
|
+
/**
|
|
165
|
+
* 32-bit FNV-1a over the string's UTF-16 code units (charCodeAt), as lowercase hex.
|
|
166
|
+
* Platform apps derive persisted database names from it, so the output format is part of the contract:
|
|
167
|
+
* `pad: true` left-pads to 8 hex digits, `pad: false` keeps the shortest form. An app keeps the form it already stores.
|
|
168
|
+
*/
|
|
169
|
+
declare function fnv1a32(text: string, options: {
|
|
170
|
+
pad: boolean;
|
|
171
|
+
}): string;
|
|
172
|
+
|
|
198
173
|
/**
|
|
199
174
|
* Local document id, in the `stock_levels` collection, that holds the time of
|
|
200
175
|
* the last successful reconcile pass (`{ completedAt }`). Lives here so the
|
|
@@ -351,6 +326,28 @@ declare function useStockOverlayAsOf(): string | undefined;
|
|
|
351
326
|
*/
|
|
352
327
|
declare function useCustomerTraits(): CustomerTraits<any> | undefined;
|
|
353
328
|
|
|
329
|
+
interface MoneyFormatProviderProps {
|
|
330
|
+
/** The store's locale for Intl; a component's own `locale` prop wins over it. */
|
|
331
|
+
locale?: string;
|
|
332
|
+
/** The store's money format (position, separators, decimals, symbol). */
|
|
333
|
+
format?: MoneyFormat;
|
|
334
|
+
children: ReactNode;
|
|
335
|
+
}
|
|
336
|
+
/** Hands a store's locale and money format to every `useFormatMoney` / `useCurrencySymbol` below it. */
|
|
337
|
+
declare function MoneyFormatProvider({ locale, format, children }: MoneyFormatProviderProps): react_jsx_runtime.JSX.Element;
|
|
338
|
+
/** The nearest provider's store money format; `undefined` outside a provider or when it has none. */
|
|
339
|
+
declare function useMoneyFormat(): MoneyFormat | undefined;
|
|
340
|
+
/**
|
|
341
|
+
* `formatMoney` with the nearest provider's locale and store format. An explicit `locale` wins over the provider's.
|
|
342
|
+
* Outside a provider it is exactly `formatMoney(money, locale)`.
|
|
343
|
+
*/
|
|
344
|
+
declare function useFormatMoney(): (money: Money, locale?: string) => string | undefined;
|
|
345
|
+
/**
|
|
346
|
+
* The symbol to show beside a money input: the store format's `symbol` when set, else `currencySymbol(currency, locale)`.
|
|
347
|
+
* Outside a provider it is exactly `currencySymbol(currency, locale)`.
|
|
348
|
+
*/
|
|
349
|
+
declare function useCurrencySymbol(): (currency: string, locale?: string) => string;
|
|
350
|
+
|
|
354
351
|
/**
|
|
355
352
|
* Takes a price and an array of tax rates, eg: [{ id: 1, rate: '4.0000', order: 1 }]
|
|
356
353
|
* Returns the calculated array of taxes tax, eg: [{ id: 1, total: 1.2345 }]
|
|
@@ -839,15 +836,12 @@ declare function validateCoupon(coupon: any, context: CouponValidationContext):
|
|
|
839
836
|
* Map `CouponInput`s (the adapter-prefetched coupon documents) to the replay's
|
|
840
837
|
* `CouponDiscountConfig` shape, keyed by the given (lowercase) codes.
|
|
841
838
|
*
|
|
842
|
-
*
|
|
843
|
-
*
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
* packages/core is the harness that relies on this now (via its own
|
|
847
|
-
* `toLegacyCouponConfigs`, which must stay in step with this function).
|
|
839
|
+
* The defaults (`amount || '0'`, `?? null`, `?? false`, array copies) live only
|
|
840
|
+
* here and must not be duplicated by callers. The sale's discount-code step
|
|
841
|
+
* (`@tallyui/pos` `sale/woocommerce/discount-codes.ts`) passes the accepted
|
|
842
|
+
* coupons' own codes.
|
|
848
843
|
*
|
|
849
|
-
* Codes absent from the map are skipped; `
|
|
850
|
-
* guarantees presence before this runs, and `recalculateCoupons` zeroes the
|
|
844
|
+
* Codes absent from the map are skipped; `recalculateCoupons` zeroes the
|
|
851
845
|
* discount for any coupon line without a config.
|
|
852
846
|
*/
|
|
853
847
|
declare function toCouponConfigs(codes: readonly string[], coupons: ReadonlyMap<string, CouponInput>): Map<string, CouponDiscountConfig>;
|
|
@@ -875,4 +869,4 @@ declare namespace index {
|
|
|
875
869
|
export { type index_CouponContext as CouponContext, type index_CouponDiscountConfig as CouponDiscountConfig, type index_CouponInput as CouponInput, type index_CouponLineInput as CouponLineInput, type index_CouponRejection as CouponRejection, type index_CouponRejectionCode as CouponRejectionCode, type index_CouponValidationContext as CouponValidationContext, type index_EngineWarning as EngineWarning, type index_LineItemInput as LineItemInput, type index_OrderTotals as OrderTotals, type index_RecalculateInput as RecalculateInput, type index_RecalculateResult as RecalculateResult, type index_TaxRateInput as TaxRateInput, type index_ValidationResult as ValidationResult, index_calculateOrderTotals as calculateOrderTotals, index_enrichCategoriesWithAncestors as enrichCategoriesWithAncestors, index_recalculateCoupons as recalculateCoupons, index_toCouponConfigs as toCouponConfigs, index_validateCoupon as validateCoupon };
|
|
876
870
|
}
|
|
877
871
|
|
|
878
|
-
export { CommandWarning, ConnectorProvider, type ConnectorProviderProps, ConnectorUnauthorizedError, CustomerTraits, DEFAULT_ICE_SERVERS, DisplayAdvertisement, type ErrorKind, IceServer, type KeyedReconcileFeedOptions, ListOrdersQuery, Money, ORDER_FILTER_FIELDS, OrderFilterField,
|
|
872
|
+
export { CommandWarning, ConnectorProvider, type ConnectorProviderProps, ConnectorUnauthorizedError, CustomerTraits, DEFAULT_ICE_SERVERS, DisplayAdvertisement, type ErrorKind, IceServer, type KeyedReconcileFeedOptions, ListOrdersQuery, Money, MoneyFormat, MoneyFormatProvider, type MoneyFormatProviderProps, ORDER_FILTER_FIELDS, OrderFilterField, ProductTraits, type ReconcileFeed, type ReconcileFeedEntry, type ReconcileFetchEntry, ReplicationAdapter, STOCK_LEVELS_LAST_PASS, SignInError, type SignInErrorCode, StockLevel, StockReconcileAdapter, type StoreSettingsChoices, StoreSettingsError, type StoreSettingsErrorCode, SyncContext, type SyncNotice, TallyConnector, TraitContext, UnsupportedOrderFilterError, VariantSummary, assertOrderDateRange, assertOrderFiltersSupported, combinePullAdapters, compareIds, createReconcileFeed, errorKind, findVariantByCode, fnv1a32, getProductStock, isRxdbRemoteVersionMismatch, knownWarnings, orderFilterFields, parseDisplayAdvertisement, rateLimitSource, useConnector, useCurrencySymbol, useCustomerTraits, useFormatMoney, useMoneyFormat, useProductStock, useProductTraits, useStockOverlaid, useStockOverlayAsOf, useTraitContext, withStockOverlay, index as woocommerceCoupons, index$1 as woocommerceTax };
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,32 @@ import {
|
|
|
4
4
|
DISPLAY_PAIR_CAPABILITY,
|
|
5
5
|
DisplaySignallingError,
|
|
6
6
|
MAX_COMMANDS_PER_BATCH,
|
|
7
|
+
ORDER_LINE_SKU_MAX,
|
|
8
|
+
ORDER_META_KEY_MAX,
|
|
9
|
+
ORDER_META_MAX,
|
|
7
10
|
ORDER_NOTE_MAX,
|
|
11
|
+
ORDER_TAX_IDS_MAX,
|
|
12
|
+
ORDER_TAX_ID_TYPE_MAX,
|
|
13
|
+
ORDER_TAX_ID_VALUE_MAX,
|
|
8
14
|
PROTOCOL_HEADER,
|
|
9
15
|
PROTOCOL_VERSION,
|
|
16
|
+
currencySymbol,
|
|
17
|
+
deriveSessionFigures,
|
|
18
|
+
deriveVariance,
|
|
19
|
+
formatMoney,
|
|
10
20
|
isCommandBatchResponse,
|
|
21
|
+
minorToMajor,
|
|
22
|
+
minorUnitDigits,
|
|
23
|
+
moneyFromDecimalString,
|
|
24
|
+
moneyFromMajor,
|
|
25
|
+
moneyToMajor,
|
|
26
|
+
normalizeMoneyText,
|
|
11
27
|
parseCommandResult,
|
|
12
|
-
rateLimitSource
|
|
13
|
-
|
|
28
|
+
rateLimitSource,
|
|
29
|
+
ratePpmFromPercent,
|
|
30
|
+
resolvePrice,
|
|
31
|
+
resolvePriceRange
|
|
32
|
+
} from "./chunk-XF3RD6GX.js";
|
|
14
33
|
import {
|
|
15
34
|
__export
|
|
16
35
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -91,6 +110,13 @@ function parseRegisterApproval(value, warn) {
|
|
|
91
110
|
warn?.("ignoring a malformed registerApproval");
|
|
92
111
|
return void 0;
|
|
93
112
|
}
|
|
113
|
+
function parseReceiptEmail(value, warn) {
|
|
114
|
+
if (value === void 0) return void 0;
|
|
115
|
+
const v = typeof value === "object" && value !== null && !Array.isArray(value) ? value.v : void 0;
|
|
116
|
+
if (typeof v === "number" && Number.isSafeInteger(v) && v > 0) return v;
|
|
117
|
+
warn?.("ignoring a malformed receiptEmail");
|
|
118
|
+
return void 0;
|
|
119
|
+
}
|
|
94
120
|
var maxVersion = (list) => {
|
|
95
121
|
const valid = Array.isArray(list) ? list.filter((v) => typeof v === "number" && Number.isSafeInteger(v) && v > 0) : [];
|
|
96
122
|
return valid.length > 0 ? Math.max(...valid) : void 0;
|
|
@@ -100,9 +126,11 @@ function parseInfoCapabilities(body, warn) {
|
|
|
100
126
|
warn?.("non-object info body: capabilities unknown");
|
|
101
127
|
return void 0;
|
|
102
128
|
}
|
|
103
|
-
const { contracts, taxRounding, lineTax, registerApproval, coupons, customerDisplay } = body;
|
|
129
|
+
const { contracts, taxRounding, lineTax, registerApproval, coupons, customerDisplay, receiptEmail, pluginContract } = body;
|
|
104
130
|
const register = maxVersion(contracts?.register);
|
|
105
131
|
const orderRefund = maxVersion(contracts?.["order.refund"]);
|
|
132
|
+
const orderReopen = maxVersion(contracts?.["order.reopen"]);
|
|
133
|
+
const orderUpdate = maxVersion(contracts?.["order.update"]);
|
|
106
134
|
const rounding = parseTaxRounding(taxRounding);
|
|
107
135
|
if (taxRounding !== void 0 && rounding === void 0) {
|
|
108
136
|
warn?.(`malformed taxRounding: rounding is unknown, so settings wait: ${JSON.stringify(taxRounding)}`);
|
|
@@ -111,15 +139,22 @@ function parseInfoCapabilities(body, warn) {
|
|
|
111
139
|
const parsedLineTax = parseLineTax(lineTax, warn);
|
|
112
140
|
const parsed = parseRegisterApproval(registerApproval, warn);
|
|
113
141
|
const display = parseDisplayAdvertisement(customerDisplay, warn);
|
|
142
|
+
const emailVersion = parseReceiptEmail(receiptEmail, warn);
|
|
143
|
+
const contractOk = typeof pluginContract === "number" && Number.isSafeInteger(pluginContract) && pluginContract >= 1;
|
|
144
|
+
if (pluginContract !== void 0 && !contractOk) warn?.(`malformed pluginContract: ${JSON.stringify(pluginContract)}`);
|
|
114
145
|
return {
|
|
115
146
|
orderCreate: maxVersion(contracts?.["order.create"]) ?? 1,
|
|
116
147
|
...orderRefund !== void 0 ? { orderRefund } : {},
|
|
148
|
+
...orderReopen !== void 0 ? { orderReopen } : {},
|
|
149
|
+
...orderUpdate !== void 0 ? { orderUpdate } : {},
|
|
117
150
|
...register !== void 0 ? { register } : {},
|
|
118
151
|
...rounding ? { taxRounding: rounding } : {},
|
|
119
152
|
...parsedLineTax ? { lineTax: parsedLineTax } : {},
|
|
120
153
|
...parsed ? { registerApproval: parsed } : {},
|
|
121
154
|
...coupons === true ? { coupons: true } : {},
|
|
122
|
-
...display ? { customerDisplay: display } : {}
|
|
155
|
+
...display ? { customerDisplay: display } : {},
|
|
156
|
+
...emailVersion !== void 0 ? { receiptEmail: emailVersion } : {},
|
|
157
|
+
...contractOk ? { pluginContract } : {}
|
|
123
158
|
};
|
|
124
159
|
}
|
|
125
160
|
|
|
@@ -249,6 +284,13 @@ function paymentMethodOf(kind) {
|
|
|
249
284
|
function defaultPaymentMethods() {
|
|
250
285
|
return [paymentMethodOf("cash"), paymentMethodOf("external")];
|
|
251
286
|
}
|
|
287
|
+
var CASH_KINDS = ["cash"];
|
|
288
|
+
function wireMethodOf(descriptor) {
|
|
289
|
+
return CASH_KINDS.includes(descriptor.kind) ? "cash" : "external";
|
|
290
|
+
}
|
|
291
|
+
function legMethodId(leg) {
|
|
292
|
+
return leg.methodId === void 0 || leg.methodId === leg.method ? leg.method : `${leg.method}:${leg.methodId}`;
|
|
293
|
+
}
|
|
252
294
|
|
|
253
295
|
// src/order-filters.ts
|
|
254
296
|
var ORDER_FILTER_FIELDS = [
|
|
@@ -306,103 +348,6 @@ function cashierPermissions(values) {
|
|
|
306
348
|
return [...new Set(values.filter(isCashierPermission))];
|
|
307
349
|
}
|
|
308
350
|
|
|
309
|
-
// src/money.ts
|
|
310
|
-
var digitsCache = /* @__PURE__ */ new Map();
|
|
311
|
-
function minorUnitDigits(currency) {
|
|
312
|
-
const code = currency.toUpperCase();
|
|
313
|
-
let digits = digitsCache.get(code);
|
|
314
|
-
if (digits === void 0) {
|
|
315
|
-
try {
|
|
316
|
-
digits = new Intl.NumberFormat("en", { style: "currency", currency: code }).resolvedOptions().maximumFractionDigits ?? 2;
|
|
317
|
-
} catch {
|
|
318
|
-
digits = 2;
|
|
319
|
-
}
|
|
320
|
-
digitsCache.set(code, digits);
|
|
321
|
-
}
|
|
322
|
-
return digits;
|
|
323
|
-
}
|
|
324
|
-
var symbolCache = /* @__PURE__ */ new Map();
|
|
325
|
-
function currencySymbol(currency, locale) {
|
|
326
|
-
const code = currency.toUpperCase();
|
|
327
|
-
const key = `${code}:${locale ?? ""}`;
|
|
328
|
-
let symbol = symbolCache.get(key);
|
|
329
|
-
if (symbol === void 0) {
|
|
330
|
-
try {
|
|
331
|
-
const part = new Intl.NumberFormat(locale, { style: "currency", currency: code }).formatToParts(0).find((p) => p.type === "currency");
|
|
332
|
-
symbol = part?.value ?? code;
|
|
333
|
-
} catch {
|
|
334
|
-
symbol = code;
|
|
335
|
-
}
|
|
336
|
-
symbolCache.set(key, symbol);
|
|
337
|
-
}
|
|
338
|
-
return symbol;
|
|
339
|
-
}
|
|
340
|
-
function moneyFromMajor(value, currency) {
|
|
341
|
-
if (value === null || value === void 0 || value === "") return void 0;
|
|
342
|
-
const major = typeof value === "number" ? value : Number(value);
|
|
343
|
-
if (!Number.isFinite(major)) return void 0;
|
|
344
|
-
const code = currency.toUpperCase();
|
|
345
|
-
return { amount: Math.round(major * 10 ** minorUnitDigits(code)), currency: code };
|
|
346
|
-
}
|
|
347
|
-
function moneyFromDecimalString(text2, currency) {
|
|
348
|
-
const trimmed = text2.trim();
|
|
349
|
-
if (!/^\d+(\.\d+)?$/.test(trimmed)) return void 0;
|
|
350
|
-
const code = currency.toUpperCase();
|
|
351
|
-
const digits = minorUnitDigits(code);
|
|
352
|
-
const [whole, fraction = ""] = trimmed.split(".");
|
|
353
|
-
if (fraction.length > digits) return void 0;
|
|
354
|
-
const amount = Number(whole) * 10 ** digits + Number(fraction.padEnd(digits, "0"));
|
|
355
|
-
return Number.isSafeInteger(amount) ? { amount, currency: code } : void 0;
|
|
356
|
-
}
|
|
357
|
-
function moneyToMajor(money) {
|
|
358
|
-
return money.amount / 10 ** minorUnitDigits(money.currency);
|
|
359
|
-
}
|
|
360
|
-
var formatters = /* @__PURE__ */ new Map();
|
|
361
|
-
function formatMoney(money, locale) {
|
|
362
|
-
if (money.currency === "XXX") return void 0;
|
|
363
|
-
const key = `${money.currency}:${locale ?? ""}`;
|
|
364
|
-
let formatter = formatters.get(key);
|
|
365
|
-
if (!formatter) {
|
|
366
|
-
try {
|
|
367
|
-
formatter = new Intl.NumberFormat(locale, { style: "currency", currency: money.currency });
|
|
368
|
-
} catch {
|
|
369
|
-
return void 0;
|
|
370
|
-
}
|
|
371
|
-
formatters.set(key, formatter);
|
|
372
|
-
}
|
|
373
|
-
return formatter.format(moneyToMajor(money));
|
|
374
|
-
}
|
|
375
|
-
function resolvePrice(prices, currency) {
|
|
376
|
-
const code = (currency ?? prices[0]?.currency)?.toUpperCase();
|
|
377
|
-
const inCurrency = prices.filter((p) => p.currency === code);
|
|
378
|
-
const base = inCurrency.find((p) => p.kind === "base");
|
|
379
|
-
const sale = inCurrency.find((p) => p.kind === "sale");
|
|
380
|
-
const strip = (p) => ({
|
|
381
|
-
amount: p.amount,
|
|
382
|
-
currency: p.currency,
|
|
383
|
-
...p.taxInclusive !== void 0 ? { taxInclusive: p.taxInclusive } : {}
|
|
384
|
-
});
|
|
385
|
-
if (sale && (!base || sale.amount < base.amount)) {
|
|
386
|
-
return { current: strip(sale), was: base ? strip(base) : void 0 };
|
|
387
|
-
}
|
|
388
|
-
return base ? { current: strip(base) } : void 0;
|
|
389
|
-
}
|
|
390
|
-
function resolvePriceRange(variants, currency) {
|
|
391
|
-
let range;
|
|
392
|
-
for (const variant of variants) {
|
|
393
|
-
const resolved = resolvePrice(variant.prices, currency);
|
|
394
|
-
if (!resolved) continue;
|
|
395
|
-
const money = resolved.current;
|
|
396
|
-
if (!range) {
|
|
397
|
-
range = { min: money, max: money };
|
|
398
|
-
} else if (money.currency === range.min.currency) {
|
|
399
|
-
if (money.amount < range.min.amount) range.min = money;
|
|
400
|
-
if (money.amount > range.max.amount) range.max = money;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
return range;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
351
|
// src/variants.ts
|
|
407
352
|
function findVariantByCode(variants, code) {
|
|
408
353
|
const normalized = code.trim().toLowerCase();
|
|
@@ -426,6 +371,19 @@ function figuresMismatchFields(fields) {
|
|
|
426
371
|
}
|
|
427
372
|
return rebuilt;
|
|
428
373
|
}
|
|
374
|
+
function lineFiguresMismatchLines(lines) {
|
|
375
|
+
if (!Array.isArray(lines) || lines.length === 0) return null;
|
|
376
|
+
const rebuilt = [];
|
|
377
|
+
for (const entry of lines) {
|
|
378
|
+
if (typeof entry !== "object" || entry === null) return null;
|
|
379
|
+
const { lineId, field, tillMinor, serverMinor } = entry;
|
|
380
|
+
if (typeof lineId !== "string" || lineId === "" || lineId.length > 64) return null;
|
|
381
|
+
if (typeof field !== "string" || field === "" || rebuilt.some((kept) => kept.lineId === lineId && kept.field === field)) return null;
|
|
382
|
+
if (!isSafeInt(tillMinor) || !isSafeInt(serverMinor) || tillMinor === serverMinor) return null;
|
|
383
|
+
rebuilt.push({ lineId, field, tillMinor, serverMinor });
|
|
384
|
+
}
|
|
385
|
+
return rebuilt;
|
|
386
|
+
}
|
|
429
387
|
function knownWarnings(warnings) {
|
|
430
388
|
if (!Array.isArray(warnings)) return [];
|
|
431
389
|
const kept = [];
|
|
@@ -469,6 +427,11 @@ function knownWarnings(warnings) {
|
|
|
469
427
|
if (fields !== null) kept.push({ code: "figures_mismatch", fields });
|
|
470
428
|
break;
|
|
471
429
|
}
|
|
430
|
+
case "line_figures_mismatch": {
|
|
431
|
+
const lines = lineFiguresMismatchLines(warning.lines);
|
|
432
|
+
if (lines !== null) kept.push({ code: "line_figures_mismatch", lines });
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
472
435
|
default:
|
|
473
436
|
continue;
|
|
474
437
|
}
|
|
@@ -492,6 +455,17 @@ function compareIds(a, b) {
|
|
|
492
455
|
return sa < sb ? -1 : sa > sb ? 1 : 0;
|
|
493
456
|
}
|
|
494
457
|
|
|
458
|
+
// src/fnv1a32.ts
|
|
459
|
+
function fnv1a32(text2, options) {
|
|
460
|
+
let hash = 2166136261;
|
|
461
|
+
for (let i = 0; i < text2.length; i++) {
|
|
462
|
+
hash ^= text2.charCodeAt(i);
|
|
463
|
+
hash = Math.imul(hash, 16777619);
|
|
464
|
+
}
|
|
465
|
+
const hex = (hash >>> 0).toString(16);
|
|
466
|
+
return options.pad ? hex.padStart(8, "0") : hex;
|
|
467
|
+
}
|
|
468
|
+
|
|
495
469
|
// src/stock-overlay.ts
|
|
496
470
|
var STOCK_LEVELS_LAST_PASS = "last-pass";
|
|
497
471
|
function withStockOverlay(doc, adapter, overlay) {
|
|
@@ -658,6 +632,32 @@ function useCustomerTraits() {
|
|
|
658
632
|
return connector.traits.customer;
|
|
659
633
|
}
|
|
660
634
|
|
|
635
|
+
// src/context/money-format-context.tsx
|
|
636
|
+
import { createContext as createContext2, useCallback, useContext as useContext2, useMemo as useMemo2 } from "react";
|
|
637
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
638
|
+
var MoneyFormatContext = createContext2({});
|
|
639
|
+
function MoneyFormatProvider({ locale, format, children }) {
|
|
640
|
+
const value = useMemo2(() => ({ locale, format }), [locale, format]);
|
|
641
|
+
return /* @__PURE__ */ jsx2(MoneyFormatContext.Provider, { value, children });
|
|
642
|
+
}
|
|
643
|
+
function useMoneyFormat() {
|
|
644
|
+
return useContext2(MoneyFormatContext).format;
|
|
645
|
+
}
|
|
646
|
+
function useFormatMoney() {
|
|
647
|
+
const { locale: storeLocale, format } = useContext2(MoneyFormatContext);
|
|
648
|
+
return useCallback(
|
|
649
|
+
(money, locale) => formatMoney(money, locale ?? storeLocale, format),
|
|
650
|
+
[storeLocale, format]
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
function useCurrencySymbol() {
|
|
654
|
+
const { locale: storeLocale, format } = useContext2(MoneyFormatContext);
|
|
655
|
+
return useCallback(
|
|
656
|
+
(currency, locale) => format?.symbol ?? currencySymbol(currency, locale ?? storeLocale),
|
|
657
|
+
[storeLocale, format]
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
661
|
// src/tax/woocommerce/index.ts
|
|
662
662
|
var woocommerce_exports = {};
|
|
663
663
|
__export(woocommerce_exports, {
|
|
@@ -1958,8 +1958,15 @@ export {
|
|
|
1958
1958
|
DISPLAY_PAIR_CAPABILITY,
|
|
1959
1959
|
DisplaySignallingError,
|
|
1960
1960
|
MAX_COMMANDS_PER_BATCH,
|
|
1961
|
+
MoneyFormatProvider,
|
|
1961
1962
|
ORDER_FILTER_FIELDS,
|
|
1963
|
+
ORDER_LINE_SKU_MAX,
|
|
1964
|
+
ORDER_META_KEY_MAX,
|
|
1965
|
+
ORDER_META_MAX,
|
|
1962
1966
|
ORDER_NOTE_MAX,
|
|
1967
|
+
ORDER_TAX_IDS_MAX,
|
|
1968
|
+
ORDER_TAX_ID_TYPE_MAX,
|
|
1969
|
+
ORDER_TAX_ID_VALUE_MAX,
|
|
1963
1970
|
PROTOCOL_HEADER,
|
|
1964
1971
|
PROTOCOL_VERSION,
|
|
1965
1972
|
STOCK_LEVELS_LAST_PASS,
|
|
@@ -1976,20 +1983,26 @@ export {
|
|
|
1976
1983
|
currencySymbol,
|
|
1977
1984
|
customerTraits,
|
|
1978
1985
|
defaultPaymentMethods,
|
|
1986
|
+
deriveSessionFigures,
|
|
1987
|
+
deriveVariance,
|
|
1979
1988
|
errorKind,
|
|
1980
1989
|
findVariantByCode,
|
|
1990
|
+
fnv1a32,
|
|
1981
1991
|
formatMoney,
|
|
1982
1992
|
getProductStock,
|
|
1983
1993
|
isCashierPermission,
|
|
1984
1994
|
isCommandBatchResponse,
|
|
1985
1995
|
isRxdbRemoteVersionMismatch,
|
|
1986
1996
|
knownWarnings,
|
|
1997
|
+
legMethodId,
|
|
1998
|
+
minorToMajor,
|
|
1987
1999
|
minorUnitDigits,
|
|
1988
2000
|
moneyFromDecimalString,
|
|
1989
2001
|
moneyFromMajor,
|
|
1990
2002
|
moneyToMajor,
|
|
1991
2003
|
neutralFailureClass,
|
|
1992
2004
|
noResponse,
|
|
2005
|
+
normalizeMoneyText,
|
|
1993
2006
|
orderFilterFields,
|
|
1994
2007
|
parseCommandResult,
|
|
1995
2008
|
parseDisplayAdvertisement,
|
|
@@ -1998,16 +2011,21 @@ export {
|
|
|
1998
2011
|
parseTaxRounding,
|
|
1999
2012
|
paymentMethodOf,
|
|
2000
2013
|
rateLimitSource,
|
|
2014
|
+
ratePpmFromPercent,
|
|
2001
2015
|
resolveCapabilities,
|
|
2002
2016
|
resolvePrice,
|
|
2003
2017
|
resolvePriceRange,
|
|
2004
2018
|
useConnector,
|
|
2019
|
+
useCurrencySymbol,
|
|
2005
2020
|
useCustomerTraits,
|
|
2021
|
+
useFormatMoney,
|
|
2022
|
+
useMoneyFormat,
|
|
2006
2023
|
useProductStock,
|
|
2007
2024
|
useProductTraits,
|
|
2008
2025
|
useStockOverlaid,
|
|
2009
2026
|
useStockOverlayAsOf,
|
|
2010
2027
|
useTraitContext,
|
|
2028
|
+
wireMethodOf,
|
|
2011
2029
|
withStockOverlay,
|
|
2012
2030
|
woocommerce_exports2 as woocommerceCoupons,
|
|
2013
2031
|
woocommerce_exports as woocommerceTax
|