@tallyui/pos 4.1.0 → 5.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.
Files changed (64) hide show
  1. package/dist/index.d.ts +584 -161
  2. package/dist/index.js +1908 -1077
  3. package/package.json +7 -6
  4. package/src/index.ts +17 -10
  5. package/src/order/index.ts +1 -0
  6. package/src/order/order-builder.ts +65 -21
  7. package/src/order/order-drafts.ts +78 -24
  8. package/src/order/taken-at.ts +5 -0
  9. package/src/order/types.ts +11 -2
  10. package/src/order/woocommerce-tax.ts +9 -12
  11. package/src/outbox/http-transport.ts +16 -1
  12. package/src/outbox/index.ts +2 -1
  13. package/src/outbox/needs-admin-reason.ts +10 -0
  14. package/src/outbox/order-outbox.ts +14 -5
  15. package/src/outbox/register-outbox.ts +4 -3
  16. package/src/outbox/types.ts +3 -1
  17. package/src/outbox/use-order-outbox.ts +7 -3
  18. package/src/pos-order/command.ts +3 -0
  19. package/src/pos-order/finalize.ts +11 -0
  20. package/src/pos-order/reopen.ts +11 -2
  21. package/src/pos-order/schema.ts +7 -2
  22. package/src/pos-order/types.ts +7 -1
  23. package/src/print/escpos/bluetooth-sink.ts +114 -0
  24. package/src/print/escpos/index.ts +4 -0
  25. package/src/print/escpos/transport.ts +3 -2
  26. package/src/print/escpos/usb-sink.ts +84 -0
  27. package/src/print/index.ts +2 -2
  28. package/src/receipt/build-receipt-data.ts +8 -1
  29. package/src/receipt/reprint.ts +2 -0
  30. package/src/receipt/types.ts +2 -0
  31. package/src/receipt-template/template-data.ts +1 -1
  32. package/src/receipt-template/wcpos/from-orders.ts +5 -1
  33. package/src/refund/index.ts +1 -0
  34. package/src/refund/needs-admin-line.ts +6 -0
  35. package/src/refund/refundable-lines.ts +2 -91
  36. package/src/refund/send-order-refund.ts +6 -1
  37. package/src/refund/submit-order-refund.ts +33 -1
  38. package/src/register/closing.ts +15 -0
  39. package/src/register/closure-document.ts +13 -5
  40. package/src/register/closure-figures.ts +83 -0
  41. package/src/register/document-labels.ts +5 -3
  42. package/src/register/expected.ts +30 -9
  43. package/src/register/index.ts +3 -1
  44. package/src/register/register-adoption.ts +42 -4
  45. package/src/register/register-document.ts +17 -0
  46. package/src/register/session-store.ts +48 -12
  47. package/src/register/use-register-session.ts +53 -20
  48. package/src/reports/adapters.ts +5 -1
  49. package/src/reports/index.ts +1 -1
  50. package/src/reports/sales-figures.ts +33 -6
  51. package/src/reports/types.ts +3 -1
  52. package/src/sale/index.ts +1 -1
  53. package/src/sale/use-sale.ts +321 -135
  54. package/src/store-orders/index.ts +5 -0
  55. package/src/store-orders/sales-range-query.ts +18 -0
  56. package/src/store-orders/use-store-orders-in-range.ts +127 -0
  57. package/src/store-orders/use-store-refunds-in-range.ts +179 -0
  58. package/src/tax/exact.ts +2 -10
  59. package/src/tax/index.ts +1 -0
  60. package/src/tender/cash-rounding.ts +49 -6
  61. package/src/tender/index.ts +1 -1
  62. package/src/tender/payment-legs.ts +5 -0
  63. package/src/tender/tender-figures.ts +3 -1
  64. package/src/outbox/types.test-d.ts +0 -27
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { MoneyFormat, Money, TaxRounding, StoreSettings, woocommerceTax, PaymentMethodDescriptor, CustomerAddress, CustomerTaxId, OrderCreateMeta, TallyConnector, SyncContext, StoreSettingsChoice, StoreSettingsChoices, Cashier, CashierPermission, ProductTraits, woocommerceCoupons, OrderCreateLine, PaymentMethodKind, OrderAddress, CommandServerRefs, CommandWarning, CommandError, StoreOrder, ReceiptTemplate, ServerCapabilities, OrderCreateEnvelope, OrderUpdateEnvelope, OrderRefundEnvelope, OrderRefundResult, Correction, RegisterInfo, RegisterCommandType, RegisterCommandResult, RegisterSessionTransitionPayload, CommandResult, AnyCommandEnvelope, CommandEnvelope, OrderCreatePayload, VariantSummary, TraitContext, IceServer, SignalMessage, DisplaySignalling, DisplaySignallingContext, DisplayAdvertisement, TillDevice, DisplayRecord, PendingPairing, CustomerInput, Customer, CustomerPatch, ProductCategory, ProductTerm, VariantOptionGroup, ListOrdersQuery, OrderFilterField, RegisterCommandEnvelope, OrderRefundLine, StoreOrderLine, OrderReopenResult, OrderReopenEnvelope } from '@tallyui/core';
4
- export { Correction, MoneyFormat as CurrencyFormat, getProductStock, ratePpmFromPercent, withStockOverlay } from '@tallyui/core';
3
+ import { MoneyFormat, Money, RoundingMode, TaxRounding, StoreSettings, woocommerceTax, PaymentMethodDescriptor, CustomerAddress, CustomerTaxId, OrderCreateMeta, TallyConnector, SyncContext, StoreSettingsChoice, StoreSettingsChoices, Cashier, CashierPermission, ProductTraits, woocommerceCoupons, StoreOrder, ListOrdersQuery, OrderFilterField, StoreRefundOrphan, StoreRefund, OrderCreateLine, PaymentMethodKind, OrderAddress, CommandServerRefs, CommandWarning, CommandError, ReceiptTemplate, ServerCapabilities, OrderCreateEnvelope, OrderUpdateEnvelope, OrderRefundEnvelope, OrderRefundResult, Correction, RegisterInfo, RegisterCommandType, RegisterCommandResult, RegisterSessionTransitionPayload, CommandResult, AnyCommandEnvelope, CommandEnvelope, OrderCreatePayload, VariantSummary, TraitContext, PaymentRounding, IceServer, SignalMessage, DisplaySignalling, DisplaySignallingContext, DisplayAdvertisement, TillDevice, DisplayRecord, PendingPairing, CustomerInput, Customer, CustomerPatch, ProductCategory, ProductTerm, VariantOptionGroup, RegisterCommandEnvelope, OrderReopenResult, OrderReopenEnvelope, StoreOrderLine } from '@tallyui/core';
4
+ export { Correction, MoneyFormat as CurrencyFormat, EarlierRefund, PricedRefund, PricedRefundLine, RefundableLine, RefundableOrderLine, getProductStock, priceRefund, ratePpmFromPercent, refundableLines, withStockOverlay } from '@tallyui/core';
5
5
  import * as rxdb from 'rxdb';
6
6
  import { RxCollection, RxJsonSchema, MangoQuery, MigrationStrategies, RxDatabase, RxLocalDocumentMutation } from 'rxdb';
7
7
  import * as rxjs from 'rxjs';
@@ -152,8 +152,6 @@ declare const MICROS_PER_MINOR = 1000000n;
152
152
  * Throws RangeError unless amount and rate are safe integers and rate is non-negative.
153
153
  */
154
154
  declare function taxMicros(amountMinor: number, ratePpm: number, pricesIncludeTax: boolean): bigint;
155
- /** #287: `half_up` is Math.round's rule, Vendure's DefaultMoneyStrategy (default-money-strategy.js:19-21). */
156
- type RoundingMode = 'half_away_from_zero' | 'half_up';
157
155
  /** Rounds micro-minor-units to integer minor units, half away from zero unless `mode` says otherwise. */
158
156
  declare function roundMicrosToMinor(micros: bigint, mode?: RoundingMode): number;
159
157
  interface TaxLineInput {
@@ -331,6 +329,8 @@ interface Order {
331
329
  /** TallyUI#709: present (true) only when store-priced coupons are set and couponPricingBasis(order) no longer equals their basis. */
332
330
  couponPricesStale?: true;
333
331
  payments: Payment[];
332
+ /** ADR-094: a cash leg that settles the sale at a rounded due records the signed difference here, counted in totalMinor; only entries whose leg counts toward paid are built in. Absent when empty. */
333
+ cashRoundings?: CashRounding[];
334
334
  customer: CustomerSummary | null;
335
335
  note: string;
336
336
  /** The sale's order meta, WooCommerce's custom fields (ADR-092 6d). Set with `useSale().setMeta`, parked with the draft,
@@ -484,6 +484,11 @@ interface AppliedDiscount extends Discount {
484
484
  id: string;
485
485
  amountMinor: number;
486
486
  }
487
+ /** ADR-094: one cash rounding, the signed minor units its leg (`paymentId`) settled the sale above (+) or below (-) its due. */
488
+ interface CashRounding {
489
+ paymentId: string;
490
+ minor: number;
491
+ }
487
492
  interface Payment {
488
493
  id: string;
489
494
  /** The store's payment record id for a leg it already holds */
@@ -503,6 +508,10 @@ interface Payment {
503
508
  reference?: string;
504
509
  /** The units of each line (`String(line id)`) this leg paid for, set when it was taken with unit picks (#1133). Absent for a leg taken by amount. */
505
510
  units?: Readonly<Record<string, number>>;
511
+ /** When the till recorded the leg (an ISO 8601 instant). Absent on store-held legs and on legs from before 4.2. */
512
+ takenAt?: string;
513
+ /** The register session the leg was taken in (money suspect S3): its cash counts there, not in the order's session. */
514
+ sessionId?: string;
506
515
  }
507
516
  interface CustomerSummary {
508
517
  id: string;
@@ -614,6 +623,19 @@ interface TaxDerivation {
614
623
  /** Everything the "Tax based on" panel shows: the setting, the address used, and the rates that match it (#722). Pure. */
615
624
  declare function taxDerivation(settings: StoreSettings, taxLocation: SaleTaxLocation): TaxDerivation;
616
625
 
626
+ /** The lines and charges `taxLinesByRate` splits, each in the tax mode its tax was rounded in (ADR-065: the
627
+ * receipt's figures, which every per-rate split must equal). Under `woocommerce` rounding a line with `netMicros`
628
+ * is in the store's mode, since WooCommerce rounds every line that way. Otherwise a line keeps its own mode, and
629
+ * a line without one is in the store's; a charge outside `woocommerce` keeps its `amountIncludesTax`, else the store's. */
630
+ declare function taxedLinesFor<L extends {
631
+ netMicros?: string;
632
+ taxInclusive?: boolean;
633
+ }, C>(lines: readonly L[], charges: readonly (C & {
634
+ amountIncludesTax?: boolean;
635
+ })[], pricesIncludeTax: boolean, rounding?: TaxRounding): Array<(L | C) & {
636
+ taxInclusive: boolean;
637
+ }>;
638
+
617
639
  type StoreSettingsResolution = {
618
640
  status: 'ready';
619
641
  settings: StoreSettings;
@@ -923,6 +945,11 @@ interface OrderBuilderOptions {
923
945
  storeOrder?: StoreOrderRef;
924
946
  afterClose?: Order['afterClose'];
925
947
  couponContext?: OrderCouponContext;
948
+ /** A restored paid draft's parked tax lines by line, fee or shipping id (row 497); held only while one of `legIds` is captured or moving. */
949
+ heldRates?: {
950
+ legIds: readonly string[];
951
+ taxLines: ReadonlyMap<string, readonly LineTaxLine[]>;
952
+ };
926
953
  }
927
954
  interface OrderBuilder {
928
955
  order$: Observable<Order>;
@@ -969,10 +996,19 @@ interface OrderBuilder {
969
996
  applyLineDiscount(lineId: string, discount: Discount): void;
970
997
  applyOrderDiscount(discount: Discount): void;
971
998
  removeDiscount(discountId: string): void;
999
+ /** ADR-094: `rounding` adds the leg's cash rounding entry with it, so no snapshot shows the leg without it (none when `minor` is 0). */
972
1000
  addPayment(payment: Omit<Payment, 'id'> & {
973
1001
  id?: string;
1002
+ }, rounding?: {
1003
+ minor: number;
974
1004
  }): string;
975
- setPaymentStatus(paymentId: string, status: PaymentLegStatus): boolean;
1005
+ /** ADR-094: adds a cash rounding entry against an existing leg; it counts in totalMinor while that leg counts toward paid. */
1006
+ addCashRounding(entry: CashRounding): void;
1007
+ /**
1008
+ * Moves a leg's status; `takenAt` is set on the leg only on a move to captured, and `sessionId` with it (S3: the
1009
+ * session that captured the leg), only on a leg that has none yet.
1010
+ */
1011
+ setPaymentStatus(paymentId: string, status: PaymentLegStatus, takenAt?: string, sessionId?: string): boolean;
976
1012
  removePayment(paymentId: string): void;
977
1013
  setCustomer(customer: CustomerSummary | null): void;
978
1014
  setNote(note: string): void;
@@ -1043,9 +1079,11 @@ interface ParkedOrderSummary {
1043
1079
  }
1044
1080
  declare function writeOrderDraft(drafts: RxCollection, snapshot: Order): Promise<string>;
1045
1081
  /**
1046
- * Rebuilds a saved order on `taxContext`. Fees and shipping re-derive their rates; under woo granularity lines re-derive
1047
- * from their class too. Outside woo, a line marked taxFromClass re-derives from its class unless `keepTaxRates` is set;
1048
- * every other line (given rates, a draft from before the marker) keeps its stored rates. `keepCoupons` puts the saved
1082
+ * Rebuilds a saved order on `taxContext`. Outside woo, a line marked taxFromClass re-derives from its class unless
1083
+ * `keepTaxRates` is set; every other line (given rates, a draft from before the marker) keeps its stored rates. Fees and
1084
+ * shipping, and under woo lines too, re-derive today's rates, except with `keepTaxRates` (row 497): then they hold their
1085
+ * parked tax lines (under woo, only those with every rate id), and the hold ends at the next build once no parked leg
1086
+ * is still captured or in motion. Granularity must match the draft's. `keepCoupons` puts the saved
1049
1087
  * coupons back as parked, figures and all, while an unlocked leg is live (ADR-077 d3, amended 2026-11-19); otherwise none.
1050
1088
  * Carried coupons always restore their priced amounts against the saved basis, keeping stale figures stale.
1051
1089
  */
@@ -1078,6 +1116,196 @@ declare function useParkedSales(drafts: RxCollection | undefined): {
1078
1116
  discard: (id: string) => Promise<void>;
1079
1117
  };
1080
1118
 
1119
+ /** Progress of one ranged read; null when idle, finished, failed or aborted. */
1120
+ interface OrderDownloadProgress {
1121
+ downloaded: number;
1122
+ total: number | null;
1123
+ }
1124
+ interface StoreOrdersInRange {
1125
+ orders: StoreOrder[];
1126
+ progress: OrderDownloadProgress | null;
1127
+ unreadable: number;
1128
+ error: unknown | null;
1129
+ complete: boolean;
1130
+ }
1131
+ type StoreOrdersRangeQuery = Omit<ListOrdersQuery, 'page' | 'perPage'>;
1132
+ /**
1133
+ * Every store order matching `query`, read online page by page (ADR-081 decision 6). Nothing is stored or cached.
1134
+ *
1135
+ * - Idle (`progress: null`, nothing called) without `connector`, `context`, `query` or `connector.listOrders`.
1136
+ * - `progress` is `{ downloaded, total }` while pages are fetched: `{ downloaded: 0, total: null }` until the first
1137
+ * page lands, then `total` is that page's `total` (`null` when the store gives no count) and stays fixed for the
1138
+ * read. `downloaded` is always `orders.length + unreadable`.
1139
+ * - Orders are deduplicated by id as pages land; the first copy stays. `unreadable` sums the `unreadable` of the first
1140
+ * page and of each later page that adds a new order id; a later page that adds none adds nothing to it.
1141
+ * - A page with `hasMore: false` finishes: `complete: true`, `progress: null`, `orders` in `listOrders`' own order.
1142
+ * - A rejection stops the read: `error` is what was thrown, `progress` is `null`, the orders read so far stay.
1143
+ * - A page with `hasMore: true` that adds no new order id also stops the read, with an `Error`, even when it reports
1144
+ * unreadable orders, so a store that keeps repeating a page stops.
1145
+ * - A `query` that differs by value, or a new `connector` or `context`, abandons the read and starts again from
1146
+ * page 1, showing none of the old orders; an equal new object changes nothing. Unmounting abandons the read.
1147
+ * So keep `connector` and `context` the same objects across renders: a new object each render restarts the read on
1148
+ * every render.
1149
+ *
1150
+ * Offset paging over a live store can repeat a row, which is dropped, or push a row past a page boundary mid-read,
1151
+ * which is then missed until the next read. Nothing is cached, so opening the screen again corrects it.
1152
+ */
1153
+ declare function useStoreOrdersInRange(connector: TallyConnector | null, context: SyncContext | null, query: StoreOrdersRangeQuery | null): StoreOrdersInRange;
1154
+
1155
+ /**
1156
+ * The read for a sales report over `[after, before)`: UTC instants with a `Z`, such as `orderFiltersQuery` gives for
1157
+ * store days. When the connector lists `modifiedAfter`, the read is widened to orders changed at or after `after` and
1158
+ * created before `before`, so an order created earlier and paid in the range is fetched. `reportOrderFromStoreOrder`
1159
+ * then places each order on its paid day, and the report's own range test drops one paid outside the range.
1160
+ * Otherwise the read is by creation date.
1161
+ */
1162
+ declare function salesRangeQuery(range: {
1163
+ after: string;
1164
+ before: string;
1165
+ }, orderFilters: readonly OrderFilterField[] | undefined): StoreOrdersRangeQuery;
1166
+
1167
+ /** A store day, `yyyy-MM-dd` in the store's timezone. */
1168
+ type StoreDay = string;
1169
+ /** Inclusive range of store days. */
1170
+ interface DayRange {
1171
+ from: StoreDay;
1172
+ to: StoreDay;
1173
+ }
1174
+ interface ReportCategory {
1175
+ id: string;
1176
+ name: string;
1177
+ }
1178
+ interface ReportLine {
1179
+ /** Grouping identity: variant, else product, else name. */
1180
+ key: string;
1181
+ name: string;
1182
+ quantity: number;
1183
+ /** After discounts, excluding tax. */
1184
+ netMinor: number;
1185
+ taxMinor: number;
1186
+ /** Cost of goods for the whole line (quantity × unit cost). Absent or null means the cost is missing, never 0. */
1187
+ costMinor?: number | null;
1188
+ /** The line's first category, when the caller joined one. */
1189
+ category?: ReportCategory;
1190
+ }
1191
+ interface ReportPayment {
1192
+ method: string;
1193
+ label?: string;
1194
+ amountMinor: number;
1195
+ }
1196
+ interface ReportTax {
1197
+ ratePpm: number;
1198
+ code?: string;
1199
+ label: string;
1200
+ taxMinor: number;
1201
+ /** The net this rate taxed; null when the source does not carry it. */
1202
+ netMinor: number | null;
1203
+ }
1204
+ /** An order as the reports read it. Money in integer minor units. */
1205
+ interface ReportOrder {
1206
+ id: string;
1207
+ /** ISO 8601 UTC instant the sale was made. */
1208
+ at: string;
1209
+ /** Gross, including tax. */
1210
+ totalMinor: number;
1211
+ taxMinor: number;
1212
+ discountMinor: number;
1213
+ /** True when the order still owes money: its unpaid remainder is `unpaid`, not `unknown`. */
1214
+ needsPayment?: boolean;
1215
+ lines: ReportLine[];
1216
+ payments: ReportPayment[];
1217
+ /** A reopened sale's payments the store already held (its locked legs): not this till's takings, but they settle the total. */
1218
+ paidEarlierMinor?: number;
1219
+ taxes: ReportTax[];
1220
+ /** Refunds embedded on the order, undated (a store order's own list). Positive. */
1221
+ refunds: Array<{
1222
+ id: string;
1223
+ amountMinor: number;
1224
+ }>;
1225
+ /** Σ the order's cash roundings, signed (ADR-094); absent when none. Always absent on a store-sourced order: its rounding is a plain fee, kept inside net (#1282). */
1226
+ roundingMinor?: number;
1227
+ }
1228
+ /** A refund dated by when it was made, counted on that store day. */
1229
+ interface ReportRefund {
1230
+ id: string;
1231
+ orderId: string;
1232
+ /** ISO 8601 UTC instant the refund was made. */
1233
+ at: string;
1234
+ /** Zero or more. Gross, tax included. */
1235
+ amountMinor: number;
1236
+ }
1237
+ /** The caller's product directory: a line's unit cost and first category. */
1238
+ type LineJoin = (line: {
1239
+ productId?: string;
1240
+ variantId?: string;
1241
+ }) => {
1242
+ unitCostMinor?: number | null;
1243
+ category?: ReportCategory;
1244
+ } | undefined;
1245
+
1246
+ interface StoreRefundsRangeQuery {
1247
+ /** The report's store days, inclusive. */
1248
+ range: DayRange;
1249
+ /** IANA zone of the store, or 'device' (as SalesFiguresInput.timezone). */
1250
+ timezone: string;
1251
+ /** The report's currency (StoreOrder.currency). A refund in any other currency is never counted. */
1252
+ currency: string;
1253
+ /** Set fields restrict the report; a refund counts only when its order carries the same value for every set field. */
1254
+ scope?: {
1255
+ storeId?: string;
1256
+ cashierId?: string;
1257
+ registerId?: string;
1258
+ };
1259
+ }
1260
+ interface OtherCurrencyRefunds {
1261
+ currency: string;
1262
+ count: number;
1263
+ amountMinor: number;
1264
+ }
1265
+ interface StoreRefundsInRange {
1266
+ /** The counted refunds as report rows. undefined when the store has no dated refunds: the report then uses its orders' embedded refunds. */
1267
+ refunds: ReportRefund[] | undefined;
1268
+ orphans: StoreRefundOrphan[];
1269
+ unreadable: number;
1270
+ unscoped: StoreRefund[];
1271
+ otherCurrency: OtherCurrencyRefunds[];
1272
+ progress: OrderDownloadProgress | null;
1273
+ error: unknown | null;
1274
+ complete: boolean;
1275
+ }
1276
+ /**
1277
+ * Every refund a store made in the report's store days, read online page by page from `listRefunds` (ADR-081
1278
+ * decision 7), as `useStoreOrdersInRange` reads orders (decision 6). Nothing is stored or cached.
1279
+ *
1280
+ * - Idle (`refunds: undefined`, `complete: false`, nothing called) without `connector`, `context` or `query`.
1281
+ * - No `connector.listRefunds`, or a page rejecting with `StoreRefundsUnsupportedError`: `refunds: undefined`,
1282
+ * `complete: true`, so `salesFigures` uses the orders' embedded refunds.
1283
+ * - The read's `dateRange` is the store days' UTC bounds (`orderFiltersQuery`). While reading, `progress` is
1284
+ * `{ downloaded, total }`: distinct refund and orphan ids plus `unreadable`, and page 1's `total` or `null`.
1285
+ * - One id set covers refunds and orphans; the first copy stays. `unreadable` sums page 1's and each later page's
1286
+ * that adds a new id. A `hasMore: true` page that adds no new id stops the read with an `Error`.
1287
+ * - Each fresh refund is sorted into exactly one place, so none is in two of `refunds`, `unscoped`, `otherCurrency`
1288
+ * and `orphans`. With a set `scope` field, each page's not-yet-asked orders are fetched with one `getOrders` call:
1289
+ * an order not returned (or no `getOrders`) makes the refund `unscoped`; an order with a different value in any set
1290
+ * field puts it outside the report, in no list; else an order missing a set field makes it `unscoped`. Then a
1291
+ * refund in `query.currency` is counted in `refunds`, in the store's order; any other goes to `otherCurrency`, one
1292
+ * row per currency, sorted by code. `orphans` are kept as they come. Only `refunds` is ever summed.
1293
+ * - A page with `hasMore: false`, its orders resolved, finishes: `complete: true`, `progress: null`. Any other
1294
+ * rejection, from `listRefunds` or `getOrders`, stops the read: `error` is it, `progress` is `null`, what was
1295
+ * counted stays.
1296
+ * - Pass `refunds` to `salesFigures` only once `complete` is `true`. While `progress` is set the list is partial.
1297
+ * After an `error` it is partial and `complete` stays `false`: the report shows the error and gives no refund
1298
+ * figure. It does not fall back to the embedded basis, so it never passes `undefined` for a failed read. With a
1299
+ * report `compare` period, `query.range` spans both periods. `unscoped`, `otherCurrency`, `orphans` and
1300
+ * `unreadable` then count the whole read, not each period.
1301
+ * - A `query` that differs by value, or a new `connector` or `context`, abandons the read and starts again from
1302
+ * page 1, showing none of the old rows; an equal new object changes nothing. Unmounting abandons the read.
1303
+ *
1304
+ * Offset paging over a live store can repeat a row, which is dropped, or push a row past a page boundary mid-read,
1305
+ * which is then missed until the next read.
1306
+ */
1307
+ declare function useStoreRefundsInRange(connector: TallyConnector | null, context: SyncContext | null, query: StoreRefundsRangeQuery | null): StoreRefundsInRange;
1308
+
1081
1309
  /** WCPOS receipt data schema version these blocks follow (wiki: fiscal groundwork, receipt identity and QR §2). */
1082
1310
  declare const RECEIPT_SCHEMA_VERSION = "1.4.0";
1083
1311
  /** 1.4 `software`: which software produced the receipt. */
@@ -1139,6 +1367,11 @@ interface ReceiptData {
1139
1367
  name: string;
1140
1368
  amountMinor: number;
1141
1369
  }>;
1370
+ /** ADR-094: the sum of the order's cash roundings, signed; present only when non-zero. Counted in totals.totalMinor. */
1371
+ rounding?: {
1372
+ name: string;
1373
+ amountMinor: number;
1374
+ };
1142
1375
  discounts: {
1143
1376
  label: string;
1144
1377
  amountMinor: number;
@@ -1264,6 +1497,10 @@ interface PosOrderPayment {
1264
1497
  tenderedMinor?: number;
1265
1498
  changeMinor?: number;
1266
1499
  reference?: string;
1500
+ /** When the till recorded the leg (`Payment.takenAt`); absent on store-held and older legs. */
1501
+ takenAt?: string;
1502
+ /** The session the leg was taken in (`Payment.sessionId`, S3); absent means the order's session. */
1503
+ sessionId?: string;
1267
1504
  }
1268
1505
  interface PosOrder {
1269
1506
  id: string;
@@ -1294,6 +1531,8 @@ interface PosOrder {
1294
1531
  /** What the store owes back on a reopened sale whose locked payments exceed its new total, in minor units (pos_orders v15, ADR-090). `finalizeOrder` writes it on every reopened sale, 0 when nothing is due; absent on a till sale. */
1295
1532
  refundDueMinor?: number;
1296
1533
  payments: PosOrderPayment[];
1534
+ /** ADR-094: the cash rounding entries, keyed by this order's payment ids and counted in totalMinor. Absent when empty. */
1535
+ cashRoundings?: CashRounding[];
1297
1536
  /** `billing` and `shipping` (#722) are frozen copies of the customer's addresses, stored only with `taxAddress`. */
1298
1537
  customer: {
1299
1538
  id?: string;
@@ -2737,7 +2976,7 @@ declare function voidMovement(sessions: RegisterSessionCollection, movements: Ca
2737
2976
  * count in the drawer, because the cash was taken, until a finalized successor carries their payments (ADR-077 R5 amended).
2738
2977
  * A refund still pending at close is not counted, and the Z lists it.
2739
2978
  */
2740
- declare function writeClosure({ closures, register, storeKey, session, counted, otherTenders, movements, orders, refunds, tillExpected, labels, resolveCashierName, softwareVersion, timezone, }: {
2979
+ declare function writeClosure({ closures, register, storeKey, session, counted, otherTenders, movements, orders, drafts, liveLegs, liveRoundings, refunds, tillExpected, labels, resolveCashierName, softwareVersion, timezone, }: {
2741
2980
  closures: ClosureCollection;
2742
2981
  /** The register document's host (`register_sessions`). */
2743
2982
  register: RegisterHost;
@@ -2749,6 +2988,18 @@ declare function writeClosure({ closures, register, storeKey, session, counted,
2749
2988
  movements: readonly CashMovement[];
2750
2989
  /** Any `pos_orders`; only those whose `sessionId` is this session's are counted. */
2751
2990
  orders: readonly PosOrder[];
2991
+ /**
2992
+ * `order_drafts` documents: a parked sale's legs taken in this session count here (S3). Optional here only because
2993
+ * `useRegisterSession`, the real caller, always passes it and `liveLegs`; any other caller must pass both, or cash taken
2994
+ * in this session but not yet on an order is missing from its Z.
2995
+ */
2996
+ drafts?: readonly {
2997
+ data?: unknown;
2998
+ }[];
2999
+ /** The live sale's taken legs (`useSale`'s `registerView().takenLegs`, S3): those taken in this session count here. See `drafts`. */
3000
+ liveLegs?: readonly Payment[];
3001
+ /** The live sale's cash rounding entries (`registerView().cashRoundings`, #1281): one on a `liveLegs` leg taken in this session counts here. */
3002
+ liveRoundings?: readonly CashRounding[];
2752
3003
  /** `pos_refunds` rows; only this session's applied ones are counted (ADR-080 amendment 1). */
2753
3004
  refunds?: readonly PosRefund[];
2754
3005
  tillExpected?: Record<string, number>;
@@ -2928,15 +3179,28 @@ interface DrawerTerms {
2928
3179
  * method's figure is its `otherTenders` amount. A refund counts once per method it touches.
2929
3180
  */
2930
3181
  declare function deriveDrawerTerms(input: Parameters<typeof deriveExpected>[0]): DrawerTerms;
3182
+ type TillLeg = {
3183
+ method: string;
3184
+ methodId?: string;
3185
+ amountMinor: number;
3186
+ storePaymentId?: string;
3187
+ sessionId?: string;
3188
+ };
3189
+ type TillOrder = {
3190
+ sessionId?: string;
3191
+ payments: readonly TillLeg[];
3192
+ };
2931
3193
  /**
2932
- * Takings per payment method for one session, for the closure sheet: this till's captured payments (`tillPayments`) of the
2933
- * orders whose `sessionId` is `sessionId`, keyed by `legMethodId`'s kind plus id (`external:stripe`), with the number of
3194
+ * Takings per payment method for one session, for the closure sheet: this till's captured payments (`tillPayments`) in
3195
+ * `sessionId`: a payment's own session, else its order's (S3), keyed by `legMethodId`'s kind plus id (`external:stripe`), with the number of
2934
3196
  * payments behind each. Local only, never synced: register rows and payloads keep `method_id: payment.method` (#256, ADR-070
2935
3197
  * decision 1). A leg with no methodId keys exactly as deriveDrawerTerms does (`cash` or its method); the figures sum to
2936
- * deriveDrawerTerms' cash sales plus other tenders for the same orders. Refunds and movements are not here: they are keyed
3198
+ * deriveDrawerTerms' cash sales plus other tenders for the same orders. `extra` adds taken legs no order holds yet (S3: a
3199
+ * parked draft's `parkedTakenLegs`, the live sale's `registerView().takenLegs`), each counted only in its own `sessionId`; they are legs,
3200
+ * not `LedgerRow`s, because a row keeps no `methodId` to key by. Refunds and movements are not here: they are keyed
2937
3201
  * by the wire method. The map has no prototype, so a platform id such as `__proto__` or `toString` is a key like any other.
2938
3202
  */
2939
- declare function takingsByMethod(orders: readonly Pick<PosOrder, 'sessionId' | 'payments'>[], sessionId: string): Record<string, DrawerTerm>;
3203
+ declare function takingsByMethod(orders: readonly TillOrder[], sessionId: string, extra?: readonly TillLeg[]): Record<string, DrawerTerm>;
2940
3204
 
2941
3205
  /**
2942
3206
  * The pure maths behind a register count: variance against the expected float, a display
@@ -3037,6 +3301,56 @@ declare function deriveSettled(recorded: RecordedFigures, corrections: readonly
3037
3301
  touched: Set<string>;
3038
3302
  };
3039
3303
 
3304
+ /**
3305
+ * One typed read of a closure's figures (#1261). `writeClosure` (session-store.ts) freezes them in the untyped
3306
+ * `Closure.breakdowns`, and a closure adopted from the store may lack any of them, so every reader goes through here.
3307
+ *
3308
+ * The one rule: a money or count value that is not a finite integer (absent, `null`, a string, NaN) is left out
3309
+ * (undefined), never read as 0. A missing group is an empty list. A payment method, tax rate or movement whose money
3310
+ * is not a finite integer is dropped from its list, and so is a movement without a string id. A cashier given as a
3311
+ * bare string becomes `{ id, name: id }`; a nameless one is named by its id.
3312
+ */
3313
+
3314
+ type ClosureFigures = {
3315
+ openingFloat: {
3316
+ expectedMinor?: number;
3317
+ countedMinor?: number;
3318
+ varianceMinor?: number;
3319
+ };
3320
+ paymentMethods: {
3321
+ id: string;
3322
+ name?: string;
3323
+ salesMinor: number;
3324
+ refundsMinor: number;
3325
+ }[];
3326
+ taxRates: {
3327
+ key: string;
3328
+ name?: string;
3329
+ netMinor: number;
3330
+ taxMinor: number;
3331
+ grossMinor: number;
3332
+ }[];
3333
+ movements: {
3334
+ id: string;
3335
+ type: string;
3336
+ amountMinor: number;
3337
+ reason: string;
3338
+ voided: boolean;
3339
+ createdAtGmt?: string;
3340
+ createdBy?: string;
3341
+ }[];
3342
+ transactionCount?: number;
3343
+ refundCount?: number;
3344
+ cashiers: {
3345
+ id: string;
3346
+ name: string;
3347
+ }[];
3348
+ taxRoundingMixed: boolean;
3349
+ taxIncludesStorePaid: boolean;
3350
+ varianceNote?: string;
3351
+ };
3352
+ declare function closureFigures(closure: Pick<Closure, 'breakdowns'>): ClosureFigures;
3353
+
3040
3354
  /**
3041
3355
  * The opening float the open-register card suggests (v2 parity A4): the register's default float, else the cash
3042
3356
  * counted at the last close, else none. Port provenance: WCPOS v2 monorepo `main` `5ac185b0e`,
@@ -3102,6 +3416,7 @@ declare const labelKeys: {
3102
3416
  no_sale: string;
3103
3417
  void: string;
3104
3418
  copy: string;
3419
+ cash_rounding: string;
3105
3420
  };
3106
3421
  declare const ENGLISH_CLOSURE_LABELS: Record<keyof typeof labelKeys, string>;
3107
3422
 
@@ -3217,6 +3532,7 @@ declare function buildClosureDocument(row: Closure, context: ClosureContext): {
3217
3532
  closure: {
3218
3533
  tax_store_paid_note?: string | undefined;
3219
3534
  tax_rounding_note?: string | undefined;
3535
+ has_cash_rounding: boolean;
3220
3536
  has_sales: boolean;
3221
3537
  has_perpetual: boolean;
3222
3538
  } & {
@@ -3283,8 +3599,15 @@ declare function buildClosureDocument(row: Closure, context: ClosureContext): {
3283
3599
  reason: string;
3284
3600
  amount_display: string;
3285
3601
  }[];
3286
- cashiers: Values[];
3602
+ cashiers: {
3603
+ id: string;
3604
+ name: string;
3605
+ }[];
3287
3606
  };
3607
+ cash_rounding?: ({
3608
+ name: string;
3609
+ amount: {} | null;
3610
+ } & Record<"amount_display", string>) | undefined;
3288
3611
  period_sales_total_display: string;
3289
3612
  period_refunds_total_display: string;
3290
3613
  perpetual_sales_total_display: string;
@@ -3329,6 +3652,7 @@ declare function buildXReportDocument(session: RegisterSession, context: Closure
3329
3652
  closure: {
3330
3653
  tax_store_paid_note?: string | undefined;
3331
3654
  tax_rounding_note?: string | undefined;
3655
+ has_cash_rounding: boolean;
3332
3656
  has_sales: boolean;
3333
3657
  has_perpetual: boolean;
3334
3658
  } & {
@@ -3381,8 +3705,15 @@ declare function buildXReportDocument(session: RegisterSession, context: Closure
3381
3705
  reason: string;
3382
3706
  amount_display: string;
3383
3707
  }[];
3384
- cashiers: Values[];
3708
+ cashiers: {
3709
+ id: string;
3710
+ name: string;
3711
+ }[];
3385
3712
  };
3713
+ cash_rounding?: ({
3714
+ name: string;
3715
+ amount: {} | null;
3716
+ } & Record<"amount_display", string>) | undefined;
3386
3717
  period_sales_total_display: string;
3387
3718
  period_refunds_total_display: string;
3388
3719
  perpetual_sales_total_display: string;
@@ -3534,8 +3865,9 @@ type SessionTarget = {
3534
3865
  * Applied opens fill a missing resume id; refused opens make open/counting sessions conflict.
3535
3866
  * Superseded rejections make open/counting sessions terminal; a conflict session leaves only by an applied open or abandon (ADR-078 decision 9); terminal/unknown states stay untouched.
3536
3867
  * Applied conflict opens restore the latest transition's counting state, otherwise open; pending rows do nothing.
3537
- * Given `host` and `storeKey`, applied rows also raise the register's counters to the store's (#651, `adoptStoreCounters`),
3868
+ * Given `host` and `storeKey`, applied rows also raise the register's counters to the store's (#651, `adoptStoreCounters`; refunds only from answers at the highest closure number among them),
3538
3869
  * and given `closures` too, a closure refused for its number is renumbered once and requeued (#655, `renumberRefused`).
3870
+ * Given `closures`, applied closure answers then set the register's perpetual refunds to the store's (`settleStoreRefunds`) when nothing of this till's is unsent.
3539
3871
  * Answers are walked in seq/key order; adoption is idempotent and safe to run at any time.
3540
3872
  */
3541
3873
  declare function adoptRegisterResults({ commands, sessions, registerId, host, storeKey, closures }: {
@@ -3589,6 +3921,10 @@ declare function reapproveClosure({ commands, closureId, approval, approvedBy, r
3589
3921
  declare class RegisterTenderInProgressError extends Error {
3590
3922
  constructor();
3591
3923
  }
3924
+ /** The live sale is still saving (or its save failed and was not retried), so the till can't count or close under it. Its message can be shown to a cashier as it is. */
3925
+ declare class RegisterSaleSavingError extends Error {
3926
+ constructor();
3927
+ }
3592
3928
  /** The register already has an `open` or `counting` session, or an open is in flight. Its message can be shown to a cashier as it is. */
3593
3929
  declare class RegisterSessionAlreadyOpenError extends Error {
3594
3930
  constructor();
@@ -3617,6 +3953,27 @@ interface UseRegisterSessionOptions {
3617
3953
  deviceName?: string | null;
3618
3954
  /** `pos_orders`: a session's sales are those whose `sessionId` is its id. */
3619
3955
  orders: RxCollection<PosOrder> | null;
3956
+ /**
3957
+ * Required (S3): `order_drafts`, the sale's own, so a parked sale's taken legs count in the session that took them;
3958
+ * `null` when the app never parks a sale. Left out, that cash would be missing from the session's Z.
3959
+ */
3960
+ drafts: RxCollection | null;
3961
+ /**
3962
+ * Required (S3): the live sale's taken legs, read when the figures are derived, so a leg still in the cart (after
3963
+ * `cancelTender`, say) counts on its session's Z; `null` when the app has no live sale. A getter, because the app
3964
+ * creates the register before the sale (the sale takes `register.saleSession`). The usual wiring is a ref:
3965
+ * ```ts
3966
+ * const saleRef = useRef<ReturnType<typeof useSale> | null>(null)
3967
+ * const register = useRegisterSession({ …, liveSale: () => saleRef.current?.registerView() ?? { takenLegs: [], saving: false } })
3968
+ * const sale = useSale(…)
3969
+ * saleRef.current = sale
3970
+ * ```
3971
+ */
3972
+ liveSale: (() => {
3973
+ takenLegs: readonly Payment[];
3974
+ saving: boolean;
3975
+ cashRoundings?: readonly CashRounding[];
3976
+ }) | null;
3620
3977
  /** The register document's host, for the closure number and perpetual totals (`writeClosure`); `null` while it opens. */
3621
3978
  register: RegisterHost | null;
3622
3979
  /** The app's neutral store key (see `bindRegister`). */
@@ -3770,6 +4127,11 @@ interface OrderTransportContext {
3770
4127
  orders: ReadonlyMap<string, PosOrder>;
3771
4128
  };
3772
4129
  }
4130
+ type NeedsAdminAnswer = {
4131
+ id: string;
4132
+ reason: string;
4133
+ message: string;
4134
+ };
3773
4135
  type TransportOutcome = {
3774
4136
  kind: 'results';
3775
4137
  results: CommandResult[];
@@ -3786,6 +4148,7 @@ type TransportOutcome = {
3786
4148
  kind: 'retry';
3787
4149
  reason: string;
3788
4150
  retryAfterMs?: number;
4151
+ needsAdmin?: NeedsAdminAnswer;
3789
4152
  };
3790
4153
  interface CommandTransport<E extends AnyCommandEnvelope = CommandEnvelope<OrderCreatePayload>> {
3791
4154
  send(batch: E[], context?: OrderTransportContext): Promise<TransportOutcome>;
@@ -4017,20 +4380,37 @@ type SaleStage = {
4017
4380
  declare const DISCOUNTS_UNSUPPORTED = "finalize: discounts are not supported by the server yet (order.create v2)";
4018
4381
  /** Every sale change refuses with this while a completion is pending (see `complete()`). */
4019
4382
  declare const SALE_SAVING = "This sale is being saved. Retry to finish it.";
4383
+ /** `complete`, `park` and `resume` refuse with this while a close for the sale's register is in flight (#1275). */
4384
+ declare const REGISTER_CLOSING = "The register is closing. Wait for the close to finish, then try again.";
4020
4385
  declare const PAYMENT_IN_MOTION = "Finish or void the payment in progress before completing the sale";
4021
4386
  /**
4022
4387
  * `switchSale()` and `closeSale()` refuse a sale whose legs took money (u19). v2 keeps a partly paid order's legs on
4023
- * switching, but a TallyUI draft keeps no tender stage, the next `startTender` replaces every unlocked leg but a kept
4024
- * paid draft's parked legs, and `resume` keeps a paid draft's parked coupons (ADR-077 d3, amended 2026-11-19): so the
4388
+ * switching, but a TallyUI draft keeps no tender stage; `startTender` keeps taken legs and legs in motion (ADR-072 d3,
4389
+ * amended 2026-11-22 and 2026-11-23), and `resume` keeps a paid draft's parked coupons (ADR-077 d3, amended 2026-11-19): so the
4025
4390
  * sale stays on the till until it is paid or its paid legs are voided.
4026
4391
  */
4027
4392
  declare const SALE_PARTLY_PAID = "This sale is partly paid. Take the rest of the payment or void the paid legs first.";
4393
+ /** newSale refuses with this while an unlocked payment leg is pending or authorized. */
4394
+ declare const SALE_CARD_IN_PROGRESS = "A card payment is still in progress. Finish or cancel it before starting a new sale.";
4028
4395
  declare const SALE_IN_TENDER = "Finish or cancel the payment before switching sales";
4029
4396
  /**
4030
4397
  * Line and total changes refuse with this while a till leg is live, as v2's resolveStage stills the cart (tally-woo 11c).
4031
4398
  * "Cancel the payment" names the leg's button, `pos_checkout.cancel_payment` ("Cancel payment") in packages/components.
4032
4399
  */
4033
4400
  declare const SALE_HAS_PAYMENT = "A payment was taken on this sale. Cancel the payment before changing the sale.";
4401
+ /** removeTender refuses a taken leg with this: it is voided, never removed (ADR-072 d3, amended 2026-11-22). */
4402
+ declare const PAYMENT_TAKEN = "This payment was taken. Void it instead of removing it.";
4403
+ /** A cash addTender refuses with this when the balance less the legs in motion leaves nothing due (row 500). */
4404
+ declare const NOTHING_DUE = "Nothing is left to pay: the payments on this sale already cover the total.";
4405
+ /** ADR-094: a cash due that rounds to nothing is entered against the last leg counting toward paid; with none, there is nothing to round against. */
4406
+ declare const NOTHING_TO_ROUND_AGAINST = "This sale rounds to nothing in cash: take it by another method.";
4407
+ declare const CASH_NOT_PAYABLE = "Cash cannot pay that amount: take a whole number of the smallest cash step.";
4408
+ declare const CASH_WAITS_FOR_PAYMENT = "Cash cannot pay that amount while another payment is in progress: finish that payment first.";
4409
+ declare const CASH_PICK_ENTRIES_MAX = 15;
4410
+ declare const CASH_PICK_LIMIT = "Too many rounded cash payments on this sale: take the rest as one payment.";
4411
+ declare const CASH_SETTLE_LIMIT = "Too many rounded cash payments on this sale: take the rest by another method.";
4412
+ /** voidTender's refusal for cashVoidRefusal's 'later_cash_rounding' (ADR-094 item 6); the components translate it as pos_checkout.void_later_cash_first. */
4413
+ declare const VOID_LATER_CASH_FIRST = "Void the later cash payment first.";
4034
4414
  /** On the receipt the finished sale refuses edits and re-tender with this; `add` starts the next sale instead (v2 #2861). */
4035
4415
  declare const SALE_FINISHED = "This sale is finished. Start a new sale to change it.";
4036
4416
  /** startTender and complete() refuse with this while the order's store-priced coupons are stale or being priced again (TallyUI#710). */
@@ -4056,7 +4436,7 @@ declare const META_CHANGE_REFUSED = "Custom fields can only change in the cart.
4056
4436
  declare const META_INVALID = "A custom field needs a name of at most 255 characters that does not start with \"_\", and a sale takes at most 50.";
4057
4437
  /** ADR-092 6b: updateLine's refusal once the sale left the cart; a line's name, SKU and regular price change only in the cart. */
4058
4438
  declare const LINE_EDIT_REFUSED = "A line can only be edited in the cart. Cancel the payment to edit it, or start a new order.";
4059
- /** #1095: restore()'s refusal of a removal whose sale moved on (reset, parked, finished) or that is already back. */
4439
+ /** #1095: restore()'s refusal of a removal whose sale moved on (reset, parked, resumed, finished), whose customer changed or whose sale was re-taxed since, or that is already back. */
4060
4440
  declare const RESTORE_STALE = "This item can no longer be put back. Add it again.";
4061
4441
  /** Taken by `removal()` before a remove; pass it to `restore()`. Hosts never build one. */
4062
4442
  type SaleRemoval = {
@@ -4119,6 +4499,8 @@ declare function useSale(settings: Pick<StoreSettings, 'currency' | 'calcDiscoun
4119
4499
  isStored?: (posOrder: PosOrder) => Promise<boolean>;
4120
4500
  /** Tests only: overrides HUNG_SAVE_CHECK_MS, so a test can shrink the hung-save poll's interval. */
4121
4501
  hungSaveCheckMs?: number;
4502
+ /** Tests only: overrides SAVE_TIMEOUT_MS, so a test can shrink the save's time bound. */
4503
+ saveTimeoutMs?: number;
4122
4504
  /**
4123
4505
  * #722: the tax context for a customer's address (`saleTaxContexts(settings)`, memoized). Each new sale is taxed for its
4124
4506
  * customer, and `setCustomer` re-taxes a cart whose new customer moves the matched rates; tender and receipt keep theirs.
@@ -4192,7 +4574,7 @@ declare function useSale(settings: Pick<StoreSettings, 'currency' | 'calcDiscoun
4192
4574
  remove(lineId: string): void;
4193
4575
  /** #1095: the line, fee or shipping line `id` as it is now, taken before a remove for `restore()`; null when it is not there. */
4194
4576
  removal(kind: SaleRemoval["kind"], id: string): SaleRemoval | null;
4195
- /** #1095, v2's Undo: puts a removal back at its old index (clamped), re-taxed when the sale's rates moved since; returns a refusal or null. */
4577
+ /** #1095, v2's Undo: puts a removal back at its old index (clamped); returns a refusal or null. Any customer change, a re-tax, a reset (park, resume, new sale) or the receipt voids it (RESTORE_STALE). */
4196
4578
  restore(removal: SaleRemoval): string | null;
4197
4579
  /** A line's discount, or the order's without a line; returns the refusal to show, or null once applied. */
4198
4580
  applyDiscount(lineId: string | null, discount: Discount): string | null;
@@ -4241,8 +4623,8 @@ declare function useSale(settings: Pick<StoreSettings, 'currency' | 'calcDiscoun
4241
4623
  amountMinor: number;
4242
4624
  reference?: string;
4243
4625
  } | null) => void;
4244
- /** ADR-072: external is capped at the balance due; change comes only from cash. A leg is captured unless a status says otherwise; a leg in motion is held against the external cap. Units are checked against the units legs hold (`heldUnitsByLine`), but a leg's amount is not tied to its units' money here; the pane enforces that (#1133). */
4245
- addTender(tender: {
4626
+ /** ADR-072: external is capped at the balance due; change comes only from cash. A cash leg records the amount applied, the amount handed over (`tenderedMinor`) and the change (`changeMinor`). A leg is captured unless a status says otherwise; a leg in motion is held against the external cap. Units are checked against the units legs hold (`heldUnitsByLine`), but a leg's amount is not tied to its units' money here; the pane enforces that (#1133). A cash part pick rounds its own target on a cashRounding store (ADR-094). */
4627
+ addTender(input: {
4246
4628
  method: "cash" | "external";
4247
4629
  methodId?: string;
4248
4630
  amountMinor: number;
@@ -4250,12 +4632,15 @@ declare function useSale(settings: Pick<StoreSettings, 'currency' | 'calcDiscoun
4250
4632
  reference?: string;
4251
4633
  units?: Readonly<Record<string, number>>;
4252
4634
  status?: "pending" | "authorized" | "captured";
4635
+ rounding?: PaymentRounding;
4253
4636
  }): string | null;
4254
4637
  setTenderStatus(paymentId: string, status: "authorized" | "captured" | "failed"): boolean;
4255
- /** The leg stays in order.payments as voided and counts nothing; removeTender still removes a leg outright. Refused on the receipt. */
4638
+ /** The leg stays in order.payments as voided and counts nothing; removeTender removes only a leg that took no money. Refused on the receipt. */
4256
4639
  voidTender(paymentId: string): boolean;
4257
4640
  /** ADR-072: remove one tender and its dropped-reference warning. An id not among the payments changes nothing. Refused on the receipt. */
4258
4641
  removeTender(paymentId: string): void;
4642
+ /** True when setTender keeps this payment; false for one it replaces and for an id not among the payments. Changes nothing. */
4643
+ tenderHeld(paymentId: string): boolean;
4259
4644
  cancelTender(): void;
4260
4645
  /**
4261
4646
  * Finalizes the tender, stamps the session (see `session`), hands the order to `onSaleCompleted`,
@@ -4271,6 +4656,7 @@ declare function useSale(settings: Pick<StoreSettings, 'currency' | 'calcDiscoun
4271
4656
  * another is in flight returns that call's promise, and a call on the receipt does nothing. While
4272
4657
  * `cashierRef` or `registerId` is out of bounds (shown as `error`), a call does nothing either,
4273
4658
  * unless it's the Retry of a pending completion, which was built with the options as they were.
4659
+ * Refused with `REGISTER_CLOSING`, changing nothing, while a close for this register is in flight (#1275).
4274
4660
  */
4275
4661
  complete: () => Promise<void>;
4276
4662
  /**
@@ -4284,24 +4670,47 @@ declare function useSale(settings: Pick<StoreSettings, 'currency' | 'calcDiscoun
4284
4670
  * save still in flight carries on in the background, a throw logged at error) and starts the new
4285
4671
  * sale outright — from the receipt, or an idle cart, there's nothing pending to abandon. Abandoning
4286
4672
  * clears the screen, never the record (the Front desk, 2026-09-25). `newSale()` never deletes,
4287
- * updates or requeues `pos_orders` itself.
4673
+ * updates or requeues `pos_orders` itself. An unfinished sale that still holds a taken payment is refused
4674
+ * with SALE_PARTLY_PAID, changing nothing, as `closeSale` refuses it; the receipt and a confirmed stored
4675
+ * pending completion are unchanged.
4676
+ * An unfinished sale with an unlocked leg in motion refuses with SALE_CARD_IN_PROGRESS, changing nothing.
4288
4677
  */
4289
4678
  newSale(): void;
4290
- /** Parks the cart in `drafts`; resolves to a refusal message, or null once parked. */
4679
+ /**
4680
+ * S3: the live sale's legs its session counts now and no stored order counts yet, for `useRegisterSession`'s
4681
+ * `liveSale`: captured till legs stamped with a session, not reopened and not counted by an after-close sale's closure
4682
+ * (`sessionTakenLegs`, the rule a parked draft's legs follow). `[]` on the receipt, whose stored order counts them.
4683
+ * `cashRoundings` are the sale's cash rounding entries on those legs, copied, counted on the Z with them (#1281).
4684
+ * `saving` is true while a completion is in flight or pending, including after a failed save, and while a
4685
+ * `park()` or `resume()` is in flight.
4686
+ */
4687
+ registerView(): {
4688
+ takenLegs: Payment[];
4689
+ saving: boolean;
4690
+ cashRoundings: CashRounding[];
4691
+ };
4692
+ /**
4693
+ * Parks the cart in `drafts`; resolves to a refusal message, or null once parked.
4694
+ * Refused with `REGISTER_CLOSING` while a close for this register is in flight (#1275).
4695
+ */
4291
4696
  park(): Promise<string | null>;
4292
4697
  /** Whether the live sale or a parked draft holds this store order; unreadable drafts do not count. */
4293
4698
  holdsStoreOrder(orderId: string): Promise<boolean>;
4294
- /** Loads a reopened store order (from reopenStoreOrder) into an empty sale, or returns why not. */
4699
+ /** Loads a reopened store order (from reopenStoreOrder) into an empty sale, or returns why not; refused with SALE_PARTLY_PAID while the live sale holds a taken payment. */
4295
4700
  openStoreOrder(order: Order): string | null;
4296
- /** Resumes a draft into an empty cart; resolves to a refusal message, or null once resumed. */
4701
+ /**
4702
+ * Resumes a draft into an empty cart; resolves to a refusal message, or null once resumed; refused with SALE_PARTLY_PAID while the live sale holds a taken payment.
4703
+ * Refused with `REGISTER_CLOSING` while a close for this register is in flight (#1275).
4704
+ */
4297
4705
  resume(draftId: string, options?: {
4298
4706
  keepParkedPrices?: boolean;
4299
4707
  }): Promise<string | null>;
4300
4708
  /**
4301
4709
  * Opens the parked draft `draftId`, or an empty sale for null (New), as a tab switch (u19, v2 cart/tabs.tsx):
4302
4710
  * parks the current sale first when it has lines, fees or shipping (a receipt is done and is not parked).
4303
- * Refused, changing nothing, while saving, for a partly paid sale (SALE_PARTLY_PAID), a payment in motion or
4711
+ * Refused, changing nothing, while saving, for a partly paid sale or an empty sale holding a taken payment (SALE_PARTLY_PAID), a payment in motion or
4304
4712
  * the tender stage. Resolves to a refusal (park's, or `resume`'s for the chosen draft), or null.
4713
+ * Refused with `REGISTER_CLOSING` while a close for this register is in flight (#1275).
4305
4714
  */
4306
4715
  switchSale(draftId: string | null): Promise<string | null>;
4307
4716
  /** Discards the current sale (nothing is parked) and starts an empty one; refused while saving, once a leg of an unfinished sale took or holds money, or in the tender stage.
@@ -5919,6 +6328,7 @@ declare function encodeEscPos(receipt: ReceiptData, options: EncodeEscPosOptions
5919
6328
  * through `createPrintQueue`, like the system transport, so one printer prints one job at a time.
5920
6329
  */
5921
6330
 
6331
+ /** Where the ESC/POS bytes go. A `write` that rejects with a `PrintError` keeps its code (`unsupported` for a device it cannot print to); any other rejection is a `failed` PrintError. */
5922
6332
  interface EscPosSink {
5923
6333
  write(bytes: Uint8Array): Promise<void>;
5924
6334
  }
@@ -5956,6 +6366,71 @@ declare function createStarWebPrntSink(options: NetworkSinkOptions & {
5956
6366
  /** The web sink for a network Epson or Star profile; null for system, usb, bluetooth, a generic vendor or no address. */
5957
6367
  declare function networkSinkFor(profile: PrinterProfile, options?: Pick<NetworkSinkOptions, 'https' | 'timeoutMs' | 'fetch'>): EscPosSink | null;
5958
6368
 
6369
+ interface WebUsbEndpoint {
6370
+ readonly endpointNumber: number;
6371
+ readonly direction: 'in' | 'out';
6372
+ readonly type: 'bulk' | 'interrupt' | 'isochronous';
6373
+ }
6374
+ /** Shaped on the DOM `USBDevice`; e2e/web/webusb-sink.spec.ts checks these member names in Chromium. */
6375
+ interface WebUsbDevice {
6376
+ readonly opened: boolean;
6377
+ readonly configuration?: {
6378
+ readonly interfaces: readonly {
6379
+ readonly interfaceNumber: number;
6380
+ readonly claimed: boolean;
6381
+ readonly alternate: {
6382
+ readonly interfaceClass: number;
6383
+ readonly endpoints: readonly WebUsbEndpoint[];
6384
+ };
6385
+ }[];
6386
+ } | null;
6387
+ readonly productName?: string | null;
6388
+ open(): Promise<void>;
6389
+ selectConfiguration(configurationValue: number): Promise<void>;
6390
+ claimInterface(interfaceNumber: number): Promise<void>;
6391
+ clearHalt(direction: 'in' | 'out', endpointNumber: number): Promise<void>;
6392
+ transferOut(endpointNumber: number, data: Uint8Array<ArrayBuffer>): Promise<{
6393
+ status: 'ok' | 'stall' | 'babble';
6394
+ bytesWritten: number;
6395
+ }>;
6396
+ }
6397
+ interface WebUsbSinkOptions {
6398
+ device: WebUsbDevice;
6399
+ /** Bytes per `transferOut`: a positive integer, default 4096. */
6400
+ chunkSize?: number;
6401
+ }
6402
+ declare function createWebUsbSink({ device, chunkSize }: WebUsbSinkOptions): EscPosSink;
6403
+
6404
+ /** The print services the sink probes, in order. The app passes them to `requestDevice` as `optionalServices`. */
6405
+ declare const BLUETOOTH_PRINT_SERVICES: readonly string[];
6406
+ interface WebBluetoothCharacteristic {
6407
+ readonly properties: {
6408
+ readonly write: boolean;
6409
+ readonly writeWithoutResponse: boolean;
6410
+ };
6411
+ writeValueWithResponse(value: Uint8Array<ArrayBuffer>): Promise<void>;
6412
+ writeValueWithoutResponse(value: Uint8Array<ArrayBuffer>): Promise<void>;
6413
+ }
6414
+ interface WebBluetoothGattService {
6415
+ getCharacteristic(characteristic: string): Promise<WebBluetoothCharacteristic>;
6416
+ }
6417
+ interface WebBluetoothGattServer {
6418
+ readonly connected: boolean;
6419
+ connect(): Promise<unknown>;
6420
+ getPrimaryService(service: string): Promise<WebBluetoothGattService>;
6421
+ }
6422
+ /** Shaped on the DOM `BluetoothDevice`; e2e/web/webbluetooth-sink.spec.ts checks these member names in Chromium. */
6423
+ interface WebBluetoothDevice {
6424
+ readonly name?: string | null;
6425
+ readonly gatt?: WebBluetoothGattServer | null;
6426
+ }
6427
+ interface WebBluetoothSinkOptions {
6428
+ device: WebBluetoothDevice;
6429
+ /** Bytes per GATT write: a positive integer, default 20. */
6430
+ chunkSize?: number;
6431
+ }
6432
+ declare function createWebBluetoothSink({ device, chunkSize }: WebBluetoothSinkOptions): EscPosSink;
6433
+
5959
6434
  /**
5960
6435
  * A standalone cash-drawer kick, ported from WCPOS v2 `packages/printer/src/printer-service.ts`
5961
6436
  * (`encodeEscposDrawerKick`, `openDrawer`) and `capabilities.ts` (`canOpenDrawer`), monorepo main.
@@ -6114,83 +6589,6 @@ type CartQuantityLine = {
6114
6589
  */
6115
6590
  declare function cartQuantities(lines: readonly CartQuantityLine[]): Map<string, number>;
6116
6591
 
6117
- /** A store day, `yyyy-MM-dd` in the store's timezone. */
6118
- type StoreDay = string;
6119
- /** Inclusive range of store days. */
6120
- interface DayRange {
6121
- from: StoreDay;
6122
- to: StoreDay;
6123
- }
6124
- interface ReportCategory {
6125
- id: string;
6126
- name: string;
6127
- }
6128
- interface ReportLine {
6129
- /** Grouping identity: variant, else product, else name. */
6130
- key: string;
6131
- name: string;
6132
- quantity: number;
6133
- /** After discounts, excluding tax. */
6134
- netMinor: number;
6135
- taxMinor: number;
6136
- /** Cost of goods for the whole line (quantity × unit cost). Absent or null means the cost is missing, never 0. */
6137
- costMinor?: number | null;
6138
- /** The line's first category, when the caller joined one. */
6139
- category?: ReportCategory;
6140
- }
6141
- interface ReportPayment {
6142
- method: string;
6143
- label?: string;
6144
- amountMinor: number;
6145
- }
6146
- interface ReportTax {
6147
- ratePpm: number;
6148
- code?: string;
6149
- label: string;
6150
- taxMinor: number;
6151
- /** The net this rate taxed; null when the source does not carry it. */
6152
- netMinor: number | null;
6153
- }
6154
- /** An order as the reports read it. Money in integer minor units. */
6155
- interface ReportOrder {
6156
- id: string;
6157
- /** ISO 8601 UTC instant the sale was made. */
6158
- at: string;
6159
- /** Gross, including tax. */
6160
- totalMinor: number;
6161
- taxMinor: number;
6162
- discountMinor: number;
6163
- /** True when the order still owes money: its unpaid remainder is `unpaid`, not `unknown`. */
6164
- needsPayment?: boolean;
6165
- lines: ReportLine[];
6166
- payments: ReportPayment[];
6167
- /** A reopened sale's payments the store already held (its locked legs): not this till's takings, but they settle the total. */
6168
- paidEarlierMinor?: number;
6169
- taxes: ReportTax[];
6170
- /** Refunds embedded on the order, undated (a store order's own list). Positive. */
6171
- refunds: Array<{
6172
- id: string;
6173
- amountMinor: number;
6174
- }>;
6175
- }
6176
- /** A refund dated by when it was made, counted on that store day. */
6177
- interface ReportRefund {
6178
- id: string;
6179
- orderId: string;
6180
- /** ISO 8601 UTC instant the refund was made. */
6181
- at: string;
6182
- /** Positive. */
6183
- amountMinor: number;
6184
- }
6185
- /** The caller's product directory: a line's unit cost and first category. */
6186
- type LineJoin = (line: {
6187
- productId?: string;
6188
- variantId?: string;
6189
- }) => {
6190
- unitCostMinor?: number | null;
6191
- category?: ReportCategory;
6192
- } | undefined;
6193
-
6194
6592
  /** What the orders filter bar holds (#721): store ids as strings, and the date range as store days. */
6195
6593
  interface OrderFilterValue {
6196
6594
  status?: string;
@@ -6328,6 +6726,11 @@ interface UseRegisterOutboxResult {
6328
6726
  }
6329
6727
  declare function useRegisterOutbox(options: UseRegisterOutboxOptions): UseRegisterOutboxResult;
6330
6728
 
6729
+ /** The retry reason prefix the transport gives a 409 needs_admin answer; the server's reason follows it. */
6730
+ declare const NEEDS_ADMIN_RETRY_PREFIX = "needs_admin:";
6731
+ /** The server's needs_admin reason inside an outbox retry reason, or undefined when the reason is anything else. */
6732
+ declare function needsAdminReasonOf(retryReason: string): string | undefined;
6733
+
6331
6734
  declare const outboxLogger: Logger;
6332
6735
 
6333
6736
  interface UseOrderOutboxOptions {
@@ -6359,7 +6762,7 @@ interface UseOrderOutboxResult {
6359
6762
  /** The newest 50 orders, newest first; empty until the current store is ready. */
6360
6763
  recent: PosOrder[];
6361
6764
  /**
6362
- * Stores a finalized order, then flushes. Throws the opening error, or "Orders are not ready.", before the store is ready.
6765
+ * Stores a finalized order, then flushes. It resolves only once `state.pending` counts the order. Throws the opening error, or "Orders are not ready.", before the store is ready.
6363
6766
  * Recording an order whose `id` is already stored, not deleted, with the same money-bearing content (`sameSale`;
6364
6767
  * a retried `complete()`) counts as stored, never overwrites it, and still flushes, whatever the stored `commandId`
6365
6768
  * (a requeue mints a new one; the difference is logged at warn). Other content rejects with `OrderContentMismatchError`.
@@ -6411,6 +6814,10 @@ type OrderRefundOutcome = {
6411
6814
  } | {
6412
6815
  kind: 'rejected';
6413
6816
  error: CommandError;
6817
+ } | {
6818
+ kind: 'needs_admin';
6819
+ reason: string;
6820
+ message: string;
6414
6821
  } | {
6415
6822
  kind: 'unknown';
6416
6823
  reason: string;
@@ -6422,10 +6829,13 @@ type OrderRefundOutcome = {
6422
6829
  } | {
6423
6830
  kind: 'unauthorized';
6424
6831
  };
6425
- /** Online only, never queued (ADR-080). On unknown, resend the same envelope (same id).
6832
+ /** Online only, never queued (ADR-080). On unknown or needs_admin, resend the same envelope (same id; Check again).
6426
6833
  * After rejected, a new attempt needs a new id. Refused and unauthorized mean the store did not take the batch. */
6427
6834
  declare function sendOrderRefund(transport: CommandTransport<OrderRefundEnvelope>, envelope: OrderRefundEnvelope): Promise<OrderRefundOutcome>;
6428
6835
 
6836
+ /** The till's lead line for a refund parked needs_admin, by reason (TallyUI #1280). Only session_closed guarantees no money moved. */
6837
+ declare function refundNeedsAdminLine(reason: string): string;
6838
+
6429
6839
  declare class RefundAnswerPendingError extends Error {
6430
6840
  readonly record: PosRefund;
6431
6841
  readonly code = "REFUND_ANSWER_PENDING";
@@ -6434,7 +6844,7 @@ declare class RefundAnswerPendingError extends Error {
6434
6844
  /** Online only, never queued; the record is written before the send.
6435
6845
  * An applied record is final; a pending one is resent only with its own envelope
6436
6846
  * (ADR-080 amendment 1). */
6437
- declare function submitOrderRefund({ refunds, transport, envelope, now }: {
6847
+ declare function submitOrderRefund(args: {
6438
6848
  refunds: PosRefundCollection;
6439
6849
  transport: CommandTransport<OrderRefundEnvelope>;
6440
6850
  envelope: OrderRefundEnvelope;
@@ -6444,54 +6854,6 @@ declare function submitOrderRefund({ refunds, transport, envelope, now }: {
6444
6854
  record: PosRefund;
6445
6855
  }>;
6446
6856
 
6447
- /**
6448
- * Ports v2 calculate-refund.ts (calculateLineItemRefund, computeRemainingRefundQuantity).
6449
- * Amounts follow ADR-080 amendment 2's cumulative-share rule.
6450
- */
6451
-
6452
- /** The fields of an order line this needs; a StoreOrderLine fits. */
6453
- type RefundableOrderLine = Pick<StoreOrderLine, 'id' | 'quantity' | 'totalMinor' | 'taxMinor'>;
6454
- /** Earlier refund lines; negative quantities count by magnitude. */
6455
- interface EarlierRefund {
6456
- lines: ReadonlyArray<Pick<OrderRefundLine, 'orderLineId' | 'quantity'>>;
6457
- }
6458
- /** Remaining quantities and amounts, with earlier refund magnitudes capped at the line quantity. */
6459
- interface RefundableLine {
6460
- orderLineId: string;
6461
- refundedQuantity: number;
6462
- refundableQuantity: number;
6463
- netMinor: number;
6464
- taxMinor: number;
6465
- }
6466
- /** A selected quantity's cumulative shares of net and tax, and their sum. */
6467
- interface PricedRefundLine {
6468
- orderLineId: string;
6469
- quantity: number;
6470
- netMinor: number;
6471
- taxMinor: number;
6472
- totalMinor: number;
6473
- }
6474
- /** Payload-ready lines and their amounts; the caller adds shipping and adjustment to totalMinor. */
6475
- interface PricedRefund {
6476
- /** Exactly orderLineId, quantity (>= 1), and restock. */
6477
- lines: OrderRefundLine[];
6478
- /** Amounts in the same order as lines. */
6479
- priced: PricedRefundLine[];
6480
- /** Requests cut to availability, including unknown lines cut to zero. */
6481
- clamped: Array<{
6482
- orderLineId: string;
6483
- requestedQuantity: number;
6484
- quantity: number;
6485
- }>;
6486
- netMinor: number;
6487
- taxMinor: number;
6488
- totalMinor: number;
6489
- }
6490
- /** Returns the quantities and amounts still refundable, in order-line order. */
6491
- declare function refundableLines(lines: readonly RefundableOrderLine[], refunds: readonly EarlierRefund[]): RefundableLine[];
6492
- /** Prices requested quantities with cumulative shares, clamping them to what remains refundable. */
6493
- declare function priceRefund(lines: readonly RefundableOrderLine[], refunds: readonly EarlierRefund[], request: readonly OrderRefundLine[]): PricedRefund;
6494
-
6495
6857
  type OrderReopenOutcome = {
6496
6858
  kind: 'applied';
6497
6859
  reopen: OrderReopenResult;
@@ -6609,6 +6971,8 @@ interface TenderFacts {
6609
6971
  /** Currency decimal places; every `*Minor` number is in these units. */
6610
6972
  dp: number;
6611
6973
  balanceMinor: number;
6974
+ /** The sum of the order's live cashRoundings, already counted in the balance. */
6975
+ entriesMinor?: number;
6612
6976
  /** The order's payment legs in ledger order; only those that count toward paid are numbered. */
6613
6977
  payments: readonly {
6614
6978
  status?: PaymentLegStatus;
@@ -6716,11 +7080,47 @@ declare function tenderVoidCollection(): {
6716
7080
  * Port of v2's cash rounding: packages/order-math/src/payments/rounding.ts and
6717
7081
  * packages/core/src/screens/main/pos/checkout/tender/tender-figures.ts.
6718
7082
  * v2's tender LEDGER: "a partial or short cash entry and every other method keep full precision".
6719
- * Local figures only; writing the rounding as an order line is unit 24.
7083
+ * The till records the rounding as an order field, Order.cashRoundings (ADR-094).
6720
7084
  */
6721
7085
 
6722
- /** The balance under a manual method's rounding, with its signed difference. */
6723
- declare function roundedDue(balanceMinor: number, method: PaymentMethodDescriptor | null): {
7086
+ /** The nearest payable cash amounts, or null when the amount is already payable. */
7087
+ declare function nearestPayableCash(amountMinor: number, incrementMinor: number): {
7088
+ belowMinor: number;
7089
+ aboveMinor: number;
7090
+ } | null;
7091
+ /** ADR-094 (cash picks): a cash part pick rounds its own target; 0 means cash cannot pay it. */
7092
+ declare function roundedPickTarget(targetMinor: number, rounding: PaymentRounding | null | undefined): number;
7093
+ /** ADR-094: the live entries a remainder rounds against, leaving out a pick leg's own entry (its leg carries units). */
7094
+ declare function remainderEntriesMinor(order: {
7095
+ payments: readonly {
7096
+ id: string;
7097
+ units?: Readonly<Record<string, number>>;
7098
+ }[];
7099
+ cashRoundings?: readonly {
7100
+ paymentId: string;
7101
+ minor: number;
7102
+ }[];
7103
+ }): number;
7104
+ /** Why a void is refused by ADR-094 item 6 (desk ruling (i), #1292): a later live cash leg's entry was computed against this leg's. */
7105
+ type CashVoidRefusal = 'later_cash_rounding';
7106
+ /**
7107
+ * ADR-094 item 6: a leg carrying a live rounding entry cannot be voided while a later live cash leg (wire method 'cash') carries one; the later cash is voided first. A non-cash leg's entry (the zero-remainder write-off) never blocks, so a leg the till cannot void never strands one it can.
7108
+ */
7109
+ declare function cashVoidRefusal(order: {
7110
+ payments: readonly {
7111
+ id: string;
7112
+ method?: string;
7113
+ status?: PaymentLegStatus;
7114
+ }[];
7115
+ cashRoundings?: readonly {
7116
+ paymentId: string;
7117
+ minor: number;
7118
+ }[];
7119
+ }, paymentId: string): CashVoidRefusal | undefined;
7120
+ /** The balance under a cash method's rounding, with its signed difference. */
7121
+ declare function roundedDue(balanceMinor: number, method: PaymentMethodDescriptor | null,
7122
+ /** The sum of the order's live cashRoundings, already counted in the balance. */
7123
+ entriesMinor?: number): {
6724
7124
  dueMinor: number;
6725
7125
  roundingMinor: number;
6726
7126
  };
@@ -6736,7 +7136,9 @@ interface TenderRounding {
6736
7136
  appliedMinor: number;
6737
7137
  }
6738
7138
  /** Figure the displayed entry and applied amount, rounding only a leg that settles at the due. */
6739
- declare function tenderRounding(state: Pick<TenderState, 'entryMinor' | 'entryDirty'>, balanceMinor: number, method: PaymentMethodDescriptor | null): TenderRounding;
7139
+ declare function tenderRounding(state: Pick<TenderState, 'entryMinor' | 'entryDirty'>, balanceMinor: number, method: PaymentMethodDescriptor | null,
7140
+ /** The sum of the order's live cashRoundings, already counted in the balance. */
7141
+ entriesMinor?: number): TenderRounding;
6740
7142
 
6741
7143
  type DatePreset = 'today' | 'yesterday' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth';
6742
7144
  declare const DATE_PRESETS: readonly DatePreset[];
@@ -6761,6 +7163,12 @@ interface SalesTotals {
6761
7163
  discountMinor: number;
6762
7164
  refundsMinor: number;
6763
7165
  embeddedRefundsMinor: number;
7166
+ /**
7167
+ * Σ cash roundings in gross; gross = net + tax + rounding (front desk, 22 Nov, Q3).
7168
+ * Only orders built by `reportOrderFromPosOrder` carry one. A store-sourced order (`reportOrderFromStoreOrder`) carries no rounding figure:
7169
+ * Woo stores its rounding as a plain fee line, so that order's rounding stays inside net (#1282, a documented limit).
7170
+ */
7171
+ roundingMinor: number;
6764
7172
  orderCount: number;
6765
7173
  averageMinor: number;
6766
7174
  items: number;
@@ -6769,6 +7177,13 @@ interface SalesTotals {
6769
7177
  /** v2 ordersSummary: the largest order total; null with no orders. */
6770
7178
  largestMinor?: number | null;
6771
7179
  margin: Margin;
7180
+ /** Which refund figure `grossAfterRefundsMinor` subtracts: `refundsMinor` or `embeddedRefundsMinor`. A report never subtracts both. */
7181
+ refundBasis: 'dated' | 'embedded';
7182
+ /**
7183
+ * `grossMinor` less the basis figure; negative when refunds exceed gross. Gross refunds come off gross only, never
7184
+ * off `netMinor` or any row.
7185
+ */
7186
+ grossAfterRefundsMinor: number;
6772
7187
  }
6773
7188
  interface PaymentRow {
6774
7189
  method: string;
@@ -6799,6 +7214,11 @@ interface DayPoint {
6799
7214
  }
6800
7215
  interface SalesFiguresInput {
6801
7216
  orders: readonly ReportOrder[];
7217
+ /**
7218
+ * Dated refunds, for every period the report shows. Pass `undefined` (not `[]`) when the store has no dated refunds
7219
+ * (no `listRefunds`, or the store does not support it), so the report uses its orders' embedded refunds.
7220
+ * `useStoreRefundsInRange().refunds` is already in that shape; pass it only once the read is `complete`.
7221
+ */
6802
7222
  refunds?: readonly ReportRefund[];
6803
7223
  range: DayRange;
6804
7224
  compare?: DayRange;
@@ -6840,13 +7260,16 @@ declare function daysOf(range: DayRange): StoreDay[];
6840
7260
  */
6841
7261
  declare function comparisonRange(range: DayRange, mode: 'previous' | 'week', preset?: DatePreset): DayRange;
6842
7262
  declare function marginOf(lines: readonly ReportLine[]): Margin;
7263
+ /** The median of minor-unit values: 0 for none; an even count rounds the mean of the middle two (`Math.round`). */
7264
+ declare function medianMinor(values: readonly number[]): number;
6843
7265
  declare function salesFigures(input: SalesFiguresInput): SalesFigures;
6844
7266
 
6845
7267
  declare function reportOrderFromPosOrder(order: PosOrder, join?: LineJoin, methodTitle?: (methodId: string) => string | undefined): ReportOrder;
7268
+ /** A store order as a report row, on its paid day (`paidAt`); an order with no `paidAt` (unpaid, or a store that records none) stays on its placed day. */
6846
7269
  declare function reportOrderFromStoreOrder(order: StoreOrder, join?: LineJoin): ReportOrder;
6847
7270
  declare function reportRefundFromPosRefund(refund: PosRefund): ReportRefund | undefined;
6848
7271
 
6849
7272
  /** @deprecated Use `minorToMajor(minor, digits)` from `@tallyui/core`, which also rejects an amount that is not a safe integer. */
6850
7273
  declare const minorToDecimal: (minor: number, exponent: number) => string;
6851
7274
 
6852
- export { ADDRESS_CHANGE_REFUSED, AFTER_CLOSE_PAYMENTS_CHANGED, APP_SETTING_DEFINITIONS, type Actor, type AddLineInput, type AppSettingCollection, type AppSettingDefinition, type AppSettingDoc, type AppSettingKey, type AppSettings, type AppliedDiscount, type ApprovalNeeded, type BackendNotFound, type BasketLine, type BroadcastChannelLike, CAMERA_BARCODE_TYPES, CAMERA_CONSTRAINTS, CART_COLUMN_IDS, COLLECT_POLL_MS, CONNECT_TIMEOUT_MS, COUPONS_NEED_CONNECTION, COUPONS_REPRICING, COUPONS_UNSUPPORTED, COUPON_CARRIED, COUPON_CARRY_STALE, CUSTOMER_RETAX_REFUSED, type CameraDecoder, type CameraScan, type CartColumnId, type CartColumnsSetting, CartError, type CartQuantityLine, type CashMovement, type CashMovementCollection, type CashierState, type CatalogueEntry, type CatalogueGridColumns, type CatalogueView, type CatalogueViewAction, type CatalogueViewState, type ChargeInput, type ChargeLine, type Closure, type ClosureApprovalStatus, type ClosureCollection, type ClosureContext, type ClosureScope, type CollectInput, type CollectOutcome, type CollectResult, type CommandTransport, type CreateClosureContextOptions, type CsvColumn, CurrencyProvider, type CurrencyProviderProps, type CustomerEditValues, type CustomerSummary, DATE_PRESETS, DECODER_ERROR_THRESHOLD, DEFAULT_APP_SETTINGS, DEFAULT_CATALOGUE_VIEW_STATE, DEFAULT_COOLDOWN_MS, DEFAULT_DECODE_INTERVAL_MS, DEFAULT_MIN_SCAN_CHARS, DEFAULT_RECEIPT_TEMPLATES, DEFAULT_SERIAL_BAUD_RATE, DEFAULT_TILE_FIELDS, DEFAULT_WEDGE_SETTINGS, DETECTOR_FORMATS, DISCOUNTS_UNSUPPORTED, DISPLAY_ACTIONS, DISPLAY_CHANNEL, DISPLAY_PROTOCOL_VERSION, DISPLAY_SIGNAL_POLL_MS, DISPLAY_TEMPLATE, type DatePreset, type DayPoint, type DayRange, type DecodeLoopOptions, type DecodeRefusal, type DecodeResult, type DetectedBarcode, type DeviceScanControl, type DeviceScanControls, type DeviceScanner, type DeviceScannerErrorHandler, type DeviceScannerErrorPhase, type DeviceScannerSettings, type DeviceScannerState, type DeviceScannerStateCell, type Discount, type DisplayAction, type DisplayCart, type DisplayClient, type DisplayClientError, type DisplayClientOptions, type DisplayClientPhase, type DisplayClientView, type DisplayClock, type DisplayConfig, type DisplayEnvelope, type DisplayLine, type DisplayLink, type DisplayPayloads, type DisplayPayment, type DisplayState, type DisplayTemplate, type DisplayTokenStore, type DisplayTotals, type DisplayTransport, type DisplayView, type DrawerTerm, type DrawerTerms, type DriverAvailability, type DriverCapabilities, type DriverStatus, type DriverStatusSource, ENGLISH_CLOSURE_LABELS, ESCPOS_CODE_PAGES, type EarlierRefund, type EncodeEscPosOptions, type EscPosBarcodeOptions, type EscPosBuilder, type EscPosQrOptions, type EscPosSink, type EscPosTransportOptions, type ExtrasNotSent, type FeeLine, type FinalizeOptions, type FloatSuggestion, type FormatWcposReceiptOptions, type GroupRow, HELLO_RETRY_MS, HID_POS_USAGE_PAGE, type HandoverSlipData, type HandoverSlipInput, type HidDeviceLike, type HidInputReportEventLike, type HidLike, type HidPosDecodeOptions, type HidPosResult, type HidScannerOptions, type HttpTransportOptions, INFORMATIONAL_EXTRAS_ORDER_CREATE_VERSION, LINE_EDIT_REFUSED, LIST_POLL_MS, type LedgerRow, type LineItem, type LineJoin, type LineTaxLine, type LogActor, type LogEntry, type LogLevel, type LogMeta, type LogPreset, type LogPresetFilters, type LogSink, type LogSyncRecord, type Logger, MAX_MESSAGE_BYTES, MAX_TENDER_MINOR, META_CHANGE_REFUSED, META_INVALID, MICROS_PER_MINOR, type Margin, type MoneyDivergence, type Movement$1 as Movement, type MovementType, type NetworkSinkOptions, type NoteDelivery, OPEN_ORDERS_POSITIONS, OPEN_SIGNAL_POLL_MS, type OpenOrdersPosition, type OpenSale, type OptionPicks, type Order, type OrderBuilder, type OrderBuilderOptions, OrderContentMismatchError, type OrderCoupon, type OrderCouponContext, type OrderCouponLine, type OrderFilterValue, type OrderManager, type OrderManagerOptions, type OrderOutbox, type OrderOutboxOptions, type OrderRefundOutcome, type OrderReopenOutcome, type OrderTaxTotals, type OrderTransportContext, type OutboxCounts, type OutboxHealth, type OutboxState, PAPER_COLUMNS, PAYMENT_IN_MOTION, PENDING_POLL_MS, PRINTER_PROFILES_COLLECTION, PRODUCT_SORT_FIELDS, type PairingError, type PairingPhase, type ParkedOrderSummary, type Payment, type PaymentDriver, type PaymentDriverRegistry, type PaymentLegStatus, type PaymentMethod, type PaymentPhase, type PaymentRow, type PaymentTransport, type PeerFactory, type PeerLink, type PeerLinkOptions, type PeerLinkState, type PlanLeg, type PosOrder, type PosOrderCoupon, type PosOrderCouponLine, type PosOrderLine, type PosOrderLocalWarning, PosOrderOpenClosedError, type PosOrderPayment, type PosOrderServerFailures, type PosOrderSyncStatus, type PosRefund, type PosRefundCollection, type PosRefundStatus, type PricedRefund, type PricedRefundLine, PrintError, type PrintErrorCode, type PrintJob, type PrintJobKind, type PrintQueue, type PrintQueueOptions, type PrintQueueState, type PrintTransport, type PrintableSale, type PrinterProfile, type PrinterProfileCollection, type ProductSort, type ProductSortValue, type ProductTermGroup, RECEIPT_SCHEMA_VERSION, REGISTER_SESSION_MIGRATION_CLOSE_WAIT_MS, REOPENABLE_CODES, REOPENED_NOT_LOADED, REOPEN_REFUSED_STATUSES, RESTORE_STALE, type RTCDataChannelLike, type RTCPeerConnectionLike, type RateTaxLine, type ReaderInfo, type ReceiptConfig, type ReceiptData, type ReceiptFiscal, type ReceiptLineItem, type ReceiptNode, type ReceiptPaper, type ReceiptRegister, type ReceiptSoftware, type ReceiptTemplateData, type ReceiptTemplateLine, type ReceiptTemplateOptions, type ReceiptTemplateRow, type RecordedFigures, RefundAnswerPendingError, type RefundableLine, type RefundableOrderLine, RegisterApprovalRequiredError, type RegisterBucket, RegisterCloseIncompleteError, type RegisterCommand, type RegisterCommandCollection, type RegisterCounters, type RegisterDocument, type RegisterFact, type RegisterHost, RegisterIdInvalidError, RegisterMovementAmountError, RegisterMovementReasonError, RegisterMovementStrandedError, RegisterNeedsUpgradeError, type RegisterOutbox, type RegisterOutboxOptions, RegisterReapproveError, type RegisterSession, RegisterSessionAlreadyOpenError, RegisterSessionClosedError, type RegisterSessionCollection, RegisterSessionConflictError, RegisterSessionOpenClosedError, RegisterSessionRequiredError, type RegisterStore, RegisterTakeOverError, RegisterTenderInProgressError, type RenderEscposOptions, type RenderReceiptOptions, type RenderSanitizeOptions, ReopenEntryError, type ReopenEntryReason, type ReopenRefusal, ReopenRefusedOrderError, type ReopenStoreOrderOutcome, type ReportCategory, type ReportLine, type ReportOrder, type ReportPayment, type ReportRefund, type ReportTax, type Repository, type ResolvePrinterOptions, type ResolveStoreSettingsOptions, SALE_FINISHED, SALE_HAS_PAYMENT, SALE_IN_TENDER, SALE_PARTLY_PAID, SALE_SAVING, SCANNER_DEVICE_KEY_MAX_LENGTH, SCANNER_PROFILES_COLLECTION, SCAN_DEDUP_WINDOW_MS, SIGNAL_POLL_MS, SIMULATED_PROVIDER, SIMULATED_TIMING, SNAPSHOT_LIFETIME_MS, SNAPSHOT_MIN_INTERVAL_MS, SNAPSHOT_POLL_MS, SNAPSHOT_RESEND_MS, SPLIT_FIXED_DISCOUNT, STANDARD_SPP_SERVICE_CLASS_ID, STORE_ORDER_OPEN_HERE, SYSTEM_PRINTER_ID, SYSTEM_PRINT_TIMING, type SaleDiscountCodes, type SaleDiscountState, type SaleDisplayInput, type SaleDisplayOptions, type SaleDisplayPublisher, type SaleRemoval, type SaleStage, type SaleTaxContext, type SaleTaxLocation, type SalesFigures, type SalesFiguresInput, type SalesTotals, type SanitizeHtmlOptions, type ScanBus, type ScanEvent, type ScanHub, ScanHubProvider, type ScanHubProviderProps, type ScanOfferResult, type ScanRejectReason, type ScanSession, type ScanSessionOptions, type ScanSource, type ScanSourceKind, type ScanTraceSettings, type ScannerConnectionType, type ScannerIdentity, type ScannerProfile, type ScannerProfileCollection, type ScannerProfileStore, type ScannerTransport, type SentOrder, type SerialLike, type SerialLineDecoder, type SerialLineDecoderOptions, type SerialPortInfoLike, type SerialPortLike, type SerialScannerOptions, type ServiceClock, type SessionDescriptionLike, type ShippingLine, type SignalPort, type SimulatedDriverOptions, type SimulatedReaderId, type SnapshotBody, type SnapshotSender, type SnapshotSenderOptions, type SplitTab, type SplitUnitLine, type StoreDay, type StorePricedAccepted, type StorePricedCodePricing, type StorePricedCoupon, type StorePricedCouponContext, type StorePricedDiscountCodesOptions, type StoreSettingsResolution, type StoreSettingsState, type StoreTemplateContext, type StuckRecord, type SwitchKind, type SwitchWarning, type SwitchWarningInput, type SwitchWarnings, type SyncRecordOutcome, type SystemPrintTransportOptions, TAX_ADDRESS_ORDER_CREATE_VERSION, TAX_IDS_CHANGE_REFUSED, TAX_IDS_INVALID, TAX_ROUNDING_MIXED_NOTE, TAX_STORE_PAID_NOTE, TENDER_GATE_FAILED, TENDER_SALE_CHANGED, TILE_FIELDS, type TaxContext, type TaxDerivation, type TaxDerivationClass, type TaxDerivationRate, type TaxLineInput, TaxProvider, type TaxProviderProps, type TaxRateMap, type TaxRateWhy, type TaxRow, type TenderAction, type TenderFacts, type TenderFigures, type TenderKey, type TenderLineId, type TenderPlan, type TenderRounding, type TenderState, type TenderView, type TenderVoid, type ThermalNode, type TileField, type TileFields, type TillDeviceHandle, type TillDeviceKeyStore, type TillDeviceOptions, type TillDisplayEntry, type TillDisplayPauseReason, type TillDisplayService, type TillDisplayServiceOptions, type TillDisplayStatus, type TillDisplaysView, type TillPairing, type TillPairingOptions, type TillPairingView, type TraceAnalysis, type TraceKey, type TraceSuggestion, type TransportOutcome, UI_SCALES, UI_THEMES, UNTAXED_ADDRESS_ORDER_CREATE_VERSION, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE, type UiScale, type UiTheme, type UnitAllocations, UnsupportedOrderVersionError, type UseBarcodeScannerOptions, type UseCameraScanOptions, type UseOrderOutboxOptions, type UseOrderOutboxResult, type UseOutboxHealthOptions, type UseOutboxHealthResult, type UseRegisterOutboxOptions, type UseRegisterOutboxResult, type UseRegisterSessionOptions, type ViewfinderStatus, WCPOS_DEFAULT_I18N, WCPOS_TAX_ID_LABELS, WEDGE_END_OF_SCAN_MS, type WcposLineView, type WcposMoneyOptions, type WcposReceiptData, type WcposReceiptDate, type WcposReceiptLine, type WcposReceiptOptions, type WcposReceiptSource, type WcposReceiptStore, type WcposReceiptView, type WcposTaxId, type WedgeDetector, type WedgeDetectorOptions, type WedgeReplayResult, type WedgeScanMeta, type WedgeSettings, type WedgeState, abandonSession, activePlan, addEntryToCart, addPosOrderCollection, addPrinterProfileCollection, addRegisterSessionCollection, addScannerProfileCollection, adoptRegisterResults, advancePerpetual, allocateOrderDiscount, analyzeScanTrace, appSettingCollection, appSettingSchema, appSettings$, appliedMinor, backToSelling, bindRegister, buildClosureDocument, buildReceiptData, buildReceiptDataFromPosOrder, buildReceiptDataFromStoreOrder, buildXReportDocument, callbackSink, cameraErrorStatus, can, canMoveLeg, canOpenDrawer, canVoidLeg, capturedMinor, cartQuantities, cashMovementSchema, catalogueEntries, catalogueViewReducer, changeMinor, clampClosureScope, closeNeedsApproval, closeSession, closureApprovalStatus, closureCommand, closureSchema, closureVariance, comparisonRange, computeOrderTax, consoleSink, countVariance, countsTowardPaid, couponPricingBasis, createBackendNotFound, createBroadcastDisplayTransport, createClosureContext, createDeviceScannerStateCell, createDisplayClient, createDisplayLink, createDisplayPeerLink, createEpsonEposSink, createEscPosTransport, createHidScanner, createHttpCommandTransport, createLogger, createOrderBuilder, createOrderManager, createOrderOutbox, createPaymentDriverRegistry, createPrintQueue, createRegisterOutbox, createRepository, createSaleDisplayPublisher, createScanBus, createScanHub, createScanSession, createSerialLineDecoder, createSerialScanner, createSimulatedDriver, createSnapshotSender, createStarWebPrntSink, createStorePricedDiscountCodes, createSystemPrintTransport, createTaxContext, createTillDevice, createTillDisplayService, createTillPairing, createTillPeerLink, createWedgeDetector, createWedgeState, csvCell, csvFromCells, daysOf, decode as decodeDisplayMessage, decodeHidPosReport, dedupeScans, denominationTotal, denominations, deriveDrawerTerms, deriveExpected, derivePaymentEvent, deriveSettled, deriveStuckRecords, detectorFormatToSymbology, disabledOptions, displayCart, displayReducer, driverForMethod, encode as encodeDisplayMessage, encodeEscPos, encodeThermalTemplate, ensureRegister, escpos, evenSplitShareMinor, exportCsv, extrasNotSent, finalizeOrder, findEntryByCode, foldWedgeKey, formatClosureDate, formatDecimalMoney, formatWcposMoney, formatWcposReceiptData, getBoundRegisterId, getDeviceId, handoverSlip, hasActor, hasTerm, hasValidRetailCheckDigit, heldUnitsByLine, inCategory, inMotionMinor, inRange, inertDeviceScanControls, inertScanHub, initTenderState, initialDisplayState, initialTenderState, isCanonicalUuid, isCarriedCouponLabel, isChooserCancel, isInMotion, isKnownSessionStatus, isLiveAtStore, isOrderReopenInFlight, isPartlyPaid, isRegisterRequeueable, isReopenOffered, isReopened, isRequeueable, isRequeueableOrder, isServerDecimal, isWebHidSupported, isWebSerialSupported, labelKeys, legStatus, listCategories, listTermGroups, lockedRefundDueMinor, makeEnvelope, marginOf, markAttentionHandled, matchVariant, matchesPresetFilters, messageBytes, methodDrivers, methodForProvider, minorToDecimal, mintClosureNumber, mintUuid, moneyDivergence, movementCommand, movementFieldError, nativeBarcodeDetector, needsAttention, networkSinkFor, nextSaleCounter, normalizeAmount, normalizeCatalogueViewState, normalizeRetailCode, normalizeTileFields, normalizeUuid, noteDelivery, observeRegister$, openDrawerJob, openSales, openSession, openSessionSelector, orderDraftSchema, orderFiltersQuery, outboxLogger, overThreshold, paidUnitsByLine, parkedOrderSummaries$, parseMinor, parseXml, percentOfMinor, pickedUnitsMinor, planLegs, posOrderCollection, posOrderSchema, posOrdersLogger, posRefundCollection, posRefundSchema, presetFilters, presetRange, priceRefund, printerProfileCollection, printerProfileSchema, productCategories, productSortValue, productTerms, quickTenderedAmounts, readAppSettings, readBoundRegister, readRegister, readScannerProfiles, reapproveClosure, receiptTemplateData, reconcileRegisterCommands, recordMovement, recordRegisterFact, refundDueOf, refundableLines, registerCommandCollection, registerCommandSchema, registerCommandsLogger, registerFactsLogger, registerSessionCollection, registerSessionSchema, registerSessionsLogger, removeScannerProfile, renderEscpos, renderHtml, renderLogiclessTemplate, renderReceiptHtml, renderReceiptTemplate, renderStoreReceiptTemplate, renderThermalPreview, reopenRefusedOrder, reopenStoreOrder, replacedOrderIds, replayWedgeDetector, reportOrderFromPosOrder, reportOrderFromStoreOrder, reportRefundFromPosRefund, requireOpenSession, resolveAppSettings, resolveGridColumns, resolvePrinter, resolveStoreSettings, restoreOrderDraft, retailCodeTwin, roundMicrosToMinor, roundedDue, runsWholeOrder, saleLogger, saleTaxContexts, salesFigures, sameSale, sanitizeHtml, saveScannerProfile, scanTimeOf, scannerDeviceKey, scannerProfileCollection, scannerProfileSchema, scannerProfileStore, scannerProfiles$, scannerTransport, searchProducts, selectClosureRows, sendOrderRefund, sendOrderReopen, serialPortIdentity, sessionOpenCommand, sessionTransitionCommand, shipsToBilling, sortProducts, splitUnitLines, stampSession, startCounting, startDecodeLoop, stockOverlay$, stockOverlayAsOf$, storeOrderForReopen, stripBoundary, submitOrderRefund, suggestFloat, summarizeOutboxHealth, switchWarnings, takeOverSession, takingsByMethod, taxDerivation, taxFiguresForBasket, taxLinesByRate, taxLogger, taxMicros, taxProviderProps, taxSettingsForLocation, templateColumns, tenderFigures, tenderReducer, tenderRounding, tenderVoidCollection, tenderVoidSchema, tillLegsTheStoreRefuses, toCsv, toCustomerInput, toCustomerPatch, toOrderCreateEnvelope, toOrderUpdateEnvelope, toPrintError, unbindRegister, unitAllocationsFromLegs, unitsMinor, unpaidUnitsByLine, useAppSettings, useBarcodeScanner, useCameraScan, useCashier, useCurrencyCode, useCurrencyFormatter, useCustomerDisplay, useDeviceScanControls, useDisplayClient, useOrderOutbox, useOutboxHealth, useParkedSales, useRegisterOutbox, useRegisterSession, useSale, useSaleDisplay, useScanHub, useStoreSettings, useTax, useTillDisplays, useTillPairing, uuidv7, validAmount, varianceText, variantFits, variantPriceLabel, voidMovement, watchOutboxHealth, wcposReceiptContext, wcposReceiptData, wcposSourceFromPosOrder, wcposSourceFromSentOrder, wcposSourceFromStoreOrder, withPricingContext, index as woocommerceDiscountCodes, writeAppSetting, writeClosure, writeOrderDraft };
7275
+ export { ADDRESS_CHANGE_REFUSED, AFTER_CLOSE_PAYMENTS_CHANGED, APP_SETTING_DEFINITIONS, type Actor, type AddLineInput, type AppSettingCollection, type AppSettingDefinition, type AppSettingDoc, type AppSettingKey, type AppSettings, type AppliedDiscount, type ApprovalNeeded, BLUETOOTH_PRINT_SERVICES, type BackendNotFound, type BasketLine, type BroadcastChannelLike, CAMERA_BARCODE_TYPES, CAMERA_CONSTRAINTS, CART_COLUMN_IDS, CASH_NOT_PAYABLE, CASH_PICK_ENTRIES_MAX, CASH_PICK_LIMIT, CASH_SETTLE_LIMIT, CASH_WAITS_FOR_PAYMENT, COLLECT_POLL_MS, CONNECT_TIMEOUT_MS, COUPONS_NEED_CONNECTION, COUPONS_REPRICING, COUPONS_UNSUPPORTED, COUPON_CARRIED, COUPON_CARRY_STALE, CUSTOMER_RETAX_REFUSED, type CameraDecoder, type CameraScan, type CartColumnId, type CartColumnsSetting, CartError, type CartQuantityLine, type CashMovement, type CashMovementCollection, type CashRounding, type CashVoidRefusal, type CashierState, type CatalogueEntry, type CatalogueGridColumns, type CatalogueView, type CatalogueViewAction, type CatalogueViewState, type ChargeInput, type ChargeLine, type Closure, type ClosureApprovalStatus, type ClosureCollection, type ClosureContext, type ClosureFigures, type ClosureScope, type CollectInput, type CollectOutcome, type CollectResult, type CommandTransport, type CreateClosureContextOptions, type CsvColumn, CurrencyProvider, type CurrencyProviderProps, type CustomerEditValues, type CustomerSummary, DATE_PRESETS, DECODER_ERROR_THRESHOLD, DEFAULT_APP_SETTINGS, DEFAULT_CATALOGUE_VIEW_STATE, DEFAULT_COOLDOWN_MS, DEFAULT_DECODE_INTERVAL_MS, DEFAULT_MIN_SCAN_CHARS, DEFAULT_RECEIPT_TEMPLATES, DEFAULT_SERIAL_BAUD_RATE, DEFAULT_TILE_FIELDS, DEFAULT_WEDGE_SETTINGS, DETECTOR_FORMATS, DISCOUNTS_UNSUPPORTED, DISPLAY_ACTIONS, DISPLAY_CHANNEL, DISPLAY_PROTOCOL_VERSION, DISPLAY_SIGNAL_POLL_MS, DISPLAY_TEMPLATE, type DatePreset, type DayPoint, type DayRange, type DecodeLoopOptions, type DecodeRefusal, type DecodeResult, type DetectedBarcode, type DeviceScanControl, type DeviceScanControls, type DeviceScanner, type DeviceScannerErrorHandler, type DeviceScannerErrorPhase, type DeviceScannerSettings, type DeviceScannerState, type DeviceScannerStateCell, type Discount, type DisplayAction, type DisplayCart, type DisplayClient, type DisplayClientError, type DisplayClientOptions, type DisplayClientPhase, type DisplayClientView, type DisplayClock, type DisplayConfig, type DisplayEnvelope, type DisplayLine, type DisplayLink, type DisplayPayloads, type DisplayPayment, type DisplayState, type DisplayTemplate, type DisplayTokenStore, type DisplayTotals, type DisplayTransport, type DisplayView, type DrawerTerm, type DrawerTerms, type DriverAvailability, type DriverCapabilities, type DriverStatus, type DriverStatusSource, ENGLISH_CLOSURE_LABELS, ESCPOS_CODE_PAGES, type EncodeEscPosOptions, type EscPosBarcodeOptions, type EscPosBuilder, type EscPosQrOptions, type EscPosSink, type EscPosTransportOptions, type ExtrasNotSent, type FeeLine, type FinalizeOptions, type FloatSuggestion, type FormatWcposReceiptOptions, type GroupRow, HELLO_RETRY_MS, HID_POS_USAGE_PAGE, type HandoverSlipData, type HandoverSlipInput, type HidDeviceLike, type HidInputReportEventLike, type HidLike, type HidPosDecodeOptions, type HidPosResult, type HidScannerOptions, type HttpTransportOptions, INFORMATIONAL_EXTRAS_ORDER_CREATE_VERSION, LINE_EDIT_REFUSED, LIST_POLL_MS, type LedgerRow, type LineItem, type LineJoin, type LineTaxLine, type LogActor, type LogEntry, type LogLevel, type LogMeta, type LogPreset, type LogPresetFilters, type LogSink, type LogSyncRecord, type Logger, MAX_MESSAGE_BYTES, MAX_TENDER_MINOR, META_CHANGE_REFUSED, META_INVALID, MICROS_PER_MINOR, type Margin, type MoneyDivergence, type Movement$1 as Movement, type MovementType, NEEDS_ADMIN_RETRY_PREFIX, NOTHING_DUE, NOTHING_TO_ROUND_AGAINST, type NeedsAdminAnswer, type NetworkSinkOptions, type NoteDelivery, OPEN_ORDERS_POSITIONS, OPEN_SIGNAL_POLL_MS, type OpenOrdersPosition, type OpenSale, type OptionPicks, type Order, type OrderBuilder, type OrderBuilderOptions, OrderContentMismatchError, type OrderCoupon, type OrderCouponContext, type OrderCouponLine, type OrderDownloadProgress, type OrderFilterValue, type OrderManager, type OrderManagerOptions, type OrderOutbox, type OrderOutboxOptions, type OrderRefundOutcome, type OrderReopenOutcome, type OrderTaxTotals, type OrderTransportContext, type OtherCurrencyRefunds, type OutboxCounts, type OutboxHealth, type OutboxState, PAPER_COLUMNS, PAYMENT_IN_MOTION, PAYMENT_TAKEN, PENDING_POLL_MS, PRINTER_PROFILES_COLLECTION, PRODUCT_SORT_FIELDS, type PairingError, type PairingPhase, type ParkedOrderSummary, type Payment, type PaymentDriver, type PaymentDriverRegistry, type PaymentLegStatus, type PaymentMethod, type PaymentPhase, type PaymentRow, type PaymentTransport, type PeerFactory, type PeerLink, type PeerLinkOptions, type PeerLinkState, type PlanLeg, type PosOrder, type PosOrderCoupon, type PosOrderCouponLine, type PosOrderLine, type PosOrderLocalWarning, PosOrderOpenClosedError, type PosOrderPayment, type PosOrderServerFailures, type PosOrderSyncStatus, type PosRefund, type PosRefundCollection, type PosRefundStatus, PrintError, type PrintErrorCode, type PrintJob, type PrintJobKind, type PrintQueue, type PrintQueueOptions, type PrintQueueState, type PrintTransport, type PrintableSale, type PrinterProfile, type PrinterProfileCollection, type ProductSort, type ProductSortValue, type ProductTermGroup, RECEIPT_SCHEMA_VERSION, REGISTER_CLOSING, REGISTER_SESSION_MIGRATION_CLOSE_WAIT_MS, REOPENABLE_CODES, REOPENED_NOT_LOADED, REOPEN_REFUSED_STATUSES, RESTORE_STALE, type RTCDataChannelLike, type RTCPeerConnectionLike, type RateTaxLine, type ReaderInfo, type ReceiptConfig, type ReceiptData, type ReceiptFiscal, type ReceiptLineItem, type ReceiptNode, type ReceiptPaper, type ReceiptRegister, type ReceiptSoftware, type ReceiptTemplateData, type ReceiptTemplateLine, type ReceiptTemplateOptions, type ReceiptTemplateRow, type RecordedFigures, RefundAnswerPendingError, RegisterApprovalRequiredError, type RegisterBucket, RegisterCloseIncompleteError, type RegisterCommand, type RegisterCommandCollection, type RegisterCounters, type RegisterDocument, type RegisterFact, type RegisterHost, RegisterIdInvalidError, RegisterMovementAmountError, RegisterMovementReasonError, RegisterMovementStrandedError, RegisterNeedsUpgradeError, type RegisterOutbox, type RegisterOutboxOptions, RegisterReapproveError, RegisterSaleSavingError, type RegisterSession, RegisterSessionAlreadyOpenError, RegisterSessionClosedError, type RegisterSessionCollection, RegisterSessionConflictError, RegisterSessionOpenClosedError, RegisterSessionRequiredError, type RegisterStore, RegisterTakeOverError, RegisterTenderInProgressError, type RenderEscposOptions, type RenderReceiptOptions, type RenderSanitizeOptions, ReopenEntryError, type ReopenEntryReason, type ReopenRefusal, ReopenRefusedOrderError, type ReopenStoreOrderOutcome, type ReportCategory, type ReportLine, type ReportOrder, type ReportPayment, type ReportRefund, type ReportTax, type Repository, type ResolvePrinterOptions, type ResolveStoreSettingsOptions, SALE_CARD_IN_PROGRESS, SALE_FINISHED, SALE_HAS_PAYMENT, SALE_IN_TENDER, SALE_PARTLY_PAID, SALE_SAVING, SCANNER_DEVICE_KEY_MAX_LENGTH, SCANNER_PROFILES_COLLECTION, SCAN_DEDUP_WINDOW_MS, SIGNAL_POLL_MS, SIMULATED_PROVIDER, SIMULATED_TIMING, SNAPSHOT_LIFETIME_MS, SNAPSHOT_MIN_INTERVAL_MS, SNAPSHOT_POLL_MS, SNAPSHOT_RESEND_MS, SPLIT_FIXED_DISCOUNT, STANDARD_SPP_SERVICE_CLASS_ID, STORE_ORDER_OPEN_HERE, SYSTEM_PRINTER_ID, SYSTEM_PRINT_TIMING, type SaleDiscountCodes, type SaleDiscountState, type SaleDisplayInput, type SaleDisplayOptions, type SaleDisplayPublisher, type SaleRemoval, type SaleStage, type SaleTaxContext, type SaleTaxLocation, type SalesFigures, type SalesFiguresInput, type SalesTotals, type SanitizeHtmlOptions, type ScanBus, type ScanEvent, type ScanHub, ScanHubProvider, type ScanHubProviderProps, type ScanOfferResult, type ScanRejectReason, type ScanSession, type ScanSessionOptions, type ScanSource, type ScanSourceKind, type ScanTraceSettings, type ScannerConnectionType, type ScannerIdentity, type ScannerProfile, type ScannerProfileCollection, type ScannerProfileStore, type ScannerTransport, type SentOrder, type SerialLike, type SerialLineDecoder, type SerialLineDecoderOptions, type SerialPortInfoLike, type SerialPortLike, type SerialScannerOptions, type ServiceClock, type SessionDescriptionLike, type ShippingLine, type SignalPort, type SimulatedDriverOptions, type SimulatedReaderId, type SnapshotBody, type SnapshotSender, type SnapshotSenderOptions, type SplitTab, type SplitUnitLine, type StoreDay, type StoreOrdersInRange, type StoreOrdersRangeQuery, type StorePricedAccepted, type StorePricedCodePricing, type StorePricedCoupon, type StorePricedCouponContext, type StorePricedDiscountCodesOptions, type StoreRefundsInRange, type StoreRefundsRangeQuery, type StoreSettingsResolution, type StoreSettingsState, type StoreTemplateContext, type StuckRecord, type SwitchKind, type SwitchWarning, type SwitchWarningInput, type SwitchWarnings, type SyncRecordOutcome, type SystemPrintTransportOptions, TAX_ADDRESS_ORDER_CREATE_VERSION, TAX_IDS_CHANGE_REFUSED, TAX_IDS_INVALID, TAX_ROUNDING_MIXED_NOTE, TAX_STORE_PAID_NOTE, TENDER_GATE_FAILED, TENDER_SALE_CHANGED, TILE_FIELDS, type TaxContext, type TaxDerivation, type TaxDerivationClass, type TaxDerivationRate, type TaxLineInput, TaxProvider, type TaxProviderProps, type TaxRateMap, type TaxRateWhy, type TaxRow, type TenderAction, type TenderFacts, type TenderFigures, type TenderKey, type TenderLineId, type TenderPlan, type TenderRounding, type TenderState, type TenderView, type TenderVoid, type ThermalNode, type TileField, type TileFields, type TillDeviceHandle, type TillDeviceKeyStore, type TillDeviceOptions, type TillDisplayEntry, type TillDisplayPauseReason, type TillDisplayService, type TillDisplayServiceOptions, type TillDisplayStatus, type TillDisplaysView, type TillPairing, type TillPairingOptions, type TillPairingView, type TraceAnalysis, type TraceKey, type TraceSuggestion, type TransportOutcome, UI_SCALES, UI_THEMES, UNTAXED_ADDRESS_ORDER_CREATE_VERSION, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE, type UiScale, type UiTheme, type UnitAllocations, UnsupportedOrderVersionError, type UseBarcodeScannerOptions, type UseCameraScanOptions, type UseOrderOutboxOptions, type UseOrderOutboxResult, type UseOutboxHealthOptions, type UseOutboxHealthResult, type UseRegisterOutboxOptions, type UseRegisterOutboxResult, type UseRegisterSessionOptions, VOID_LATER_CASH_FIRST, type ViewfinderStatus, WCPOS_DEFAULT_I18N, WCPOS_TAX_ID_LABELS, WEDGE_END_OF_SCAN_MS, type WcposLineView, type WcposMoneyOptions, type WcposReceiptData, type WcposReceiptDate, type WcposReceiptLine, type WcposReceiptOptions, type WcposReceiptSource, type WcposReceiptStore, type WcposReceiptView, type WcposTaxId, type WebBluetoothDevice, type WebBluetoothSinkOptions, type WebUsbDevice, type WebUsbSinkOptions, type WedgeDetector, type WedgeDetectorOptions, type WedgeReplayResult, type WedgeScanMeta, type WedgeSettings, type WedgeState, abandonSession, activePlan, addEntryToCart, addPosOrderCollection, addPrinterProfileCollection, addRegisterSessionCollection, addScannerProfileCollection, adoptRegisterResults, advancePerpetual, allocateOrderDiscount, analyzeScanTrace, appSettingCollection, appSettingSchema, appSettings$, appliedMinor, backToSelling, bindRegister, buildClosureDocument, buildReceiptData, buildReceiptDataFromPosOrder, buildReceiptDataFromStoreOrder, buildXReportDocument, callbackSink, cameraErrorStatus, can, canMoveLeg, canOpenDrawer, canVoidLeg, capturedMinor, cartQuantities, cashMovementSchema, cashVoidRefusal, catalogueEntries, catalogueViewReducer, changeMinor, clampClosureScope, closeNeedsApproval, closeSession, closureApprovalStatus, closureCommand, closureFigures, closureSchema, closureVariance, comparisonRange, computeOrderTax, consoleSink, countVariance, countsTowardPaid, couponPricingBasis, createBackendNotFound, createBroadcastDisplayTransport, createClosureContext, createDeviceScannerStateCell, createDisplayClient, createDisplayLink, createDisplayPeerLink, createEpsonEposSink, createEscPosTransport, createHidScanner, createHttpCommandTransport, createLogger, createOrderBuilder, createOrderManager, createOrderOutbox, createPaymentDriverRegistry, createPrintQueue, createRegisterOutbox, createRepository, createSaleDisplayPublisher, createScanBus, createScanHub, createScanSession, createSerialLineDecoder, createSerialScanner, createSimulatedDriver, createSnapshotSender, createStarWebPrntSink, createStorePricedDiscountCodes, createSystemPrintTransport, createTaxContext, createTillDevice, createTillDisplayService, createTillPairing, createTillPeerLink, createWebBluetoothSink, createWebUsbSink, createWedgeDetector, createWedgeState, csvCell, csvFromCells, daysOf, decode as decodeDisplayMessage, decodeHidPosReport, dedupeScans, denominationTotal, denominations, deriveDrawerTerms, deriveExpected, derivePaymentEvent, deriveSettled, deriveStuckRecords, detectorFormatToSymbology, disabledOptions, displayCart, displayReducer, driverForMethod, encode as encodeDisplayMessage, encodeEscPos, encodeThermalTemplate, ensureRegister, escpos, evenSplitShareMinor, exportCsv, extrasNotSent, finalizeOrder, findEntryByCode, foldWedgeKey, formatClosureDate, formatDecimalMoney, formatWcposMoney, formatWcposReceiptData, getBoundRegisterId, getDeviceId, handoverSlip, hasActor, hasTerm, hasValidRetailCheckDigit, heldUnitsByLine, inCategory, inMotionMinor, inRange, inertDeviceScanControls, inertScanHub, initTenderState, initialDisplayState, initialTenderState, isCanonicalUuid, isCarriedCouponLabel, isChooserCancel, isInMotion, isKnownSessionStatus, isLiveAtStore, isOrderReopenInFlight, isPartlyPaid, isRegisterRequeueable, isReopenOffered, isReopened, isRequeueable, isRequeueableOrder, isServerDecimal, isWebHidSupported, isWebSerialSupported, labelKeys, legStatus, listCategories, listTermGroups, lockedRefundDueMinor, makeEnvelope, marginOf, markAttentionHandled, matchVariant, matchesPresetFilters, medianMinor, messageBytes, methodDrivers, methodForProvider, minorToDecimal, mintClosureNumber, mintUuid, moneyDivergence, movementCommand, movementFieldError, nativeBarcodeDetector, nearestPayableCash, needsAdminReasonOf, needsAttention, networkSinkFor, nextSaleCounter, normalizeAmount, normalizeCatalogueViewState, normalizeRetailCode, normalizeTileFields, normalizeUuid, noteDelivery, observeRegister$, openDrawerJob, openSales, openSession, openSessionSelector, orderDraftSchema, orderFiltersQuery, outboxLogger, overThreshold, paidUnitsByLine, parkedOrderSummaries$, parseMinor, parseXml, percentOfMinor, pickedUnitsMinor, planLegs, posOrderCollection, posOrderSchema, posOrdersLogger, posRefundCollection, posRefundSchema, presetFilters, presetRange, printerProfileCollection, printerProfileSchema, productCategories, productSortValue, productTerms, quickTenderedAmounts, readAppSettings, readBoundRegister, readRegister, readScannerProfiles, reapproveClosure, receiptTemplateData, reconcileRegisterCommands, recordMovement, recordRegisterFact, refundDueOf, refundNeedsAdminLine, registerCommandCollection, registerCommandSchema, registerCommandsLogger, registerFactsLogger, registerSessionCollection, registerSessionSchema, registerSessionsLogger, remainderEntriesMinor, removeScannerProfile, renderEscpos, renderHtml, renderLogiclessTemplate, renderReceiptHtml, renderReceiptTemplate, renderStoreReceiptTemplate, renderThermalPreview, reopenRefusedOrder, reopenStoreOrder, replacedOrderIds, replayWedgeDetector, reportOrderFromPosOrder, reportOrderFromStoreOrder, reportRefundFromPosRefund, requireOpenSession, resolveAppSettings, resolveGridColumns, resolvePrinter, resolveStoreSettings, restoreOrderDraft, retailCodeTwin, roundMicrosToMinor, roundedDue, roundedPickTarget, runsWholeOrder, saleLogger, saleTaxContexts, salesFigures, salesRangeQuery, sameSale, sanitizeHtml, saveScannerProfile, scanTimeOf, scannerDeviceKey, scannerProfileCollection, scannerProfileSchema, scannerProfileStore, scannerProfiles$, scannerTransport, searchProducts, selectClosureRows, sendOrderRefund, sendOrderReopen, serialPortIdentity, sessionOpenCommand, sessionTransitionCommand, shipsToBilling, sortProducts, splitUnitLines, stampSession, startCounting, startDecodeLoop, stockOverlay$, stockOverlayAsOf$, storeOrderForReopen, stripBoundary, submitOrderRefund, suggestFloat, summarizeOutboxHealth, switchWarnings, takeOverSession, takingsByMethod, taxDerivation, taxFiguresForBasket, taxLinesByRate, taxLogger, taxMicros, taxProviderProps, taxSettingsForLocation, taxedLinesFor, templateColumns, tenderFigures, tenderReducer, tenderRounding, tenderVoidCollection, tenderVoidSchema, tillLegsTheStoreRefuses, toCsv, toCustomerInput, toCustomerPatch, toOrderCreateEnvelope, toOrderUpdateEnvelope, toPrintError, unbindRegister, unitAllocationsFromLegs, unitsMinor, unpaidUnitsByLine, useAppSettings, useBarcodeScanner, useCameraScan, useCashier, useCurrencyCode, useCurrencyFormatter, useCustomerDisplay, useDeviceScanControls, useDisplayClient, useOrderOutbox, useOutboxHealth, useParkedSales, useRegisterOutbox, useRegisterSession, useSale, useSaleDisplay, useScanHub, useStoreOrdersInRange, useStoreRefundsInRange, useStoreSettings, useTax, useTillDisplays, useTillPairing, uuidv7, validAmount, varianceText, variantFits, variantPriceLabel, voidMovement, watchOutboxHealth, wcposReceiptContext, wcposReceiptData, wcposSourceFromPosOrder, wcposSourceFromSentOrder, wcposSourceFromStoreOrder, withPricingContext, index as woocommerceDiscountCodes, writeAppSetting, writeClosure, writeOrderDraft };