@tallyui/pos 3.2.1 → 3.4.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 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, StoreSettings, StoreSettingsChoices, ProductTraits, PaymentMethodKind, CommandServerRefs, CommandWarning, CommandError, ServerCapabilities, OrderCreateEnvelope, RegisterCommandType, RegisterCommandResult, VariantSummary, TraitContext, CommandResult, AnyCommandEnvelope, CommandEnvelope, OrderCreatePayload, RegisterCommandEnvelope } from '@tallyui/core';
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,18 @@ 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
+ shippingTaxClass?: string;
129
+ taxClassSlugs?: readonly string[];
130
+ getTaxRates?(taxClass?: string, options?: {
131
+ shipping?: boolean;
132
+ }): readonly WooRate[];
126
133
  /** Tax rate for a tax class as integer parts per million (19% = 190000); the default class when omitted or unknown. */
127
134
  getTaxRatePpm(taxClass?: string): number;
128
135
  /** 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 +140,8 @@ interface TaxContext {
133
140
  }
134
141
 
135
142
  declare const taxLogger: Logger;
136
- interface TaxProviderProps {
143
+ interface TaxProviderProps extends Pick<StoreSettings, 'taxRoundAtSubtotal' | 'shippingTaxClass' | 'taxClassSlugs'> {
144
+ taxRates?: StoreSettings['taxRates'];
137
145
  ratesPpm: Record<string, number>;
138
146
  pricesIncludeTax: boolean;
139
147
  /** `ServerCapabilities.taxRounding` (#287); a change restarts an idle sale under it. */
@@ -142,7 +150,7 @@ interface TaxProviderProps {
142
150
  rateCodes?: Record<string, string>;
143
151
  children: ReactNode;
144
152
  }
145
- declare function TaxProvider({ ratesPpm, pricesIncludeTax, rounding, rateCodes, children }: TaxProviderProps): react_jsx_runtime.JSX.Element;
153
+ declare function TaxProvider({ ratesPpm, pricesIncludeTax, rounding, rateCodes, taxRates, shippingTaxClass, taxClassSlugs, children }: TaxProviderProps): react_jsx_runtime.JSX.Element;
146
154
  declare function useTax(): TaxContext;
147
155
 
148
156
  type StoreSettingsResolution = {
@@ -307,6 +315,10 @@ interface DisplayLine {
307
315
  }
308
316
  interface LineItem {
309
317
  id: string;
318
+ taxClass?: string;
319
+ /** WooCommerce's stored net at rounding precision, in integer micro-minor units, and its rounded gross. */
320
+ netMicros?: string;
321
+ totalMinor?: number;
310
322
  custom?: true;
311
323
  taxStatus?: 'none';
312
324
  productId: string;
@@ -328,13 +340,15 @@ interface LineItem {
328
340
  }
329
341
  interface ChargeLine {
330
342
  id: string;
343
+ netMicros?: string;
344
+ totalMinor?: number;
331
345
  name: string;
332
346
  amountMinor: number;
333
347
  taxClass?: string;
334
348
  taxStatus: 'taxable' | 'none';
335
349
  taxLines: LineItem['taxLines'];
336
350
  netMinor: number;
337
- taxMicros: number;
351
+ taxMicros: string;
338
352
  }
339
353
  interface FeeLine extends ChargeLine {
340
354
  }
@@ -349,6 +363,8 @@ interface ChargeInput {
349
363
  }
350
364
  interface LineTaxLine {
351
365
  code?: string;
366
+ rateId?: number;
367
+ compound?: boolean;
352
368
  ratePpm: number;
353
369
  taxMicros: string;
354
370
  }
@@ -632,6 +648,8 @@ interface PosOrderLine {
632
648
  id: string;
633
649
  productId: string;
634
650
  variantId?: string;
651
+ custom?: OrderCreateLine['custom'];
652
+ taxStatus?: 'taxable' | 'none';
635
653
  name: string;
636
654
  sku: string;
637
655
  quantity: number;
@@ -639,6 +657,7 @@ interface PosOrderLine {
639
657
  /** Line discounts plus the allocated order-discount share, in the line's own tax mode (ADR-062). */
640
658
  discountMinor: number;
641
659
  netMinor: number;
660
+ netMicros?: string;
642
661
  taxLines: Array<{
643
662
  code?: string;
644
663
  ratePpm: number;
@@ -663,6 +682,8 @@ interface PosOrder {
663
682
  currency: string;
664
683
  pricesIncludeTax: boolean;
665
684
  lines: PosOrderLine[];
685
+ fees?: FeeLine[];
686
+ shipping?: ShippingLine[];
666
687
  subtotalMinor: number;
667
688
  discountMinor: number;
668
689
  taxMinor: number;
@@ -690,9 +711,9 @@ interface PosOrder {
690
711
  * The order.create version every attempt under this `commandId` goes out at: the outbox records it before the first
691
712
  * send, and lowers it only on a downgrade (ADR-065 amendment). Absent means not sent yet (or requeued).
692
713
  */
693
- sentVersion?: 1 | 2 | 3 | 4;
714
+ sentVersion?: 1 | 2 | 3 | 4 | 5;
694
715
  /** The version first tried, before the downgrade (the order's audit). */
695
- downgradedFrom?: 1 | 2 | 3 | 4;
716
+ downgradedFrom?: 1 | 2 | 3 | 4 | 5;
696
717
  /** ADR-065: the receipt's display figures, in integer minor units of `currency` at `exponent`. */
697
718
  display?: DisplayTotals & {
698
719
  currency: string;
@@ -776,6 +797,9 @@ declare function toOrderCreateEnvelope(order: PosOrder, deviceId: string, attemp
776
797
  * nothing else. Its migration sets it on every older row. It is one-way like version 5.
777
798
  * Version 7 adds `saleId`, the sale order's id (ADR-072; never sent), and changes nothing else. Its migration is the
778
799
  * identity: older orders have no `saleId`. It is one-way like version 6.
800
+ * Version 8 adds fees, shipping, custom lines (ADR-075) and the woocommerce tax rounding (ADR-076), and changes nothing else.
801
+ * It also stores the WooCommerce 6dp net (`netMicros`) under the woocommerce rounding (ADR-076 amendment).
802
+ * Its migration is the identity. It is one-way like version 7.
779
803
  */
780
804
  declare const posOrderSchema: RxJsonSchema<PosOrder>;
781
805
  /**
@@ -1935,6 +1959,9 @@ declare function useSale(settings: Pick<StoreSettings, 'currency'>, opts: {
1935
1959
  stage: SaleStage;
1936
1960
  error: string | null;
1937
1961
  idle: boolean;
1962
+ /** The store's capabilities as passed in: a component offers fees, shipping and custom lines
1963
+ * only when `orderCreate >= 5`, and their tax status and class only as `lineTax` allows. */
1964
+ capabilities: ServerCapabilities | undefined;
1938
1965
  /** A completion is pending (see `complete()`): the sale is locked, and the UI offers Retry. */
1939
1966
  saving: boolean;
1940
1967
  /** The failed save's order is confirmed stored (see `isStored`): the UI also offers Continue (`continueSale()`). */
@@ -2053,6 +2080,13 @@ declare class CartError extends Error {
2053
2080
  }
2054
2081
  declare function addEntryToCart<Doc>(builder: OrderBuilder, entry: CatalogueEntry<Doc>, traits: ProductTraits<Doc>, currency: string): string;
2055
2082
 
2083
+ /** Local-only context for a transport (ADR-076 amendment 1): never serialised, never part of a payload. */
2084
+ interface OrderTransportContext {
2085
+ /** The stored (frozen) order of each envelope in the batch, keyed by the envelope's `id` (its commandId). */
2086
+ local: {
2087
+ orders: ReadonlyMap<string, PosOrder>;
2088
+ };
2089
+ }
2056
2090
  type TransportOutcome = {
2057
2091
  kind: 'results';
2058
2092
  results: CommandResult[];
@@ -2071,7 +2105,7 @@ type TransportOutcome = {
2071
2105
  retryAfterMs?: number;
2072
2106
  };
2073
2107
  interface CommandTransport<E extends AnyCommandEnvelope = CommandEnvelope<OrderCreatePayload>> {
2074
- send(batch: E[]): Promise<TransportOutcome>;
2108
+ send(batch: E[], context?: OrderTransportContext): Promise<TransportOutcome>;
2075
2109
  }
2076
2110
  interface OutboxState {
2077
2111
  pending: number;
@@ -2415,4 +2449,4 @@ declare function planLegs(plan: TenderPlan, rowsSinceFrom: {
2415
2449
  };
2416
2450
  };
2417
2451
 
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 };
2452
+ 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 };