@tallyui/pos 3.2.1 → 3.3.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/index.d.ts +37 -8
- package/dist/index.js +304 -50
- package/package.json +6 -6
- package/src/index.ts +1 -1
- package/src/order/order-builder.ts +51 -19
- package/src/order/order-drafts.ts +1 -0
- package/src/order/types.ts +11 -3
- package/src/order/woocommerce-tax.ts +68 -0
- package/src/outbox/index.ts +1 -1
- package/src/outbox/order-outbox.ts +5 -3
- package/src/outbox/types.ts +8 -1
- package/src/pos-order/command.ts +21 -6
- package/src/pos-order/finalize.ts +37 -6
- package/src/pos-order/schema.ts +41 -5
- package/src/pos-order/types.ts +9 -4
- package/src/receipt/build-receipt-data.ts +3 -1
- package/src/register/closure-document.ts +1 -1
- package/src/register/session-store.ts +2 -2
- package/src/sale/cart.ts +1 -0
- package/src/store-settings/map-store-settings.ts +5 -1
- package/src/tax/exact.ts +3 -1
- package/src/tax/index.ts +1 -1
- package/src/tax/tax-provider.tsx +7 -4
- package/src/tax/types.ts +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { Money, TaxRounding, TallyConnector, SyncContext, StoreSettingsChoice,
|
|
3
|
+
import { Money, TaxRounding, StoreSettings, TallyConnector, SyncContext, StoreSettingsChoice, StoreSettingsChoices, ProductTraits, OrderCreateLine, PaymentMethodKind, CommandServerRefs, CommandWarning, CommandError, ServerCapabilities, OrderCreateEnvelope, RegisterCommandType, RegisterCommandResult, VariantSummary, TraitContext, CommandResult, AnyCommandEnvelope, CommandEnvelope, OrderCreatePayload, RegisterCommandEnvelope } from '@tallyui/core';
|
|
4
4
|
export { getProductStock, withStockOverlay } from '@tallyui/core';
|
|
5
5
|
export { countFresh, readFresh, watchFresh } from '@tallyui/core/rxdb';
|
|
6
6
|
import * as rxdb from 'rxdb';
|
|
@@ -97,6 +97,7 @@ interface RateTaxLine {
|
|
|
97
97
|
}
|
|
98
98
|
type TaxedLine = {
|
|
99
99
|
netMinor: number;
|
|
100
|
+
netMicros?: string;
|
|
100
101
|
discountMinor?: number;
|
|
101
102
|
taxInclusive: boolean;
|
|
102
103
|
taxLines: readonly {
|
|
@@ -117,12 +118,16 @@ type TaxedLine = {
|
|
|
117
118
|
*/
|
|
118
119
|
declare function taxLinesByRate(lines: readonly TaxedLine[], orderTaxMinor: number, taxLabels?: Record<number, string>, rounding?: TaxRounding): RateTaxLine[];
|
|
119
120
|
|
|
121
|
+
type WooRate = NonNullable<StoreSettings['taxRates']>[string][number];
|
|
120
122
|
/** Tax rates as integer parts per million (19% = 190000). */
|
|
121
123
|
type TaxRateMap = {
|
|
122
124
|
default: number;
|
|
123
125
|
[taxClass: string]: number;
|
|
124
126
|
};
|
|
125
127
|
interface TaxContext {
|
|
128
|
+
getTaxRates?(taxClass?: string, options?: {
|
|
129
|
+
shipping?: boolean;
|
|
130
|
+
}): readonly WooRate[];
|
|
126
131
|
/** Tax rate for a tax class as integer parts per million (19% = 190000); the default class when omitted or unknown. */
|
|
127
132
|
getTaxRatePpm(taxClass?: string): number;
|
|
128
133
|
/** The backend's name for that class's rate, when mapped: a `per_rate_group_items` store groups by name and value (#287). */
|
|
@@ -133,7 +138,8 @@ interface TaxContext {
|
|
|
133
138
|
}
|
|
134
139
|
|
|
135
140
|
declare const taxLogger: Logger;
|
|
136
|
-
interface TaxProviderProps {
|
|
141
|
+
interface TaxProviderProps extends Pick<StoreSettings, 'taxRoundAtSubtotal' | 'shippingTaxClass' | 'taxClassSlugs'> {
|
|
142
|
+
taxRates?: StoreSettings['taxRates'];
|
|
137
143
|
ratesPpm: Record<string, number>;
|
|
138
144
|
pricesIncludeTax: boolean;
|
|
139
145
|
/** `ServerCapabilities.taxRounding` (#287); a change restarts an idle sale under it. */
|
|
@@ -142,7 +148,7 @@ interface TaxProviderProps {
|
|
|
142
148
|
rateCodes?: Record<string, string>;
|
|
143
149
|
children: ReactNode;
|
|
144
150
|
}
|
|
145
|
-
declare function TaxProvider({ ratesPpm, pricesIncludeTax, rounding, rateCodes, children }: TaxProviderProps): react_jsx_runtime.JSX.Element;
|
|
151
|
+
declare function TaxProvider({ ratesPpm, pricesIncludeTax, rounding, rateCodes, taxRates, children }: TaxProviderProps): react_jsx_runtime.JSX.Element;
|
|
146
152
|
declare function useTax(): TaxContext;
|
|
147
153
|
|
|
148
154
|
type StoreSettingsResolution = {
|
|
@@ -307,6 +313,10 @@ interface DisplayLine {
|
|
|
307
313
|
}
|
|
308
314
|
interface LineItem {
|
|
309
315
|
id: string;
|
|
316
|
+
taxClass?: string;
|
|
317
|
+
/** WooCommerce's stored net at rounding precision, in integer micro-minor units, and its rounded gross. */
|
|
318
|
+
netMicros?: string;
|
|
319
|
+
totalMinor?: number;
|
|
310
320
|
custom?: true;
|
|
311
321
|
taxStatus?: 'none';
|
|
312
322
|
productId: string;
|
|
@@ -328,13 +338,15 @@ interface LineItem {
|
|
|
328
338
|
}
|
|
329
339
|
interface ChargeLine {
|
|
330
340
|
id: string;
|
|
341
|
+
netMicros?: string;
|
|
342
|
+
totalMinor?: number;
|
|
331
343
|
name: string;
|
|
332
344
|
amountMinor: number;
|
|
333
345
|
taxClass?: string;
|
|
334
346
|
taxStatus: 'taxable' | 'none';
|
|
335
347
|
taxLines: LineItem['taxLines'];
|
|
336
348
|
netMinor: number;
|
|
337
|
-
taxMicros:
|
|
349
|
+
taxMicros: string;
|
|
338
350
|
}
|
|
339
351
|
interface FeeLine extends ChargeLine {
|
|
340
352
|
}
|
|
@@ -349,6 +361,8 @@ interface ChargeInput {
|
|
|
349
361
|
}
|
|
350
362
|
interface LineTaxLine {
|
|
351
363
|
code?: string;
|
|
364
|
+
rateId?: number;
|
|
365
|
+
compound?: boolean;
|
|
352
366
|
ratePpm: number;
|
|
353
367
|
taxMicros: string;
|
|
354
368
|
}
|
|
@@ -632,6 +646,8 @@ interface PosOrderLine {
|
|
|
632
646
|
id: string;
|
|
633
647
|
productId: string;
|
|
634
648
|
variantId?: string;
|
|
649
|
+
custom?: OrderCreateLine['custom'];
|
|
650
|
+
taxStatus?: 'taxable' | 'none';
|
|
635
651
|
name: string;
|
|
636
652
|
sku: string;
|
|
637
653
|
quantity: number;
|
|
@@ -639,6 +655,7 @@ interface PosOrderLine {
|
|
|
639
655
|
/** Line discounts plus the allocated order-discount share, in the line's own tax mode (ADR-062). */
|
|
640
656
|
discountMinor: number;
|
|
641
657
|
netMinor: number;
|
|
658
|
+
netMicros?: string;
|
|
642
659
|
taxLines: Array<{
|
|
643
660
|
code?: string;
|
|
644
661
|
ratePpm: number;
|
|
@@ -663,6 +680,8 @@ interface PosOrder {
|
|
|
663
680
|
currency: string;
|
|
664
681
|
pricesIncludeTax: boolean;
|
|
665
682
|
lines: PosOrderLine[];
|
|
683
|
+
fees?: FeeLine[];
|
|
684
|
+
shipping?: ShippingLine[];
|
|
666
685
|
subtotalMinor: number;
|
|
667
686
|
discountMinor: number;
|
|
668
687
|
taxMinor: number;
|
|
@@ -690,9 +709,9 @@ interface PosOrder {
|
|
|
690
709
|
* The order.create version every attempt under this `commandId` goes out at: the outbox records it before the first
|
|
691
710
|
* send, and lowers it only on a downgrade (ADR-065 amendment). Absent means not sent yet (or requeued).
|
|
692
711
|
*/
|
|
693
|
-
sentVersion?: 1 | 2 | 3 | 4;
|
|
712
|
+
sentVersion?: 1 | 2 | 3 | 4 | 5;
|
|
694
713
|
/** The version first tried, before the downgrade (the order's audit). */
|
|
695
|
-
downgradedFrom?: 1 | 2 | 3 | 4;
|
|
714
|
+
downgradedFrom?: 1 | 2 | 3 | 4 | 5;
|
|
696
715
|
/** ADR-065: the receipt's display figures, in integer minor units of `currency` at `exponent`. */
|
|
697
716
|
display?: DisplayTotals & {
|
|
698
717
|
currency: string;
|
|
@@ -776,6 +795,9 @@ declare function toOrderCreateEnvelope(order: PosOrder, deviceId: string, attemp
|
|
|
776
795
|
* nothing else. Its migration sets it on every older row. It is one-way like version 5.
|
|
777
796
|
* Version 7 adds `saleId`, the sale order's id (ADR-072; never sent), and changes nothing else. Its migration is the
|
|
778
797
|
* identity: older orders have no `saleId`. It is one-way like version 6.
|
|
798
|
+
* Version 8 adds fees, shipping, custom lines (ADR-075) and the woocommerce tax rounding (ADR-076), and changes nothing else.
|
|
799
|
+
* It also stores the WooCommerce 6dp net (`netMicros`) under the woocommerce rounding (ADR-076 amendment).
|
|
800
|
+
* Its migration is the identity. It is one-way like version 7.
|
|
779
801
|
*/
|
|
780
802
|
declare const posOrderSchema: RxJsonSchema<PosOrder>;
|
|
781
803
|
/**
|
|
@@ -2053,6 +2075,13 @@ declare class CartError extends Error {
|
|
|
2053
2075
|
}
|
|
2054
2076
|
declare function addEntryToCart<Doc>(builder: OrderBuilder, entry: CatalogueEntry<Doc>, traits: ProductTraits<Doc>, currency: string): string;
|
|
2055
2077
|
|
|
2078
|
+
/** Local-only context for a transport (ADR-076 amendment 1): never serialised, never part of a payload. */
|
|
2079
|
+
interface OrderTransportContext {
|
|
2080
|
+
/** The stored (frozen) order of each envelope in the batch, keyed by the envelope's `id` (its commandId). */
|
|
2081
|
+
local: {
|
|
2082
|
+
orders: ReadonlyMap<string, PosOrder>;
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2056
2085
|
type TransportOutcome = {
|
|
2057
2086
|
kind: 'results';
|
|
2058
2087
|
results: CommandResult[];
|
|
@@ -2071,7 +2100,7 @@ type TransportOutcome = {
|
|
|
2071
2100
|
retryAfterMs?: number;
|
|
2072
2101
|
};
|
|
2073
2102
|
interface CommandTransport<E extends AnyCommandEnvelope = CommandEnvelope<OrderCreatePayload>> {
|
|
2074
|
-
send(batch: E[]): Promise<TransportOutcome>;
|
|
2103
|
+
send(batch: E[], context?: OrderTransportContext): Promise<TransportOutcome>;
|
|
2075
2104
|
}
|
|
2076
2105
|
interface OutboxState {
|
|
2077
2106
|
pending: number;
|
|
@@ -2415,4 +2444,4 @@ declare function planLegs(plan: TenderPlan, rowsSinceFrom: {
|
|
|
2415
2444
|
};
|
|
2416
2445
|
};
|
|
2417
2446
|
|
|
2418
|
-
export { type Actor, type AddLineInput, type AppliedDiscount, type BackendNotFound, type BasketLine, CartError, type CashMovement, type CashMovementCollection, type CatalogueEntry, type ChargeInput, type ChargeLine, type Closure, type ClosureCollection, type ClosureContext, type ClosureScope, type CommandTransport, type Correction, CurrencyProvider, type CurrencyProviderProps, type CustomerSummary, DISCOUNTS_UNSUPPORTED, type Discount, type DisplayLine, type DisplayTotals, type FeeLine, type FinalizeOptions, type HttpTransportOptions, type LedgerRow, type LineItem, type LineTaxLine, type LogEntry, type LogLevel, type LogSink, type Logger, MAX_TENDER_MINOR, MICROS_PER_MINOR, type Movement$1 as Movement, type MovementType, type Order, type OrderBuilder, type OrderBuilderOptions, OrderContentMismatchError, type OrderManager, type OrderManagerOptions, type OrderOutbox, type OrderOutboxOptions, type OrderTaxTotals, type OutboxState, type ParkedOrderSummary, type Payment, type PaymentMethod, type PaymentTransport, type PlanLeg, type PosOrder, type PosOrderLine, type PosOrderLocalWarning, PosOrderOpenClosedError, type PosOrderPayment, type PosOrderServerFailures, type PosOrderSyncStatus, type RateTaxLine, type ReceiptConfig, type ReceiptData, type ReceiptLineItem, type RecordedFigures, RegisterApprovalRequiredError, type RegisterBucket, RegisterCloseIncompleteError, type RegisterCommand, type RegisterCommandCollection, type RegisterCounters, type RegisterDocument, type RegisterFact, type RegisterHost, RegisterIdInvalidError, RegisterMovementAmountError, RegisterMovementReasonError, RegisterMovementStrandedError, type RegisterOutbox, type RegisterOutboxOptions, type RegisterSession, RegisterSessionAlreadyOpenError, RegisterSessionClosedError, type RegisterSessionCollection, RegisterSessionRequiredError, type RegisterStore, RegisterTenderInProgressError, type Repository, type ResolveStoreSettingsOptions, SALE_SAVING, type SaleStage, type SentOrder, type ShippingLine, type SplitTab, type StoreSettingsResolution, type StoreSettingsState, TAX_ROUNDING_MIXED_NOTE, type TaxContext, type TaxLineInput, TaxProvider, type TaxProviderProps, type TaxRateMap, type TenderAction, type TenderKey, type TenderLineId, type TenderPlan, type TenderState, type TenderView, type TransportOutcome, UnsupportedOrderVersionError, type UseOrderOutboxOptions, type UseOrderOutboxResult, type UseRegisterOutboxOptions, type UseRegisterOutboxResult, type UseRegisterSessionOptions, activePlan, addEntryToCart, addPosOrderCollection, advancePerpetual, allocateOrderDiscount, appliedMinor, backToSelling, bindRegister, buildClosureDocument, buildReceiptData, buildXReportDocument, callbackSink, cashMovementSchema, catalogueEntries, changeMinor, clampClosureScope, closeNeedsApproval, closeSession, closureCommand, closureSchema, computeOrderTax, consoleSink, countVariance, createBackendNotFound, createHttpCommandTransport, createLogger, createOrderBuilder, createOrderManager, createOrderOutbox, createRegisterOutbox, createRepository, denominationTotal, denominations, deriveExpected, deriveSettled, ensureRegister, evenSplitShareMinor, exportCsv, finalizeOrder, findEntryByCode, formatClosureDate, getBoundRegisterId, getDeviceId, initTenderState, initialTenderState, isServerDecimal, labelKeys, minorToDecimal, mintClosureNumber, mintUuid, movementCommand, movementFieldError, needsAttention, nextSaleCounter, normalizeAmount, observeRegister$, openSession, openSessionSelector, orderDraftSchema, outboxLogger, overThreshold, parkedOrderSummaries$, parseMinor, planLegs, posOrderCollection, posOrderSchema, posOrdersLogger, quickTenderedAmounts, ratePpmFromPercent, readBoundRegister, readRegister, reconcileRegisterCommands, recordMovement, recordRegisterFact, registerCommandCollection, registerCommandSchema, registerCommandsLogger, registerFactsLogger, registerSessionCollection, registerSessionSchema, requireOpenSession, resolveStoreSettings, restoreOrderDraft, roundMicrosToMinor, saleLogger, sameSale, searchProducts, selectClosureRows, sessionOpenCommand, sessionTransitionCommand, stampSession, startCounting, stockOverlay$, stockOverlayAsOf$, taxFiguresForBasket, taxLinesByRate, taxLogger, taxMicros, taxProviderProps, tenderReducer, toOrderCreateEnvelope, unbindRegister, useCurrencyCode, useCurrencyFormatter, useOrderOutbox, useParkedSales, useRegisterOutbox, useRegisterSession, useSale, useStoreSettings, useTax, uuidv7, validAmount, varianceText, variantPriceLabel, voidMovement, withPricingContext, writeClosure, writeOrderDraft };
|
|
2447
|
+
export { type Actor, type AddLineInput, type AppliedDiscount, type BackendNotFound, type BasketLine, CartError, type CashMovement, type CashMovementCollection, type CatalogueEntry, type ChargeInput, type ChargeLine, type Closure, type ClosureCollection, type ClosureContext, type ClosureScope, type CommandTransport, type Correction, CurrencyProvider, type CurrencyProviderProps, type CustomerSummary, DISCOUNTS_UNSUPPORTED, type Discount, type DisplayLine, type DisplayTotals, type FeeLine, type FinalizeOptions, type HttpTransportOptions, type LedgerRow, type LineItem, type LineTaxLine, type LogEntry, type LogLevel, type LogSink, type Logger, MAX_TENDER_MINOR, MICROS_PER_MINOR, type Movement$1 as Movement, type MovementType, type Order, type OrderBuilder, type OrderBuilderOptions, OrderContentMismatchError, type OrderManager, type OrderManagerOptions, type OrderOutbox, type OrderOutboxOptions, type OrderTaxTotals, type OrderTransportContext, type OutboxState, type ParkedOrderSummary, type Payment, type PaymentMethod, type PaymentTransport, type PlanLeg, type PosOrder, type PosOrderLine, type PosOrderLocalWarning, PosOrderOpenClosedError, type PosOrderPayment, type PosOrderServerFailures, type PosOrderSyncStatus, type RateTaxLine, type ReceiptConfig, type ReceiptData, type ReceiptLineItem, type RecordedFigures, RegisterApprovalRequiredError, type RegisterBucket, RegisterCloseIncompleteError, type RegisterCommand, type RegisterCommandCollection, type RegisterCounters, type RegisterDocument, type RegisterFact, type RegisterHost, RegisterIdInvalidError, RegisterMovementAmountError, RegisterMovementReasonError, RegisterMovementStrandedError, type RegisterOutbox, type RegisterOutboxOptions, type RegisterSession, RegisterSessionAlreadyOpenError, RegisterSessionClosedError, type RegisterSessionCollection, RegisterSessionRequiredError, type RegisterStore, RegisterTenderInProgressError, type Repository, type ResolveStoreSettingsOptions, SALE_SAVING, type SaleStage, type SentOrder, type ShippingLine, type SplitTab, type StoreSettingsResolution, type StoreSettingsState, TAX_ROUNDING_MIXED_NOTE, type TaxContext, type TaxLineInput, TaxProvider, type TaxProviderProps, type TaxRateMap, type TenderAction, type TenderKey, type TenderLineId, type TenderPlan, type TenderState, type TenderView, type TransportOutcome, UnsupportedOrderVersionError, type UseOrderOutboxOptions, type UseOrderOutboxResult, type UseRegisterOutboxOptions, type UseRegisterOutboxResult, type UseRegisterSessionOptions, activePlan, addEntryToCart, addPosOrderCollection, advancePerpetual, allocateOrderDiscount, appliedMinor, backToSelling, bindRegister, buildClosureDocument, buildReceiptData, buildXReportDocument, callbackSink, cashMovementSchema, catalogueEntries, changeMinor, clampClosureScope, closeNeedsApproval, closeSession, closureCommand, closureSchema, computeOrderTax, consoleSink, countVariance, createBackendNotFound, createHttpCommandTransport, createLogger, createOrderBuilder, createOrderManager, createOrderOutbox, createRegisterOutbox, createRepository, denominationTotal, denominations, deriveExpected, deriveSettled, ensureRegister, evenSplitShareMinor, exportCsv, finalizeOrder, findEntryByCode, formatClosureDate, getBoundRegisterId, getDeviceId, initTenderState, initialTenderState, isServerDecimal, labelKeys, minorToDecimal, mintClosureNumber, mintUuid, movementCommand, movementFieldError, needsAttention, nextSaleCounter, normalizeAmount, observeRegister$, openSession, openSessionSelector, orderDraftSchema, outboxLogger, overThreshold, parkedOrderSummaries$, parseMinor, planLegs, posOrderCollection, posOrderSchema, posOrdersLogger, quickTenderedAmounts, ratePpmFromPercent, readBoundRegister, readRegister, reconcileRegisterCommands, recordMovement, recordRegisterFact, registerCommandCollection, registerCommandSchema, registerCommandsLogger, registerFactsLogger, registerSessionCollection, registerSessionSchema, requireOpenSession, resolveStoreSettings, restoreOrderDraft, roundMicrosToMinor, saleLogger, sameSale, searchProducts, selectClosureRows, sessionOpenCommand, sessionTransitionCommand, stampSession, startCounting, stockOverlay$, stockOverlayAsOf$, taxFiguresForBasket, taxLinesByRate, taxLogger, taxMicros, taxProviderProps, tenderReducer, toOrderCreateEnvelope, unbindRegister, useCurrencyCode, useCurrencyFormatter, useOrderOutbox, useParkedSales, useRegisterOutbox, useRegisterSession, useSale, useStoreSettings, useTax, uuidv7, validAmount, varianceText, variantPriceLabel, voidMovement, withPricingContext, writeClosure, writeOrderDraft };
|