@tallyui/components 4.2.0 → 5.1.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 +120 -50
- package/dist/index.js +2216 -1717
- package/package.json +10 -9
- package/src/cart/cart-columns-form.tsx +1 -1
- package/src/cart/cart-line-strip.tsx +17 -4
- package/src/customer/customer-dropdown.tsx +6 -2
- package/src/customer/customer-editor.tsx +2 -2
- package/src/customer/customer-picker.tsx +15 -12
- package/src/i18n/locales/en/components.json +22 -2
- package/src/index.ts +2 -0
- package/src/layout/settings-layout.tsx +16 -4
- package/src/lib/motion.ts +6 -0
- package/src/order/index.ts +1 -0
- package/src/order/refund-form.tsx +16 -3
- package/src/order/refund-needs-admin-notice.tsx +29 -0
- package/src/register/register-count.tsx +1 -1
- package/src/reports/card-panel.tsx +3 -1
- package/src/reports/cards.tsx +1 -0
- package/src/sale/cancel-payment-view.tsx +102 -0
- package/src/sale/cart.tsx +17 -9
- package/src/sale/catalogue-settings-form.tsx +2 -2
- package/src/sale/catalogue.tsx +53 -9
- package/src/sale/customer-display-screen.tsx +2 -1
- package/src/sale/open-sale-tabs.tsx +23 -3
- package/src/sale/orders-list.tsx +167 -11
- package/src/sale/receipt.tsx +1 -0
- package/src/sale/sale-error-text.ts +10 -0
- package/src/sale/sync-status.tsx +6 -1
- package/src/sale/tender-ledger.tsx +47 -9
- package/src/sale/tender-pane.tsx +112 -40
- package/src/sale/tender.tsx +7 -5
- package/src/sale/void-in-flight.ts +19 -0
- package/src/ui/tabs/index.tsx +1 -1
- package/src/checkout/payment-types.test-d.ts +0 -28
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
import { useState, type JSX } from 'react';
|
|
7
7
|
import { Pressable, Text, View } from 'react-native';
|
|
8
8
|
import { useFormatMoney, wireMethodOf, type PaymentMethodDescriptor } from '@tallyui/core';
|
|
9
|
-
import { canVoidLeg, countsTowardPaid, legStatus, type PaymentLegStatus, type useSale } from '@tallyui/pos';
|
|
9
|
+
import { canVoidLeg, countsTowardPaid, legStatus, type Payment, type PaymentLegStatus, type useSale } from '@tallyui/pos';
|
|
10
|
+
import { cashVoidRefusal } from '@tallyui/pos';
|
|
10
11
|
import { cn } from '@tallyui/theme';
|
|
11
12
|
import { useT } from '../i18n';
|
|
12
13
|
import { ConfirmDialog } from '../ui/confirm-dialog';
|
|
13
14
|
import { heldTillLeg } from './held-leg';
|
|
14
15
|
import { offeredMethods } from './offered-methods';
|
|
15
16
|
import { shortTime } from './since-text';
|
|
17
|
+
import { claimVoid, releaseVoid } from './void-in-flight';
|
|
16
18
|
|
|
17
19
|
/** v2 labels.ts statusLabel, as catalogue keys. */
|
|
18
20
|
const STATUS_LABEL: Record<PaymentLegStatus, string> = {
|
|
@@ -24,13 +26,32 @@ const STATUS_TONE: Record<PaymentLegStatus, string> = {
|
|
|
24
26
|
pending: 'text-muted-foreground', authorized: 'text-success', captured: 'text-success', failed: 'text-destructive', voided: 'text-muted-foreground',
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
// One leg's line in v2's cancel-payment view (use-tender-flow.ts cancelOne): voidable cash not captured by the server goes back as
|
|
30
|
+
// `cashMinor` cash, any other voidable leg is voided on its method, and a leg the till cannot void is refunded from the order.
|
|
31
|
+
export function cancelLine(t: ReturnType<typeof useT>, money: (minor: number) => string, leg: ReturnType<typeof useSale>['order']['payments'][number],
|
|
32
|
+
descriptor: PaymentMethodDescriptor | undefined, voidable: boolean, cashMinor: number): string {
|
|
33
|
+
if (!voidable) return t('pos_checkout.refund_on_method', { amount: money(leg.amountMinor), title: descriptor?.title ?? leg.methodId ?? leg.method });
|
|
34
|
+
return descriptor?.kind === 'cash' && descriptor.capture.mode !== 'server'
|
|
35
|
+
? t('pos_checkout.return_cash', { amount: money(cashMinor) })
|
|
36
|
+
: t('pos_checkout.void_on_method', { amount: money(leg.amountMinor), title: descriptor?.title ?? leg.methodId ?? leg.method });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function TenderLedger({ sale, methods, closing = false, confirmVoid = false, beforeVoid, afterVoid }: { sale: ReturnType<typeof useSale>; methods?: PaymentMethodDescriptor[]; closing?: boolean;
|
|
28
40
|
/** v2's "Cancel this payment?" before a leg is voided (use-tender-flow.ts cancelOne). Default false: Cancel payment voids at once. */
|
|
29
|
-
confirmVoid?: boolean
|
|
41
|
+
confirmVoid?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Runs before Cancel payment voids the leg (a host journalling each void first, as v2's awaited cancelOnePayment); the
|
|
44
|
+
* void waits for it. Returning `false` or throwing keeps the leg (the host reports its own error). Absent, the void is immediate.
|
|
45
|
+
*/
|
|
46
|
+
beforeVoid?: (leg: Payment) => boolean | void | Promise<boolean | void>;
|
|
47
|
+
/** Runs after a void that beforeVoid approved, with voidTender's result: false means the leg was kept (voided, locked or finished elsewhere meanwhile), so the host reverses what beforeVoid journalled. Not called without beforeVoid, nor when beforeVoid refuses. */
|
|
48
|
+
afterVoid?: (leg: Payment, voided: boolean) => void }): JSX.Element | null {
|
|
30
49
|
const formatMoney = useFormatMoney();
|
|
31
50
|
const t = useT();
|
|
32
51
|
/** The id of the leg the one question is about (confirmVoid). */
|
|
33
52
|
const [asking, setAsking] = useState<string | null>(null);
|
|
53
|
+
/** The ids of the legs whose beforeVoid is in flight here: drives their disabled Cancel payment. The guard is the shared set in void-in-flight.ts. */
|
|
54
|
+
const [voiding, setVoiding] = useState<ReadonlySet<string>>(new Set());
|
|
34
55
|
const { order, stage } = sale;
|
|
35
56
|
if (stage.kind !== 'tender') return null;
|
|
36
57
|
|
|
@@ -46,16 +67,27 @@ export function TenderLedger({ sale, methods, closing = false, confirmVoid = fal
|
|
|
46
67
|
const firstPending = order.payments.find((leg) => legStatus(leg) === 'pending');
|
|
47
68
|
const askedLeg = order.payments.find((leg) => leg.id === asking);
|
|
48
69
|
const asked = askedLeg && descriptorOf(askedLeg);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
const question = askedLeg && asked ? cancelLine(t, money, askedLeg, asked, true, askedLeg.amountMinor) : undefined;
|
|
71
|
+
|
|
72
|
+
const cancel = async (leg: Payment) => {
|
|
73
|
+
if (cashVoidRefusal(order, leg.id)) { sale.voidTender(leg.id); return; } // ADR-094 item 6: the core refuses and sets the error; beforeVoid never journals a refused void
|
|
74
|
+
if (!beforeVoid) { sale.voidTender(leg.id); return; }
|
|
75
|
+
if (!claimVoid(order.id, leg.id)) return; // #1271: another view, or this ledger before a remount, is journalling this leg
|
|
76
|
+
setVoiding((ids) => new Set(ids).add(leg.id));
|
|
77
|
+
let go = false;
|
|
78
|
+
try { go = (await beforeVoid(leg)) !== false; } catch { /* the leg stays; the host reports its own error */ } finally { releaseVoid(order.id, leg.id); }
|
|
79
|
+
setVoiding((ids) => { const next = new Set(ids); next.delete(leg.id); return next; });
|
|
80
|
+
if (!go) return;
|
|
81
|
+
const voided = sale.voidTender(leg.id);
|
|
82
|
+
try { afterVoid?.(leg, voided); } catch { /* the host reports its own error */ }
|
|
83
|
+
};
|
|
53
84
|
|
|
54
85
|
const legs = <View testID="tender-ledger" className="gap-1">
|
|
55
86
|
{order.payments.length === 0 ? <Text className="text-muted-foreground">{t('pos_checkout.no_payments_yet')}</Text> : order.payments.map((leg) => {
|
|
56
87
|
const status = legStatus(leg);
|
|
57
88
|
const voided = status === 'voided';
|
|
58
89
|
const descriptor = descriptorOf(leg);
|
|
90
|
+
const inFlight = voiding.has(leg.id);
|
|
59
91
|
return <View key={leg.id} testID={`tender-leg-${leg.id}`} className="gap-1 border-b border-border py-2">
|
|
60
92
|
<View className="flex-row items-center gap-2">
|
|
61
93
|
<Text className={cn('flex-1 font-semibold text-foreground', voided && 'line-through')}>{descriptor?.title ?? leg.methodId ?? leg.method}</Text>
|
|
@@ -66,15 +98,21 @@ export function TenderLedger({ sale, methods, closing = false, confirmVoid = fal
|
|
|
66
98
|
{leg.takenAt ? <Text testID={`tender-leg-${leg.id}-time`} className="text-sm text-muted-foreground">{shortTime(leg.takenAt)}</Text> : null}
|
|
67
99
|
{leg === firstPending ? <Text className="text-sm text-muted-foreground">{t('pos_checkout.next_leg')}</Text> : null}
|
|
68
100
|
{descriptor && canVoidLeg(leg, descriptor) && !heldTillLeg(order, leg) ? <Pressable testID={`tender-leg-${leg.id}-void`} accessibilityRole="button" accessibilityLabel={t('pos_checkout.cancel_payment')}
|
|
69
|
-
|
|
101
|
+
disabled={inFlight} accessibilityState={{ disabled: inFlight }}
|
|
102
|
+
onPress={() => (confirmVoid ? setAsking(leg.id) : void cancel(leg))} className="self-start min-h-11 justify-center px-2">
|
|
70
103
|
<Text className="text-destructive">{t('pos_checkout.cancel_payment')}</Text>
|
|
71
104
|
</Pressable> : null}
|
|
72
105
|
</View>;
|
|
73
106
|
})}
|
|
107
|
+
{/* ADR-094: each live cash rounding, signed, under the legs. */}
|
|
108
|
+
{order.cashRoundings?.map((entry) => <View key={`rounding-${entry.paymentId}`} testID={`tender-rounding-${entry.paymentId}`} className="flex-row items-center gap-2 border-b border-border py-2">
|
|
109
|
+
<Text className="flex-1 text-muted-foreground">{t('pos_checkout.rounding')}</Text>
|
|
110
|
+
<Text className="text-foreground">{money(entry.minor)}</Text>
|
|
111
|
+
</View>)}
|
|
74
112
|
{!closing && balance === 0 && settled ? <Text className="text-sm text-success">{paidInFull}</Text> : null}
|
|
75
113
|
{confirmVoid ? <ConfirmDialog testID="tender-leg-void-dialog" tone="destructive" title={t('pos_checkout.cancel_payment_question')} description={question}
|
|
76
114
|
confirmLabel={t('pos_checkout.cancel_payment')} open={asking !== null} onOpenChange={(open) => { if (!open) setAsking(null); }}
|
|
77
|
-
onConfirm={() => { if (
|
|
115
|
+
onConfirm={() => { if (askedLeg) void cancel(askedLeg); }} /> : null}
|
|
78
116
|
</View>;
|
|
79
117
|
if (!closing) return legs;
|
|
80
118
|
|
package/src/sale/tender-pane.tsx
CHANGED
|
@@ -5,20 +5,22 @@
|
|
|
5
5
|
* comes from pos (useSale's captured-only totals, tenderRounding, quickTenderedAmounts, planLegs).
|
|
6
6
|
* The caption row and the hero figure follow tender-pane.tsx's caption row and AmountFigure (v2 :390-459).
|
|
7
7
|
*/
|
|
8
|
-
import { useEffect, useState, type JSX } from 'react';
|
|
8
|
+
import { useEffect, useState, type ComponentProps, type JSX } from 'react';
|
|
9
9
|
import { Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
|
10
10
|
import { useFormatMoney, minorUnitDigits, wireMethodOf, type PaymentMethodDescriptor } from '@tallyui/core';
|
|
11
11
|
import {
|
|
12
|
-
activePlan, changeMinor, countsTowardPaid, evenSplitShareMinor, inMotionMinor, isInMotion, legStatus, lockedRefundDueMinor, planLegs, quickTenderedAmounts, tenderRounding, tillLegsTheStoreRefuses,
|
|
12
|
+
activePlan, CASH_PICK_ENTRIES_MAX, changeMinor, countsTowardPaid, evenSplitShareMinor, inMotionMinor, isInMotion, legStatus, lockedRefundDueMinor, nearestPayableCash, planLegs, quickTenderedAmounts, remainderEntriesMinor, roundedPickTarget, tenderRounding, tillLegsTheStoreRefuses, writeOffLeg,
|
|
13
13
|
type TenderAction, type TenderKey, type TenderPlan, type TenderState, type useSale,
|
|
14
14
|
} from '@tallyui/pos';
|
|
15
15
|
import { cn } from '@tallyui/theme';
|
|
16
16
|
import { QUICK_CASH_STEPS } from '../checkout/cash-tendered';
|
|
17
17
|
import { useT } from '../i18n';
|
|
18
|
+
import { saleErrorText } from './sale-error-text';
|
|
18
19
|
import { DIGIT_ROWS, Keypad } from '../input/keypad';
|
|
19
20
|
import { offeredMethods, tenderOf } from './offered-methods';
|
|
20
21
|
import { heldTillLeg } from './held-leg';
|
|
21
|
-
import {
|
|
22
|
+
import { CancelPaymentView, cancelLegs, legDescriptor, voidableLeg } from './cancel-payment-view';
|
|
23
|
+
import { cancelLine, TenderLedger } from './tender-ledger';
|
|
22
24
|
import { pickFigure } from './use-tender';
|
|
23
25
|
import { BanknoteIcon } from '../ui/icon/banknote-icon';
|
|
24
26
|
import { CreditCardIcon } from '../ui/icon/credit-card-icon';
|
|
@@ -35,9 +37,13 @@ export interface TenderPaneProps {
|
|
|
35
37
|
methods?: PaymentMethodDescriptor[];
|
|
36
38
|
/** Draws the payments ledger in the pane. Pass `false` when the host shows it in the cart column, as v2 does (Cart's `tenderLedger`). Default `true`. */
|
|
37
39
|
ledger?: boolean;
|
|
38
|
-
/** Draws the Back button
|
|
40
|
+
/** Draws the Back button: `sale.cancelTender`, or the cancel-payment view first when money was taken here. Pass `false` when the host leaves the tender stage itself, as v2's phone checkout does. Default `true`. */ back?: boolean;
|
|
39
41
|
/** Passed to the ledger: v2's "Cancel this payment?" before a leg is voided. Default `false`: Cancel payment voids at once. */
|
|
40
42
|
confirmVoid?: boolean;
|
|
43
|
+
/** Passed to the ledger: runs before Cancel payment voids a leg; the void waits for it, and `false` or a throw keeps the leg. */
|
|
44
|
+
beforeVoid?: ComponentProps<typeof TenderLedger>['beforeVoid'];
|
|
45
|
+
/** Passed to the ledger: runs after a void `beforeVoid` approved, with whether the leg was voided; `false` means the host reverses its journal entry. */
|
|
46
|
+
afterVoid?: ComponentProps<typeof TenderLedger>['afterVoid'];
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
/** order.create's bound on `payments[].reference`, in UTF-16 units. */
|
|
@@ -59,17 +65,22 @@ const rowsSince = (payments: readonly Leg[], plan: TenderPlan | null) => {
|
|
|
59
65
|
.map((leg) => ({ title: leg.method, amountMinor: leg.amountMinor }));
|
|
60
66
|
};
|
|
61
67
|
|
|
62
|
-
export function TenderPane({ sale, state, dispatch, methods, ledger = true, back = true, confirmVoid }: TenderPaneProps): JSX.Element | null {
|
|
68
|
+
export function TenderPane({ sale, state, dispatch, methods, ledger = true, back = true, confirmVoid, beforeVoid, afterVoid }: TenderPaneProps): JSX.Element | null {
|
|
63
69
|
const formatMoney = useFormatMoney();
|
|
64
70
|
const { order, stage } = sale;
|
|
65
71
|
const t = useT();
|
|
66
72
|
const [reference, setReference] = useState('');
|
|
67
73
|
const [refusal, setRefusal] = useState(false);
|
|
74
|
+
const [cancelling, setCancelling] = useState(false);
|
|
68
75
|
const balance = order.balanceDueMinor;
|
|
76
|
+
// Leaving the tender stage ends the cancel-payment view (state adjusted while rendering, so it never outlives the stage).
|
|
77
|
+
if (stage.kind !== 'tender' && cancelling) setCancelling(false);
|
|
69
78
|
// The ledger changed (a leg taken or voided) and the entry is untouched: pre-type the next leg or plan share.
|
|
70
79
|
useEffect(() => {
|
|
71
80
|
if (!state.entryDirty) dispatch({ type: 'tender-recorded', rowsSinceFrom: rowsSince(order.payments, state.plan), balanceMinor: balance });
|
|
72
81
|
}, [order.payments, balance, state.entryDirty, state.plan, dispatch]);
|
|
82
|
+
const legsKey = order.payments.map((leg) => `${leg.id}:${legStatus(leg)}`).join(',');
|
|
83
|
+
useEffect(() => setRefusal(false), [legsKey]);
|
|
73
84
|
if (stage.kind !== 'tender') return null;
|
|
74
85
|
|
|
75
86
|
const offered = offeredMethods(methods);
|
|
@@ -81,14 +92,51 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
81
92
|
const pick = state.plan || Object.keys(state.pickedUnits).length === 0 ? null : pickFigure(order, state.pickedUnits);
|
|
82
93
|
const target = pick ? Math.min(pick.minor, balance - inMotionMinor(order.payments)) : balance;
|
|
83
94
|
const partPick = pick !== null && target < balance;
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
95
|
+
// ADR-094: the pane rounds exactly when addTender does: only on a store whose connector declares cashRounding, and only while no leg is in motion.
|
|
96
|
+
const rounds = sale.capabilities?.cashRounding === true && inMotionMinor(order.payments) === 0;
|
|
97
|
+
// ADR-094 item 7 (carry): a cash part pick rounds its target less the live entries; addTender rounds the leg, the pane shows the same figure.
|
|
98
|
+
const pickRounding = rounds && method !== null && wireMethodOf(method) === 'cash' && method.capture.mode === 'manual' && method.defaults.rounding ? method.defaults.rounding : null;
|
|
99
|
+
const entries = remainderEntriesMinor(order);
|
|
100
|
+
const pickTarget = partPick ? roundedPickTarget(target, pickRounding, entries) : target;
|
|
101
|
+
const entry = state.entryDirty ? state.entryMinor : pickTarget;
|
|
102
|
+
const figures = partPick ? tenderRounding({ entryMinor: entry, entryDirty: state.entryDirty }, pickTarget, null) : tenderRounding(state, balance, rounds ? method : null, entries);
|
|
103
|
+
// Promotion: a carried pick at the whole-settle due is taken as that settle (addTender), so it meets the settle's 16-entry cap.
|
|
104
|
+
const promoted = partPick && pickRounding !== null && pickTarget === tenderRounding(state, balance, method, entries).roundedDueMinor;
|
|
105
|
+
// "Rounded from": a pick's own goods when its amount differs from them; a settle's balance.
|
|
106
|
+
const roundedFrom = promoted ? (pickTarget !== balance ? balance : null) : partPick ? (pickTarget !== target ? target : null) : figures.roundingMinor !== 0 ? balance : null;
|
|
107
|
+
const cashNotPayable = rounds && pick === null && method !== null && wireMethodOf(method) === 'cash' && method.capture.mode === 'manual' && method.defaults.rounding
|
|
108
|
+
&& figures.roundingMinor === 0 && figures.appliedMinor < figures.roundedDueMinor
|
|
109
|
+
? nearestPayableCash(figures.entryMinor, method.defaults.rounding.incrementMinor) : null;
|
|
110
|
+
const cashWaits = sale.capabilities?.cashRounding === true && inMotionMinor(order.payments) > 0 && method !== null
|
|
111
|
+
&& wireMethodOf(method) === 'cash' && method.capture.mode === 'manual' && method.defaults.rounding && (partPick
|
|
112
|
+
? nearestPayableCash(target, method.defaults.rounding.incrementMinor) !== null
|
|
113
|
+
: figures.entryMinor > 0 && nearestPayableCash(Math.min(figures.entryMinor, balance - inMotionMinor(order.payments)), method.defaults.rounding.incrementMinor) !== null);
|
|
114
|
+
// order-payload-shape.ts's 16-entry cap: a pick that would add an entry is refused once the sale has CASH_PICK_ENTRIES_MAX.
|
|
115
|
+
const pickLimit = partPick && !promoted && pickTarget !== target && (order.cashRoundings ?? []).length >= CASH_PICK_ENTRIES_MAX;
|
|
116
|
+
const pickRefused = (partPick && entry > 0 && (givesChange ? entry < pickTarget : entry !== pickTarget))
|
|
87
117
|
|| (pick !== null && !partPick && figures.appliedMinor > 0 && figures.appliedMinor < figures.roundedDueMinor);
|
|
88
|
-
|
|
89
|
-
|
|
118
|
+
// Row 500: judged against the due less the legs in motion, as addTender records the leg's change.
|
|
119
|
+
// ADR-094: a cash due rounded to nothing still settles the sale (v2 tender-pane.tsx:1062), where the store's connector declares cashRounding.
|
|
120
|
+
const zeroDue = sale.capabilities?.cashRounding === true && !partPick && figures.roundedDueMinor === 0 && figures.roundingMinor !== 0
|
|
121
|
+
&& inMotionMinor(order.payments) === 0;
|
|
122
|
+
// The 16-entry cap as addTender applies it: a settle that adds an entry is refused at 16; a write-off onto a leg with one is not.
|
|
123
|
+
const lastCounted = writeOffLeg(order);
|
|
124
|
+
const settleLimit = ((!partPick && sale.capabilities?.cashRounding === true && figures.roundingMinor !== 0) || (promoted && pickTarget !== balance))
|
|
125
|
+
&& (order.cashRoundings ?? []).length > CASH_PICK_ENTRIES_MAX
|
|
126
|
+
&& !(zeroDue && lastCounted !== undefined && (order.cashRoundings ?? []).some((e) => e.paymentId === lastCounted.id));
|
|
127
|
+
// With no other method, a cash-only store frees an entry by voiding its latest rounded cash leg, which no later cash leg's entry blocks; offered methods are all manual capture.
|
|
128
|
+
const otherWay = offered.some((m) => !(wireMethodOf(m) === 'cash' && m.defaults.rounding));
|
|
129
|
+
const lastRounded = order.payments.filter(countsTowardPaid).filter((leg) => leg.method === 'cash' && (order.cashRoundings ?? []).some((e) => e.paymentId === leg.id)).at(-1);
|
|
130
|
+
const entryChange = zeroDue ? 0 : partPick ? changeMinor(figures.entryMinor, figures.appliedMinor, givesChange)
|
|
131
|
+
: changeMinor(figures.entryMinor, Math.min(figures.appliedMinor, Math.max(0, balance - inMotionMinor(order.payments)) + figures.roundingMinor), givesChange);
|
|
132
|
+
// What Take can still pay: pos caps a leg at the balance less the legs in motion (use-sale.ts addTender).
|
|
133
|
+
const dueNow = Math.max(0, balance - inMotionMinor(order.payments));
|
|
134
|
+
const left = dueNow + figures.roundingMinor - figures.appliedMinor;
|
|
90
135
|
const noChange = !partPick && method !== null && !givesChange && figures.entryMinor > balance;
|
|
91
|
-
|
|
136
|
+
// Take records only dueNow here (pos caps the leg), so the hint names it without blocking.
|
|
137
|
+
const capped = !partPick && method !== null && !givesChange && dueNow > 0 && figures.entryMinor > dueNow;
|
|
138
|
+
const cannotTake = (figures.appliedMinor <= 0 && !zeroDue) || (partPick && pickTarget === 0) || noChange || pickRefused || cashNotPayable !== null || cashWaits || pickLimit || settleLimit || (!partPick && balance - inMotionMinor(order.payments) <= 0);
|
|
139
|
+
const changeLeads = !cannotTake && entryChange > 0;
|
|
92
140
|
// v2 tender-pane.tsx:405-410: the caption names the balance only when it differs from the figure shown.
|
|
93
141
|
const balanceInCaption = balance === 0 || figures.entryMinor !== balance;
|
|
94
142
|
const rows = rowsSince(order.payments, state.plan).map(({ title, amountMinor }) => ({ title, minor: amountMinor }));
|
|
@@ -98,30 +146,41 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
98
146
|
const splitOn = state.splitView || plan !== null;
|
|
99
147
|
// v2 tender-figures.ts: a typed part payment comes first, and the ways divide what is left after it.
|
|
100
148
|
const typed = state.entryDirty && figures.appliedMinor > 0 && figures.appliedMinor < balance;
|
|
101
|
-
const restMinor = balance - (typed ? figures.appliedMinor : 0);
|
|
149
|
+
const restMinor = balance - (typed ? (partPick ? target : figures.appliedMinor) : 0);
|
|
102
150
|
const thisPaymentMinor = planned ? planned.thisPaymentMinor : balance;
|
|
103
|
-
const dueMinor = partPick ?
|
|
151
|
+
const dueMinor = partPick ? pickTarget : planned && planned.thisPaymentMinor < balance ? planned.thisPaymentMinor : figures.roundedDueMinor;
|
|
104
152
|
const chips = givesChange ? quickTenderedAmounts(dueMinor, QUICK_CASH_STEPS.map((step) => step * 10 ** minorUnitDigits(order.currency))) : [];
|
|
105
153
|
// v2 tender-pane.tsx:942-954: a method that gives no change gets one chip setting the entry to the due figure; hidden in percent entry, as v2 does.
|
|
106
154
|
const balanceChip = method !== null && !givesChange && state.entryMode !== 'percent' ? dueMinor : null;
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const hint =
|
|
112
|
-
:
|
|
155
|
+
const unstamped = order.payments.filter((leg) => leg.takenAt === undefined && !sale.tenderHeld(leg.id));
|
|
156
|
+
const [prefill] = unstamped;
|
|
157
|
+
// startTender('external')'s one unstamped card leg for the rest, beside any kept taken or voided legs: its reference is edited in place.
|
|
158
|
+
const cardReference = unstamped.length === 1 && prefill.method === 'external' && legStatus(prefill) === 'captured' && balance === 0;
|
|
159
|
+
const hint = cashNotPayable ? (cashNotPayable.belowMinor === 0 ? t('pos_checkout.cash_not_payable_above', { above: money(cashNotPayable.aboveMinor) })
|
|
160
|
+
: t('pos_checkout.cash_not_payable', { below: money(cashNotPayable.belowMinor), above: money(cashNotPayable.aboveMinor) }))
|
|
161
|
+
: cashWaits ? t('pos_checkout.cash_waits_for_payment')
|
|
162
|
+
: pickLimit ? t('pos_checkout.cash_pick_limit')
|
|
163
|
+
: settleLimit ? (otherWay ? t('pos_checkout.cash_settle_limit')
|
|
164
|
+
: lastRounded && voidableLeg(order, offered, lastRounded) ? t('pos_checkout.cash_settle_limit_void', { amount: money(lastRounded.amountMinor) })
|
|
165
|
+
: t('pos_checkout.cash_settle_limit_park', { amount: lastRounded ? money(lastRounded.amountMinor) : '' }))
|
|
166
|
+
: partPick ? (pickTarget === 0 ? t('pos_checkout.pick_rounds_to_nothing')
|
|
167
|
+
: pickRefused || entry === pickTarget ? t('pos_checkout.pick_amount_due', { amount: money(pickTarget) })
|
|
168
|
+
: givesChange && entry > pickTarget ? (cannotTake ? '' : t('pos_checkout.change_due', { amount: money(entry - pickTarget) })) : '')
|
|
113
169
|
: pickRefused ? t('pos_checkout.pick_amount_due', { amount: money(figures.roundedDueMinor) })
|
|
114
|
-
: noChange ? t('pos_checkout.no_change_for_method', { amount: money(
|
|
115
|
-
:
|
|
116
|
-
|
|
117
|
-
|
|
170
|
+
: capped || (noChange && dueNow === balance) ? t('pos_checkout.no_change_for_method', { amount: money(dueNow), method: method?.title })
|
|
171
|
+
: zeroDue ? ''
|
|
172
|
+
: entryChange > 0 ? (cannotTake ? '' : t('pos_checkout.change_due', { amount: money(entryChange) }))
|
|
173
|
+
: !cannotTake && figures.appliedMinor < dueNow && figures.entryMinor > 0 ? t('pos_checkout.part_payment_left', { left: money(left) }) : '';
|
|
174
|
+
// ADR-090 gate 36c: once the store's legs cover the total, finalize refuses every till leg; name them and offer their void.
|
|
118
175
|
const refused = tillLegsTheStoreRefuses(order);
|
|
119
|
-
const
|
|
176
|
+
const refusedLegs = order.payments.filter((leg) => refused.includes(leg.id));
|
|
177
|
+
const refusedMinor = refusedLegs.reduce((total, leg) => total + leg.amountMinor, 0);
|
|
178
|
+
// A refused leg the till cannot void (held, or refund-only) leaves the sale only able to park (ADR-072 d3, amended 2026-11-22).
|
|
179
|
+
const kept = refusedLegs.filter((leg) => !voidableLeg(order, offered, leg));
|
|
120
180
|
const canComplete = balance === 0 && !order.payments.some(isInMotion) && refused.length === 0;
|
|
121
181
|
// ADR-090 gate 36 (desk Q4): changeDueMinor counts locked legs; what they hold beyond the total is the store's refund due, never till change.
|
|
122
182
|
const refundDue = Math.min(order.changeDueMinor, lockedRefundDueMinor(order));
|
|
123
183
|
const tillChange = order.changeDueMinor - refundDue + order.payments.reduce((sum, leg) => sum + (!leg.locked && countsTowardPaid(leg) ? leg.changeMinor ?? 0 : 0), 0);
|
|
124
|
-
const cannotTake = figures.appliedMinor <= 0 || noChange || pickRefused;
|
|
125
184
|
|
|
126
185
|
function take() {
|
|
127
186
|
if (!method || pickRefused) return;
|
|
@@ -129,14 +188,20 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
129
188
|
// No pick stands (a plan is set, or nothing is picked): the leg carries no units. Otherwise it carries the picks that stand (pickFigure), never the raw ones.
|
|
130
189
|
const units = pick === null ? {} : { units: pick.picks };
|
|
131
190
|
const id = tender.method === 'cash'
|
|
132
|
-
? sale.addTender({ ...tender, ...units, amountMinor: partPick ? target : figures.entryMinor, ...(partPick ? { tenderedMinor: entry } : {}) })
|
|
191
|
+
? sale.addTender({ ...tender, ...units, amountMinor: partPick ? target : figures.entryMinor, ...(partPick ? { tenderedMinor: entry, ...(method.capture.mode === 'manual' && method.defaults.rounding ? { rounding: method.defaults.rounding } : {}) } : {}),
|
|
192
|
+
...(!partPick && method.capture.mode === 'manual' && method.defaults.rounding ? { rounding: method.defaults.rounding } : {}) })
|
|
133
193
|
: sale.addTender({ ...tender, ...units, amountMinor: partPick ? target : figures.appliedMinor, ...(reference ? { reference } : {}) });
|
|
134
194
|
if (id === null) { setRefusal(true); return; }
|
|
135
195
|
setRefusal(false);
|
|
136
196
|
setReference('');
|
|
137
|
-
|
|
197
|
+
// A zero-due settle returns the leg its entry went on, which already holds its own units.
|
|
198
|
+
dispatch({ type: 'tender-started', paymentId: id, units: pick === null || zeroDue ? {} : pick.picks });
|
|
138
199
|
}
|
|
139
200
|
|
|
201
|
+
if (cancelling) return <View dataSet={{ print: 'hide' }} testID="tender-pane" className="gap-4 p-4">
|
|
202
|
+
<CancelPaymentView sale={sale} methods={methods} beforeVoid={beforeVoid} afterVoid={afterVoid} onClose={() => setCancelling(false)} />
|
|
203
|
+
</View>;
|
|
204
|
+
|
|
140
205
|
return <View dataSet={{ print: 'hide' }} testID="tender-pane" className="gap-4 p-4">
|
|
141
206
|
<View testID="tender-headline" className="items-center gap-1">
|
|
142
207
|
<View className="flex-row flex-wrap items-center justify-center gap-2">
|
|
@@ -163,19 +228,19 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
163
228
|
{changeLeads ? <>
|
|
164
229
|
<Text testID="tender-entry-hint" className="text-4xl font-bold text-success">{hint}</Text>
|
|
165
230
|
<Text testID="tender-tendered-line" className="min-h-6 text-sm text-muted-foreground">{t('pos_checkout.tendered')} <Text testID="tender-entry-amount" className="font-semibold text-foreground">{money(figures.entryMinor)}</Text>{order.totalMinor !== balance ? ` · ${t('common.total')} ${money(order.totalMinor)}` : ''}</Text>
|
|
166
|
-
{
|
|
231
|
+
{roundedFrom !== null ? <Text className="text-sm text-muted-foreground">{t('pos_checkout.rounded_from', { amount: money(roundedFrom) })}</Text> : null}
|
|
167
232
|
</> : <>
|
|
168
233
|
<Text testID="tender-entry-amount" className={cn('text-4xl font-bold text-foreground', !state.entryDirty && 'opacity-70')}>{money(figures.entryMinor)}</Text>
|
|
169
|
-
{
|
|
170
|
-
<Text testID="tender-entry-hint" className={cn('min-h-6 text-center text-sm', noChange || pickRefused
|
|
234
|
+
{roundedFrom !== null ? <Text className="text-sm text-muted-foreground">{t('pos_checkout.rounded_from', { amount: money(roundedFrom) })}</Text> : null}
|
|
235
|
+
<Text testID="tender-entry-hint" className={cn('min-h-6 text-center text-sm', noChange || capped || pickRefused || cashWaits || pickLimit || settleLimit ? 'text-warning-text' : 'text-muted-foreground')}>{hint}</Text>
|
|
171
236
|
</>}
|
|
172
237
|
</View> : null}
|
|
173
238
|
|
|
174
|
-
{ledger ? <TenderLedger sale={sale} methods={methods} confirmVoid={confirmVoid} /> : null}
|
|
239
|
+
{ledger ? <TenderLedger sale={sale} methods={methods} confirmVoid={confirmVoid} beforeVoid={beforeVoid} afterVoid={afterVoid} /> : null}
|
|
175
240
|
|
|
176
241
|
{/* cardReference holds only for an external leg; the edit keeps that leg's method and its own methodId. */}
|
|
177
242
|
{cardReference ? <TextInput accessibilityLabel={t('tender.terminal_reference')} placeholder={t('tender.terminal_reference')} maxLength={REFERENCE_MAX}
|
|
178
|
-
value={
|
|
243
|
+
value={prefill.reference ?? ''} onChangeText={(text) => sale.setTender({ method: 'external', ...(prefill.methodId !== undefined ? { methodId: prefill.methodId } : {}), amountMinor: prefill.amountMinor, reference: text })}
|
|
179
244
|
className="rounded-md border border-border px-3 py-2 text-foreground" /> : null}
|
|
180
245
|
|
|
181
246
|
{balance > 0 ? <View testID="tender-entry" className="gap-3">
|
|
@@ -202,7 +267,7 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
202
267
|
))}
|
|
203
268
|
</View>
|
|
204
269
|
{planned ? <Text testID="tender-plan" className="text-sm text-muted-foreground">{t('pos_checkout.n_of_ways', { n: planned.label.n, ways: planned.label.ways })}</Text> : null}
|
|
205
|
-
{method
|
|
270
|
+
{method && wireMethodOf(method) === 'external' ? <TextInput accessibilityLabel={t('tender.terminal_reference')} placeholder={t('tender.terminal_reference')} maxLength={REFERENCE_MAX}
|
|
206
271
|
value={reference} onChangeText={setReference} className="rounded-md border border-border px-3 py-2 text-foreground" /> : null}
|
|
207
272
|
{state.splitView && !plan ? <>
|
|
208
273
|
<Text testID="tender-split-heading" className="text-center text-sm text-muted-foreground">
|
|
@@ -221,7 +286,11 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
221
286
|
</View>)}
|
|
222
287
|
</ScrollView>
|
|
223
288
|
</> : null}
|
|
224
|
-
{chips.length || balanceChip !== null ? <View testID="tender-quick" className="flex-row flex-wrap justify-center gap-2">
|
|
289
|
+
{chips.length || balanceChip !== null || cashNotPayable ? <View testID="tender-quick" className="flex-row flex-wrap justify-center gap-2">
|
|
290
|
+
{cashNotPayable ? [cashNotPayable.belowMinor, cashNotPayable.aboveMinor].filter((minor) => minor !== 0).map((minor) => <Pressable key={minor}
|
|
291
|
+
testID={minor === cashNotPayable.belowMinor ? 'tender-payable-below' : 'tender-payable-above'} accessibilityRole="button" onPress={() => dispatch({ type: 'set-entry', minor })} className={button}>
|
|
292
|
+
<Text className="font-semibold text-foreground">{money(minor)}</Text>
|
|
293
|
+
</Pressable>) : null}
|
|
225
294
|
{chips.map((minor, index) => <Pressable key={minor} testID={index === 0 ? 'tender-quick-exact' : `tender-quick-${minor}`} accessibilityRole="button"
|
|
226
295
|
onPress={() => dispatch({ type: 'set-entry', minor })} className={cn(button, state.entryDirty && figures.entryMinor === minor && 'border-primary')}>
|
|
227
296
|
<Text className="font-semibold text-foreground">{index === 0 ? t('pos_checkout.exact_amount', { amount: money(minor) }) : money(minor)}</Text>
|
|
@@ -241,22 +310,25 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
241
310
|
</View> : null}
|
|
242
311
|
|
|
243
312
|
{refused.length > 0 ? <>
|
|
244
|
-
<Text testID="tender-store-holds" className="text-foreground">{t('pos_checkout.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
313
|
+
<Text testID="tender-store-holds" className="text-foreground">{kept.length ? t('pos_checkout.store_holds_park', { amount: money(kept.reduce((total, leg) => total + leg.amountMinor, 0)) })
|
|
314
|
+
: t('pos_checkout.store_holds_payment', { amount: money(refusedMinor) })}</Text>
|
|
315
|
+
{refusedLegs.filter((leg) => !heldTillLeg(order, leg)).map((leg) => voidableLeg(order, offered, leg)
|
|
316
|
+
? <Pressable key={leg.id} testID={`tender-leg-${leg.id}-refused-void`} accessibilityRole="button" onPress={() => sale.voidTender(leg.id)} className={button}>
|
|
317
|
+
<Text className="text-center text-foreground">{t('pos_checkout.cancel_payment')}</Text>
|
|
318
|
+
</Pressable>
|
|
319
|
+
: <Text key={leg.id} testID={`tender-leg-${leg.id}-refused-refund`} className="text-foreground">{cancelLine(t, money, leg, legDescriptor(offered, leg), false, leg.amountMinor)}</Text>)}
|
|
248
320
|
</> : null}
|
|
249
321
|
<Pressable testID="tender-complete" accessibilityRole="button" disabled={!canComplete} onPress={sale.complete}
|
|
250
322
|
className={cn('rounded-md bg-primary px-4 py-3', !canComplete && 'opacity-50')}>
|
|
251
323
|
<Text className="text-center font-semibold text-primary-foreground">{t('tender.complete_sale')}</Text>
|
|
252
324
|
</Pressable>
|
|
253
|
-
{sale.error ? <Text accessibilityRole="alert" className="text-destructive">{sale.error}</Text> : null}
|
|
325
|
+
{sale.error ? <Text accessibilityRole="alert" className="text-destructive">{saleErrorText(t, sale.error)}</Text> : null}
|
|
254
326
|
{sale.canContinue ? <>
|
|
255
327
|
<Text className="text-foreground">{t('tender.stored_will_send')}</Text>
|
|
256
328
|
<Pressable accessibilityRole="button" onPress={() => sale.continueSale()} className="rounded-md bg-primary px-4 py-3">
|
|
257
329
|
<Text className="text-center font-semibold text-primary-foreground">{t('tender.continue')}</Text>
|
|
258
330
|
</Pressable>
|
|
259
331
|
</> : null}
|
|
260
|
-
{back ? <Pressable accessibilityRole="button" onPress={sale.cancelTender} className={button}><Text className="text-center text-foreground">{t('common.back')}</Text></Pressable> : null}
|
|
332
|
+
{back ? <Pressable accessibilityRole="button" onPress={() => (cancelLegs(order).length ? setCancelling(true) : sale.cancelTender())} className={button}><Text className="text-center text-foreground">{t('common.back')}</Text></Pressable> : null}
|
|
261
333
|
</View>;
|
|
262
334
|
}
|
package/src/sale/tender.tsx
CHANGED
|
@@ -2,22 +2,24 @@ import { useReducer, type JSX } from 'react';
|
|
|
2
2
|
import { type PaymentMethodDescriptor } from '@tallyui/core';
|
|
3
3
|
import { initTenderState, tenderReducer, type useSale } from '@tallyui/pos';
|
|
4
4
|
import { openingMethodId, type useTender } from './use-tender';
|
|
5
|
-
import { TenderPane } from './tender-pane';
|
|
5
|
+
import { TenderPane, type TenderPaneProps } from './tender-pane';
|
|
6
6
|
|
|
7
7
|
type Sale = ReturnType<typeof useSale>;
|
|
8
8
|
|
|
9
|
-
function HostedPane({ sale, method, methods, ledger, back, confirmVoid, tender }: TenderProps & { method: string }) {
|
|
9
|
+
function HostedPane({ sale, method, methods, ledger, back, confirmVoid, beforeVoid, afterVoid, tender }: TenderProps & { method: string }) {
|
|
10
10
|
const [state, dispatch] = useReducer(tenderReducer, { methodId: openingMethodId(method, methods), balanceMinor: sale.order.balanceDueMinor, payments: sale.order.payments }, initTenderState);
|
|
11
|
-
return <TenderPane sale={sale} state={tender ? tender.state : state} dispatch={tender ? tender.dispatch : dispatch} methods={methods} ledger={ledger} back={back} confirmVoid={confirmVoid} />;
|
|
11
|
+
return <TenderPane sale={sale} state={tender ? tender.state : state} dispatch={tender ? tender.dispatch : dispatch} methods={methods} ledger={ledger} back={back} confirmVoid={confirmVoid} beforeVoid={beforeVoid} afterVoid={afterVoid} />;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
type TenderProps = { sale: Sale; methods?: PaymentMethodDescriptor[]; /** Passed to TenderPane: `false` leaves the ledger to Cart's `tenderLedger`. Default `true`. */ ledger?: boolean; /** Passed to TenderPane: `false` hides Back (v2's phone checkout). Default `true`. */ back?: boolean;
|
|
15
15
|
/** Passed to TenderPane's ledger: v2's "Cancel this payment?" before a leg is voided. Default `false`. */ confirmVoid?: boolean;
|
|
16
|
+
/** Passed to TenderPane's ledger and its cancel-payment view: runs before either voids a leg; the void waits for it. */ beforeVoid?: TenderPaneProps['beforeVoid'];
|
|
17
|
+
/** Passed to TenderPane's ledger and its cancel-payment view: runs after either voids a leg `beforeVoid` approved, with whether it was voided. */ afterVoid?: TenderPaneProps['afterVoid'];
|
|
16
18
|
/** One reducer shared with Cart's `picker` (useTender). Without it, Tender keeps its own reducer, as before. */ tender?: ReturnType<typeof useTender> };
|
|
17
19
|
|
|
18
20
|
/** The tender pane with its own reducer, opened on the method `startTender` chose. Renders nothing outside the tender stage. */
|
|
19
|
-
export function Tender({ sale, methods, ledger, back, confirmVoid, tender }: TenderProps): JSX.Element | null {
|
|
20
|
-
return sale.stage.kind === 'tender' ? <HostedPane sale={sale} method={sale.stage.method} methods={methods} ledger={ledger} back={back} confirmVoid={confirmVoid} tender={tender} /> : null;
|
|
21
|
+
export function Tender({ sale, methods, ledger, back, confirmVoid, beforeVoid, afterVoid, tender }: TenderProps): JSX.Element | null {
|
|
22
|
+
return sale.stage.kind === 'tender' ? <HostedPane sale={sale} method={sale.stage.method} methods={methods} ledger={ledger} back={back} confirmVoid={confirmVoid} beforeVoid={beforeVoid} afterVoid={afterVoid} tender={tender} /> : null;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/** @deprecated Use Tender: the pane now handles split payments. */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The legs whose beforeVoid is in flight, shared by every TenderLedger and CancelPaymentView (#1271): a second mounted
|
|
3
|
+
* view, or a ledger remounted while the hook awaits, cannot run the hook again for the same leg. Keyed by order and leg.
|
|
4
|
+
*/
|
|
5
|
+
const inFlight = new Set<string>();
|
|
6
|
+
const keyOf = (orderId: string, legId: string) => `${orderId}\u0000${legId}`;
|
|
7
|
+
|
|
8
|
+
/** Holds the leg for one beforeVoid; false when another view already holds it. */
|
|
9
|
+
export function claimVoid(orderId: string, legId: string): boolean {
|
|
10
|
+
const key = keyOf(orderId, legId);
|
|
11
|
+
if (inFlight.has(key)) return false;
|
|
12
|
+
inFlight.add(key);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Lets the leg go once its beforeVoid has settled. */
|
|
17
|
+
export function releaseVoid(orderId: string, legId: string): void {
|
|
18
|
+
inFlight.delete(keyOf(orderId, legId));
|
|
19
|
+
}
|
package/src/ui/tabs/index.tsx
CHANGED
|
@@ -8,7 +8,7 @@ const Tabs = TabsPrimitive.Root;
|
|
|
8
8
|
function TabsList({ className, ...props }: React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>) {
|
|
9
9
|
return (
|
|
10
10
|
<TabsPrimitive.List
|
|
11
|
-
className={cn('inline-flex h-10 items-center justify-center rounded-md bg-muted p-1', className)}
|
|
11
|
+
className={cn('inline-flex flex-row h-10 items-center justify-center rounded-md bg-muted p-1', className)}
|
|
12
12
|
{...props}
|
|
13
13
|
/>
|
|
14
14
|
);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, expectTypeOf, it } from 'vitest';
|
|
2
|
-
import type { PaymentKind } from '@tallyui/core';
|
|
3
|
-
import type {
|
|
4
|
-
OrderFilterBarProps,
|
|
5
|
-
PaymentMethod,
|
|
6
|
-
PaymentMethodKind,
|
|
7
|
-
PaymentSelectorMethod,
|
|
8
|
-
PaymentSelectorProps,
|
|
9
|
-
} from '../index';
|
|
10
|
-
|
|
11
|
-
describe('component payment types', () => {
|
|
12
|
-
it('keeps PaymentMethodKind as an alias of core PaymentKind', () => {
|
|
13
|
-
expectTypeOf<PaymentMethodKind>().toEqualTypeOf<PaymentKind>();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('keeps PaymentMethod as an alias of PaymentSelectorMethod', () => {
|
|
17
|
-
expectTypeOf<PaymentMethod>().toEqualTypeOf<PaymentSelectorMethod>();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('uses PaymentSelectorMethod for selector methods', () => {
|
|
21
|
-
expectTypeOf<PaymentSelectorProps['methods']>().toEqualTypeOf<PaymentSelectorMethod[]>();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('uses core PaymentKind for optional filter kinds', () => {
|
|
25
|
-
type PaymentOption = NonNullable<NonNullable<OrderFilterBarProps['options']>['paymentMethod']>[number];
|
|
26
|
-
expectTypeOf<PaymentOption['kind']>().toEqualTypeOf<PaymentKind | undefined>();
|
|
27
|
-
});
|
|
28
|
-
});
|