@tallyui/pos 3.7.1 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +167 -16
- package/dist/index.js +487 -49
- package/package.json +8 -7
- package/src/index.ts +5 -3
- package/src/order/index.ts +2 -1
- package/src/order/order-builder.ts +41 -9
- package/src/order/order-drafts.ts +3 -1
- package/src/order/types.ts +11 -1
- package/src/order/woocommerce-tax.ts +61 -4
- package/src/outbox/register-outbox.ts +26 -3
- package/src/outbox/types.test-d.ts +5 -0
- package/src/outbox/use-register-outbox.ts +6 -2
- package/src/refund/index.ts +3 -0
- package/src/refund/pos-refund.ts +35 -0
- package/src/refund/send-order-refund.ts +43 -0
- package/src/refund/submit-order-refund.ts +85 -0
- package/src/register/expected.ts +23 -6
- package/src/register/index.ts +2 -1
- package/src/register/register-adoption.ts +105 -0
- package/src/register/register-commands.ts +20 -7
- package/src/register/schemas.ts +3 -3
- package/src/register/session-store.ts +42 -6
- package/src/register/use-register-session.ts +64 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { Money, TaxRounding, StoreSettings, TallyConnector, SyncContext, StoreSettingsChoice, StoreSettingsChoices, ProductTraits, ProductCategory, TraitContext, OrderCreateLine, PaymentMethodKind, CommandServerRefs, CommandWarning, CommandError, ServerCapabilities, OrderCreateEnvelope, RegisterCommandType, RegisterCommandResult, RegisterSessionTransitionPayload, VariantSummary, CommandResult, AnyCommandEnvelope, CommandEnvelope, OrderCreatePayload, RegisterCommandEnvelope } from '@tallyui/core';
|
|
3
|
+
import { Money, TaxRounding, StoreSettings, TallyConnector, SyncContext, StoreSettingsChoice, StoreSettingsChoices, ProductTraits, woocommerceCoupons, ProductCategory, TraitContext, OrderCreateLine, PaymentMethodKind, CommandServerRefs, CommandWarning, CommandError, ServerCapabilities, OrderCreateEnvelope, OrderRefundEnvelope, OrderRefundResult, RegisterCommandType, RegisterCommandResult, RegisterSessionTransitionPayload, VariantSummary, CommandResult, AnyCommandEnvelope, CommandEnvelope, OrderCreatePayload, RegisterCommandEnvelope } from '@tallyui/core';
|
|
4
4
|
export { getProductStock, withStockOverlay } from '@tallyui/core';
|
|
5
5
|
export { countFresh, readFresh, watchFresh } from '@tallyui/core/rxdb';
|
|
6
6
|
import * as rxdb from 'rxdb';
|
|
@@ -249,6 +249,11 @@ declare function createRepository<T extends {
|
|
|
249
249
|
id: string;
|
|
250
250
|
}>(collection: RxCollection<T>): Repository<T>;
|
|
251
251
|
|
|
252
|
+
interface OrderCoupon {
|
|
253
|
+
code: string;
|
|
254
|
+
discountMinor: number;
|
|
255
|
+
discountTaxMinor: number;
|
|
256
|
+
}
|
|
252
257
|
interface Order {
|
|
253
258
|
id: string;
|
|
254
259
|
status: 'draft' | 'parked' | 'saved' | 'completed';
|
|
@@ -256,6 +261,8 @@ interface Order {
|
|
|
256
261
|
fees?: FeeLine[];
|
|
257
262
|
shipping?: ShippingLine[];
|
|
258
263
|
discounts: AppliedDiscount[];
|
|
264
|
+
/** Present only after coupon replay; discountMinor excludes coupons, which are carried here. */
|
|
265
|
+
coupons?: OrderCoupon[];
|
|
259
266
|
payments: Payment[];
|
|
260
267
|
customer: CustomerSummary | null;
|
|
261
268
|
note: string;
|
|
@@ -301,6 +308,11 @@ interface DisplayTotals {
|
|
|
301
308
|
name: string;
|
|
302
309
|
amountMinor: number;
|
|
303
310
|
}>;
|
|
311
|
+
/** Present exactly when Order.coupons is. */
|
|
312
|
+
coupons?: Array<{
|
|
313
|
+
code: string;
|
|
314
|
+
amountMinor: number;
|
|
315
|
+
}>;
|
|
304
316
|
orderDiscountMinor: number;
|
|
305
317
|
}
|
|
306
318
|
/** One line in the display mode (ADR-063): before any discount, with its own discounts as sub-rows. */
|
|
@@ -416,10 +428,18 @@ interface AddLineInput {
|
|
|
416
428
|
taxClass?: string;
|
|
417
429
|
}
|
|
418
430
|
|
|
431
|
+
interface OrderCouponContext {
|
|
432
|
+
configs: ReadonlyMap<string, woocommerceCoupons.CouponDiscountConfig>;
|
|
433
|
+
productCategories: ReadonlyMap<number, {
|
|
434
|
+
id: number;
|
|
435
|
+
}[]>;
|
|
436
|
+
calcDiscountsSequentially: boolean;
|
|
437
|
+
}
|
|
419
438
|
interface OrderBuilderOptions {
|
|
420
439
|
currency: string;
|
|
421
440
|
taxContext: TaxContext;
|
|
422
441
|
id?: string;
|
|
442
|
+
couponContext?: OrderCouponContext;
|
|
423
443
|
}
|
|
424
444
|
interface OrderBuilder {
|
|
425
445
|
order$: Observable<Order>;
|
|
@@ -449,6 +469,8 @@ interface OrderBuilder {
|
|
|
449
469
|
removePayment(paymentId: string): void;
|
|
450
470
|
setCustomer(customer: CustomerSummary | null): void;
|
|
451
471
|
setNote(note: string): void;
|
|
472
|
+
/** Replaces the coupon codes with their trimmed, lower-case, deduplicated list. */
|
|
473
|
+
setCoupons(codes: readonly string[]): void;
|
|
452
474
|
clear(): void;
|
|
453
475
|
getSnapshot(): Order;
|
|
454
476
|
}
|
|
@@ -966,17 +988,40 @@ declare function movementFieldError(input: {
|
|
|
966
988
|
reason: string;
|
|
967
989
|
}): 'amount' | 'reason' | null;
|
|
968
990
|
|
|
991
|
+
type PosRefundStatus = 'pending' | 'applied' | 'rejected' | 'unsent';
|
|
992
|
+
interface PosRefund {
|
|
993
|
+
id: string;
|
|
994
|
+
commandId: string;
|
|
995
|
+
orderId: string;
|
|
996
|
+
sessionId: string;
|
|
997
|
+
registerId: string;
|
|
998
|
+
envelope: OrderRefundEnvelope;
|
|
999
|
+
status: PosRefundStatus;
|
|
1000
|
+
result?: OrderRefundResult;
|
|
1001
|
+
duplicate?: boolean;
|
|
1002
|
+
error?: CommandError;
|
|
1003
|
+
createdAt: string;
|
|
1004
|
+
updatedAt: string;
|
|
1005
|
+
}
|
|
1006
|
+
type PosRefundCollection = RxCollection<PosRefund>;
|
|
1007
|
+
declare const posRefundSchema: RxJsonSchema<PosRefund>;
|
|
1008
|
+
/** Local-only, never replicated (ADR-080 amendment 1).
|
|
1009
|
+
* Added with addCollections like cash_movements. */
|
|
1010
|
+
declare const posRefundCollection: () => {
|
|
1011
|
+
schema: RxJsonSchema<PosRefund>;
|
|
1012
|
+
};
|
|
1013
|
+
|
|
969
1014
|
/**
|
|
970
1015
|
* What the register should hold at close, per tender method: the session's cash float plus
|
|
971
1016
|
* captured payments and cash movements — never what the cashier counts. Port provenance
|
|
972
1017
|
* (ADR-032 amendment 1): WCPOS `next` `3b5331b5c`.
|
|
973
1018
|
*
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
* `refunded_amount`
|
|
977
|
-
* `deriveExpected` covers only the float, the session's captured payment rows, and its
|
|
978
|
-
* paid-in/paid-out cash movements under WCPOS's void rules.
|
|
1019
|
+
* Refunds come from the till's applied `pos_refunds`, counted in the record's own `sessionId`
|
|
1020
|
+
* (ADR-080 amendment 1), by the server's rule. WCPOS's `attributeRefunds` fallbacks (allocations,
|
|
1021
|
+
* `refunded_amount`) are not ported: the store attributes each refund to a tender in `byMethod`.
|
|
979
1022
|
*/
|
|
1023
|
+
|
|
1024
|
+
type RefundRow = Pick<PosRefund, 'id' | 'sessionId' | 'status' | 'result'>;
|
|
980
1025
|
/** `session_id`, `kind`, `method_id`, `status` kept as WCPOS names them; money is TallyUI's integer-minor-units convention. */
|
|
981
1026
|
type LedgerRow = {
|
|
982
1027
|
session_id?: string | null;
|
|
@@ -997,18 +1042,19 @@ type Movement$1 = {
|
|
|
997
1042
|
/**
|
|
998
1043
|
* Expected totals per tender method: the counted float, plus every captured ledger row for the
|
|
999
1044
|
* session (grouped under `cash` for cash rows, else `method_id`), plus its non-voided
|
|
1000
|
-
* paid-in/paid-out movements.
|
|
1045
|
+
* paid-in/paid-out movements, minus its applied refunds.
|
|
1001
1046
|
*
|
|
1002
1047
|
* A movement is excluded when its own `voided_by` is set, or when a `type: 'void'` row's
|
|
1003
1048
|
* `voids` names its id; the `void` row itself carries no amount of its own.
|
|
1004
1049
|
*/
|
|
1005
|
-
declare function deriveExpected({ session, movements, ledgerRowsBySession, }: {
|
|
1050
|
+
declare function deriveExpected({ session, movements, ledgerRowsBySession, refunds, }: {
|
|
1006
1051
|
session: {
|
|
1007
1052
|
id: string;
|
|
1008
1053
|
countedFloatMinor: number;
|
|
1009
1054
|
};
|
|
1010
1055
|
movements: readonly Movement$1[];
|
|
1011
1056
|
ledgerRowsBySession: readonly LedgerRow[];
|
|
1057
|
+
refunds?: readonly RefundRow[];
|
|
1012
1058
|
}): Record<string, number>;
|
|
1013
1059
|
|
|
1014
1060
|
/**
|
|
@@ -1074,8 +1120,8 @@ interface RegisterSession {
|
|
|
1074
1120
|
register_id: string;
|
|
1075
1121
|
/** The app's neutral store key (see `bindRegister`). */
|
|
1076
1122
|
store_key?: string | null;
|
|
1077
|
-
/** Stored status is an open string so a later local state costs no migration (ADR-078 decision 9); the union names today's states. */
|
|
1078
|
-
status: 'open' | 'counting' | 'closed' | 'conflict' | 'superseded';
|
|
1123
|
+
/** Stored status is an open string so a later local state costs no migration (ADR-078 decision 9); the union names today's states. `abandoned` is local only and terminal (the cashier chose another register while in conflict). */
|
|
1124
|
+
status: 'open' | 'counting' | 'closed' | 'conflict' | 'superseded' | 'abandoned';
|
|
1079
1125
|
/** The store session this local id was resumed as (ADR-078 decision 2), never the session that superseded it; null until a resume. */
|
|
1080
1126
|
server_session_id?: string | null;
|
|
1081
1127
|
/** The store's day the session opened, `yyyy-MM-dd`. */
|
|
@@ -1130,7 +1176,7 @@ interface Closure {
|
|
|
1130
1176
|
counted: TenderMap;
|
|
1131
1177
|
variance: TenderMap;
|
|
1132
1178
|
period_sales_total_minor: number;
|
|
1133
|
-
/**
|
|
1179
|
+
/** The session's applied refunds (ADR-080 amendment 1); 0 when the app passes none. */
|
|
1134
1180
|
period_refunds_total_minor: number;
|
|
1135
1181
|
perpetual_sales_total_minor: number;
|
|
1136
1182
|
perpetual_refunds_total_minor: number;
|
|
@@ -1261,6 +1307,15 @@ declare class RegisterNeedsUpgradeError extends Error {
|
|
|
1261
1307
|
readonly code = "REGISTER_NEEDS_UPGRADE";
|
|
1262
1308
|
constructor();
|
|
1263
1309
|
}
|
|
1310
|
+
/** Opening is refused while the register has a `conflict` session (ADR-078); its message can be shown to a cashier as it is. */
|
|
1311
|
+
declare class RegisterSessionConflictError extends Error {
|
|
1312
|
+
readonly code = "REGISTER_SESSION_CONFLICT";
|
|
1313
|
+
constructor();
|
|
1314
|
+
}
|
|
1315
|
+
declare class RegisterTakeOverError extends Error {
|
|
1316
|
+
readonly code: 'REGISTER_TAKEOVER_UNSUPPORTED' | 'REGISTER_TAKEOVER_PENDING';
|
|
1317
|
+
constructor(code: 'REGISTER_TAKEOVER_UNSUPPORTED' | 'REGISTER_TAKEOVER_PENDING');
|
|
1318
|
+
}
|
|
1264
1319
|
/** ADR-068 6a: movement amounts must be safe integers, positive for paid_in/paid_out and zero for no_sale. */
|
|
1265
1320
|
declare class RegisterMovementAmountError extends Error {
|
|
1266
1321
|
constructor(type: 'paid_in' | 'paid_out' | 'no_sale', amountMinor: number);
|
|
@@ -1341,8 +1396,9 @@ declare function voidMovement(sessions: RegisterSessionCollection, movements: Ca
|
|
|
1341
1396
|
* Only a closed session (`closed` with `closed_at_gmt`) has a closure, and a closed session is
|
|
1342
1397
|
* final, so its existing closure is returned as it was frozen. Orders the server rejected still
|
|
1343
1398
|
* count in the drawer, because the cash was taken.
|
|
1399
|
+
* A refund still pending at close is not counted, and the Z lists it.
|
|
1344
1400
|
*/
|
|
1345
|
-
declare function writeClosure({ closures, register, storeKey, session, counted, otherTenders, movements, orders, tillExpected, labels, resolveCashierName, softwareVersion, timezone, }: {
|
|
1401
|
+
declare function writeClosure({ closures, register, storeKey, session, counted, otherTenders, movements, orders, refunds, tillExpected, labels, resolveCashierName, softwareVersion, timezone, }: {
|
|
1346
1402
|
closures: ClosureCollection;
|
|
1347
1403
|
/** The register document's host (`register_sessions`). */
|
|
1348
1404
|
register: RegisterHost;
|
|
@@ -1354,6 +1410,8 @@ declare function writeClosure({ closures, register, storeKey, session, counted,
|
|
|
1354
1410
|
movements: readonly CashMovement[];
|
|
1355
1411
|
/** Any `pos_orders`; only those whose `sessionId` is this session's are counted. */
|
|
1356
1412
|
orders: readonly PosOrder[];
|
|
1413
|
+
/** `pos_refunds` rows; only this session's applied ones are counted (ADR-080 amendment 1). */
|
|
1414
|
+
refunds?: readonly PosRefund[];
|
|
1357
1415
|
tillExpected?: Record<string, number>;
|
|
1358
1416
|
labels?: {
|
|
1359
1417
|
register_name: string;
|
|
@@ -1840,9 +1898,11 @@ declare const registerCommandCollection: () => {
|
|
|
1840
1898
|
schema: RxJsonSchema<RegisterCommand>;
|
|
1841
1899
|
};
|
|
1842
1900
|
type BuiltCommand = Pick<RegisterCommand, 'key' | 'type' | 'payload'> & {
|
|
1843
|
-
version: 1;
|
|
1901
|
+
version: 1 | 2;
|
|
1844
1902
|
};
|
|
1845
|
-
declare function sessionOpenCommand(s: RegisterSession
|
|
1903
|
+
declare function sessionOpenCommand(s: RegisterSession, v2?: {
|
|
1904
|
+
deviceName?: string | null;
|
|
1905
|
+
}): BuiltCommand;
|
|
1846
1906
|
declare function sessionTransitionCommand(s: RegisterSession & {
|
|
1847
1907
|
status: RegisterSessionTransitionPayload['status'];
|
|
1848
1908
|
status_at: string;
|
|
@@ -1850,7 +1910,7 @@ declare function sessionTransitionCommand(s: RegisterSession & {
|
|
|
1850
1910
|
declare function movementCommand(m: CashMovement): BuiltCommand;
|
|
1851
1911
|
declare function closureCommand(c: Closure): BuiltCommand;
|
|
1852
1912
|
/** Appends missing facts in dependency order; the bytes of an existing key never change. */
|
|
1853
|
-
declare function reconcileRegisterCommands({ commands, sessions, movements, closures, host, storeKey, registerId, now, observed }: {
|
|
1913
|
+
declare function reconcileRegisterCommands({ commands, sessions, movements, closures, host, storeKey, registerId, now, observed, registerContract, deviceName }: {
|
|
1854
1914
|
commands: RegisterCommandCollection;
|
|
1855
1915
|
sessions: RegisterSessionCollection;
|
|
1856
1916
|
movements: CashMovementCollection;
|
|
@@ -1860,6 +1920,8 @@ declare function reconcileRegisterCommands({ commands, sessions, movements, clos
|
|
|
1860
1920
|
registerId: string;
|
|
1861
1921
|
now?: string;
|
|
1862
1922
|
observed?: RegisterSession[];
|
|
1923
|
+
registerContract?: number;
|
|
1924
|
+
deviceName?: string | null;
|
|
1863
1925
|
}): Promise<string[]>;
|
|
1864
1926
|
|
|
1865
1927
|
/** A sale is at tender, so the till can't count or close under it. Its message can be shown to a cashier as it is. */
|
|
@@ -1883,11 +1945,15 @@ interface UseRegisterSessionOptions {
|
|
|
1883
1945
|
sessions: RegisterSessionCollection | null;
|
|
1884
1946
|
/** `cash_movements`; `null` while it opens. */
|
|
1885
1947
|
movements: CashMovementCollection | null;
|
|
1948
|
+
/** `pos_refunds` (`posRefundCollection()`); `null` while it opens. Leave it out when the app takes no refunds (ADR-080 amendment 1). */
|
|
1949
|
+
refunds?: PosRefundCollection | null;
|
|
1886
1950
|
/** `closures`; `null` while it opens. */
|
|
1887
1951
|
closures: ClosureCollection | null;
|
|
1888
1952
|
/** `register_commands`, created with `registerCommandCollection()`; `null` while it opens. */
|
|
1889
1953
|
commands?: RegisterCommandCollection | null;
|
|
1890
1954
|
capabilities?: ServerCapabilities;
|
|
1955
|
+
/** The till's name from the app's settings, sent on a register v2 open; the app supplies its platform fallback. */
|
|
1956
|
+
deviceName?: string | null;
|
|
1891
1957
|
/** `pos_orders`: a session's sales are those whose `sessionId` is its id. */
|
|
1892
1958
|
orders: RxCollection<PosOrder> | null;
|
|
1893
1959
|
/** The register document's host, for the closure number and perpetual totals (`writeClosure`); `null` while it opens. */
|
|
@@ -1920,6 +1986,20 @@ interface UseRegisterSessionOptions {
|
|
|
1920
1986
|
}
|
|
1921
1987
|
declare function useRegisterSession(options: UseRegisterSessionOptions): {
|
|
1922
1988
|
session: RegisterSession | null;
|
|
1989
|
+
/** The other till's live session, or the session this till is waiting to take over. */
|
|
1990
|
+
conflict: {
|
|
1991
|
+
sessionId: string;
|
|
1992
|
+
takingOver: boolean;
|
|
1993
|
+
openedAt?: undefined;
|
|
1994
|
+
openedBy?: undefined;
|
|
1995
|
+
deviceName?: undefined;
|
|
1996
|
+
} | {
|
|
1997
|
+
sessionId: string;
|
|
1998
|
+
openedAt: string | undefined;
|
|
1999
|
+
openedBy: string | undefined;
|
|
2000
|
+
deviceName: string | undefined;
|
|
2001
|
+
takingOver: boolean;
|
|
2002
|
+
} | undefined;
|
|
1923
2003
|
/** Any unknown session status in the current snapshot means the register needs upgrade. */
|
|
1924
2004
|
needsUpgrade: boolean;
|
|
1925
2005
|
movements: CashMovement[];
|
|
@@ -1946,11 +2026,14 @@ declare function useRegisterSession(options: UseRegisterSessionOptions): {
|
|
|
1946
2026
|
sessions: RegisterSessionCollection;
|
|
1947
2027
|
} | null>;
|
|
1948
2028
|
actions: {
|
|
2029
|
+
takeOver: () => Promise<void>;
|
|
2030
|
+
chooseAnotherRegister: () => Promise<void>;
|
|
1949
2031
|
/**
|
|
1950
2032
|
* Refuses with `RegisterSessionAlreadyOpenError` while the register has a live session or
|
|
1951
2033
|
* another open is running (in any hook instance), and with `RegisterCloseIncompleteError`
|
|
1952
2034
|
* while an earlier close hasn't finished: a new session would lock the till behind it.
|
|
1953
2035
|
* An unknown stored status refuses with `RegisterNeedsUpgradeError`.
|
|
2036
|
+
* A conflict session refuses with `RegisterSessionConflictError`; superseded and abandoned sessions do not block.
|
|
1954
2037
|
*/
|
|
1955
2038
|
openSession: (input: {
|
|
1956
2039
|
expectedFloatMinor: number | null;
|
|
@@ -1982,6 +2065,29 @@ declare function useRegisterSession(options: UseRegisterSessionOptions): {
|
|
|
1982
2065
|
};
|
|
1983
2066
|
};
|
|
1984
2067
|
|
|
2068
|
+
type SessionTarget = {
|
|
2069
|
+
commands: RegisterCommandCollection;
|
|
2070
|
+
sessions: RegisterSessionCollection;
|
|
2071
|
+
sessionId: string;
|
|
2072
|
+
now?: string;
|
|
2073
|
+
};
|
|
2074
|
+
/**
|
|
2075
|
+
* Applied opens fill a missing resume id; refused opens make open/counting sessions conflict.
|
|
2076
|
+
* 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.
|
|
2077
|
+
* Applied conflict opens restore the latest transition's counting state, otherwise open; pending rows do nothing.
|
|
2078
|
+
* Answers are walked in seq/key order; adoption is idempotent and safe to run at any time.
|
|
2079
|
+
*/
|
|
2080
|
+
declare function adoptRegisterResults({ commands, sessions, registerId }: {
|
|
2081
|
+
commands: RegisterCommandCollection;
|
|
2082
|
+
sessions: RegisterSessionCollection;
|
|
2083
|
+
registerId: string;
|
|
2084
|
+
}): Promise<void>;
|
|
2085
|
+
declare function takeOverSession({ commands, sessions, sessionId, now, registerContract }: SessionTarget & {
|
|
2086
|
+
/** The store's register contract (`capabilities.register`); take over needs 2, and a missing value counts as below 2. */
|
|
2087
|
+
registerContract?: number;
|
|
2088
|
+
}): Promise<void>;
|
|
2089
|
+
declare function abandonSession(input: SessionTarget): Promise<void>;
|
|
2090
|
+
|
|
1985
2091
|
type CatalogueEntry<Doc> = {
|
|
1986
2092
|
product: Doc;
|
|
1987
2093
|
variant: VariantSummary;
|
|
@@ -2287,6 +2393,9 @@ declare function createOrderOutbox(options: OrderOutboxOptions): OrderOutbox;
|
|
|
2287
2393
|
|
|
2288
2394
|
interface RegisterOutboxOptions {
|
|
2289
2395
|
collection: RxCollection<RegisterCommand>;
|
|
2396
|
+
/** The till's `register_sessions`. With it, a refused open (`register_session_already_open`) stops blocking its register
|
|
2397
|
+
* once its session is `abandoned` (ADR-078 decision 9). Without it, that refusal always blocks. */
|
|
2398
|
+
sessions?: RegisterSessionCollection;
|
|
2290
2399
|
transport: CommandTransport<RegisterCommandEnvelope>;
|
|
2291
2400
|
deviceId: string;
|
|
2292
2401
|
/** Checked at the start of every run; false sends nothing. */
|
|
@@ -2314,6 +2423,8 @@ declare function createRegisterOutbox(options: RegisterOutboxOptions): RegisterO
|
|
|
2314
2423
|
interface UseRegisterOutboxOptions {
|
|
2315
2424
|
/** `register_commands` (see `registerCommandCollection()`); `null` while it opens or when there's no store. A new collection (a store switch) restarts the outbox. */
|
|
2316
2425
|
commands: RegisterCommandCollection | null;
|
|
2426
|
+
/** The till's `register_sessions`; abandoned sessions unblock refused opens. A new collection restarts the outbox. */
|
|
2427
|
+
sessions?: RegisterSessionCollection | null;
|
|
2317
2428
|
/** Builds the transport; called when the outbox is created: on each new collection or device id (twice under React StrictMode's double effect, which stops the first outbox). */
|
|
2318
2429
|
transport(): CommandTransport<RegisterCommandEnvelope>;
|
|
2319
2430
|
/** The device id sent on every command. A change restarts the outbox. */
|
|
@@ -2392,6 +2503,46 @@ interface UseOrderOutboxResult {
|
|
|
2392
2503
|
/** Opens the order store for `storeKey`, runs its outbox and watches the recent orders (lifted from medusapos/app, ADR-052). */
|
|
2393
2504
|
declare function useOrderOutbox(options: UseOrderOutboxOptions): UseOrderOutboxResult;
|
|
2394
2505
|
|
|
2506
|
+
type OrderRefundOutcome = {
|
|
2507
|
+
kind: 'applied';
|
|
2508
|
+
refund: OrderRefundResult;
|
|
2509
|
+
duplicate: boolean;
|
|
2510
|
+
} | {
|
|
2511
|
+
kind: 'rejected';
|
|
2512
|
+
error: CommandError;
|
|
2513
|
+
} | {
|
|
2514
|
+
kind: 'unknown';
|
|
2515
|
+
reason: string;
|
|
2516
|
+
retryAfterMs?: number;
|
|
2517
|
+
} | {
|
|
2518
|
+
kind: 'refused';
|
|
2519
|
+
status: number;
|
|
2520
|
+
reason: string;
|
|
2521
|
+
} | {
|
|
2522
|
+
kind: 'unauthorized';
|
|
2523
|
+
};
|
|
2524
|
+
/** Online only, never queued (ADR-080). On unknown, resend the same envelope (same id).
|
|
2525
|
+
* After rejected, a new attempt needs a new id. Refused and unauthorized mean the store did not take the batch. */
|
|
2526
|
+
declare function sendOrderRefund(transport: CommandTransport<OrderRefundEnvelope>, envelope: OrderRefundEnvelope): Promise<OrderRefundOutcome>;
|
|
2527
|
+
|
|
2528
|
+
declare class RefundAnswerPendingError extends Error {
|
|
2529
|
+
readonly record: PosRefund;
|
|
2530
|
+
readonly code = "REFUND_ANSWER_PENDING";
|
|
2531
|
+
constructor(record: PosRefund);
|
|
2532
|
+
}
|
|
2533
|
+
/** Online only, never queued; the record is written before the send.
|
|
2534
|
+
* An applied record is final; a pending one is resent only with its own envelope
|
|
2535
|
+
* (ADR-080 amendment 1). */
|
|
2536
|
+
declare function submitOrderRefund({ refunds, transport, envelope, now }: {
|
|
2537
|
+
refunds: PosRefundCollection;
|
|
2538
|
+
transport: CommandTransport<OrderRefundEnvelope>;
|
|
2539
|
+
envelope: OrderRefundEnvelope;
|
|
2540
|
+
now?: () => string;
|
|
2541
|
+
}): Promise<{
|
|
2542
|
+
outcome: OrderRefundOutcome;
|
|
2543
|
+
record: PosRefund;
|
|
2544
|
+
}>;
|
|
2545
|
+
|
|
2395
2546
|
/** The transport a payment terminal is reached over: hardware-neutral, not tied to any backend. */
|
|
2396
2547
|
type PaymentTransport = 'bluetooth' | 'usb' | 'network' | 'tap_to_pay';
|
|
2397
2548
|
type TenderView = 'select' | 'amount' | 'cancel';
|
|
@@ -2577,4 +2728,4 @@ declare function tenderVoidCollection(): {
|
|
|
2577
2728
|
readonly schema: RxJsonSchema<TenderVoid>;
|
|
2578
2729
|
};
|
|
2579
2730
|
|
|
2580
|
-
export { type Actor, type AddLineInput, type AppliedDiscount, type BackendNotFound, type BasketLine, CartError, type CashMovement, type CashMovementCollection, type CatalogueEntry, type CatalogueGridColumns, type CatalogueView, type CatalogueViewAction, type CatalogueViewState, type ChargeInput, type ChargeLine, type Closure, type ClosureCollection, type ClosureContext, type ClosureScope, type CommandTransport, type Correction, CurrencyProvider, type CurrencyProviderProps, type CustomerSummary, DEFAULT_CATALOGUE_VIEW_STATE, DISCOUNTS_UNSUPPORTED, type Discount, type DisplayLine, type DisplayTotals, type FeeLine, type FinalizeOptions, type HttpTransportOptions, type LedgerRow, type LineItem, type LineTaxLine, type LogEntry, type LogLevel, type LogSink, type Logger, MAX_TENDER_MINOR, MICROS_PER_MINOR, type Movement$1 as Movement, type MovementType, type Order, type OrderBuilder, type OrderBuilderOptions, OrderContentMismatchError, type OrderManager, type OrderManagerOptions, type OrderOutbox, type OrderOutboxOptions, type OrderTaxTotals, type OrderTransportContext, type OutboxState, PRODUCT_SORT_FIELDS, type ParkedOrderSummary, type Payment, type PaymentMethod, type PaymentTransport, type PlanLeg, type PosOrder, type PosOrderLine, type PosOrderLocalWarning, PosOrderOpenClosedError, type PosOrderPayment, type PosOrderServerFailures, type PosOrderSyncStatus, type ProductSort, type ProductSortValue, RECEIPT_SCHEMA_VERSION, REGISTER_SESSION_MIGRATION_CLOSE_WAIT_MS, type RateTaxLine, type ReceiptConfig, type ReceiptData, type ReceiptFiscal, type ReceiptLineItem, type ReceiptRegister, type ReceiptSoftware, type RecordedFigures, 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, type RegisterSession, RegisterSessionAlreadyOpenError, RegisterSessionClosedError, type RegisterSessionCollection, RegisterSessionOpenClosedError, RegisterSessionRequiredError, type RegisterStore, RegisterTenderInProgressError, type Repository, type ResolveStoreSettingsOptions, SALE_SAVING, type SaleStage, type SentOrder, type ShippingLine, type SplitTab, type StoreSettingsResolution, type StoreSettingsState, TAX_ROUNDING_MIXED_NOTE, type TaxContext, type TaxLineInput, TaxProvider, type TaxProviderProps, type TaxRateMap, type TenderAction, type TenderKey, type TenderLineId, type TenderPlan, type TenderState, type TenderView, type TenderVoid, type TransportOutcome, UnsupportedOrderVersionError, type UseOrderOutboxOptions, type UseOrderOutboxResult, type UseRegisterOutboxOptions, type UseRegisterOutboxResult, type UseRegisterSessionOptions, activePlan, addEntryToCart, addPosOrderCollection, addRegisterSessionCollection, advancePerpetual, allocateOrderDiscount, appliedMinor, backToSelling, bindRegister, buildClosureDocument, buildReceiptData, buildXReportDocument, callbackSink, cashMovementSchema, catalogueEntries, catalogueViewReducer, changeMinor, clampClosureScope, closeNeedsApproval, closeSession, closureCommand, closureSchema, computeOrderTax, consoleSink, countVariance, createBackendNotFound, createHttpCommandTransport, createLogger, createOrderBuilder, createOrderManager, createOrderOutbox, createRegisterOutbox, createRepository, denominationTotal, denominations, deriveExpected, deriveSettled, ensureRegister, evenSplitShareMinor, exportCsv, finalizeOrder, findEntryByCode, formatClosureDate, getBoundRegisterId, getDeviceId, inCategory, initTenderState, initialTenderState, isKnownSessionStatus, isServerDecimal, labelKeys, listCategories, minorToDecimal, mintClosureNumber, mintUuid, movementCommand, movementFieldError, needsAttention, nextSaleCounter, normalizeAmount, normalizeCatalogueViewState, observeRegister$, openSession, openSessionSelector, orderDraftSchema, outboxLogger, overThreshold, parkedOrderSummaries$, parseMinor, planLegs, posOrderCollection, posOrderSchema, posOrdersLogger, productCategories, productSortValue, quickTenderedAmounts, ratePpmFromPercent, readBoundRegister, readRegister, reconcileRegisterCommands, recordMovement, recordRegisterFact, registerCommandCollection, registerCommandSchema, registerCommandsLogger, registerFactsLogger, registerSessionCollection, registerSessionSchema, registerSessionsLogger, requireOpenSession, resolveGridColumns, resolveStoreSettings, restoreOrderDraft, roundMicrosToMinor, saleLogger, sameSale, searchProducts, selectClosureRows, sessionOpenCommand, sessionTransitionCommand, sortProducts, stampSession, startCounting, stockOverlay$, stockOverlayAsOf$, taxFiguresForBasket, taxLinesByRate, taxLogger, taxMicros, taxProviderProps, tenderReducer, tenderVoidCollection, tenderVoidSchema, toOrderCreateEnvelope, unbindRegister, useCurrencyCode, useCurrencyFormatter, useOrderOutbox, useParkedSales, useRegisterOutbox, useRegisterSession, useSale, useStoreSettings, useTax, uuidv7, validAmount, varianceText, variantPriceLabel, voidMovement, withPricingContext, writeClosure, writeOrderDraft };
|
|
2731
|
+
export { type Actor, type AddLineInput, type AppliedDiscount, type BackendNotFound, type BasketLine, CartError, type CashMovement, type CashMovementCollection, type CatalogueEntry, type CatalogueGridColumns, type CatalogueView, type CatalogueViewAction, type CatalogueViewState, type ChargeInput, type ChargeLine, type Closure, type ClosureCollection, type ClosureContext, type ClosureScope, type CommandTransport, type Correction, CurrencyProvider, type CurrencyProviderProps, type CustomerSummary, DEFAULT_CATALOGUE_VIEW_STATE, DISCOUNTS_UNSUPPORTED, type Discount, type DisplayLine, type DisplayTotals, type FeeLine, type FinalizeOptions, type HttpTransportOptions, type LedgerRow, type LineItem, type LineTaxLine, type LogEntry, type LogLevel, type LogSink, type Logger, MAX_TENDER_MINOR, MICROS_PER_MINOR, type Movement$1 as Movement, type MovementType, type Order, type OrderBuilder, type OrderBuilderOptions, OrderContentMismatchError, type OrderCoupon, type OrderCouponContext, type OrderManager, type OrderManagerOptions, type OrderOutbox, type OrderOutboxOptions, type OrderRefundOutcome, type OrderTaxTotals, type OrderTransportContext, type OutboxState, PRODUCT_SORT_FIELDS, type ParkedOrderSummary, type Payment, type PaymentMethod, type PaymentTransport, type PlanLeg, type PosOrder, type PosOrderLine, type PosOrderLocalWarning, PosOrderOpenClosedError, type PosOrderPayment, type PosOrderServerFailures, type PosOrderSyncStatus, type PosRefund, type PosRefundCollection, type PosRefundStatus, type ProductSort, type ProductSortValue, RECEIPT_SCHEMA_VERSION, REGISTER_SESSION_MIGRATION_CLOSE_WAIT_MS, type RateTaxLine, type ReceiptConfig, type ReceiptData, type ReceiptFiscal, type ReceiptLineItem, type ReceiptRegister, type ReceiptSoftware, 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, type RegisterSession, RegisterSessionAlreadyOpenError, RegisterSessionClosedError, type RegisterSessionCollection, RegisterSessionConflictError, RegisterSessionOpenClosedError, RegisterSessionRequiredError, type RegisterStore, RegisterTakeOverError, RegisterTenderInProgressError, type Repository, type ResolveStoreSettingsOptions, SALE_SAVING, type SaleStage, type SentOrder, type ShippingLine, type SplitTab, type StoreSettingsResolution, type StoreSettingsState, TAX_ROUNDING_MIXED_NOTE, type TaxContext, type TaxLineInput, TaxProvider, type TaxProviderProps, type TaxRateMap, type TenderAction, type TenderKey, type TenderLineId, type TenderPlan, type TenderState, type TenderView, type TenderVoid, type TransportOutcome, UnsupportedOrderVersionError, type UseOrderOutboxOptions, type UseOrderOutboxResult, type UseRegisterOutboxOptions, type UseRegisterOutboxResult, type UseRegisterSessionOptions, abandonSession, activePlan, addEntryToCart, addPosOrderCollection, addRegisterSessionCollection, adoptRegisterResults, advancePerpetual, allocateOrderDiscount, appliedMinor, backToSelling, bindRegister, buildClosureDocument, buildReceiptData, buildXReportDocument, callbackSink, cashMovementSchema, catalogueEntries, catalogueViewReducer, changeMinor, clampClosureScope, closeNeedsApproval, closeSession, closureCommand, closureSchema, computeOrderTax, consoleSink, countVariance, createBackendNotFound, createHttpCommandTransport, createLogger, createOrderBuilder, createOrderManager, createOrderOutbox, createRegisterOutbox, createRepository, denominationTotal, denominations, deriveExpected, deriveSettled, ensureRegister, evenSplitShareMinor, exportCsv, finalizeOrder, findEntryByCode, formatClosureDate, getBoundRegisterId, getDeviceId, inCategory, initTenderState, initialTenderState, isKnownSessionStatus, isServerDecimal, labelKeys, listCategories, minorToDecimal, mintClosureNumber, mintUuid, movementCommand, movementFieldError, needsAttention, nextSaleCounter, normalizeAmount, normalizeCatalogueViewState, observeRegister$, openSession, openSessionSelector, orderDraftSchema, outboxLogger, overThreshold, parkedOrderSummaries$, parseMinor, planLegs, posOrderCollection, posOrderSchema, posOrdersLogger, posRefundCollection, posRefundSchema, productCategories, productSortValue, quickTenderedAmounts, ratePpmFromPercent, readBoundRegister, readRegister, reconcileRegisterCommands, recordMovement, recordRegisterFact, registerCommandCollection, registerCommandSchema, registerCommandsLogger, registerFactsLogger, registerSessionCollection, registerSessionSchema, registerSessionsLogger, requireOpenSession, resolveGridColumns, resolveStoreSettings, restoreOrderDraft, roundMicrosToMinor, saleLogger, sameSale, searchProducts, selectClosureRows, sendOrderRefund, sessionOpenCommand, sessionTransitionCommand, sortProducts, stampSession, startCounting, stockOverlay$, stockOverlayAsOf$, submitOrderRefund, takeOverSession, taxFiguresForBasket, taxLinesByRate, taxLogger, taxMicros, taxProviderProps, tenderReducer, tenderVoidCollection, tenderVoidSchema, toOrderCreateEnvelope, unbindRegister, useCurrencyCode, useCurrencyFormatter, useOrderOutbox, useParkedSales, useRegisterOutbox, useRegisterSession, useSale, useStoreSettings, useTax, uuidv7, validAmount, varianceText, variantPriceLabel, voidMovement, withPricingContext, writeClosure, writeOrderDraft };
|