@tallyui/core 5.0.0 → 5.2.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-RPBSJ3FB.js → chunk-PQ3DB6CJ.js} +9 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -1
- package/dist/{refund-share-BZ_Ff9Zk.d.ts → refund-share-DVf_0clD.d.ts} +111 -3
- package/dist/server/index.cjs +252 -230
- package/dist/server/index.d.cts +18 -4
- package/dist/server/index.d.ts +8 -4
- package/dist/server/index.js +244 -229
- package/package.json +1 -1
- package/src/context/connector-context.tsx +5 -0
- package/src/index.ts +2 -1
- package/src/server/batch.ts +26 -8
- package/src/server/fiscal-figures.ts +12 -5
- package/src/server/order-payload-shape.ts +2 -1
- package/src/server/refund-share.ts +12 -3
- package/src/types/commands.ts +3 -1
- package/src/types/connector.ts +66 -0
- package/src/types/orders.ts +6 -0
|
@@ -489,6 +489,13 @@ function roundRatio(n, d, mode = "half_away_from_zero") {
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
// src/server/refund-share.ts
|
|
492
|
+
function pricingBase({ totalMinor, taxMinor, soldTotalMinor, soldTaxMinor }) {
|
|
493
|
+
if (soldTotalMinor === void 0 && soldTaxMinor === void 0) return [totalMinor, taxMinor];
|
|
494
|
+
if (soldTotalMinor === void 0 || soldTaxMinor === void 0 || !Number.isSafeInteger(soldTotalMinor) || !Number.isSafeInteger(soldTaxMinor)) {
|
|
495
|
+
throw new RangeError("A line carries both sold figures or neither, as safe integers");
|
|
496
|
+
}
|
|
497
|
+
return [soldTotalMinor, soldTaxMinor];
|
|
498
|
+
}
|
|
492
499
|
function refundableLines(lines, refunds) {
|
|
493
500
|
const earlier = refunds.flatMap((refund) => refund.lines);
|
|
494
501
|
for (const refund of earlier) {
|
|
@@ -499,7 +506,7 @@ function refundableLines(lines, refunds) {
|
|
|
499
506
|
throw new RangeError("Order line values must be safe integers and quantity non-negative");
|
|
500
507
|
}
|
|
501
508
|
const refundedQuantity = earlier.reduce((sum, refund) => refund.orderLineId === line.id ? Math.min(line.quantity, sum + Math.abs(refund.quantity)) : sum, 0);
|
|
502
|
-
const [netMinor, taxMinor] =
|
|
509
|
+
const [netMinor, taxMinor] = pricingBase(line).map((total) => line.quantity === 0 ? 0 : total - Number(roundRatio(BigInt(refundedQuantity) * BigInt(total), BigInt(line.quantity), "half_up")));
|
|
503
510
|
return {
|
|
504
511
|
orderLineId: line.id,
|
|
505
512
|
refundedQuantity,
|
|
@@ -524,7 +531,7 @@ function priceRefund(lines, refunds, request) {
|
|
|
524
531
|
if (quantity < 1) continue;
|
|
525
532
|
const line = lines[index];
|
|
526
533
|
const refundedQuantity = available[index].refundedQuantity;
|
|
527
|
-
const [netMinor, taxMinor] =
|
|
534
|
+
const [netMinor, taxMinor] = pricingBase(line).map((total) => Number(roundRatio(BigInt(refundedQuantity + quantity) * BigInt(total), BigInt(line.quantity), "half_up")) - Number(roundRatio(BigInt(refundedQuantity) * BigInt(total), BigInt(line.quantity), "half_up")));
|
|
528
535
|
const totalMinor = netMinor + taxMinor;
|
|
529
536
|
result.lines.push({ orderLineId, quantity, restock });
|
|
530
537
|
result.priced.push({ orderLineId, quantity, netMinor, taxMinor, totalMinor });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 './refund-share-
|
|
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 EarlierRefund, af as FailureClass, ag as FingerprintReconcileAdapter, ah as IdReconcileAdapter, ai as ListRefundsQuery, aj as MAX_COMMANDS_PER_BATCH, ak as NEEDS_ADMIN_MESSAGE_MAX, al as ORDER_LINE_SKU_MAX, am as ORDER_META_KEY_MAX, an as ORDER_META_MAX, ao as ORDER_NOTE_MAX, ap as ORDER_TAX_IDS_MAX, aq as ORDER_TAX_ID_TYPE_MAX, ar as ORDER_TAX_ID_VALUE_MAX, as as OrderAddress, at as OrderCreateCoupon, au as OrderCreateCouponInvalidData, av as OrderCreateCouponLine, aw as OrderCreateDisplay, ax as OrderCreateEnvelope, ay as OrderCreateLine, az as OrderCreateMeta, aA as OrderCreatePayload, aB as OrderCreatePayment, aC as OrderCreateTaxId, aD as OrderCreateTaxRate, aE as OrderCreateTotalMismatchData, aF as OrderRefundAmountMismatchData, aG as OrderRefundEnvelope, aH as OrderRefundLine, aI as OrderRefundNoOpenSessionData, aJ as OrderRefundOrderStateData, aK as OrderRefundPayload, aL as OrderRefundQuantityExceedsData, aM as OrderRefundRejectionCode, aN as OrderRefundResult, aO as OrderReopenEnvelope, aP as OrderReopenOrderStateData, aQ as OrderReopenPayload, aR as OrderReopenPaymentInMotionData, aS as OrderReopenRejectionCode, aT as OrderReopenResult, aU as OrderUpdateEnvelope, aV as OrderUpdateFee, aW as OrderUpdateLine, aX as OrderUpdatePayload, aY as OrderUpdatePayment, aZ as OrderUpdateRejectionCode, a_ as OrderUpdateReopenRequiredData, a$ as OrderUpdateShipping, b0 as PROTOCOL_HEADER, b1 as PROTOCOL_VERSION, b2 as PaymentHardware, b3 as PaymentKind, b4 as PaymentMethodDescriptor, b5 as PaymentMethodKind, b6 as PaymentOfflineMode, b7 as PaymentRounding, b8 as PaymentTipsMode, b9 as PaymentTransport, ba as PendingPairing, bb as PricedRefund, bc as PricedRefundLine, bd as ProductCategory, be as ProductPrice, bf as ProductTerm, bg as ReceiptTemplate, bh as ReceiptTemplateKind, bi as RefundableLine, bj as RefundableOrderLine, bk 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 './refund-share-DVf_0clD.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 EarlierRefund, af as FailureClass, ag as FingerprintReconcileAdapter, ah as IdReconcileAdapter, ai as ListRefundsQuery, aj as MAX_COMMANDS_PER_BATCH, ak as NEEDS_ADMIN_MESSAGE_MAX, al as ORDER_LINE_SKU_MAX, am as ORDER_META_KEY_MAX, an as ORDER_META_MAX, ao as ORDER_NOTE_MAX, ap as ORDER_TAX_IDS_MAX, aq as ORDER_TAX_ID_TYPE_MAX, ar as ORDER_TAX_ID_VALUE_MAX, as as OrderAddress, at as OrderCreateCoupon, au as OrderCreateCouponInvalidData, av as OrderCreateCouponLine, aw as OrderCreateDisplay, ax as OrderCreateEnvelope, ay as OrderCreateLine, az as OrderCreateMeta, aA as OrderCreatePayload, aB as OrderCreatePayment, aC as OrderCreateTaxId, aD as OrderCreateTaxRate, aE as OrderCreateTotalMismatchData, aF as OrderRefundAmountMismatchData, aG as OrderRefundEnvelope, aH as OrderRefundLine, aI as OrderRefundNoOpenSessionData, aJ as OrderRefundOrderStateData, aK as OrderRefundPayload, aL as OrderRefundQuantityExceedsData, aM as OrderRefundRejectionCode, aN as OrderRefundResult, aO as OrderReopenEnvelope, aP as OrderReopenOrderStateData, aQ as OrderReopenPayload, aR as OrderReopenPaymentInMotionData, aS as OrderReopenRejectionCode, aT as OrderReopenResult, aU as OrderUpdateEnvelope, aV as OrderUpdateFee, aW as OrderUpdateLine, aX as OrderUpdatePayload, aY as OrderUpdatePayment, aZ as OrderUpdateRejectionCode, a_ as OrderUpdateReopenRequiredData, a$ as OrderUpdateShipping, b0 as PROTOCOL_HEADER, b1 as PROTOCOL_VERSION, b2 as PaymentHardware, b3 as PaymentKind, b4 as PaymentMethodDescriptor, b5 as PaymentMethodKind, b6 as PaymentOfflineMode, b7 as PaymentRounding, b8 as PaymentTipsMode, b9 as PaymentTransport, ba as PendingPairing, bb as PricedRefund, bc as PricedRefundLine, bd as ProductCategory, be as ProductPrice, bf as ProductTerm, bg as ReceiptTemplate, bh as ReceiptTemplateKind, bi as RefundableLine, bj as RefundableOrderLine, bk as RefusedOrderSettlement, bl as RegisterApprovalInvalidData, bm as RegisterApprovalRequiredData, bn as RegisterClosureSubmitPayload, bo as RegisterCommandEnvelope, bp as RegisterCommandResult, bq as RegisterCommandType, br as RegisterInfo, bs as RegisterMovementRecordPayload, bt as RegisterMovementVoidPayload, bu as RegisterSessionAlreadyOpenData, bv as RegisterSessionOpenPayload, bw as RegisterSessionSupersededData, bx as RegisterSessionTransitionPayload, by as RemoteIdEntry, bz as ResolvedPrice, bA as RoundingMode, bB as ServerCapabilities, bC as SettleCancelRequest, bD as SettleOutcome, bE as SettlePayRequest, bF as SettlePayResult, bG as SettlePayment, bH as SettleReverseLeg, bI as SettleReverseRequest, bJ as SettleReverseResult, bK as SignInResult, bL as SignalMessage, bM as StockStatus, bN as StoreClosure, bO as StoreOrder, bP as StoreOrderCharge, bQ as StoreOrderLine, bR as StoreOrderPage, bS as StoreOrderPayment, bT as StoreOrderRefund, bU as StoreOrderRefundLine, bV as StoreRefund, bW as StoreRefundOrphan, bX as StoreRefundPage, bY as StoreSettings, bZ as StoreSettingsChoice, b_ as StoreTaxClass, b$ as StoreTaxRate, c0 as StoreTaxRateLocation, c1 as TaxRounding, c2 as TillDevice, c3 as UpdateRequired, c4 as VariantOptionGroup, c5 as cashierPermissions, c6 as classifyFailure, c7 as currencySymbol, c8 as customerTraits, c9 as defaultPaymentMethods, ca as deriveSessionFigures, cb as deriveVariance, cc as formatMoney, cd as isCashierPermission, ce as isCommandBatchResponse, cf as legMethodId, cg as minorToMajor, ch as minorUnitDigits, ci as moneyFromDecimalString, cj as moneyFromMajor, ck as moneyToMajor, cl as neutralFailureClass, cm as noResponse, cn as normalizeMoneyText, co as parseCommandResult, cp as parseInfoCapabilities, cq as parseLineTax, cr as parseTaxRounding, cs as paymentMethodOf, ct as priceRefund, cu as ratePpmFromPercent, cv as refundableLines, cw as resolveCapabilities, cx as resolvePrice, cy as resolvePriceRange, cz as roundRatio, cA as wireMethodOf } from './refund-share-DVf_0clD.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import 'rxdb';
|
|
@@ -301,6 +301,8 @@ declare function ConnectorProvider({ connector, traitContext, stockOverlay, stoc
|
|
|
301
301
|
* Access the active connector. Throws if used outside a ConnectorProvider.
|
|
302
302
|
*/
|
|
303
303
|
declare function useConnector(): TallyConnector;
|
|
304
|
+
/** Returns the active connector, or null without a provider. */
|
|
305
|
+
declare function useOptionalConnector(): TallyConnector | null;
|
|
304
306
|
/**
|
|
305
307
|
* Convenience hook: grab just the product traits from the active connector.
|
|
306
308
|
*/
|
|
@@ -875,4 +877,4 @@ declare namespace index {
|
|
|
875
877
|
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
878
|
}
|
|
877
879
|
|
|
878
|
-
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, StoreRefundsUnsupportedError, 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 };
|
|
880
|
+
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, StoreRefundsUnsupportedError, 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, useOptionalConnector, useProductStock, useProductTraits, useStockOverlaid, useStockOverlayAsOf, useTraitContext, withStockOverlay, index as woocommerceCoupons, index$1 as woocommerceTax };
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
resolvePrice,
|
|
34
34
|
resolvePriceRange,
|
|
35
35
|
roundRatio
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-PQ3DB6CJ.js";
|
|
37
37
|
import {
|
|
38
38
|
__export
|
|
39
39
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -605,6 +605,9 @@ function useConnector() {
|
|
|
605
605
|
}
|
|
606
606
|
return connector;
|
|
607
607
|
}
|
|
608
|
+
function useOptionalConnector() {
|
|
609
|
+
return useContext(ConnectorContext);
|
|
610
|
+
}
|
|
608
611
|
function useProductTraits() {
|
|
609
612
|
const connector = useConnector();
|
|
610
613
|
return connector.traits.product;
|
|
@@ -2038,6 +2041,7 @@ export {
|
|
|
2038
2041
|
useCustomerTraits,
|
|
2039
2042
|
useFormatMoney,
|
|
2040
2043
|
useMoneyFormat,
|
|
2044
|
+
useOptionalConnector,
|
|
2041
2045
|
useProductStock,
|
|
2042
2046
|
useProductTraits,
|
|
2043
2047
|
useStockOverlaid,
|
|
@@ -1177,8 +1177,10 @@ interface OrderCreateFee {
|
|
|
1177
1177
|
clientFeeId: string;
|
|
1178
1178
|
/** Recorded fee title, 1–255 characters. */
|
|
1179
1179
|
name: string;
|
|
1180
|
-
/** Instruction: integer >= 0, gross when pricesIncludeTax, net otherwise; never discounted. */
|
|
1180
|
+
/** Instruction: integer >= 0, gross when its own mode (`amountIncludesTax`, else `pricesIncludeTax`) includes tax, net otherwise; never discounted. */
|
|
1181
1181
|
amountMinor: number;
|
|
1182
|
+
/** Instruction (vendurepos 2.10b): `amountMinor`'s own mode, gross when true and net when false. Absent means `pricesIncludeTax`'s. Sent only to a store whose connector declares `chargeTaxMode`, and only when it differs from `pricesIncludeTax`. */
|
|
1183
|
+
amountIncludesTax?: boolean;
|
|
1182
1184
|
/** Instruction: `none` means no tax on this fee. */
|
|
1183
1185
|
taxStatus: 'taxable' | 'none';
|
|
1184
1186
|
/** Instruction, at most 64 characters; absent means the standard class. */
|
|
@@ -1372,6 +1374,12 @@ interface StoreOrderLine {
|
|
|
1372
1374
|
/** After discounts, excluding tax. */
|
|
1373
1375
|
totalMinor: number;
|
|
1374
1376
|
taxMinor: number;
|
|
1377
|
+
/** The line's total after discounts, excluding tax, as sold, before any return; set by a connector whose live totals shrink on return (connector-medusa at plugin contract 7), absent otherwise. */
|
|
1378
|
+
soldTotalMinor?: number;
|
|
1379
|
+
/** The tax beside `soldTotalMinor`, as sold. Present exactly when it is. */
|
|
1380
|
+
soldTaxMinor?: number;
|
|
1381
|
+
/** The store's returned quantity for the line (requested, received or dismissed returns); absent when the store does not say. Refund pricing does not read it. */
|
|
1382
|
+
returnedQuantity?: number;
|
|
1375
1383
|
}
|
|
1376
1384
|
/** A fee or shipping line: excluding tax, the tax beside it. A fee may be negative.
|
|
1377
1385
|
* `taxMinor` is such that `totalMinor + taxMinor` is the gross rounded once. */
|
|
@@ -2103,6 +2111,8 @@ interface ServerCapabilities {
|
|
|
2103
2111
|
pluginContract?: number;
|
|
2104
2112
|
/** True only when the store's connector carries order.create's `cashRoundings` (ADR-094). Absent: the till never rounds a cash leg, and finalize refuses an order with entries. */
|
|
2105
2113
|
cashRounding?: boolean;
|
|
2114
|
+
/** True only when the store takes a fee's or shipping charge's own tax mode as order.create's `amountIncludesTax` (vendurepos 2.10b). Absent: finalize converts every charge to the order's mode and sends no `amountIncludesTax`. */
|
|
2115
|
+
chargeTaxMode?: boolean;
|
|
2106
2116
|
}
|
|
2107
2117
|
/** #287, ADR-071. `custom`: the till computes as when absent; that server never emits `figures_mismatch` for subtotal or tax. */
|
|
2108
2118
|
type TaxRounding = {
|
|
@@ -2219,11 +2229,101 @@ interface ConnectorTraits {
|
|
|
2219
2229
|
product: ProductTraits;
|
|
2220
2230
|
customer?: CustomerTraits;
|
|
2221
2231
|
}
|
|
2232
|
+
/** The answer to one `settleRefusedOrder` call. */
|
|
2233
|
+
type SettleOutcome =
|
|
2234
|
+
/** The order is cancelled. */
|
|
2235
|
+
{
|
|
2236
|
+
kind: 'done';
|
|
2237
|
+
status: string;
|
|
2238
|
+
}
|
|
2239
|
+
/** It is not a waiting unpaid order any more; nothing was cancelled. `capturedMinor` is what the store holds as captured. */
|
|
2240
|
+
| {
|
|
2241
|
+
kind: 'changed';
|
|
2242
|
+
status: string;
|
|
2243
|
+
capturedMinor: number;
|
|
2244
|
+
}
|
|
2245
|
+
/** The store or this check said no. */
|
|
2246
|
+
| {
|
|
2247
|
+
kind: 'refused';
|
|
2248
|
+
code: string;
|
|
2249
|
+
message: string;
|
|
2250
|
+
}
|
|
2251
|
+
/** The store no longer has it. */
|
|
2252
|
+
| {
|
|
2253
|
+
kind: 'gone';
|
|
2254
|
+
}
|
|
2255
|
+
/** No definite answer: try again later with the same `attemptId`. */
|
|
2256
|
+
| {
|
|
2257
|
+
kind: 'retry';
|
|
2258
|
+
reason: string;
|
|
2259
|
+
};
|
|
2260
|
+
/** Which order to settle: the store's id, the till's own order uuid, and the id of this attempt. */
|
|
2261
|
+
interface SettleCancelRequest {
|
|
2262
|
+
storeOrderId: string;
|
|
2263
|
+
clientOrderId: string;
|
|
2264
|
+
attemptId: string;
|
|
2265
|
+
}
|
|
2266
|
+
/** One till leg to record on the store order (#1101 slice 3): a new payment id, the till leg's method, amount and cash tendered. */
|
|
2267
|
+
interface SettlePayment {
|
|
2268
|
+
id: string;
|
|
2269
|
+
method: PaymentMethodKind;
|
|
2270
|
+
amountMinor: number;
|
|
2271
|
+
tenderedMinor?: number;
|
|
2272
|
+
}
|
|
2273
|
+
/** Record the till's unrecorded legs on the store order a refused sale left part paid. */
|
|
2274
|
+
interface SettlePayRequest extends SettleCancelRequest {
|
|
2275
|
+
currency: string;
|
|
2276
|
+
payments: readonly SettlePayment[];
|
|
2277
|
+
}
|
|
2278
|
+
/** `recorded`: the ids in `payments` the store holds as captured when the call ends, in request order. */
|
|
2279
|
+
interface SettlePayResult {
|
|
2280
|
+
outcome: SettleOutcome;
|
|
2281
|
+
recorded: readonly string[];
|
|
2282
|
+
}
|
|
2283
|
+
/** One till leg to take off the store order (#1101 slice 4): its store payment id and the void's command id, kept across repeats of an attempt.
|
|
2284
|
+
* `amountMinor` is the till leg's amount in minor units, which the connector checks against the store row. */
|
|
2285
|
+
interface SettleReverseLeg {
|
|
2286
|
+
paymentId: string;
|
|
2287
|
+
commandId: string;
|
|
2288
|
+
amountMinor: number;
|
|
2289
|
+
}
|
|
2290
|
+
/** Void the till's recorded legs on the store order a refused sale left part paid, then cancel it. */
|
|
2291
|
+
interface SettleReverseRequest extends SettleCancelRequest {
|
|
2292
|
+
legs: readonly SettleReverseLeg[];
|
|
2293
|
+
}
|
|
2294
|
+
/** `voided`: the request's payment ids the store holds as voided when the call ends, in request order. */
|
|
2295
|
+
interface SettleReverseResult {
|
|
2296
|
+
outcome: SettleOutcome;
|
|
2297
|
+
voided: readonly string[];
|
|
2298
|
+
}
|
|
2299
|
+
/** Settlement of an order the store created before it refused the sale. */
|
|
2300
|
+
interface RefusedOrderSettlement {
|
|
2301
|
+
cancel?: (context: SyncContext, request: SettleCancelRequest) => Promise<SettleOutcome>;
|
|
2302
|
+
/**
|
|
2303
|
+
* Records the till's unrecorded legs, money the customer already paid at the till, on a part-paid store order: no new
|
|
2304
|
+
* money is taken. `done` means every payment is recorded and the order reads `completed`; `changed` means nothing was
|
|
2305
|
+
* sent because the store's figures or status do not match; `gone` comes only from the uuid resolver's 404; `retry`
|
|
2306
|
+
* means no definite answer: send again with the same `attemptId` and payment ids.
|
|
2307
|
+
*/
|
|
2308
|
+
pay?: (context: SyncContext, request: SettlePayRequest) => Promise<SettlePayResult>;
|
|
2309
|
+
/**
|
|
2310
|
+
* No money moves: the cashier hands it back. `voided` lists the legs the store holds as voided when the call ends.
|
|
2311
|
+
* `done`: every leg is voided and the order reads `cancelled`.
|
|
2312
|
+
* `changed`: the store shows money or a status the till does not hold, so nothing more was sent.
|
|
2313
|
+
* `refused`: the store refused this step, or answered in a way that is not a usable ledger answer (as for `cancel` and `pay`).
|
|
2314
|
+
* The order is not cancelled. A refused void always stops the run before any cancel is sent.
|
|
2315
|
+
* `gone`: only from the uuid resolver's 404.
|
|
2316
|
+
* `retry`: no definite answer. Send again with the same `attemptId` and command ids.
|
|
2317
|
+
*/
|
|
2318
|
+
reverse?: (context: SyncContext, request: SettleReverseRequest) => Promise<SettleReverseResult>;
|
|
2319
|
+
}
|
|
2222
2320
|
/**
|
|
2223
2321
|
* The main connector interface.
|
|
2224
2322
|
* Each backend (WooCommerce, Medusa, Vendure, etc.) implements this.
|
|
2225
2323
|
*/
|
|
2226
2324
|
interface TallyConnector {
|
|
2325
|
+
/** True when the store's live order-line totals shrink as units are returned while `quantity` stays the sold quantity (Medusa). The refund form then refuses a partial refund of a line without `soldTotalMinor`/`soldTaxMinor`. Absent: line totals are as sold. */
|
|
2326
|
+
lineTotalsShrinkOnReturn?: boolean;
|
|
2227
2327
|
/** Unique identifier for this connector */
|
|
2228
2328
|
id: string;
|
|
2229
2329
|
/** Human-readable name */
|
|
@@ -2349,6 +2449,14 @@ interface TallyConnector {
|
|
|
2349
2449
|
* read-only; rejects as `listOrders`. `undefined` when the connector has no order history.
|
|
2350
2450
|
*/
|
|
2351
2451
|
getOrders?: (context: SyncContext, ids: readonly string[]) => Promise<StoreOrder[]>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Settles an order the store created before it refused the sale: online only, never through the outbox. `cancel`
|
|
2454
|
+
* cancels it only when the store's own current record shows nothing paid; `pay` records the till's unrecorded legs
|
|
2455
|
+
* only when the store's due is exactly their sum. `attemptId` identifies one attempt and is
|
|
2456
|
+
* sent again unchanged until a definite answer; `retry` means no definite answer. Rejects with
|
|
2457
|
+
* `ConnectorUnauthorizedError` for credentials. `undefined` when the connector can't settle refused orders.
|
|
2458
|
+
*/
|
|
2459
|
+
settleRefusedOrder?: RefusedOrderSettlement;
|
|
2352
2460
|
/**
|
|
2353
2461
|
* The store's refunds, newest first, one page per call, dated by when each was made (ADR-081 decision 7): online only,
|
|
2354
2462
|
* read-only. Rejects as `listOrders` does; a `dateRange` end that is not a UTC instant ending in Z is a TypeError
|
|
@@ -2479,7 +2587,7 @@ declare function roundRatio(n: bigint, d: bigint, mode?: RoundingMode): bigint;
|
|
|
2479
2587
|
*/
|
|
2480
2588
|
|
|
2481
2589
|
/** The fields of an order line this needs; a StoreOrderLine fits. */
|
|
2482
|
-
type RefundableOrderLine = Pick<StoreOrderLine, 'id' | 'quantity' | 'totalMinor' | 'taxMinor'>;
|
|
2590
|
+
type RefundableOrderLine = Pick<StoreOrderLine, 'id' | 'quantity' | 'totalMinor' | 'taxMinor' | 'soldTotalMinor' | 'soldTaxMinor'>;
|
|
2483
2591
|
/** Earlier refund lines; negative quantities count by magnitude. */
|
|
2484
2592
|
interface EarlierRefund {
|
|
2485
2593
|
lines: ReadonlyArray<Pick<OrderRefundLine, 'orderLineId' | 'quantity'>>;
|
|
@@ -2521,4 +2629,4 @@ declare function refundableLines(lines: readonly RefundableOrderLine[], refunds:
|
|
|
2521
2629
|
/** Prices requested quantities with cumulative shares, clamping them to what remains refundable. */
|
|
2522
2630
|
declare function priceRefund(lines: readonly RefundableOrderLine[], refunds: readonly EarlierRefund[], request: readonly OrderRefundLine[]): PricedRefund;
|
|
2523
2631
|
|
|
2524
|
-
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 OrderUpdateShipping 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 OrderCreatePayload as aA, type OrderCreatePayment as aB, type OrderCreateTaxId as aC, type OrderCreateTaxRate as aD, type OrderCreateTotalMismatchData as aE, type OrderRefundAmountMismatchData as aF, type OrderRefundEnvelope as aG, type OrderRefundLine as aH, type OrderRefundNoOpenSessionData as aI, type OrderRefundOrderStateData as aJ, type OrderRefundPayload as aK, type OrderRefundQuantityExceedsData as aL, type OrderRefundRejectionCode as aM, type OrderRefundResult as aN, type OrderReopenEnvelope as aO, type OrderReopenOrderStateData as aP, type OrderReopenPayload as aQ, type OrderReopenPaymentInMotionData as aR, type OrderReopenRejectionCode as aS, type OrderReopenResult as aT, type OrderUpdateEnvelope as aU, type OrderUpdateFee as aV, type OrderUpdateLine as aW, type OrderUpdatePayload as aX, type OrderUpdatePayment as aY, type OrderUpdateRejectionCode as aZ, type OrderUpdateReopenRequiredData as a_, type DisplaySignalling as aa, type DisplaySignallingContext as ab, DisplaySignallingError as ac, type DisplaySignallingErrorCode as ad, type EarlierRefund as ae, type FailureClass as af, type FingerprintReconcileAdapter as ag, type IdReconcileAdapter as ah, type ListRefundsQuery as ai, MAX_COMMANDS_PER_BATCH as aj, NEEDS_ADMIN_MESSAGE_MAX as ak, ORDER_LINE_SKU_MAX as al, ORDER_META_KEY_MAX as am, ORDER_META_MAX as an, ORDER_NOTE_MAX as ao, ORDER_TAX_IDS_MAX as ap, ORDER_TAX_ID_TYPE_MAX as aq, ORDER_TAX_ID_VALUE_MAX as ar, type OrderAddress as as, type OrderCreateCoupon as at, type OrderCreateCouponInvalidData as au, type OrderCreateCouponLine as av, type OrderCreateDisplay as aw, type OrderCreateEnvelope as ax, type OrderCreateLine as ay, type OrderCreateMeta as az, type SyncContext as b,
|
|
2632
|
+
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 OrderUpdateShipping 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 OrderCreatePayload as aA, type OrderCreatePayment as aB, type OrderCreateTaxId as aC, type OrderCreateTaxRate as aD, type OrderCreateTotalMismatchData as aE, type OrderRefundAmountMismatchData as aF, type OrderRefundEnvelope as aG, type OrderRefundLine as aH, type OrderRefundNoOpenSessionData as aI, type OrderRefundOrderStateData as aJ, type OrderRefundPayload as aK, type OrderRefundQuantityExceedsData as aL, type OrderRefundRejectionCode as aM, type OrderRefundResult as aN, type OrderReopenEnvelope as aO, type OrderReopenOrderStateData as aP, type OrderReopenPayload as aQ, type OrderReopenPaymentInMotionData as aR, type OrderReopenRejectionCode as aS, type OrderReopenResult as aT, type OrderUpdateEnvelope as aU, type OrderUpdateFee as aV, type OrderUpdateLine as aW, type OrderUpdatePayload as aX, type OrderUpdatePayment as aY, type OrderUpdateRejectionCode as aZ, type OrderUpdateReopenRequiredData as a_, type DisplaySignalling as aa, type DisplaySignallingContext as ab, DisplaySignallingError as ac, type DisplaySignallingErrorCode as ad, type EarlierRefund as ae, type FailureClass as af, type FingerprintReconcileAdapter as ag, type IdReconcileAdapter as ah, type ListRefundsQuery as ai, MAX_COMMANDS_PER_BATCH as aj, NEEDS_ADMIN_MESSAGE_MAX as ak, ORDER_LINE_SKU_MAX as al, ORDER_META_KEY_MAX as am, ORDER_META_MAX as an, ORDER_NOTE_MAX as ao, ORDER_TAX_IDS_MAX as ap, ORDER_TAX_ID_TYPE_MAX as aq, ORDER_TAX_ID_VALUE_MAX as ar, type OrderAddress as as, type OrderCreateCoupon as at, type OrderCreateCouponInvalidData as au, type OrderCreateCouponLine as av, type OrderCreateDisplay as aw, type OrderCreateEnvelope as ax, type OrderCreateLine as ay, type OrderCreateMeta as az, type SyncContext as b, type StoreTaxRate as b$, PROTOCOL_HEADER as b0, PROTOCOL_VERSION as b1, type PaymentHardware as b2, type PaymentKind as b3, type PaymentMethodDescriptor as b4, type PaymentMethodKind as b5, type PaymentOfflineMode as b6, type PaymentRounding as b7, type PaymentTipsMode as b8, type PaymentTransport as b9, type RoundingMode as bA, type ServerCapabilities as bB, type SettleCancelRequest as bC, type SettleOutcome as bD, type SettlePayRequest as bE, type SettlePayResult as bF, type SettlePayment as bG, type SettleReverseLeg as bH, type SettleReverseRequest as bI, type SettleReverseResult as bJ, type SignInResult as bK, type SignalMessage as bL, type StockStatus as bM, type StoreClosure as bN, type StoreOrder as bO, type StoreOrderCharge as bP, type StoreOrderLine as bQ, type StoreOrderPage as bR, type StoreOrderPayment as bS, type StoreOrderRefund as bT, type StoreOrderRefundLine as bU, type StoreRefund as bV, type StoreRefundOrphan as bW, type StoreRefundPage as bX, type StoreSettings as bY, type StoreSettingsChoice as bZ, type StoreTaxClass as b_, type PendingPairing as ba, type PricedRefund as bb, type PricedRefundLine as bc, type ProductCategory as bd, type ProductPrice as be, type ProductTerm as bf, type ReceiptTemplate as bg, type ReceiptTemplateKind as bh, type RefundableLine as bi, type RefundableOrderLine as bj, type RefusedOrderSettlement as bk, type RegisterApprovalInvalidData as bl, type RegisterApprovalRequiredData as bm, type RegisterClosureSubmitPayload as bn, type RegisterCommandEnvelope as bo, type RegisterCommandResult as bp, type RegisterCommandType as bq, type RegisterInfo as br, type RegisterMovementRecordPayload as bs, type RegisterMovementVoidPayload as bt, type RegisterSessionAlreadyOpenData as bu, type RegisterSessionOpenPayload as bv, type RegisterSessionSupersededData as bw, type RegisterSessionTransitionPayload as bx, type RemoteIdEntry as by, type ResolvedPrice as bz, type TraitContext as c, type StoreTaxRateLocation as c0, type TaxRounding as c1, type TillDevice as c2, type UpdateRequired as c3, type VariantOptionGroup as c4, cashierPermissions as c5, classifyFailure as c6, currencySymbol as c7, customerTraits as c8, defaultPaymentMethods as c9, wireMethodOf as cA, currencyDecimals as cB, majorToMinor as cC, deriveSessionFigures as ca, deriveVariance as cb, formatMoney as cc, isCashierPermission as cd, isCommandBatchResponse as ce, legMethodId as cf, minorToMajor as cg, minorUnitDigits as ch, moneyFromDecimalString as ci, moneyFromMajor as cj, moneyToMajor as ck, neutralFailureClass as cl, noResponse as cm, normalizeMoneyText as cn, parseCommandResult as co, parseInfoCapabilities as cp, parseLineTax as cq, parseTaxRounding as cr, paymentMethodOf as cs, priceRefund as ct, ratePpmFromPercent as cu, refundableLines as cv, resolveCapabilities as cw, resolvePrice as cx, resolvePriceRange as cy, roundRatio as cz, 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 };
|