@tallyui/components 3.20.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/index.d.ts +1114 -90
  2. package/dist/index.js +8077 -3352
  3. package/package.json +10 -11
  4. package/src/cart/cart-charge-line.tsx +58 -0
  5. package/src/cart/cart-columns-form.tsx +98 -0
  6. package/src/cart/cart-columns.tsx +49 -18
  7. package/src/cart/cart-foot.tsx +7 -2
  8. package/src/cart/cart-line-strip.tsx +59 -0
  9. package/src/cart/cart-line.tsx +20 -8
  10. package/src/cart/cart-note-row.tsx +30 -0
  11. package/src/cart/cart-panel.tsx +9 -1
  12. package/src/cart/cart-row-motion.tsx +125 -0
  13. package/src/cart/cart-total.tsx +44 -15
  14. package/src/cart/index.ts +2 -1
  15. package/src/checkout/cash-tendered.tsx +8 -7
  16. package/src/checkout/change-display.tsx +2 -1
  17. package/src/checkout/index.ts +1 -1
  18. package/src/checkout/payment-selector.tsx +6 -2
  19. package/src/checkout/payment-types.test-d.ts +28 -0
  20. package/src/customer/address-editor.tsx +87 -0
  21. package/src/customer/address-fields.tsx +120 -0
  22. package/src/customer/customer-dropdown.tsx +200 -0
  23. package/src/customer/customer-editor.tsx +99 -0
  24. package/src/customer/customer-form.tsx +39 -5
  25. package/src/customer/customer-picker.tsx +38 -14
  26. package/src/customer/customers-list.tsx +83 -0
  27. package/src/customer/index.ts +5 -0
  28. package/src/filter/filter-pills.tsx +63 -0
  29. package/src/i18n/locales/en/components.json +85 -0
  30. package/src/index.ts +40 -2
  31. package/src/input/decimal-entry.ts +21 -0
  32. package/src/layout/checkout-layout.tsx +1 -1
  33. package/src/layout/live-tab-screen.tsx +1 -1
  34. package/src/layout/pos-layout.tsx +80 -4
  35. package/src/layout/settings-layout.tsx +1 -1
  36. package/src/layout/store-settings-choice-screen.tsx +1 -1
  37. package/src/lib/current-row.ts +13 -0
  38. package/src/lib/money-input.ts +16 -0
  39. package/src/lib/motion.ts +22 -0
  40. package/src/lib/use-reduced-motion.ts +20 -0
  41. package/src/order/index.ts +1 -1
  42. package/src/order/order-detail.tsx +123 -5
  43. package/src/order/order-filter-bar.tsx +7 -57
  44. package/src/order/order-status-badge.tsx +42 -19
  45. package/src/order/refund-form.tsx +7 -5
  46. package/src/product/camera-scan-button.tsx +2 -0
  47. package/src/product/category-nav.tsx +8 -0
  48. package/src/product/category-tile.tsx +65 -15
  49. package/src/product/in-cart-badge.tsx +55 -6
  50. package/src/product/index.ts +1 -0
  51. package/src/product/press-veil.tsx +7 -0
  52. package/src/product/product-card.tsx +5 -1
  53. package/src/product/product-grid.tsx +5 -0
  54. package/src/product/product-price.tsx +6 -3
  55. package/src/product/product-stock-badge.tsx +3 -2
  56. package/src/product/product-table.tsx +96 -8
  57. package/src/product/products-screen-columns.tsx +74 -0
  58. package/src/product/variant-tile.tsx +68 -0
  59. package/src/product/variation-picker.tsx +3 -3
  60. package/src/product/view-toggle.tsx +33 -4
  61. package/src/register/cashier-sheet.tsx +195 -0
  62. package/src/register/closure-sheet.tsx +54 -3
  63. package/src/register/handover-slip.tsx +2 -1
  64. package/src/register/index.ts +2 -1
  65. package/src/register/movement-sheet.tsx +66 -7
  66. package/src/register/open-register-card.tsx +11 -11
  67. package/src/register/register-bar.helpers.ts +17 -4
  68. package/src/register/register-bar.tsx +26 -5
  69. package/src/register/register-count.tsx +158 -24
  70. package/src/register/register-panel.tsx +16 -5
  71. package/src/register/register-side-sheet.tsx +32 -8
  72. package/src/register/switch-confirm.tsx +2 -2
  73. package/src/reports/card-panel.tsx +131 -0
  74. package/src/reports/cards.tsx +53 -36
  75. package/src/reports/hero.tsx +2 -1
  76. package/src/reports/index.ts +1 -0
  77. package/src/reports/sales-room.tsx +4 -2
  78. package/src/sale/breadcrumb.tsx +48 -0
  79. package/src/sale/cart-bar.tsx +2 -1
  80. package/src/sale/cart.tsx +127 -38
  81. package/src/sale/catalogue-settings-form.tsx +92 -0
  82. package/src/sale/catalogue.tsx +304 -42
  83. package/src/sale/category-browse.tsx +27 -0
  84. package/src/sale/charge-form.tsx +85 -21
  85. package/src/sale/customer-display-screen.tsx +22 -6
  86. package/src/sale/discount-form.tsx +132 -28
  87. package/src/sale/index.ts +6 -3
  88. package/src/sale/line-popover.tsx +72 -36
  89. package/src/sale/offered-methods.ts +16 -0
  90. package/src/sale/open-sale-tabs.tsx +58 -10
  91. package/src/sale/order-note-sheet.tsx +37 -0
  92. package/src/sale/order-reference.ts +3 -0
  93. package/src/sale/orders-list.tsx +76 -37
  94. package/src/sale/parked-sales.tsx +2 -1
  95. package/src/sale/price-form.tsx +7 -5
  96. package/src/sale/product-filter-bar.tsx +38 -5
  97. package/src/sale/receipt-sheet.tsx +243 -0
  98. package/src/sale/receipt.tsx +19 -9
  99. package/src/sale/sync-status.tsx +10 -0
  100. package/src/sale/tender-ledger.tsx +92 -0
  101. package/src/sale/tender-pane.tsx +159 -73
  102. package/src/sale/tender.tsx +10 -7
  103. package/src/sale/use-tender.ts +63 -0
  104. package/src/scale/min-target.tsx +36 -0
  105. package/src/settings/barcode-scanning-settings.tsx +164 -0
  106. package/src/settings/connector-status.tsx +1 -1
  107. package/src/settings/customer-display-settings.tsx +12 -25
  108. package/src/settings/index.ts +5 -0
  109. package/src/settings/printer-form.tsx +161 -0
  110. package/src/settings/printing-settings.tsx +268 -0
  111. package/src/settings/settings-group.tsx +2 -1
  112. package/src/settings/tax-calculation-settings.tsx +1 -1
  113. package/src/shell/added-to-cart-toast.tsx +61 -0
  114. package/src/shell/app-shell.tsx +5 -1
  115. package/src/shell/connectivity-toast.tsx +70 -0
  116. package/src/shell/index.ts +2 -0
  117. package/src/shell/nav-drawer.tsx +5 -2
  118. package/src/shell/nav-item.tsx +7 -4
  119. package/src/shell/nav-rail.tsx +9 -2
  120. package/src/ui/accordion/index.tsx +86 -8
  121. package/src/ui/alert-dialog/index.tsx +19 -5
  122. package/src/ui/combobox/index.tsx +21 -2
  123. package/src/ui/confirm-dialog/index.tsx +53 -0
  124. package/src/ui/dialog/index.tsx +68 -14
  125. package/src/ui/dialog/motion.ts +54 -0
  126. package/src/ui/icon/activity-heartbeat-icon.tsx +7 -0
  127. package/src/ui/icon/alert-circle-icon.tsx +5 -0
  128. package/src/ui/icon/alert-triangle-icon.tsx +7 -0
  129. package/src/ui/icon/banknote-icon.tsx +11 -0
  130. package/src/ui/icon/cash-register-icon.tsx +10 -0
  131. package/src/ui/icon/category-icon.tsx +7 -0
  132. package/src/ui/icon/chart-line-icon.tsx +5 -0
  133. package/src/ui/icon/check-icon.tsx +5 -0
  134. package/src/ui/icon/chevron-left-icon.tsx +4 -0
  135. package/src/ui/icon/chevron-right-icon.tsx +4 -0
  136. package/src/ui/icon/credit-card-icon.tsx +10 -0
  137. package/src/ui/icon/discount-icon.tsx +11 -0
  138. package/src/ui/icon/gift-icon.tsx +10 -0
  139. package/src/ui/icon/info-circle-icon.tsx +10 -0
  140. package/src/ui/icon/map-pin-icon.tsx +10 -0
  141. package/src/ui/icon/message-question-icon.tsx +7 -0
  142. package/src/ui/icon/pencil-icon.tsx +10 -0
  143. package/src/ui/icon/plus-icon.tsx +9 -0
  144. package/src/ui/icon/printer-icon.tsx +10 -0
  145. package/src/ui/icon/receipt-icon.tsx +7 -0
  146. package/src/ui/icon/settings-icon.tsx +10 -0
  147. package/src/ui/icon/sticky-note-icon.tsx +10 -0
  148. package/src/ui/icon/user-icon.tsx +4 -0
  149. package/src/ui/icon/users-icon.tsx +7 -0
  150. package/src/ui/icon/view-grid-icon.tsx +7 -0
  151. package/src/ui/icon/view-list-icon.tsx +7 -0
  152. package/src/ui/index.ts +24 -1
  153. package/src/ui/list-row/index.tsx +93 -0
  154. package/src/ui/notice/index.tsx +65 -0
  155. package/src/ui/select/index.tsx +2 -0
  156. package/src/ui/skeleton/index.tsx +37 -0
  157. package/src/ui/status-badge/index.tsx +43 -0
  158. package/src/ui/switch/index.tsx +1 -1
  159. package/src/ui/tabs/index.tsx +11 -2
  160. package/src/ui/toggle-group/index.tsx +3 -1
  161. package/src/ui/tone-disc/index.tsx +41 -0
@@ -0,0 +1,195 @@
1
+ import { Pressable, View } from 'react-native';
2
+ import { useFormatMoney } from '@tallyui/core';
3
+
4
+ import { PressVeil } from '../product/press-veil';
5
+ import { Avatar, avatarInitials } from '../ui/avatar';
6
+ import { Button } from '../ui/button';
7
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '../ui/dialog';
8
+ import { ChevronRightIcon } from '../ui/icon/chevron-right-icon';
9
+ import { Text } from '../ui/text';
10
+ import { ToneDisc } from '../ui/tone-disc';
11
+ import { RegisterIcon } from './register-side-sheet';
12
+ import { countLine } from './switch-confirm';
13
+
14
+ export type CashierSheetDrawer = {
15
+ /** The door was pressed: the app opens its register panel. */ onOpen: () => void;
16
+ /** v2's `busy` (a payment in progress, a busy switch): the door cannot be pressed. */ disabled?: boolean;
17
+ } & (
18
+ | { state: 'closed'; /** The last closure's number, the store's own when acknowledged. Default "—". */ lastClosure?: string | number }
19
+ | {
20
+ state: 'open' | 'counting';
21
+ /** Expected cash in integer minor units, a blind count's number of sales, or pending figures. */
22
+ figure: { kind: 'cash'; amountMinor: number; currency: string } | { kind: 'blind'; salesCount: number } | { kind: 'pending' };
23
+ /** The open time, already formatted ("HH:mm" in the store's zone). */
24
+ openedAt: string;
25
+ opener: { name: string; avatar?: string };
26
+ /** Only when there is more than one register (v2 :182-185). */ registerName?: string;
27
+ /** state "counting" only: when the count began, already formatted. Default "—". */ countingSince?: string;
28
+ }
29
+ );
30
+
31
+ export interface CashierSheetCashier {
32
+ id: string; name: string; avatar?: string;
33
+ /** This cashier's open carts on this register; the line is hidden at 0 or undefined. */ openCarts?: number;
34
+ }
35
+ export interface CashierSheetHandTo {
36
+ /** The other cashiers (the app leaves out the one signed in, as v2's UserRows does). */ cashiers: CashierSheetCashier[];
37
+ /** A row was pressed: the app shows its `SwitchConfirm kind="cashier"`. The sheet stays open. */ onHandTo: (id: string) => void;
38
+ /** v2's `busy` (a busy switch): every row is disabled. */ disabled?: boolean;
39
+ /** v2's `countingHere`: a count is open on this register; rows are disabled and the header says why. */ counting?: boolean;
40
+ }
41
+ export interface CashierSheetPlace {
42
+ /** The current store's or register's name. */ name: string;
43
+ /** "Switch" was pressed: the app opens its own picker (`RegisterPicker` for registers). Absent hides the verb (v2 shows it with two or more). */ onSwitch?: () => void;
44
+ /** Why Switch is held (v2: "Needs the store to switch" offline; the open-sale reason for registers). Drawn under the row unless `paying`, and disables Switch. */ heldReason?: string;
45
+ /** v2's `busy`: Switch is disabled, with no line. */ disabled?: boolean;
46
+ }
47
+
48
+ export interface CashierSheetProps {
49
+ cashier: { name: string; avatar?: string };
50
+ /** The header line, already joined: store · register (when there are several) · "since HH:mm". Hidden when absent. */
51
+ description?: string;
52
+ /** "Your sales today", in integer minor units. Hidden when absent. */
53
+ salesToday?: { amountMinor: number; currency: string };
54
+ /** Sign out pressed. The sheet stays open; the app decides, after its `SwitchConfirm`. */
55
+ onSignOut: () => void;
56
+ /** v2's holds (a payment in progress, a busy switch): Sign out is disabled. */
57
+ signOutDisabled?: boolean;
58
+ onOpenChange: (open: boolean) => void;
59
+ /** v2's drawer door under "Your sales today": the app's figures; pressing it opens the app's register panel. Hidden when absent. */
60
+ drawer?: CashierSheetDrawer;
61
+ /** v2's "Hand the till to": the other cashiers; pressing a row calls `onHandTo(id)`. Hidden when absent or empty. */ handTo?: CashierSheetHandTo;
62
+ /** v2's `paying` hold: shows "Finish the payment first" and disables the hand-to rows (Sign out keeps `signOutDisabled`). */ paying?: boolean;
63
+ /** The sales the store has still to hear; the notice is hidden at 0 or undefined. */ awaitingStore?: number;
64
+ /** v2's Store row; hidden when absent. */ store?: CashierSheetPlace;
65
+ /** v2's Register row; hidden when absent. The app passes it only when bound with two or more registers, as v2 does. */ register?: CashierSheetPlace;
66
+ }
67
+
68
+ /**
69
+ * The cashier's sheet on the right edge: the header, "Your sales today", the drawer door, the awaiting-store and payment hold
70
+ * notices, "Hand the till to", the Store and Register rows and Sign out (v2 parity S9a-S9d). The app
71
+ * mounts it while open, as `SwitchConfirm` and `MovementSheet` are mounted. Port provenance: WCPOS v2 monorepo
72
+ * `main` ec022c989 `packages/core/src/screens/main/pos/cart/user-sheet.tsx` (:632 the container, :654-676 the
73
+ * header, :680-687 the sales row, :688-691 the drawer door from :120-165 and :180-229, :693-723 the notices and "Hand the
74
+ * till to" from :231-289, :724-753 the Store and Register rows with `StoreRow` from :436-475, :800-821 Sign out), with its English copy (`core.json` `register.*`). Literal
75
+ * English, as the other register components carry it. Not here: v2's in-sheet store and register panes (the app opens its own picker) and the Woo footer.
76
+ */
77
+ export function CashierSheet({ cashier, description, salesToday, onSignOut, signOutDisabled = false, onOpenChange, drawer, handTo, paying = false, awaitingStore = 0, store, register }: CashierSheetProps) {
78
+ const formatMoney = useFormatMoney();
79
+ return (
80
+ <Dialog open onOpenChange={onOpenChange}>
81
+ <DialogContent side="right" testID="cashier-sheet" className="flex-col">
82
+ <DialogHeader className="flex-row items-center gap-3">
83
+ <Avatar size="lg" src={cashier.avatar} alt={cashier.name} fallback={avatarInitials(cashier.name)} />
84
+ <View className="min-w-0 flex-1 gap-1">
85
+ <DialogTitle numberOfLines={1}>{cashier.name}</DialogTitle>
86
+ {!!description && <DialogDescription testID="cashier-sheet-description">{description}</DialogDescription>}
87
+ </View>
88
+ </DialogHeader>
89
+ <View className="flex-1">
90
+ {salesToday && (
91
+ <View testID="cashier-sheet-sales-today" className="flex-row items-center justify-between px-3 py-2.5">
92
+ <Text className="font-medium">Your sales today</Text>
93
+ <Text className="text-xl font-semibold tabular-nums">
94
+ {formatMoney({ amount: salesToday.amountMinor, currency: salesToday.currency })}
95
+ </Text>
96
+ </View>
97
+ )}
98
+ {drawer && <DrawerDoor drawer={drawer} />}
99
+ {awaitingStore > 0 && <View testID="cashier-sheet-awaiting-store" className="bg-warning/10 mx-3 mt-2 gap-1 rounded-md p-3">
100
+ <Text className="font-semibold">{`Awaiting store · ${countLine(awaitingStore, 'sale', 'sales')}`}</Text>
101
+ <Text className="text-sm text-muted-foreground">Sent when you are signed in online.</Text>
102
+ </View>}
103
+ {paying && <View testID="cashier-sheet-hold" className="bg-info/10 mx-3 mt-2 rounded-md p-3"><Text className="font-semibold">Finish the payment first</Text></View>}
104
+ {handTo && handTo.cashiers.length > 0 && <HandTo handTo={handTo} paying={paying} />}
105
+ {(store || register) && <View testID="cashier-sheet-places" className="mt-2">
106
+ {store && <PlaceRow id="store" label="Store" place={store} paying={paying} />}
107
+ {register && <PlaceRow id="register" label="Register" place={register} paying={paying} />}
108
+ </View>}
109
+ </View>
110
+ <DialogFooter bordered>
111
+ <Button variant="destructive" testID="cashier-sheet-sign-out" disabled={signOutDisabled} onPress={onSignOut}>
112
+ <Text>Sign out</Text>
113
+ </Button>
114
+ </DialogFooter>
115
+ </DialogContent>
116
+ </Dialog>
117
+ );
118
+ }
119
+
120
+ /** v2's `PropertyRow` key · value · verb line (property-row/index.tsx) for the Store and Register rows (user-sheet.tsx:436-475, :724-753). */
121
+ function PlaceRow({ id, label, place, paying }: { id: 'store' | 'register'; label: string; place: CashierSheetPlace; paying: boolean }) {
122
+ return (
123
+ <View testID={`cashier-sheet-${id}`} className="px-3 py-2">
124
+ <View className="min-h-11 flex-row items-center gap-3">
125
+ <Text className="w-32 shrink-0 text-sm text-muted-foreground">{label}</Text>
126
+ <Text className="min-w-0 flex-1" numberOfLines={1}>{place.name}</Text>
127
+ {place.onSwitch && <Button variant="link" size="sm" testID={`cashier-sheet-${id}-switch`} disabled={!!place.disabled || paying || !!place.heldReason} onPress={place.onSwitch}>
128
+ <Text>Switch</Text>
129
+ </Button>}
130
+ </View>
131
+ {!!place.heldReason && !paying && <Text testID={`cashier-sheet-${id}-held`} className="text-sm text-muted-foreground">{place.heldReason}</Text>}
132
+ </View>
133
+ );
134
+ }
135
+
136
+ /** v2's "Hand the till to" (user-sheet.tsx:701-723) with `UserRows` and `CashierRow` (:246-322), from the app's list. */
137
+ function HandTo({ handTo, paying }: { handTo: CashierSheetHandTo; paying: boolean }) {
138
+ const disabled = !!handTo.disabled || paying || !!handTo.counting;
139
+ return (
140
+ <View testID="cashier-sheet-hand-to">
141
+ <View className="mt-2 flex-row items-center justify-between border-b border-border px-3 py-2">
142
+ <Text className="text-sm text-muted-foreground">Hand the till to</Text>
143
+ {handTo.counting && !paying && <Text testID="cashier-sheet-count-hold" className="text-sm font-medium">Finish or abandon the count first</Text>}
144
+ </View>
145
+ {handTo.cashiers.map(({ id, name, avatar, openCarts = 0 }) => (
146
+ <Pressable key={id} testID={`cashier-sheet-hand-to-${id}`} accessibilityRole="button" disabled={disabled} onPress={() => handTo.onHandTo(id)} className="flex-row items-center gap-3 px-3 py-2.5">
147
+ {({ pressed }) => <>
148
+ <Avatar size="md" src={avatar} alt={name} fallback={avatarInitials(name)} />
149
+ <View className="min-w-0 flex-1">
150
+ <Text className="font-medium" numberOfLines={1}>{name}</Text>
151
+ {openCarts > 0 && <Text testID={`cashier-sheet-open-carts-${id}`} className="text-sm text-muted-foreground">{countLine(openCarts, 'open cart', 'open carts')}</Text>}
152
+ </View>
153
+ <PressVeil pressed={pressed} />
154
+ </>}
155
+ </Pressable>
156
+ ))}
157
+ </View>
158
+ );
159
+ }
160
+
161
+ /** v2 `DrawerDoor` (user-sheet.tsx:180-229) with `useDrawerFigure`'s lines (:120-165), from the app's figures. */
162
+ function DrawerDoor({ drawer }: { drawer: CashierSheetDrawer }) {
163
+ const formatMoney = useFormatMoney();
164
+ const open = drawer.state !== 'closed';
165
+ const f = open ? drawer.figure : undefined;
166
+ const amount = drawer.state === 'closed' ? `Register closed · last closure ${drawer.lastClosure ?? '—'}`
167
+ : !f || f.kind === 'pending' ? '—'
168
+ : f.kind === 'blind' ? `${f.salesCount} ${f.salesCount === 1 ? 'sale' : 'sales'}`
169
+ : formatMoney({ amount: f.amountMinor, currency: f.currency });
170
+ const verbs = drawer.state === 'counting' ? `Counting since ${drawer.countingSince ?? '—'} · back to the count`
171
+ : open ? 'Pay in · Pay out · Close register' : 'Last closure · Open register';
172
+ return (
173
+ <Pressable testID="cashier-sheet-drawer" accessibilityRole="button" disabled={drawer.disabled} onPress={drawer.onOpen} className="mx-3 rounded-lg border border-border">
174
+ {({ pressed }) => <>
175
+ <View className="flex-row items-center gap-3 px-3 py-2.5">
176
+ <ToneDisc tone="muted" icon={RegisterIcon} size="sm" />
177
+ <View className="min-w-0 flex-1">
178
+ <Text className="font-medium">In the drawer</Text>
179
+ {open && <View className="flex-row items-center gap-1">
180
+ <Text testID="cashier-sheet-drawer-opener" className="text-sm text-muted-foreground">{f?.kind === 'pending' ? 'Figures arrive with the next sync.'
181
+ : `${drawer.registerName ? `${drawer.registerName} · ` : ''}opened ${drawer.openedAt} by`}</Text>
182
+ {f?.kind !== 'pending' && <Avatar size="sm" src={drawer.opener.avatar} alt={drawer.opener.name} fallback={avatarInitials(drawer.opener.name)} />}
183
+ </View>}
184
+ </View>
185
+ <Text testID="cashier-sheet-drawer-figure" className={f ? 'text-xl font-semibold tabular-nums' : undefined}>{amount}</Text>
186
+ </View>
187
+ <View testID="cashier-sheet-drawer-verbs" className="flex-row items-center justify-between border-t border-border px-3 py-2">
188
+ <Text className="text-primary">{verbs}</Text>
189
+ <View className="text-primary"><ChevronRightIcon size={18} /></View>
190
+ </View>
191
+ <PressVeil pressed={pressed} className="rounded-lg" />
192
+ </>}
193
+ </Pressable>
194
+ );
195
+ }
@@ -1,9 +1,9 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
  import { AccessibilityInfo, Animated, View } from 'react-native';
3
3
  import type { useRegisterSession } from '@tallyui/pos';
4
- import { countVariance, TAX_ROUNDING_MIXED_NOTE, varianceText } from '@tallyui/pos';
4
+ import { countVariance, TAX_ROUNDING_MIXED_NOTE, TAX_STORE_PAID_NOTE, varianceText } from '@tallyui/pos';
5
5
 
6
- import { formatMoney, minorUnitDigits } from '@tallyui/core';
6
+ import { useFormatMoney, minorUnitDigits } from '@tallyui/core';
7
7
  import { errorText } from '../lib/error-text';
8
8
  import { Button } from '../ui/button';
9
9
  import { Dialog, DialogContent, DialogTitle } from '../ui/dialog';
@@ -60,6 +60,7 @@ export interface ClosureSheetProps {
60
60
  * while blind, per the register-screens-b design, since TallyUI's closure lists every tender.
61
61
  */
62
62
  export function ClosureSheet({ register, currency, onPrint, onDone }: ClosureSheetProps) {
63
+ const formatMoney = useFormatMoney();
63
64
  const { lastClosure: closure, blind } = register;
64
65
  const digits = minorUnitDigits(currency);
65
66
  const { opacity, scale } = useCompletionMotion();
@@ -69,6 +70,7 @@ export function ClosureSheet({ register, currency, onPrint, onDone }: ClosureShe
69
70
  const methods = Object.keys(closure.counted);
70
71
  const approvedByName = closure.breakdowns.approved_by_name;
71
72
  const approvedById = closure.breakdowns.approved_by;
73
+ const note = closure.breakdowns.variance_note;
72
74
  const approvedBy =
73
75
  typeof approvedByName === 'string' && approvedByName
74
76
  ? approvedByName
@@ -109,7 +111,47 @@ export function ClosureSheet({ register, currency, onPrint, onDone }: ClosureShe
109
111
  <Text testID="closure-number" className="text-muted-foreground min-h-11">{`Closure #${closure.number}`}</Text>
110
112
  {!blind && (
111
113
  <View testID="closure-figures" className="gap-3">
112
- {methods.map((method) => {
114
+ {methods.includes('cash') && (() => {
115
+ // v2's closure hero (closure-body.tsx): the signed cash variance, then Counted and Expected boxes.
116
+ const money = (minor: number) => formatMoney({ amount: minor, currency }) ?? '';
117
+ const countedMinor = closure.counted.cash ?? 0;
118
+ const expectedMinor = closure.expected.cash ?? 0;
119
+ const varianceMinor = closure.variance.cash ?? countVariance(countedMinor, expectedMinor);
120
+ const word = varianceWord(
121
+ varianceMinor === 0 ? 'register.exact' : varianceMinor < 0 ? 'register.short' : 'register.over',
122
+ );
123
+ const signed =
124
+ varianceMinor < 0
125
+ ? `−${money(Math.abs(varianceMinor))}`
126
+ : varianceMinor > 0
127
+ ? `+${money(Math.abs(varianceMinor))}`
128
+ : money(0);
129
+ const tone =
130
+ varianceMinor < 0 ? 'text-destructive' : varianceMinor > 0 ? 'text-success' : 'text-foreground';
131
+ return (
132
+ <View key="cash" className="gap-3">
133
+ <View className="items-center gap-1">
134
+ <Text testID="closure-variance-eyebrow" className="text-muted-foreground text-xs font-semibold uppercase">
135
+ {`Variance · ${word}`}
136
+ </Text>
137
+ <Text testID="closure-variance-cash" className={`text-4xl font-bold tabular-nums text-center ${tone}`}>
138
+ {signed}
139
+ </Text>
140
+ </View>
141
+ <View className="flex-row gap-2">
142
+ {([['Counted', 'closure-counted-cash', countedMinor], ['Expected', 'closure-expected-cash', expectedMinor]] as const).map(
143
+ ([label, testID, minor]) => (
144
+ <View key={testID} className="border-border flex-1 rounded-lg border px-3 py-2.5">
145
+ <Text className="text-muted-foreground text-sm">{label}</Text>
146
+ <Text testID={testID} className="text-xl font-bold tabular-nums">{money(minor)}</Text>
147
+ </View>
148
+ ),
149
+ )}
150
+ </View>
151
+ </View>
152
+ );
153
+ })()}
154
+ {methods.filter((method) => method !== 'cash').map((method) => {
113
155
  const countedMinor = closure.counted[method] ?? 0;
114
156
  const expectedMinor = closure.expected[method] ?? 0;
115
157
  const varianceMinor = closure.variance[method] ?? countVariance(countedMinor, expectedMinor);
@@ -147,12 +189,21 @@ export function ClosureSheet({ register, currency, onPrint, onDone }: ClosureShe
147
189
  )}
148
190
  </View>
149
191
  )}
192
+ {/* v2's note line: words, not money, so it shows blind too. */}
193
+ {typeof note === 'string' && !!note.trim() && (
194
+ <Text testID="closure-variance-note" className="text-muted-foreground">{`Note · ${note}`}</Text>
195
+ )}
150
196
  {/* Not a figure either (#287). The wording is approved by the Front desk, 2026-09-30. */}
151
197
  {closure.breakdowns.tax_rounding_mixed === true && (
152
198
  <Text testID="closure-tax-rounding-mixed" className="text-muted-foreground">
153
199
  {TAX_ROUNDING_MIXED_NOTE}
154
200
  </Text>
155
201
  )}
202
+ {closure.breakdowns.tax_includes_store_paid === true && (
203
+ <Text testID="closure-tax-store-paid" className="text-muted-foreground">
204
+ {TAX_STORE_PAID_NOTE}
205
+ </Text>
206
+ )}
156
207
  {!!error && (
157
208
  <Text testID="closure-print-error" className="text-destructive">
158
209
  {error}
@@ -1,7 +1,7 @@
1
1
  import { View } from 'react-native';
2
2
  import type { HandoverSlipData } from '@tallyui/pos';
3
3
 
4
- import { formatMoney } from '@tallyui/core';
4
+ import { useFormatMoney } from '@tallyui/core';
5
5
  import { Text } from '../ui/text';
6
6
  import { tenderLabel } from './register-count';
7
7
  import { countLine } from './switch-confirm';
@@ -19,6 +19,7 @@ export interface HandoverSlipProps {
19
19
  * No dialog: the host places it, for example in a print preview. No expected figures while blind.
20
20
  */
21
21
  export function HandoverSlip({ slip, currency }: HandoverSlipProps) {
22
+ const formatMoney = useFormatMoney();
22
23
  const register = [slip.registerName, slip.openedAtTime && `open since ${slip.openedAtTime}`, slip.openedByName]
23
24
  .filter(Boolean)
24
25
  .join(' · ');
@@ -8,7 +8,8 @@ export { describeRegisterBarPill, type RegisterBarPill } from './register-bar.he
8
8
  export { MovementSheet, type MovementSheetProps } from './movement-sheet';
9
9
  export { RegisterPanel, type RegisterPanelProps } from './register-panel';
10
10
  export { RegisterColumn, type RegisterColumnProps } from './register-column';
11
- export { RegisterCount, APPROVAL_REQUIRED_TEXT, type RegisterCountProps } from './register-count';
11
+ export { RegisterCount, APPROVAL_REQUIRED_TEXT, tenderLabel, type RegisterCountProps } from './register-count';
12
12
  export { ClosureSheet, type ClosureSheetProps } from './closure-sheet';
13
13
  export { SwitchConfirm, type SwitchConfirmProps } from './switch-confirm';
14
14
  export { HandoverSlip, type HandoverSlipProps } from './handover-slip';
15
+ export { CashierSheet, type CashierSheetProps } from './cashier-sheet';
@@ -1,9 +1,13 @@
1
1
  import { useRef, useState } from 'react';
2
+ import { Pressable, View, type TextInput } from 'react-native';
2
3
  import type { MovementType, useRegisterSession } from '@tallyui/pos';
3
4
  import { movementFieldError, normalizeAmount, parseMinor } from '@tallyui/pos';
4
5
 
5
- import { currencySymbol, minorUnitDigits } from '@tallyui/core';
6
+ import { useCurrencySymbol, useFormatMoney, useMoneyFormat, minorUnitDigits } from '@tallyui/core';
7
+ import { cn } from '@tallyui/theme';
8
+ import { useT } from '../i18n';
6
9
  import { errorText } from '../lib/error-text';
10
+ import { readMoneyText } from '../lib/money-input';
7
11
  import { Button } from '../ui/button';
8
12
  import { Dialog, DialogContent, DialogTitle } from '../ui/dialog';
9
13
  import { Input } from '../ui/input';
@@ -16,6 +20,14 @@ const LABELS: Record<MovementType, string> = {
16
20
  no_sale: 'No sale',
17
21
  };
18
22
 
23
+ // v2's `REASONS` (`movement-sheet.tsx:39`): the store's common reasons per type, v2's keys and order.
24
+ const REASONS: Record<MovementType, readonly { key: string; label: string }[]> = {
25
+ paid_out: [{ key: 'supplier', label: 'Supplier' }, { key: 'petty_cash', label: 'Petty cash' }, { key: 'bank', label: 'Bank' },
26
+ { key: 'tips', label: 'Tips' }, { key: 'change', label: 'Change' }],
27
+ paid_in: [{ key: 'float', label: 'Float' }, { key: 'change', label: 'Change' }, { key: 'bank', label: 'Bank' }],
28
+ no_sale: [{ key: 'change', label: 'Change' }, { key: 'mistake', label: 'Mistake' }, { key: 'drawer_check', label: 'Drawer check' }],
29
+ };
30
+
19
31
  const AMOUNT_LABEL_ID = 'movement-amount-label';
20
32
  const REASON_LABEL_ID = 'movement-reason-label';
21
33
 
@@ -30,6 +42,8 @@ export interface MovementSheetProps {
30
42
  onOpenChange: (open: boolean) => void;
31
43
  /** A no-sale opens the drawer once recorded (LEDGER 66); there is nothing to open otherwise. */
32
44
  onOpenDrawer?: () => void;
45
+ /** Replaces the default reason chips for this type; `[]` shows only "Other…". */
46
+ reasons?: readonly string[];
33
47
  }
34
48
 
35
49
  /**
@@ -40,7 +54,11 @@ export interface MovementSheetProps {
40
54
  * after: a refusal afterwards would mean cash already moved with no record of it. A no-sale
41
55
  * hides the amount field, always records zero, and opens the drawer once the row is written.
42
56
  */
43
- export function MovementSheet({ register, type, currency, onDone, onOpenChange, onOpenDrawer }: MovementSheetProps) {
57
+ export function MovementSheet({ register, type, currency, onDone, onOpenChange, onOpenDrawer, reasons }: MovementSheetProps) {
58
+ const t = useT();
59
+ const currencySymbol = useCurrencySymbol();
60
+ const formatMoney = useFormatMoney();
61
+ const format = useMoneyFormat();
44
62
  const digits = minorUnitDigits(currency);
45
63
  const [amount, setAmount] = useState('');
46
64
  const [reason, setReason] = useState('');
@@ -49,16 +67,36 @@ export function MovementSheet({ register, type, currency, onDone, onOpenChange,
49
67
  // the rendered busy state, claims the submission the instant the first tap runs.
50
68
  const busyRef = useRef(false);
51
69
  const [error, setError] = useState('');
52
- const invalid = movementFieldError({ type, amount, reason });
70
+ const reasonRef = useRef<TextInput>(null);
71
+ const chips = reasons
72
+ ? reasons.map((label) => ({ key: label.toLowerCase().replace(/[^a-z0-9]+/g, '-'), label }))
73
+ : REASONS[type];
74
+ const canonical = readMoneyText(amount, format);
75
+ const refused = !!format && type !== 'no_sale' && amount !== '' && canonical === undefined;
76
+ const fieldError = refused ? 'amount' : movementFieldError({ type, amount: canonical ?? amount, reason });
77
+ const typed = normalizeAmount(canonical ?? amount);
78
+ const amountMinor = type === 'no_sale' ? 0 : fieldError === 'amount' ? NaN : parseMinor(typed, digits);
79
+ // The server's grammar allows any decimal places and 15 integer digits; the currency and a safe integer allow fewer.
80
+ // recordMovement refuses anything but a safe integer (ADR-068 6a) after the cash has moved, so the same test gates
81
+ // the tap. The amount is checked before the reason.
82
+ const invalid = type === 'no_sale' || fieldError === 'amount' ? fieldError
83
+ : Number.isNaN(amountMinor) ? 'places'
84
+ : !Number.isSafeInteger(amountMinor) ? 'amount'
85
+ : fieldError;
86
+ // v2's confirm label (`movement-sheet.tsx:126`): it names the minor amount `confirm` records, in the store's format;
87
+ // an amount the gate refuses (blank, zero, invalid, too many places, too large) reads the bare verb. A no sale keeps "Record".
88
+ const figure = type !== 'no_sale' && fieldError !== 'amount' && Number.isSafeInteger(amountMinor)
89
+ ? formatMoney({ amount: amountMinor, currency }) : undefined;
90
+ const verb = type === 'paid_in' ? (figure ? t('register.put_in', { amount: figure }) : t('register.put_cash_in'))
91
+ : type === 'paid_out' ? (figure ? t('register.take_out', { amount: figure }) : t('register.take_cash_out'))
92
+ : 'Record';
53
93
  const confirm = async () => {
54
94
  if (invalid || busyRef.current) return;
55
95
  busyRef.current = true;
56
96
  setBusy(true);
57
97
  setError('');
58
- const normalized = type === 'no_sale' ? '0' : normalizeAmount(amount);
59
98
  const trimmedReason = reason.trim();
60
99
  try {
61
- const amountMinor = parseMinor(normalized, digits);
62
100
  const row = await register.actions.recordMovement({ type, amountMinor, reason: trimmedReason });
63
101
  onDone?.(row.id, type, amountMinor);
64
102
  if (type === 'no_sale') onOpenDrawer?.();
@@ -94,8 +132,28 @@ export function MovementSheet({ register, type, currency, onDone, onOpenChange,
94
132
  <Label testID="movement-reason-label" nativeID={REASON_LABEL_ID}>
95
133
  Reason
96
134
  </Label>
135
+ <View testID="movement-reason-chips" className="flex-row flex-wrap gap-2">
136
+ {[...chips, { key: 'other', label: 'Other…' }].map(({ key, label }) => {
137
+ const other = key === 'other';
138
+ const on = !other && reason === label;
139
+ return (
140
+ <Pressable key={key} testID={`movement-reason-${key.replace(/_/g, '-')}`} role="button"
141
+ aria-pressed={other ? undefined : on}
142
+ onPress={() => {
143
+ setReason(on || other ? '' : label);
144
+ if (other) reasonRef.current?.focus();
145
+ }}
146
+ className={cn('rounded-full px-3 py-1.5', on ? 'bg-primary' : 'bg-accent')}>
147
+ <Text className={cn('text-xs font-semibold', on ? 'text-primary-foreground' : 'text-muted-foreground')}>
148
+ {label}
149
+ </Text>
150
+ </Pressable>
151
+ );
152
+ })}
153
+ </View>
97
154
  <Input>
98
155
  <Input.Field
156
+ ref={reasonRef}
99
157
  testID="movement-reason"
100
158
  placeholder="Reason"
101
159
  value={reason}
@@ -107,11 +165,12 @@ export function MovementSheet({ register, type, currency, onDone, onOpenChange,
107
165
  {!!error && <Text className="text-destructive">{error}</Text>}
108
166
  {!!invalid && (
109
167
  <Text testID="movement-invalid" className="text-muted-foreground">
110
- {invalid === 'amount' ? 'Enter a valid amount.' : 'Enter a reason.'}
168
+ {invalid === 'amount' ? 'Enter a valid amount.' : invalid !== 'places' ? 'Enter a reason.'
169
+ : digits === 0 ? 'Enter a whole amount.' : `Enter an amount with at most ${digits} decimal places.`}
111
170
  </Text>
112
171
  )}
113
172
  <Button testID="movement-confirm" disabled={!!invalid || busy} onPress={confirm}>
114
- <Text>{busy ? 'Recording…' : 'Record'}</Text>
173
+ <Text>{busy ? 'Recording…' : verb}</Text>
115
174
  </Button>
116
175
  </DialogContent>
117
176
  </Dialog>
@@ -3,9 +3,10 @@ import { View } from 'react-native';
3
3
  import type { useRegisterSession } from '@tallyui/pos';
4
4
  import { parseMinor, validAmount } from '@tallyui/pos';
5
5
 
6
- import { currencySymbol, formatMoney, minorUnitDigits } from '@tallyui/core';
6
+ import { useCurrencySymbol, useFormatMoney, useMoneyFormat, minorUnitDigits } from '@tallyui/core';
7
7
  import { cn } from '@tallyui/theme';
8
8
  import { errorText } from '../lib/error-text';
9
+ import { moneyInputText, readMoneyText } from '../lib/money-input';
9
10
  import { Button } from '../ui/button';
10
11
  import { Input } from '../ui/input';
11
12
  import { Label } from '../ui/label';
@@ -33,15 +34,19 @@ export interface OpenRegisterCardProps {
33
34
  * typed, because `enteredAmount` only ever starts from it, never re-derives from it.
34
35
  */
35
36
  export function OpenRegisterCard({ register, currency, configuredFloatMinor, className }: OpenRegisterCardProps) {
37
+ const formatMoney = useFormatMoney();
38
+ const currencySymbol = useCurrencySymbol();
39
+ const format = useMoneyFormat();
36
40
  const digits = minorUnitDigits(currency);
37
41
  const lastCountedMinor = register.lastClosure?.counted?.cash ?? null;
38
42
  const expectedFloatMinor = configuredFloatMinor ?? lastCountedMinor ?? null;
39
43
  const [enteredAmount, setEnteredAmount] = useState<string | null>(null);
40
- const amount = enteredAmount ?? (expectedFloatMinor != null ? decimal(expectedFloatMinor, digits) : '');
44
+ const amount = enteredAmount ?? (expectedFloatMinor != null ? moneyInputText(expectedFloatMinor, currency, format) : '');
41
45
  const [busy, setBusy] = useState(false);
42
46
  const [error, setError] = useState('');
43
- const valid = validAmount(amount, digits);
44
- const countedMinor = valid ? parseMinor(amount, digits) : NaN;
47
+ const canonical = readMoneyText(amount, format);
48
+ const valid = canonical !== undefined && validAmount(canonical, digits);
49
+ const countedMinor = valid ? parseMinor(canonical, digits) : NaN;
45
50
  const open = async () => {
46
51
  if (busy || !valid) return;
47
52
  setBusy(true);
@@ -76,7 +81,7 @@ export function OpenRegisterCard({ register, currency, configuredFloatMinor, cla
76
81
  testID="open-register-chip-configured"
77
82
  variant="outline"
78
83
  className="min-h-11"
79
- onPress={() => setEnteredAmount(decimal(configuredFloatMinor, digits))}
84
+ onPress={() => setEnteredAmount(moneyInputText(configuredFloatMinor, currency, format))}
80
85
  >
81
86
  <Text>Use the configured float ({formatMoney({ amount: configuredFloatMinor, currency })})</Text>
82
87
  </Button>
@@ -86,7 +91,7 @@ export function OpenRegisterCard({ register, currency, configuredFloatMinor, cla
86
91
  testID="open-register-chip-last"
87
92
  variant="outline"
88
93
  className="min-h-11"
89
- onPress={() => setEnteredAmount(decimal(lastCountedMinor, digits))}
94
+ onPress={() => setEnteredAmount(moneyInputText(lastCountedMinor, currency, format))}
90
95
  >
91
96
  <Text>Use the last counted cash ({formatMoney({ amount: lastCountedMinor, currency })})</Text>
92
97
  </Button>
@@ -103,8 +108,3 @@ export function OpenRegisterCard({ register, currency, configuredFloatMinor, cla
103
108
  </View>
104
109
  );
105
110
  }
106
-
107
- function decimal(minor: number, digits: number): string {
108
- const scale = 10 ** digits;
109
- return (minor / scale).toFixed(digits);
110
- }
@@ -17,6 +17,10 @@ export type RegisterBarPill =
17
17
  | 'Choose a register'
18
18
  | 'Close not finished'
19
19
  | 'Offline'
20
+ | `Offline · ${number} sale to send`
21
+ | `Offline · ${number} sales to send`
22
+ | `${number} sale awaiting store`
23
+ | `${number} sales awaiting store`
20
24
  | 'Approval needed'
21
25
  | 'Counting'
22
26
  | 'Overdue'
@@ -25,12 +29,14 @@ export type RegisterBarPill =
25
29
  /**
26
30
  * Priority, matching WCPOS's ordering: choosing a register outranks everything (LEDGER 48);
27
31
  * then a closed session whose close isn't in flight (TallyUI: it blocks selling until Finish
28
- * closing); then an unreachable store reads as offline, ahead of any session state; approval needed
29
- * outranks plain counting; an open, overdue session outranks a session-less "closed" pill.
32
+ * closing); then an unreachable store reads as offline, counting sales still to send, ahead of any
33
+ * session state; approval needed outranks plain counting; an open, overdue session outranks a
34
+ * session-less "closed" pill; online sales awaiting the store rank last.
30
35
  */
31
36
  export function describeRegisterBarPill({
32
37
  registerId,
33
38
  online,
39
+ awaitingStore = 0,
34
40
  sessionStatus,
35
41
  overdue = false,
36
42
  approvalRequired = false,
@@ -40,6 +46,8 @@ export function describeRegisterBarPill({
40
46
  /** The register this till is bound to, or `null` when it isn't bound yet. */
41
47
  registerId: string | null;
42
48
  online: boolean;
49
+ /** Sales taken that the store has still to hear (v2's useAwaitingStoreCount); 0 or omitted counts nothing. */
50
+ awaitingStore?: number;
43
51
  /** `conflict` and `superseded` (ADR-078 decision 9) get no pill of their own yet; step 3b decides theirs. */
44
52
  sessionStatus?: RegisterSession['status'] | null;
45
53
  overdue?: boolean;
@@ -51,10 +59,15 @@ export function describeRegisterBarPill({
51
59
  }): RegisterBarPill | null {
52
60
  if (registerId === null) return 'Choose a register';
53
61
  if (sessionStatus === 'closed' && !closing) return 'Close not finished';
54
- if (!online) return 'Offline';
62
+ if (!online) return awaitingStore > 0
63
+ ? `Offline · ${awaitingStore} ${awaitingStore === 1 ? 'sale' : 'sales'} to send`
64
+ : 'Offline';
55
65
  if (sessionStatus === 'counting' && !approvalRequired) return 'Counting';
56
66
  if (approvalRequired) return 'Approval needed';
57
67
  if (sessionStatus === 'open' && overdue) return 'Overdue';
58
68
  if (sessionsOn && !sessionStatus) return 'Register closed';
59
- return null;
69
+ // Online, the sales the store has not answered rank last: they need no action (v2).
70
+ return awaitingStore > 0
71
+ ? `${awaitingStore} ${awaitingStore === 1 ? 'sale' : 'sales'} awaiting store`
72
+ : null;
60
73
  }