@tallyui/core 3.12.0 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-UFWXJAMF.js → chunk-CSXNXRBA.js} +2 -0
- package/dist/{command-result-CrM7yjwk.d.ts → command-result-CoCa8PXJ.d.ts} +22 -5
- package/dist/index.d.ts +248 -6
- package/dist/index.js +76 -4
- package/dist/server/index.d.ts +8 -6
- package/dist/server/index.js +11 -3
- package/package.json +1 -1
- package/src/commands.ts +2 -0
- package/src/connectivity.ts +41 -0
- package/src/index.ts +11 -2
- package/src/server/batch.ts +1 -0
- package/src/server/index.ts +1 -1
- package/src/server/order-payload-shape.ts +5 -1
- package/src/server/register-outcome.ts +2 -0
- package/src/server/register-payload-shape.ts +4 -0
- package/src/server/rejection-codes.ts +1 -2
- package/src/server/versions.ts +4 -1
- package/src/types/cashier.ts +32 -0
- package/src/types/commands.ts +17 -4
- package/src/types/connector.ts +61 -4
- package/src/types/customers.ts +32 -3
- package/src/types/index.ts +1 -0
- package/src/types/payment-methods.ts +103 -0
- package/src/types/registers.ts +15 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { PaymentMethodKind } from './commands';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A payment method the till can offer, backend-neutral (a port of WCPOS v2's Payments Contract
|
|
5
|
+
* v1 descriptor, `order-math/src/payments/types.ts`). A connector maps its own model into it:
|
|
6
|
+
* WooCommerce gateways, Medusa payment providers, Vendure payment methods. Amounts are integer
|
|
7
|
+
* minor units of the store currency. Open vocabularies keep values this build has never seen, so
|
|
8
|
+
* the till can show such a method disabled instead of dropping it.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** A known value, or any other string this build does not know yet. */
|
|
12
|
+
type OpenEnum<Known extends string> = Known | (string & {});
|
|
13
|
+
|
|
14
|
+
/** What kind of money the method takes. Not the order's wire method: that is `PaymentMethodKind`. */
|
|
15
|
+
export type PaymentKind = 'cash' | 'card' | 'stored_value' | 'bank_transfer' | 'other';
|
|
16
|
+
|
|
17
|
+
/** How the payment is taken. `manual`: the cashier records it (cash, a standalone terminal). */
|
|
18
|
+
export type CaptureMode = 'manual' | 'webview' | 'server' | 'device' | 'stored_value' | 'gateway';
|
|
19
|
+
|
|
20
|
+
/** The transport a payment terminal is reached over. */
|
|
21
|
+
export type PaymentTransport = 'bluetooth' | 'usb' | 'network' | 'tap_to_pay';
|
|
22
|
+
|
|
23
|
+
/** Whether a leg can be taken while the till is offline: recorded, queued to settle later, or not at all. */
|
|
24
|
+
export type PaymentOfflineMode = 'record' | 'queue' | 'none';
|
|
25
|
+
|
|
26
|
+
/** Where a tip is entered, if anywhere. */
|
|
27
|
+
export type PaymentTipsMode = 'none' | 'on_reader' | 'at_till';
|
|
28
|
+
|
|
29
|
+
/** The terminal hardware behind a method: readers the server lists, or transports an SDK discovers. */
|
|
30
|
+
export type PaymentHardware =
|
|
31
|
+
| {
|
|
32
|
+
discovery: OpenEnum<'server'>;
|
|
33
|
+
readers: { id: string; label: string; status: OpenEnum<'online' | 'offline'>; default: boolean }[];
|
|
34
|
+
defaultReader: string | null;
|
|
35
|
+
lockToDefault: boolean;
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
discovery: OpenEnum<'sdk' | 'manual'>;
|
|
39
|
+
transports: { transport: OpenEnum<PaymentTransport>; offline: OpenEnum<PaymentOfflineMode>; tips: OpenEnum<PaymentTipsMode> }[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** One way to capture a method's payments. */
|
|
43
|
+
export interface CaptureModeEntry {
|
|
44
|
+
mode: OpenEnum<CaptureMode>;
|
|
45
|
+
/** The payment provider's own name, e.g. a terminal vendor; `null` for none. */
|
|
46
|
+
provider: string | null;
|
|
47
|
+
hardware: PaymentHardware | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Cash rounding for the method: the due amount rounds to a multiple of `incrementMinor`; `nearest` rounds half up. */
|
|
51
|
+
export type PaymentRounding = { incrementMinor: number; mode: 'nearest' | 'up' | 'down' } | null;
|
|
52
|
+
|
|
53
|
+
export interface PaymentMethodDescriptor {
|
|
54
|
+
/** The connector's own id for the method, stable across reads. */
|
|
55
|
+
id: string;
|
|
56
|
+
/** The name the till shows. */
|
|
57
|
+
title: string;
|
|
58
|
+
kind: OpenEnum<PaymentKind>;
|
|
59
|
+
capture: CaptureModeEntry & {
|
|
60
|
+
/** Every way the method can be captured, the primary first; absent when `mode` is the only one. */
|
|
61
|
+
modes?: CaptureModeEntry[];
|
|
62
|
+
};
|
|
63
|
+
capabilities: {
|
|
64
|
+
/** `partial`: the method may take less than the balance (a split leg). */
|
|
65
|
+
amount: { partial: boolean; minMinor?: number; maxMinor?: number };
|
|
66
|
+
/** Whether tendering more than is due gives change. */
|
|
67
|
+
change: boolean;
|
|
68
|
+
refunds: { via: OpenEnum<'provider' | 'manual' | 'device' | 'none'>; partial: boolean };
|
|
69
|
+
tips: OpenEnum<PaymentTipsMode>;
|
|
70
|
+
offline: OpenEnum<PaymentOfflineMode>;
|
|
71
|
+
/** Whether a taken leg can be voided. */
|
|
72
|
+
void: boolean;
|
|
73
|
+
};
|
|
74
|
+
defaults: {
|
|
75
|
+
rounding: PaymentRounding;
|
|
76
|
+
/** Whether taking the payment opens the cash drawer. */
|
|
77
|
+
openDrawer: boolean;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The descriptor of one of today's two wire methods: its `id` is the `PaymentMethodKind`. */
|
|
82
|
+
export function paymentMethodOf(kind: PaymentMethodKind): PaymentMethodDescriptor {
|
|
83
|
+
return {
|
|
84
|
+
id: kind,
|
|
85
|
+
title: kind === 'cash' ? 'Cash' : 'Card terminal',
|
|
86
|
+
kind: kind === 'cash' ? 'cash' : 'card',
|
|
87
|
+
capture: { mode: 'manual', provider: null, hardware: null },
|
|
88
|
+
capabilities: {
|
|
89
|
+
amount: { partial: true },
|
|
90
|
+
change: kind === 'cash',
|
|
91
|
+
refunds: { via: 'manual', partial: true },
|
|
92
|
+
tips: 'none',
|
|
93
|
+
offline: 'record',
|
|
94
|
+
void: true,
|
|
95
|
+
},
|
|
96
|
+
defaults: { rounding: null, openDrawer: kind === 'cash' },
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Today's two methods, cash then the card terminal: what the till offers when the connector has no `paymentMethods`. */
|
|
101
|
+
export function defaultPaymentMethods(): PaymentMethodDescriptor[] {
|
|
102
|
+
return [paymentMethodOf('cash'), paymentMethodOf('external')];
|
|
103
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A register (till) in the store's register directory (v2 parity A4). Platform-neutral: each connector maps its own
|
|
3
|
+
* register model onto it. Money is integer minor units of the store's currency.
|
|
4
|
+
* The cash variance threshold is not here: it is the store's (ADR-082, `capabilities.registerApproval`).
|
|
5
|
+
*/
|
|
6
|
+
export interface RegisterInfo {
|
|
7
|
+
/** The platform's register id. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** The register's display name, as the cashier picks it. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** The cash the drawer should open with; absent when the store sets none. */
|
|
12
|
+
defaultFloatMinor?: number;
|
|
13
|
+
/** When the register is due to close: a local store time, `HH:MM` on a 24-hour clock; absent when the store sets none. */
|
|
14
|
+
expectedCloseTime?: string;
|
|
15
|
+
}
|