@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/src/sale/cart.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useState, type ReactNode } from 'react';
1
+ import { useState, type ComponentProps, type ReactNode } from 'react';
2
2
  import { Pressable, Text, View, useWindowDimensions } from 'react-native';
3
3
  import { buildReceiptData } from '@tallyui/pos';
4
4
  import type { useSale } from '@tallyui/pos';
@@ -17,12 +17,17 @@ import { OrderNoteSheet } from './order-note-sheet';
17
17
  import { TenderLedger } from './tender-ledger';
18
18
  import { ShoppingCartIcon } from '../ui';
19
19
  import { useT } from '../i18n';
20
+ import { saleErrorText } from './sale-error-text';
20
21
 
21
22
  /** `taxLabel` names each tax row; VAT isn't universal, so a platform passes its own (medusapos passes `VAT ${rate}%`). */
22
- export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10000}%`, canEditPrice = false, onPriceChange, quickDiscounts, taxClasses, afterSubtotal, showTotal = true, couponDiscountMinor, orderActions = true, orderDiscountChips = true, checkout, noteSheet, tenderLedger, picker, lineEditor = 'inline',
23
+ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10000}%`, taxDisplay = 'itemized', canEditPrice = false, onPriceChange, quickDiscounts, taxClasses, afterSubtotal, showTotal = true, couponDiscountMinor, orderActions = true, orderDiscountChips = true, checkout, noteSheet, tenderLedger, picker, lineEditor = 'inline',
23
24
  lineCommit = 'apply', columns, chargeTaxSwitch = true,
24
25
  emptyIcon = <ShoppingCartIcon size={48} />, emptyText = 'Tap a product to start a sale' }:
25
- { sale: ReturnType<typeof useSale>; taxLabel?: (ratePpm: number) => string;
26
+ { sale: ReturnType<typeof useSale>;
27
+ /** Names each tax row from its rate. The second argument carries the row's own tax `code` (when it has one) and `ratePpm`, so two rates with the same percentage can be told apart. */
28
+ taxLabel?: (ratePpm: number, rate: { code?: string; ratePpm: number }) => string;
29
+ /** `itemized` (default): one row per rate, under `taxLabel`. `single`: one "Total Tax" row with the order's total tax, drawn only when that is not 0. */
30
+ taxDisplay?: 'itemized' | 'single';
26
31
  taxClasses?: ReadonlyArray<{ id: string; label: string }>;
27
32
  /** Shows a Price action on each line. Pass the till's own permission; the control isn't shown without it. */
28
33
  canEditPrice?: boolean;
@@ -54,8 +59,8 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
54
59
  * names the note (default "Customer note"; a platform whose note the customer never sees passes its own, e.g.
55
60
  * "Order note"). Needs `checkout`; when given, it replaces `checkout.note`. */
56
61
  noteSheet?: { label?: string };
57
- /** v2's checkout cart (stilled-cart.tsx): while `sale.stage` is tender, the payments ledger (each leg with its status and Cancel payment, then Total, Paid and Remaining) sits under the totals in place of the foot. `methods` names the legs, as on Tender. Pair it with `<Tender ledger={false} />`. `confirmVoid` asks v2's "Cancel this payment?" before a leg is voided (default `false`). */
58
- tenderLedger?: { methods?: PaymentMethodDescriptor[]; confirmVoid?: boolean };
62
+ /** v2's checkout cart (stilled-cart.tsx): while `sale.stage` is tender, the payments ledger (each leg with its status and Cancel payment, then Total, Paid and Remaining) sits under the totals in place of the foot. `methods` names the legs, as on Tender. Pair it with `<Tender ledger={false} />`. `confirmVoid` asks v2's "Cancel this payment?" before a leg is voided (default `false`). `beforeVoid` runs before Cancel payment voids a leg, as on TenderLedger. */
63
+ tenderLedger?: { methods?: PaymentMethodDescriptor[]; confirmVoid?: boolean; beforeVoid?: ComponentProps<typeof TenderLedger>['beforeVoid']; afterVoid?: ComponentProps<typeof TenderLedger>['afterVoid'] };
59
64
  /** WCPOS v2's split-by-item bill (stilled-cart.tsx): the cart is read-only, and each line whose quantity is a positive
60
65
  * whole number, whose total is not negative and that has units left unpaid shows this payment's `− n of unpaid +`
61
66
  * stepper in its quantity cell, with what the picked units add under it. `picked`: this payment's units per line id;
@@ -85,6 +90,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
85
90
  /** The empty cart's line. Default: v2's "Tap a product to start a sale". */
86
91
  emptyText?: string;
87
92
  }) {
93
+ const t = useT();
88
94
  const { order } = sale;
89
95
  const [noteOpen, setNoteOpen] = useState(false);
90
96
  // v2's empty cart: an icon and a line, no heads and no foot. A fee or shipping row alone keeps the cart.
@@ -92,7 +98,9 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
92
98
  const money = (amount: number) => ({ amount, currency: order.currency });
93
99
  // order.display's figures (TallyUI ADR-063), with its tax split by rate; never app arithmetic (medusapos ADR 0008).
94
100
  const { totals, fees, shipping } = buildReceiptData(order, { storeName: '' });
95
- const taxRows = totals.taxLines.map((line) => ({ label: taxLabel(line.ratePpm), amount: money(line.amountMinor) }));
101
+ const taxRows = taxDisplay === 'single'
102
+ ? totals.taxMinor !== 0 ? [{ label: 'Total Tax', amount: money(totals.taxMinor) }] : []
103
+ : totals.taxLines.map((line) => ({ label: taxLabel(line.ratePpm, { code: line.code, ratePpm: line.ratePpm }), amount: money(line.amountMinor) }));
96
104
  // Each line before its discounts, with its own discounts' amounts. The order discounts are one figure: a single
97
105
  // order discount's chip carries it; several keep their own labels, as no single one has a display amount.
98
106
  const display = (lineId: string) => order.display.lines.find((line) => line.lineId === lineId)!;
@@ -187,7 +195,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
187
195
  className="text-muted-foreground">{emptyIcon}</View>}
188
196
  <Text testID="cart-empty-text" className="text-center text-muted-foreground">{emptyText}</Text>
189
197
  {/* The footer is gone, so a resume or coupon message on an empty cart shows here. */}
190
- {sale.error ? <Text accessibilityRole="alert" className="text-destructive">{sale.error}</Text> : null}
198
+ {sale.error ? <Text accessibilityRole="alert" className="text-destructive">{saleErrorText(t, sale.error)}</Text> : null}
191
199
  </View> : undefined}
192
200
  afterItems={<>
193
201
  {(['fees', 'shipping'] as const).map((kind) => <MotionRows key={kind} items={order[kind] ?? []} keyOf={(charge) => charge.id}
@@ -235,8 +243,8 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
235
243
  fees={money(fees.reduce((sum, row) => sum + row.amountMinor, 0))}
236
244
  shipping={money(shipping.reduce((sum, row) => sum + row.amountMinor, 0))}
237
245
  taxLines={taxRows} taxInclusive={totals.taxInclusive} afterSubtotal={afterSubtotal} showTotal={showTotal} />
238
- {sale.error ? <Text accessibilityRole="alert" className="text-destructive">{sale.error}</Text> : null}
239
- {tenderLedger && sale.stage.kind === 'tender' ? <TenderLedger sale={sale} methods={tenderLedger.methods} confirmVoid={tenderLedger.confirmVoid} closing /> : checkout ? <><CartFoot total={money(totals.totalMinor)} onCheckout={checkout.onCheckout}
246
+ {sale.error ? <Text accessibilityRole="alert" className="text-destructive">{saleErrorText(t, sale.error)}</Text> : null}
247
+ {tenderLedger && sale.stage.kind === 'tender' ? <TenderLedger sale={sale} methods={tenderLedger.methods} confirmVoid={tenderLedger.confirmVoid} beforeVoid={tenderLedger.beforeVoid} afterVoid={tenderLedger.afterVoid} closing /> : checkout ? <><CartFoot total={money(totals.totalMinor)} onCheckout={checkout.onCheckout}
240
248
  actions={noteSheet ? [{ label: 'Order details', onPress: () => setNoteOpen(true) }, ...(checkout.actions ?? [])] : checkout.actions}
241
249
  note={noteSheet ? { text: order.note, onPress: () => setNoteOpen(true) } : checkout.note} disabled={!order.lineItems.length} />
242
250
  {noteSheet && noteOpen ? <OrderNoteSheet value={order.note} onChangeText={sale.setNote}
@@ -54,7 +54,7 @@ export function CatalogueSettingsForm({
54
54
  const auto = gridColumns === 'auto';
55
55
  return (
56
56
  <View testID={testID} className={cn('gap-1', className)} {...viewProps}>
57
- <Text role="heading" className="pb-1 text-base font-semibold">{t('common.tile_size')}</Text>
57
+ <Text role="heading" aria-level={4} className="pb-1 text-base font-semibold">{t('common.tile_size')}</Text>
58
58
  <View className="flex-row items-center gap-3 py-1">
59
59
  <Switch testID={`${testID}-auto`} accessibilityLabel={t('common.auto')} checked={auto}
60
60
  onCheckedChange={(on) => onGridColumnsChange(on ? 'auto' : V2_TILE_SIZE)} />
@@ -68,7 +68,7 @@ export function CatalogueSettingsForm({
68
68
  <Text className="w-6 text-right tabular-nums">{String(gridColumns)}</Text>
69
69
  </View>
70
70
  )}
71
- <Text role="heading" className="pb-1 pt-3 text-base font-semibold">{t('common.tile_fields')}</Text>
71
+ <Text role="heading" aria-level={4} className="pb-1 pt-3 text-base font-semibold">{t('common.tile_fields')}</Text>
72
72
  {(Object.keys(DEFAULT_TILE_FIELDS) as TileField[]).map((field) => {
73
73
  const label = t(LABELS[field]);
74
74
  return (
@@ -22,7 +22,7 @@ import { Breadcrumb } from './breadcrumb';
22
22
  import { CategoryTile, TileStack } from '../product/category-tile';
23
23
  import { useT } from '../i18n';
24
24
  import { SearchInput } from '../input';
25
- import { VStack, IconButton, PlusIcon } from '../ui';
25
+ import { VStack, IconButton, PlusIcon, ChevronDownIcon, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui';
26
26
  import { skeletonCount } from '../ui/skeleton';
27
27
  import { useMinTarget } from '../scale/min-target';
28
28
  import { usePointer } from '../scale/use-pointer';
@@ -278,6 +278,17 @@ export function Catalogue<Doc>({ products, traits, currency, onSelect, statusTex
278
278
  const [chooserId, setChooserId] = useState<string | null>(null);
279
279
  // The product ids whose table rows are expanded (local, never saved).
280
280
  const [expandedIds, setExpandedIds] = useState<ReadonlySet<string>>(() => new Set());
281
+ // An expanded row's option filters (product id to group name to value), dropped when the row collapses.
282
+ const [variantFilters, setVariantFilters] = useState<Readonly<Record<string, Readonly<Record<string, string>>>>>({});
283
+ function toggleExpanded(key: string) {
284
+ const open = !expandedIds.has(key);
285
+ setExpandedIds((current) => {
286
+ const next = new Set(current);
287
+ if (open) next.add(key); else next.delete(key);
288
+ return next;
289
+ });
290
+ if (!open) setVariantFilters((current) => { const next = { ...current }; delete next[key]; return next; });
291
+ }
281
292
  const [width, setWidth] = useState(0);
282
293
  const [loadingHeight, setLoadingHeight] = useState(0);
283
294
  const columns = resolveGridColumns(state.gridColumns, width);
@@ -376,9 +387,46 @@ export function Catalogue<Doc>({ products, traits, currency, onSelect, statusTex
376
387
  }
377
388
 
378
389
  function variantRows(product: Doc) {
379
- const variants = entries.filter((entry) => traits.getId(entry.product) === traits.getId(product));
390
+ const id = traits.getId(product);
391
+ const variants = entries.filter((entry) => traits.getId(entry.product) === id);
380
392
  if (variants.length === 0) return <Text className="px-3 py-1.5 text-sm text-muted-foreground">No variants to show.</Text>;
381
- return variants.map((entry) => (
393
+ const picked = variantFilters[id] ?? {};
394
+ const groups = (traits.getVariantOptions?.(product) ?? []).filter(({ values }) => values.length > 1);
395
+ // A variant leaving a group unset fits any value of it; a picked group that draws no select no longer filters.
396
+ const matching = variants.filter(({ variant: { options } }) => groups.every(({ name }) => !picked[name]
397
+ || options === undefined || !Object.prototype.hasOwnProperty.call(options, name) || options[name] === picked[name]));
398
+ const pick = (group: string, value: string) => setVariantFilters((current) => {
399
+ const next = { ...current[id] };
400
+ if (value === '') delete next[group]; else next[group] = value;
401
+ return { ...current, [id]: next };
402
+ });
403
+ // v2 variations/filters.tsx: a select per option group, then a chevron that folds the row.
404
+ const bar = (
405
+ <View key="filters" testID={`variation-filters-${id}`} className="flex-row items-center gap-2 border-t border-border px-3 py-1">
406
+ <View className="min-w-0 flex-1 flex-row flex-wrap gap-2">
407
+ {groups.map(({ name, values }) => (
408
+ <Select key={name} value={{ value: picked[name] ?? '', label: picked[name] ? `${name}: ${picked[name]}` : name }}
409
+ onValueChange={(option) => { if (option) pick(name, option.value); }}>
410
+ <SelectTrigger testID={`variation-filter-${id}-${name}`} accessibilityLabel={picked[name] ? `${name}: ${picked[name]}` : name} className="h-9 w-auto">
411
+ <SelectValue className="text-sm text-foreground" />
412
+ </SelectTrigger>
413
+ <SelectContent>
414
+ {['', ...values].map((value) => (
415
+ <SelectItem key={value} value={value} label={value || name}>
416
+ <Text className="text-sm text-popover-foreground">{value || 'All'}</Text>
417
+ </SelectItem>
418
+ ))}
419
+ </SelectContent>
420
+ </Select>
421
+ ))}
422
+ </View>
423
+ <IconButton size="sm" testID={`variation-filters-${id}-collapse`} accessibilityLabel="Collapse" onPress={() => toggleExpanded(id)}>
424
+ <View className="text-muted-foreground" style={{ transform: [{ rotate: '180deg' }] }}><ChevronDownIcon size={18} /></View>
425
+ </IconButton>
426
+ </View>
427
+ );
428
+ if (matching.length === 0) return [bar, <Text key="none" className="px-3 py-1.5 text-sm text-muted-foreground">No variants match.</Text>];
429
+ return [bar, ...matching.map((entry) => (
382
430
  <View key={entry.variant.id} testID={`variation-row-${entry.variant.id}`} className="flex-row items-center gap-3 border-t border-border px-3 py-1.5">
383
431
  <View testID={`variation-row-${entry.variant.id}-chips`} className="min-w-0 flex-1 flex-row flex-wrap gap-1">
384
432
  {chipsOf(entry).map((chip, index) => <Text key={index} className="rounded bg-foreground/12 px-1.5 text-xs font-bold text-foreground">{chip}</Text>)}
@@ -391,7 +439,7 @@ export function Catalogue<Doc>({ products, traits, currency, onSelect, statusTex
391
439
  </IconButton>
392
440
  </View>
393
441
  </View>
394
- ));
442
+ ))];
395
443
  }
396
444
 
397
445
  // The variations popover (#719): the one open popover's product id, and each product's current entries in order.
@@ -530,11 +578,7 @@ export function Catalogue<Doc>({ products, traits, currency, onSelect, statusTex
530
578
  sortItems={false} onSelect={selectProduct} emptyState={emptyState} loading={showLoading}
531
579
  showThumbnail={tableRow?.thumbnail} showAddButton={tableRow?.addButton}
532
580
  isExpanded={tableRow?.expand ? (doc) => expandedIds.has(traits.getId(doc)) : undefined}
533
- onToggleExpand={tableRow?.expand ? (doc) => setExpandedIds((current) => {
534
- const key = traits.getId(doc), next = new Set(current);
535
- if (next.has(key)) next.delete(key); else next.add(key);
536
- return next;
537
- }) : undefined}
581
+ onToggleExpand={tableRow?.expand ? (doc) => toggleExpanded(traits.getId(doc)) : undefined}
538
582
  renderExpanded={tableRow?.expand ? variantRows : undefined} variationsButton={tableRow?.variationsButton}
539
583
  cartQuantity={(doc) => quantities.get(traits.getId(doc)) ?? 0} />
540
584
  ) : drillEntries.length > 0 ? <LevelWrap level onBack={() => setDrillId(null)}>
@@ -10,7 +10,7 @@ const COPY = {
10
10
  discount: 'Discount', total_tax: 'Tax', included_tax: 'Tax included', total: 'Total', paid_so_far: 'Paid so far',
11
11
  present_card: 'Please present your card', approved: 'Approved', declined: 'Declined',
12
12
  try_another_card: 'Please try another card or ask staff', paid_in_full: 'Paid in full', change: 'Change',
13
- thank_you: 'Thank you', tendered: 'Tendered',
13
+ thank_you: 'Thank you', tendered: 'Tendered', rounding: 'Rounding',
14
14
  };
15
15
 
16
16
  const CARD = { started: 'bg-primary', approved: 'bg-success', complete: 'bg-success', declined: 'bg-destructive' };
@@ -67,6 +67,7 @@ export function CustomerDisplayScreen({ state }: { state: DisplayState }) {
67
67
  {row(t('subtotal'), money(receipt.totals.subtotalMinor))}
68
68
  {receipt.fees.map((charge, index) => row(charge.name, money(charge.amountMinor), `fee-${index}`))}
69
69
  {receipt.shipping.map((charge, index) => row(charge.name, money(charge.amountMinor), `shipping-${index}`))}
70
+ {receipt.rounding ? row(t('rounding'), money(receipt.rounding.amountMinor), 'rounding') : null}
70
71
  {receipt.totals.discountMinor > 0 ? row(t('discount'), `-${money(receipt.totals.discountMinor)}`) : null}
71
72
  {receipt.totals.taxMinor > 0 ? row(t(receipt.totals.taxInclusive ? 'included_tax' : 'total_tax'), money(receipt.totals.taxMinor)) : null}
72
73
  {total}
@@ -1,8 +1,10 @@
1
1
  import { useEffect, useRef, useState, type JSX } from 'react';
2
- import { Platform, Pressable, ScrollView, View } from 'react-native';
2
+ import { Animated, Platform, Pressable, ScrollView, View } from 'react-native';
3
3
  import { useFormatMoney } from '@tallyui/core';
4
4
  import { isPartlyPaid, type OpenSale } from '@tallyui/pos';
5
5
  import { cn } from '@tallyui/theme';
6
+ import { CROSSFADE, EASE, NEW_TAB_WIDTH, PLUS_WIDTH } from '../lib/motion';
7
+ import { useReducedMotion } from '../lib/use-reduced-motion';
6
8
  import { Text } from '../ui/text';
7
9
 
8
10
  const AGE_TICK_MS = 60_000; // Ages tick once a minute (v2).
@@ -52,6 +54,22 @@ export function OpenSaleTabs({ sales, currency, onSelect, onNew, className }: Op
52
54
  // v2 cart/tabs.tsx: on a blank cart the active position is the + cell, just past the last sale; no wrap.
53
55
  const activeIndex = blank ? sales.length : sales.findIndex((sale) => sale.current);
54
56
  const focusPending = useRef(false);
57
+ const reduced = useReducedMotion() !== false; // Reduced or unknown motion jumps, as cart-line-strip.tsx.
58
+ const width = useRef(new Animated.Value(blank ? NEW_TAB_WIDTH : PLUS_WIDTH)).current;
59
+ const fade = useRef(new Animated.Value(blank ? 1 : 0)).current;
60
+ const [label, setLabel] = useState(blank); // "New" stays mounted through its fade out (v2 FadeOut).
61
+ const was = useRef(blank);
62
+ useEffect(() => {
63
+ if (was.current === blank) return; // The values start at their target: nothing animates on mount.
64
+ was.current = blank;
65
+ if (blank) setLabel(true);
66
+ const go = (value: Animated.Value, toValue: number, done = () => {}) => {
67
+ if (reduced) { value.setValue(toValue); done(); return; }
68
+ Animated.timing(value, { toValue, duration: CROSSFADE, easing: EASE, useNativeDriver: false }).start(({ finished }) => { if (finished) done(); });
69
+ };
70
+ go(width, blank ? NEW_TAB_WIDTH : PLUS_WIDTH); // v2 cart/tabs.tsx: the + cell widens to "+ New" on the blank cart.
71
+ go(fade, blank ? 1 : 0, () => { if (!was.current) setLabel(false); });
72
+ }, [blank, reduced, width, fade]);
55
73
  const step = (delta: number) => {
56
74
  const at = activeIndex + delta;
57
75
  if (at < 0 || at > sales.length) return;
@@ -103,13 +121,15 @@ export function OpenSaleTabs({ sales, currency, onSelect, onNew, className }: Op
103
121
  );
104
122
  })}
105
123
  </ScrollView>
124
+ <Animated.View className="h-full overflow-hidden" style={{ width }}>
106
125
  <Pressable testID="new-sale-tab" ref={follow(blank)} accessibilityRole="tab" accessibilityLabel="New order" accessibilityState={{ selected: blank }} aria-selected={blank}
107
126
  // Already on the blank cart: + is a place, not an action (v2).
108
127
  onPress={() => { if (!blank) onNew(); }}
109
- className={`h-full flex-row items-center justify-center gap-1.5 px-3 ${blank ? 'border-b-2 border-primary' : ''}`}>
128
+ className={`h-full w-full flex-row items-center justify-center gap-1.5 px-3 ${blank ? 'border-b-2 border-primary' : ''}`}>
110
129
  <Text className={blank ? 'text-primary' : 'text-foreground'}>+</Text>
111
- {blank && <Text testID="new-sale-tab-label" className="font-semibold">New</Text>}
130
+ {(blank || (!reduced && label)) && <Animated.View style={{ opacity: fade, flexShrink: 0 }}><Text testID="new-sale-tab-label" className="font-semibold">New</Text></Animated.View>}
112
131
  </Pressable>
132
+ </Animated.View>
113
133
  </View>
114
134
  );
115
135
  }
@@ -1,9 +1,10 @@
1
1
  import { useEffect, useId, useRef, useState, type ReactNode } from 'react';
2
2
  import { Pressable, ScrollView, Text, View } from 'react-native';
3
- import { useFormatMoney, knownWarnings } from '@tallyui/core';
4
- import { extrasNotSent, isRequeueableOrder, needsAttention, noteDelivery, refundDueOf, REOPENABLE_CODES, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE, type OutboxState, type PosOrder } from '@tallyui/pos';
3
+ import { useFormatMoney, knownWarnings, type SettleOutcome } from '@tallyui/core';
4
+ import { canCancelOnStore, canPayRestOnStore, extrasNotSent, isRequeueableOrder, needsAdminReasonOf, needsAttention, noteDelivery, refundDueOf, REOPENABLE_CODES, settledOnStore, storeOrderLeft, unrecordedLegs, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE, type OutboxState, type PosOrder } from '@tallyui/pos';
5
5
  import { META_NOT_SENT, NOTE_NOT_SENT, orderReference, TAX_IDS_NOT_SENT } from './order-reference';
6
6
  import { sinceText } from './since-text';
7
+ import { ConfirmDialog } from '../ui/confirm-dialog';
7
8
 
8
9
  /** One order from the store's own history (ADR-052 amendment 1), mapped by the app from its platform. */
9
10
  export type OrderHistoryRow = {
@@ -34,6 +35,9 @@ const REFUSAL_SENTENCES = new Map([
34
35
  ]);
35
36
  // Any other code, or none: platform_error's sentence, as the generic fallback (approved by the Front desk, 2026-09-30).
36
37
  const refusalSentence = (code: string | undefined) => REFUSAL_SENTENCES.get(code ?? '') ?? REFUSAL_SENTENCES.get('platform_error')!;
38
+ /** Pay the rest on store's dialog (#1101 slice 3): the front desk's wording until slice 4 handles money given back. */
39
+ const GIVE_BACK = "If the money was given back, do not record it; a manager must check the order in the store's admin.";
40
+ const methodLabel = (method: string) => (method === 'cash' ? 'Cash' : 'Card terminal');
37
41
  const REOPEN_AGAIN_SENTENCE = "This order was changed in the online store after it was reopened here, so your change wasn't sent. Reopen the order and make the change again.";
38
42
 
39
43
  /** Keeps an unparseable value as is, like medusapos's date util, since `Intl` throws on an invalid date. */
@@ -50,23 +54,73 @@ export type OrderSyncNoticesProps = {
50
54
  children?: ReactNode;
51
55
  };
52
56
 
57
+ // #1280: only session_closed guarantees the store holds no order.
58
+ const NEEDS_ADMIN_SESSION_CLOSED = 'Not in the online store yet. A manager must finish this sale in the store admin.';
59
+ const NEEDS_ADMIN_SALE = 'Not finished in the online store. A manager must check this sale in the store admin.';
60
+
53
61
  /** The per-sale sync notices OrdersList shows under each order, for an app's own order screen. */
54
62
  export function OrderSyncNotices({ order, stuck, children }: OrderSyncNoticesProps) {
55
63
  const formatMoney = useFormatMoney();
56
64
  // The order's own stuck entry: its clock and latest reason, not the earliest across all stuck orders.
57
65
  const stuckEntry = order.syncStatus === 'pending' ? stuck?.orders.find((entry) => entry.commandId === order.commandId) : undefined;
66
+ const needsAdminReason = stuckEntry ? needsAdminReasonOf(stuckEntry.reason) : undefined;
67
+ const left = storeOrderLeft(order);
68
+ // #1101: the store created this order, so invalid_payload's "a form the store can't read" would be wrong.
58
69
  const sentence = order.syncStatus === 'rejected'
59
70
  ? order.storeOrderId !== undefined && ['reopen_required', 'revision_conflict'].includes(order.error?.code ?? '')
60
- ? REOPEN_AGAIN_SENTENCE : refusalSentence(order.error?.code)
71
+ ? REOPEN_AGAIN_SENTENCE : refusalSentence(left && order.error?.code === 'invalid_payload' ? 'platform_error' : order.error?.code)
61
72
  : order.syncStatus === 'pending' && order.error?.code === UPDATE_UNSENDABLE ? UPDATE_UNSENDABLE_MESSAGE : undefined;
62
73
  const extras = extrasNotSent(order);
74
+ // #1101: where the till's cancel, or pay of the rest, of the order the refused sale left on the store stands. Done, gone
75
+ // and changed say it in place of the "left" line; refused and sending add to it. The store's code and message never show (#269).
76
+ const kind = order.storeSettlement?.kind;
77
+ const settlement = order.syncStatus === 'rejected' && (kind === 'cancel' || kind === 'pay') ? order.storeSettlement : undefined;
78
+ const reference = left?.reference ?? orderReference(order);
79
+ const money = (amount: number) => formatMoney({ amount, currency: order.currency });
80
+ const sum = (legs: { amountMinor: number }[]) => legs.reduce((total, leg) => total + leg.amountMinor, 0);
81
+ const paidThere = settlement?.capturedMinor ? `: ${money(settlement.capturedMinor)} is paid there` : '';
82
+ // A pay's R: what the store had recorded at the refusal, plus each leg this till has recorded since.
83
+ const recorded = money((left?.recordedMinor ?? 0) + sum(settlement?.payments?.filter((payment) => payment.done) ?? []));
84
+ const cashTaken = sum(order.payments.filter((payment) => payment.method === 'cash'));
85
+ // What this till has recorded on the stored pay, on this press or an earlier one: true in every state.
86
+ const doneMinor = sum(settlement?.payments?.filter((payment) => payment.done) ?? []);
87
+ const nothing = doneMinor > 0 ? `${money(doneMinor)} was recorded from this till.` : 'Nothing was recorded from this till.';
88
+ const settledText = settlement?.kind === 'pay'
89
+ ? settlement.state === 'done' ? `Order #${reference} is paid on the store.`
90
+ : settlement.state === 'gone' ? `Order #${reference} is not on the store any more; ${recorded} was recorded on it.`
91
+ : settlement.state !== 'changed' ? undefined
92
+ : settlement.storeStatus === 'completed' ? `Order #${reference} is already paid on the store. ${nothing}`
93
+ : `Order #${reference} changed on the store${paidThere}. ${nothing} Check it in the store's admin.`
94
+ : settlement?.state === 'done' ? `Order #${reference} was cancelled on the store.${cashTaken
95
+ ? ` If you gave back the ${money(cashTaken)} cash taken on this till, record it as a pay-out.` : ''}`
96
+ : settlement?.state === 'gone' ? `Order #${reference} was removed on the store.`
97
+ : settlement?.state === 'changed' ? `Order #${reference} changed on the store${paidThere}. Nothing was cancelled from this till. Check it in the store's admin.`
98
+ : undefined;
99
+ const pay = settlement?.kind === 'pay';
100
+ const addedText = settlement?.state === 'refused' ? pay
101
+ ? `The store did not record the rest of order #${reference}: ${recorded} of ${money(order.totalMinor)} is recorded there. Check it in the store's admin.`
102
+ : `The store did not cancel order #${reference}. Check it in the store's admin.`
103
+ : settlement?.state === 'sending' ? pay ? `Recording the rest of order #${reference} on the store is not finished.`
104
+ : `Cancelling order #${reference} on the store is not finished.` : undefined;
105
+ // A pay gone with money recorded on the store is not settled (`settledOnStore`): it stays a destructive line.
106
+ const settled = !!settlement && settledOnStore(order);
63
107
  return <>
64
108
  {stuckEntry ? <Text className="text-destructive">
65
- {/* The same words for any reason, with no reason code; the hour as the status line has it (numeric, #245). */}
66
- {`Hasn't reached the online store since ${sinceText(stuckEntry)}.`}
109
+ {/* A parked sale needs a manager; other retries keep the hour as the status line has it (numeric, #245), with no reason code. */}
110
+ {needsAdminReason !== undefined
111
+ ? needsAdminReason === 'session_closed' ? NEEDS_ADMIN_SESSION_CLOSED : NEEDS_ADMIN_SALE
112
+ : `Hasn't reached the online store since ${sinceText(stuckEntry)}.`}
67
113
  </Text> : null}
68
114
  {/* The code's sentence alone: the cashier sees no error code and never the store's message. */}
69
- {sentence ? <Text className="text-destructive">{sentence}</Text> : null}
115
+ {sentence && !settled ? <Text className="text-destructive">{sentence}</Text> : null}
116
+ {settledText ? <Text testID={`order-settlement-${order.id}`} className={settled ? 'text-foreground' : 'text-destructive'}>{settledText}</Text> : null}
117
+ {/* What the store had recorded at the refusal, not the order's state now. */}
118
+ {left && !settledText ? <Text testID={`order-left-on-store-${order.id}`} className="text-destructive">
119
+ {left.recordedMinor === 0
120
+ ? `Order #${left.reference} was left pending on the online store. Nothing was paid there.`
121
+ : `Order #${left.reference} was left part paid on the online store: ${formatMoney({ amount: left.recordedMinor, currency: order.currency })} of ${formatMoney({ amount: order.totalMinor, currency: order.currency })}.`}
122
+ </Text> : null}
123
+ {addedText ? <Text testID={`order-settlement-${order.id}`} className="text-destructive">{addedText}</Text> : null}
70
124
  {/* A late sale (ADR-032) needs no Retry of its own; a rejected one still gets its Retry below. */}
71
125
  {order.lateSessionId !== undefined ? <Text className="text-foreground">Taken after the register closed. It is not in that register's closure.</Text> : null}
72
126
  {order.countedInClosureOf !== undefined ? <Text className="text-foreground">Recorded after the register closed. Its payment is in that register's closure.</Text> : null}
@@ -109,14 +163,24 @@ export function OrderSyncNotices({ order, stuck, children }: OrderSyncNoticesPro
109
163
  * `onReopen` adds Reopen to a Needs attention row the store refused with a reopenable code (`REOPENABLE_CODES`), not yet
110
164
  * reopened and with no store order: the app wires `reopenRefusedOrder`. When it refuses `coupon_carry_inexact` with a
111
165
  * `toCollectMinor`, the row offers "Reopen without the coupon", which calls it again with `{ withoutCoupons: true }`.
112
- * `onResume` adds Resume to a reopened row; the app resumes the parked sale, whose draft id is the order's id. */
113
- export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, footer, stuck, history, onOpen, onReopen, onResume }: {
166
+ * `onResume` adds Resume to a reopened row; the app resumes the parked sale, whose draft id is the order's id.
167
+ * `onCancelOnStore` adds "Cancel order on store" to a Needs attention row whose refused sale left an unpaid order on the
168
+ * store (`canCancelOnStore`, #1101), asked in a confirm dialog first: the app wires `useOrderOutbox`'s `cancelOnStore`.
169
+ * A cancel still `sending` is finished with no dialog. With it, such a row offers no Retry, except an `insufficient_stock`
170
+ * refusal's, which reads "Try the payment again".
171
+ * `onPayRestOnStore` adds "Pay the rest on store" to a Needs attention row whose refused sale left a part-paid order on
172
+ * the store (`canPayRestOnStore`, #1101 slice 3), asked in a confirm dialog naming each leg to record (no money is taken):
173
+ * the app wires `useOrderOutbox`'s `payRestOnStore`. A pay still `sending` is finished with no dialog. With it, a row
174
+ * with money recorded on the store offers no Retry. */
175
+ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, footer, stuck, history, onOpen, onReopen, onResume, onCancelOnStore, onPayRestOnStore }: {
114
176
  orders: PosOrder[]; onRetry(orderIds: string[]): Promise<number>; formatDate?: (iso: string) => string; footer?: ReactNode;
115
177
  stuck?: OutboxState['stuck'];
116
178
  history?: OrderHistoryRow[];
117
179
  onOpen?: (row: PosOrder | OrderHistoryRow) => void;
118
180
  onReopen?: (order: PosOrder, options?: { withoutCoupons: true }) => Promise<void>;
119
181
  onResume?: (order: PosOrder) => void;
182
+ onCancelOnStore?: (order: PosOrder) => Promise<SettleOutcome | { kind: 'not_offered' }>;
183
+ onPayRestOnStore?: (order: PosOrder) => Promise<SettleOutcome | { kind: 'not_offered' }>;
120
184
  }) {
121
185
  const formatMoney = useFormatMoney();
122
186
  const hintId = useId();
@@ -146,6 +210,51 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
146
210
  reopening.current.delete(order.id);
147
211
  }
148
212
  }
213
+ /** Each row's Cancel order on store (#1101): in flight, or the last press got no answer from the store. */
214
+ const cancelling = useRef(new Set<string>());
215
+ const [cancels, setCancels] = useState(new Map<string, 'busy' | 'failed'>());
216
+ const [askingCancel, setAskingCancel] = useState<PosOrder | null>(null);
217
+ const setCancel = (id: string, state?: 'busy' | 'failed') => setCancels((current) => {
218
+ const next = new Map(current);
219
+ if (state) next.set(id, state); else next.delete(id);
220
+ return next;
221
+ });
222
+ async function cancelOnStore(order: PosOrder) {
223
+ if (!onCancelOnStore || cancelling.current.has(order.id)) return;
224
+ cancelling.current.add(order.id);
225
+ setCancel(order.id, 'busy');
226
+ try {
227
+ const outcome = await onCancelOnStore(order);
228
+ setCancel(order.id, outcome.kind === 'retry' ? 'failed' : undefined);
229
+ } catch {
230
+ setCancel(order.id, 'failed');
231
+ } finally {
232
+ cancelling.current.delete(order.id);
233
+ }
234
+ }
235
+ /** Each row's Pay the rest on store (#1101 slice 3): in flight, the last press got no answer from the store, or the store
236
+ * answered that the order is not completed there yet (`not_completed`). */
237
+ const paying = useRef(new Set<string>());
238
+ const [pays, setPays] = useState(new Map<string, 'busy' | 'failed' | 'unfinished'>());
239
+ const [askingPay, setAskingPay] = useState<PosOrder | null>(null);
240
+ const setPay = (id: string, state?: 'busy' | 'failed' | 'unfinished') => setPays((current) => {
241
+ const next = new Map(current);
242
+ if (state) next.set(id, state); else next.delete(id);
243
+ return next;
244
+ });
245
+ async function payRestOnStore(order: PosOrder) {
246
+ if (!onPayRestOnStore || paying.current.has(order.id)) return;
247
+ paying.current.add(order.id);
248
+ setPay(order.id, 'busy');
249
+ try {
250
+ const outcome = await onPayRestOnStore(order);
251
+ setPay(order.id, outcome.kind !== 'retry' ? undefined : outcome.reason === 'not_completed' ? 'unfinished' : 'failed');
252
+ } catch {
253
+ setPay(order.id, 'failed');
254
+ } finally {
255
+ paying.current.delete(order.id);
256
+ }
257
+ }
149
258
  const [expanded, setExpanded] = useState(new Set<string>());
150
259
  useEffect(() => {
151
260
  for (const id of retrying.current) {
@@ -187,6 +296,17 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
187
296
  const reopenable = attention && !!onReopen && order.syncStatus === 'rejected' && REOPENABLE_CODES.includes(order.error?.code ?? '')
188
297
  && order.storeOrderId === undefined && order.reopenedAt === undefined;
189
298
  const reopenState = reopens.get(order.id);
299
+ const cancellable = attention && !!onCancelOnStore && canCancelOnStore(order);
300
+ const cancelState = cancels.get(order.id);
301
+ const finishing = order.storeSettlement?.kind === 'cancel' && order.storeSettlement.state === 'sending';
302
+ // #1101: with the cancel wired, an unpaid order left on the store is cancelled rather than resent, except a stock refusal.
303
+ const left = storeOrderLeft(order);
304
+ const payable = attention && !!onPayRestOnStore && canPayRestOnStore(order);
305
+ const payState = pays.get(order.id);
306
+ const finishingPay = order.storeSettlement?.kind === 'pay' && order.storeSettlement.state === 'sending';
307
+ // #1101 slice 3: with the pay wired, a part-paid order left on the store has its rest recorded, never resent.
308
+ const retryLabel = onPayRestOnStore && left && left.recordedMinor > 0 ? undefined : onCancelOnStore && left?.recordedMinor === 0
309
+ ? order.error?.code === 'insufficient_stock' ? 'Try the payment again' : undefined : 'Retry';
190
310
  return (
191
311
  <View key={order.id} className="gap-1 rounded-md border border-border bg-card p-3">
192
312
  {/* RN-web drops accessibilityHint; aria-describedby carries it on web. */}
@@ -209,7 +329,7 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
209
329
  {isExpanded ? <View testID={`order-detail-${order.id}`} className="mt-1 gap-1 border-t border-border pt-2">
210
330
  {order.lines.map((line) => <Text key={line.id} className="text-foreground">{`${line.quantity} × ${line.name}`}</Text>)}
211
331
  {order.payments.map((payment) => <Text key={payment.id} className="text-muted-foreground">
212
- {`${payment.method === 'cash' ? 'Cash' : 'Card terminal'} ${formatMoney({ amount: payment.amountMinor, currency: order.currency })}${payment.reference ? ` · ${payment.reference}` : ''}`}
332
+ {`${methodLabel(payment.method)} ${formatMoney({ amount: payment.amountMinor, currency: order.currency })}${payment.reference ? ` · ${payment.reference}` : ''}`}
213
333
  </Text>)}
214
334
  {refundDueMinor > 0 ? <Text testID={`order-refund-due-${order.id}`} className="text-foreground">
215
335
  {`Refund due ${formatMoney({ amount: refundDueMinor, currency: order.currency })}`}</Text> : null}
@@ -217,7 +337,7 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
217
337
  </View> : null}
218
338
  <OrderSyncNotices order={order} stuck={stuck}>
219
339
  {/* Retry is offered only for an order the outbox resends (isRequeueableOrder). */}
220
- {section.title === 'Needs attention' && isRequeueableOrder(order)
340
+ {section.title === 'Needs attention' && isRequeueableOrder(order) && retryLabel
221
341
  ? <Pressable accessibilityRole="button" disabled={retryingIds.has(order.id)} onPress={async () => {
222
342
  if (retrying.current.has(order.id)) return;
223
343
  retrying.current.add(order.id);
@@ -227,8 +347,30 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
227
347
  setRetryingIds(new Set(retrying.current));
228
348
  }
229
349
  }} className="rounded-md bg-primary px-4 py-2">
230
- <Text className="text-center font-semibold text-primary-foreground">Retry</Text>
350
+ <Text className="text-center font-semibold text-primary-foreground">{retryLabel}</Text>
231
351
  </Pressable> : null}
352
+ {cancellable ? <Pressable accessibilityRole="button" testID={`order-${order.id}-cancel-on-store`} disabled={cancelState === 'busy'}
353
+ onPress={() => {
354
+ if (cancelling.current.has(order.id)) return;
355
+ if (finishing) void cancelOnStore(order); else setAskingCancel(order);
356
+ }} className="rounded-md border border-border px-4 py-2">
357
+ <Text className="text-center font-semibold text-foreground">
358
+ {cancelState === 'busy' ? 'Cancelling on store…' : finishing ? 'Finish cancelling on store' : 'Cancel order on store'}
359
+ </Text>
360
+ </Pressable> : null}
361
+ {cancellable && cancelState === 'failed' ? <Text testID={`order-${order.id}-cancel-on-store-error`} className="text-muted-foreground">
362
+ Could not reach the store. Try again.</Text> : null}
363
+ {payable ? <Pressable accessibilityRole="button" testID={`order-${order.id}-pay-rest-on-store`} disabled={payState === 'busy'}
364
+ onPress={() => {
365
+ if (paying.current.has(order.id)) return;
366
+ if (finishingPay) void payRestOnStore(order); else setAskingPay(order);
367
+ }} className="rounded-md bg-primary px-4 py-2">
368
+ <Text className="text-center font-semibold text-primary-foreground">
369
+ {payState === 'busy' ? 'Recording on store…' : finishingPay ? 'Finish recording on store' : 'Pay the rest on store'}
370
+ </Text>
371
+ </Pressable> : null}
372
+ {payable && (payState === 'failed' || payState === 'unfinished') ? <Text testID={`order-${order.id}-pay-rest-on-store-error`} className="text-muted-foreground">
373
+ {payState === 'unfinished' ? "The store has not finished this order yet. Try again, or check it in the store's admin." : 'Could not reach the store. Try again.'}</Text> : null}
232
374
  {/* Reopen needs a reopenable code, which Retry never resends (NOT_REQUEUEABLE), so the two never show together. */}
233
375
  {attention && order.reopenedAt !== undefined ? <>
234
376
  <Text testID={`order-${order.id}-reopened`} className="text-muted-foreground">Reopened as a parked sale.</Text>
@@ -258,6 +400,20 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
258
400
  })}
259
401
  </View>
260
402
  ))}
403
+ {askingCancel ? ((reference) => <ConfirmDialog testID={`order-${askingCancel.id}-cancel-on-store-dialog`} tone="destructive" open
404
+ onOpenChange={(open) => { if (!open) setAskingCancel(null); }} title={`Cancel order #${reference} on the store?`}
405
+ description={`Order #${reference} is waiting on the online store with nothing paid. This cancels it there. The payments taken on this till stay as they are.`}
406
+ cancelLabel="Keep order" confirmLabel="Cancel order on store"
407
+ onConfirm={() => { setAskingCancel(null); void cancelOnStore(askingCancel); }} />)(storeOrderLeft(askingCancel)?.reference ?? orderReference(askingCancel)) : null}
408
+ {askingPay ? ((reference, legs, stored) => <ConfirmDialog testID={`order-${askingPay.id}-pay-rest-on-store-dialog`} tone="default" open
409
+ onOpenChange={(open) => { if (!open) setAskingPay(null); }} title={`Record the rest of order #${reference} on the store?`}
410
+ description={[...legs.filter((_leg, index) => !(stored?.kind === 'pay' && stored.payments?.length === legs.length && stored.payments[index].done))
411
+ .map((leg) => `${methodLabel(leg.method)} ${formatMoney({ amount: leg.amountMinor, currency: askingPay.currency })}, already taken on this till.`),
412
+ 'No money is taken now.', GIVE_BACK].join('\n')}
413
+ cancelLabel="Keep as is" confirmLabel="Record on store"
414
+ onConfirm={() => { setAskingPay(null); void payRestOnStore(askingPay); }} />)(storeOrderLeft(askingPay)?.reference ?? orderReference(askingPay),
415
+ // Only the legs still to record: the stored pay is index-aligned with them when the lengths match, as the outbox reuses it.
416
+ unrecordedLegs(askingPay), askingPay.storeSettlement) : null}
261
417
  {footer}
262
418
  </ScrollView>;
263
419
  }
@@ -87,6 +87,7 @@ export function Receipt(props: ReceiptProps) {
87
87
  {/* Charges are not in the subtotal (order.display): they follow it and its discounts, before tax. */}
88
88
  {receipt.fees.map((charge, index) => row(charge.name, money(charge.amountMinor), false, index))}
89
89
  {receipt.shipping.map((charge, index) => row(charge.name, money(charge.amountMinor), false, index))}
90
+ {receipt.rounding ? row(receipt.rounding.name, money(receipt.rounding.amountMinor)) : null}
90
91
  {taxRows}
91
92
  {row('Total', money(totals.totalMinor), true)}
92
93
  {receipt.payments.map((payment, index) => row(payment.method === 'cash' ? 'Cash tendered'
@@ -0,0 +1,10 @@
1
+ import { CASH_NOT_PAYABLE, CASH_PICK_LIMIT, CASH_SETTLE_LIMIT, CASH_WAITS_FOR_PAYMENT, VOID_LATER_CASH_FIRST } from '@tallyui/pos';
2
+ import type { useT } from '../i18n';
3
+ /** The sale's error as the cashier reads it: a core refusal with a catalogue key is translated; any other shows as given. */
4
+ export function saleErrorText(t: ReturnType<typeof useT>, error: string): string {
5
+ return error === VOID_LATER_CASH_FIRST ? t('pos_checkout.void_later_cash_first')
6
+ : error === CASH_NOT_PAYABLE ? t('pos_checkout.cash_not_payable_typed')
7
+ : error === CASH_WAITS_FOR_PAYMENT ? t('pos_checkout.cash_waits_for_payment')
8
+ : error === CASH_PICK_LIMIT ? t('pos_checkout.cash_pick_limit')
9
+ : error === CASH_SETTLE_LIMIT ? t('pos_checkout.cash_settle_limit') : error;
10
+ }
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from 'react';
2
2
  import { AccessibilityInfo, Platform, Text, View } from 'react-native';
3
3
  import type { SyncNotice } from '@tallyui/core';
4
4
  import type { OutboxState } from '@tallyui/pos';
5
+ import { needsAdminReasonOf } from '@tallyui/pos';
5
6
  import { sinceText } from './since-text';
6
7
 
7
8
  /**
@@ -50,6 +51,8 @@ const PULL_NOTICE_FALLBACK: PullNoticeText = {
50
51
  const BACKEND_MISSING = "Sales aren't reaching the online store. Keep selling: they're saved on this till and will send by themselves.";
51
52
  // The same line once an order is stuck, with the store missing or not; {time} is the real first failure or about the virtual since.
52
53
  const BACKEND_MISSING_SINCE = "Sales haven't reached the online store since {time}. Keep selling: they're saved on this till and will send by themselves.";
54
+ // #1280: parked sales keep retrying while a manager finishes them in the store admin.
55
+ const NEEDS_ADMIN_SALES = (n: number) => `${n === 1 ? '1 sale needs' : `${n} sales need`} a manager in the store admin. Keep selling: new sales are saved on this till.`;
53
56
  // The line instead when no sale waits but till updates do, and its "since" variant once registerState.stuck is set.
54
57
  const TILL_UPDATES_MISSING = "Till updates aren't reaching the online store. Keep selling: they're saved on this till and will send by themselves.";
55
58
  const TILL_UPDATES_MISSING_SINCE = "Till updates haven't reached the online store since {time}. Keep selling: they're saved on this till and will send by themselves.";
@@ -115,16 +118,18 @@ export function SyncStatus({ state, registerState, pluginName = 'the POS plugin'
115
118
  const label = [state.pending && count(state.pending, 'sale'),
116
119
  updates && count(updates, 'till update')].filter(Boolean).join(' and ') + ' waiting to sync';
117
120
  const { stuck } = state;
121
+ const needsAdmin = stuck?.orders.filter((entry) => needsAdminReasonOf(entry.reason) !== undefined).length ?? 0;
118
122
  const backendMissing = state.backendMissing ?? registerState?.backendMissing;
119
123
  const backendMissingText = state.pending === 0 && updates > 0 ? (registerState?.stuck
120
124
  ? TILL_UPDATES_MISSING_SINCE.replace('{time}', () => sinceText(registerState.stuck!)) : TILL_UPDATES_MISSING)
121
125
  : stuck ? BACKEND_MISSING_SINCE.replace('{time}', () => sinceText(stuck)) : BACKEND_MISSING;
122
126
  const upToDate = state.pending === 0 && updates === 0;
123
127
  // The sentence shows with the store missing, or once the waiting sales (with none waiting, the till updates) are stuck, then as
124
- // its "since" variant: the same words for any reason, and no reason code.
128
+ // its "since" variant, unless a parked sale needs a manager; no reason code is shown.
125
129
  // A refused batch from the outbox shown (the sales', whenever a sale waits) replaces that sentence: it is the store's latest
126
130
  // answer, and sending waits for that outbox's next command or start.
127
131
  const sentence = outbox.refused ? ` · ${outbox === state ? SALES_REFUSED : TILL_UPDATES_REFUSED}`
132
+ : outbox === state && needsAdmin > 0 ? ` · ${NEEDS_ADMIN_SALES(needsAdmin)}`
128
133
  : backendMissing || (state.pending === 0 && updates > 0 ? registerState?.stuck : stuck) ? ` · ${backendMissingText}` : '';
129
134
  // The live region holds only the substance (counts and the sentence), so it is announced when that changes and never as sending
130
135
  // or retrying flips or the countdown ticks: those are a short line of their own below it, outside any live region.