@tallyui/core 3.11.0 → 3.13.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.
@@ -0,0 +1,81 @@
1
+ import type { PaymentMethodKind } from './commands';
2
+
3
+ /** A line of an order the store holds (ADR-081). Money in integer minor units of the order's currency, as the store
4
+ * records it: every amount excludes tax, and the tax is beside it.
5
+ * Each tax field is such that net + tax is the gross rounded once. */
6
+ export interface StoreOrderLine {
7
+ /** The store's line id: what `OrderRefundLine.orderLineId` names. */
8
+ id: string;
9
+ /** The till's line id when a till created the line (its `clientLineId`); absent otherwise. */
10
+ clientLineId?: string;
11
+ productId?: string;
12
+ /** The sellable the till's `variantId` names (a WooCommerce variation, or the product itself when simple). */
13
+ variantId?: string;
14
+ name: string;
15
+ sku?: string;
16
+ quantity: number;
17
+ /** Before discounts, excluding tax. */
18
+ subtotalMinor: number;
19
+ subtotalTaxMinor: number;
20
+ /** After discounts, excluding tax. */
21
+ totalMinor: number;
22
+ taxMinor: number;
23
+ }
24
+
25
+ /** A fee or shipping line: excluding tax, the tax beside it. A fee may be negative.
26
+ * `taxMinor` is such that `totalMinor + taxMinor` is the gross rounded once. */
27
+ export interface StoreOrderCharge { name: string; totalMinor: number; taxMinor: number }
28
+
29
+ export interface StoreOrderPayment {
30
+ /** The store's own method id, e.g. WooCommerce's `pos_cash`. */
31
+ method: string;
32
+ /** The store's name for it, e.g. "Cash". */
33
+ title?: string;
34
+ /** Set only when the method is one the till itself takes. */
35
+ kind?: PaymentMethodKind;
36
+ amountMinor: number;
37
+ }
38
+
39
+ /** A refund the store already recorded against the order. */
40
+ export interface StoreOrderRefund { id: string; /** Positive. */ amountMinor: number; reason?: string }
41
+
42
+ /** An order as the store holds it, read online (ADR-081); never stored by the till. */
43
+ export interface StoreOrder {
44
+ /** The store's order id: what `OrderRefundPayload.orderId` and `CommandServerRefs.orderId` carry. */
45
+ id: string;
46
+ /** The number the store shows (`CommandServerRefs.displayId`). */
47
+ reference: string;
48
+ /** The till's `PosOrder.id` when a till created the order; absent otherwise. */
49
+ clientOrderId?: string;
50
+ /** The platform's own status word (WooCommerce: `completed`, `refunded`, …); the app labels it. */
51
+ status: string;
52
+ /** ISO 8601, UTC. */
53
+ placedAt: string;
54
+ currency: string;
55
+ pricesIncludeTax: boolean;
56
+ customer: { id?: string; name?: string; email?: string } | null;
57
+ lines: StoreOrderLine[];
58
+ fees: StoreOrderCharge[];
59
+ shipping: StoreOrderCharge[];
60
+ /** `discountMinor + discountTaxMinor` is the coupon's gross discount rounded once. */
61
+ coupons: Array<{ code: string; discountMinor: number; discountTaxMinor: number }>;
62
+ /** Tax by rate; `amountMinor` includes the rate's shipping tax. */
63
+ taxLines: Array<{ label: string; code?: string; ratePpm: number; amountMinor: number }>;
64
+ discountMinor: number;
65
+ discountTaxMinor: number;
66
+ taxMinor: number;
67
+ totalMinor: number;
68
+ payments: StoreOrderPayment[];
69
+ refunds: StoreOrderRefund[];
70
+ }
71
+
72
+ export interface ListOrdersQuery {
73
+ /** 1-based; default 1. */
74
+ page?: number;
75
+ /** 1..100; default 25. */
76
+ perPage?: number;
77
+ /** The platform's own order search. */
78
+ search?: string;
79
+ }
80
+
81
+ export interface StoreOrderPage { orders: StoreOrder[]; hasMore: boolean }
@@ -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
+ }