@tallyui/components 4.0.0 → 4.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 +10 -2
- package/dist/index.js +89 -14
- package/package.json +9 -9
- package/src/sale/held-leg.ts +6 -0
- package/src/sale/line-popover.tsx +2 -1
- package/src/sale/orders-list.tsx +62 -3
- package/src/sale/tender-ledger.tsx +2 -1
- package/src/sale/tender-pane.tsx +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -3193,8 +3193,12 @@ declare function OrderSyncNotices({ order, stuck, children }: OrderSyncNoticesPr
|
|
|
3193
3193
|
* (medusapos: the feedback link). The router and session redirect stay in the app. `stuck` is the outbox's
|
|
3194
3194
|
* `state.stuck` (`useOrderOutbox`): those pending orders need attention too, each with its own entry's reason and since.
|
|
3195
3195
|
* `onOpen` adds an Open button to each row that passes its order to the app.
|
|
3196
|
-
* `history` adds read-only store order rows to Recent (ADR-052 amendment 1).
|
|
3197
|
-
|
|
3196
|
+
* `history` adds read-only store order rows to Recent (ADR-052 amendment 1).
|
|
3197
|
+
* `onReopen` adds Reopen to a Needs attention row the store refused with a reopenable code (`REOPENABLE_CODES`), not yet
|
|
3198
|
+
* reopened and with no store order: the app wires `reopenRefusedOrder`. When it refuses `coupon_carry_inexact` with a
|
|
3199
|
+
* `toCollectMinor`, the row offers "Reopen without the coupon", which calls it again with `{ withoutCoupons: true }`.
|
|
3200
|
+
* `onResume` adds Resume to a reopened row; the app resumes the parked sale, whose draft id is the order's id. */
|
|
3201
|
+
declare function OrdersList({ orders, onRetry, formatDate, footer, stuck, history, onOpen, onReopen, onResume }: {
|
|
3198
3202
|
orders: PosOrder[];
|
|
3199
3203
|
onRetry(orderIds: string[]): Promise<number>;
|
|
3200
3204
|
formatDate?: (iso: string) => string;
|
|
@@ -3202,6 +3206,10 @@ declare function OrdersList({ orders, onRetry, formatDate, footer, stuck, histor
|
|
|
3202
3206
|
stuck?: OutboxState['stuck'];
|
|
3203
3207
|
history?: OrderHistoryRow[];
|
|
3204
3208
|
onOpen?: (row: PosOrder | OrderHistoryRow) => void;
|
|
3209
|
+
onReopen?: (order: PosOrder, options?: {
|
|
3210
|
+
withoutCoupons: true;
|
|
3211
|
+
}) => Promise<void>;
|
|
3212
|
+
onResume?: (order: PosOrder) => void;
|
|
3205
3213
|
}): react_jsx_runtime.JSX.Element;
|
|
3206
3214
|
|
|
3207
3215
|
/** Pass `useParkedSales(drafts)`'s `parked` and `discard`, or your own parked store's list and handlers (`onPark`, `onResume`, `onDiscard`) with the same results. */
|
package/dist/index.js
CHANGED
|
@@ -10053,6 +10053,7 @@ function LinePopover({
|
|
|
10053
10053
|
onEscapeKeyDown: () => {
|
|
10054
10054
|
discard.current = true;
|
|
10055
10055
|
},
|
|
10056
|
+
pointerEvents: open ? "auto" : "none",
|
|
10056
10057
|
children: /* @__PURE__ */ jsx170(
|
|
10057
10058
|
Animated9.View,
|
|
10058
10059
|
{
|
|
@@ -10192,6 +10193,11 @@ import { useFormatMoney as useFormatMoney20, wireMethodOf as wireMethodOf2 } fro
|
|
|
10192
10193
|
import { canVoidLeg, countsTowardPaid, legStatus } from "@tallyui/pos";
|
|
10193
10194
|
import { cn as cn112 } from "@tallyui/theme";
|
|
10194
10195
|
|
|
10196
|
+
// src/sale/held-leg.ts
|
|
10197
|
+
function heldTillLeg(order, leg) {
|
|
10198
|
+
return !!leg.locked || !!leg.reopened || !!order.afterClose?.payments.some((p) => p.id === leg.id);
|
|
10199
|
+
}
|
|
10200
|
+
|
|
10195
10201
|
// src/sale/offered-methods.ts
|
|
10196
10202
|
import { defaultPaymentMethods, wireMethodOf } from "@tallyui/core";
|
|
10197
10203
|
function offeredMethods(methods) {
|
|
@@ -10246,7 +10252,7 @@ function TenderLedger({ sale, methods, closing = false, confirmVoid = false }) {
|
|
|
10246
10252
|
] }),
|
|
10247
10253
|
leg.reference ? /* @__PURE__ */ jsx172(Text46, { className: "text-sm text-muted-foreground", children: leg.reference }) : null,
|
|
10248
10254
|
leg === firstPending ? /* @__PURE__ */ jsx172(Text46, { className: "text-sm text-muted-foreground", children: t("pos_checkout.next_leg") }) : null,
|
|
10249
|
-
descriptor && canVoidLeg(leg, descriptor) ? /* @__PURE__ */ jsx172(
|
|
10255
|
+
descriptor && canVoidLeg(leg, descriptor) && !heldTillLeg(order, leg) ? /* @__PURE__ */ jsx172(
|
|
10250
10256
|
Pressable46,
|
|
10251
10257
|
{
|
|
10252
10258
|
testID: `tender-leg-${leg.id}-void`,
|
|
@@ -10884,7 +10890,7 @@ function TenderPane({ sale, state, dispatch, methods, ledger = true, back = true
|
|
|
10884
10890
|
const chips = givesChange ? quickTenderedAmounts2(dueMinor, QUICK_CASH_STEPS.map((step) => step * 10 ** minorUnitDigits11(order.currency))) : [];
|
|
10885
10891
|
const balanceChip = method !== null && !givesChange && state.entryMode !== "percent" ? dueMinor : null;
|
|
10886
10892
|
const [onlyLeg] = order.payments;
|
|
10887
|
-
const cardReference = order.payments.length === 1 && onlyLeg.method === "external" && legStatus2(onlyLeg) === "captured" && balance === 0;
|
|
10893
|
+
const cardReference = order.payments.length === 1 && onlyLeg.method === "external" && legStatus2(onlyLeg) === "captured" && balance === 0 && !heldTillLeg(order, onlyLeg);
|
|
10888
10894
|
const hint = partPick ? pickRefused || entry === target ? t("pos_checkout.pick_amount_due", { amount: money(target) }) : givesChange && entry > target ? t("pos_checkout.change_due", { amount: money(entry - target) }) : "" : pickRefused ? t("pos_checkout.pick_amount_due", { amount: money(figures.roundedDueMinor) }) : noChange ? t("pos_checkout.no_change_for_method", { amount: money(balance), method: method?.title }) : entryChange > 0 ? t("pos_checkout.change_due", { amount: money(entryChange) }) : figures.appliedMinor < balance && figures.entryMinor > 0 ? t("pos_checkout.part_payment_left", { left: money(left) }) : "";
|
|
10889
10895
|
const refused = tillLegsTheStoreRefuses(order);
|
|
10890
10896
|
const refusedMinor = order.payments.filter((leg) => refused.includes(leg.id)).reduce((total, leg) => total + leg.amountMinor, 0);
|
|
@@ -11052,7 +11058,7 @@ function TenderPane({ sale, state, dispatch, methods, ledger = true, back = true
|
|
|
11052
11058
|
] }) : null,
|
|
11053
11059
|
refused.length > 0 ? /* @__PURE__ */ jsxs114(Fragment41, { children: [
|
|
11054
11060
|
/* @__PURE__ */ jsx177(Text49, { testID: "tender-store-holds", className: "text-foreground", children: t("pos_checkout.store_holds_payment", { amount: money(refusedMinor) }) }),
|
|
11055
|
-
refused.map((id) => /* @__PURE__ */ jsx177(Pressable49, { testID: `tender-leg-${id}-remove`, accessibilityRole: "button", onPress: () => sale.removeTender(id), className: button5, children: /* @__PURE__ */ jsx177(Text49, { className: "text-center text-foreground", children: t("pos_checkout.remove_payment") }) }, id))
|
|
11061
|
+
refused.filter((id) => !order.payments.some((leg) => leg.id === id && heldTillLeg(order, leg))).map((id) => /* @__PURE__ */ jsx177(Pressable49, { testID: `tender-leg-${id}-remove`, accessibilityRole: "button", onPress: () => sale.removeTender(id), className: button5, children: /* @__PURE__ */ jsx177(Text49, { className: "text-center text-foreground", children: t("pos_checkout.remove_payment") }) }, id))
|
|
11056
11062
|
] }) : null,
|
|
11057
11063
|
/* @__PURE__ */ jsx177(
|
|
11058
11064
|
Pressable49,
|
|
@@ -12389,7 +12395,7 @@ function SyncStatus({ state, registerState, pluginName = "the POS plugin", pullN
|
|
|
12389
12395
|
import { useEffect as useEffect24, useId as useId4, useRef as useRef26, useState as useState56 } from "react";
|
|
12390
12396
|
import { Pressable as Pressable55, ScrollView as ScrollView23, Text as Text57, View as View116 } from "react-native";
|
|
12391
12397
|
import { useFormatMoney as useFormatMoney25, knownWarnings } from "@tallyui/core";
|
|
12392
|
-
import { extrasNotSent, isRequeueableOrder, needsAttention, noteDelivery as noteDelivery2, refundDueOf, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE } from "@tallyui/pos";
|
|
12398
|
+
import { extrasNotSent, isRequeueableOrder, needsAttention, noteDelivery as noteDelivery2, refundDueOf, REOPENABLE_CODES, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE } from "@tallyui/pos";
|
|
12393
12399
|
import { Fragment as Fragment48, jsx as jsx188, jsxs as jsxs124 } from "react/jsx-runtime";
|
|
12394
12400
|
var STATUS_LABEL2 = { pending: "Waiting to sync", applied: "Synced", rejected: "Not accepted" };
|
|
12395
12401
|
var FIGURE_LABELS = /* @__PURE__ */ new Map([["subtotalMinor", "Subtotal"], ["taxMinor", "Tax"], ["discountMinor", "Discount"]]);
|
|
@@ -12405,7 +12411,9 @@ var REFUSAL_SENTENCES = /* @__PURE__ */ new Map([
|
|
|
12405
12411
|
["unknown_variant", "The online store refused this sale: that product variation no longer exists."],
|
|
12406
12412
|
["invalid_quantity", "The online store refused this sale: a quantity or a discount on it isn't allowed."],
|
|
12407
12413
|
["underpaid", "The online store refused this sale: the payments add up to less than the total."],
|
|
12408
|
-
["unsupported_currency", "The online store refused this sale: the store doesn't take this currency."]
|
|
12414
|
+
["unsupported_currency", "The online store refused this sale: the store doesn't take this currency."],
|
|
12415
|
+
["coupon_invalid", "The online store refused this sale: a coupon on it isn't valid now. Reopen it to sell it again."],
|
|
12416
|
+
["total_mismatch", "The online store refused this sale: its total didn't match the store's. Reopen it to sell it again."]
|
|
12409
12417
|
]);
|
|
12410
12418
|
var refusalSentence = (code) => REFUSAL_SENTENCES.get(code ?? "") ?? REFUSAL_SENTENCES.get("platform_error");
|
|
12411
12419
|
var 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.";
|
|
@@ -12432,11 +12440,34 @@ function OrderSyncNotices({ order, stuck, children }) {
|
|
|
12432
12440
|
knownWarnings(order.warnings).filter((warning) => warning.code !== "register_session_unknown").map((warning, index) => /* @__PURE__ */ jsx188(View116, { className: "border-l-4 border-warning pl-2", children: /* @__PURE__ */ jsx188(Text57, { className: "text-foreground", children: warning.code === "insufficient_stock" ? `${warning.quantity} sold without stock: ${order.lines.find((line) => line.variantId === warning.variantId)?.name}` : warning.code === "tax_rate_mismatch" ? `Tax at ${(warning.ratePpm / 1e4).toLocaleString(void 0, { maximumFractionDigits: 4 })}%: store ${formatMoney2({ amount: warning.serverMinor, currency: order.currency })} vs POS ${formatMoney2({ amount: warning.expectedMinor, currency: order.currency })}` : warning.code === "customer_ignored" ? `The online store didn't recognise the customer on this sale, so it was saved as a guest sale. Customer id: ${warning.customerId}.` : warning.code === "figures_mismatch" ? `The online store worked out different figures for this sale. ${warning.fields.map(({ field, tillMinor, serverMinor }) => `${FIGURE_LABELS.get(field) ?? field}: till ${formatMoney2({ amount: tillMinor, currency: order.currency })}, store ${formatMoney2({ amount: serverMinor, currency: order.currency })}.`).join(" ")}` : warning.code === "line_figures_mismatch" ? ((n) => `The online store worked out different figures for ${n === 1 ? "one line" : `${n} lines`} of this sale.`)(new Set(warning.lines.map((line) => line.lineId)).size) : warning.bridgeMinor !== void 0 ? `Store calculated ${formatMoney2({ amount: warning.serverMinor, currency: order.currency })}; a rounding line of ${warning.bridgeMinor > 0 ? "+" : ""}${formatMoney2({ amount: warning.bridgeMinor, currency: order.currency })} brought it to ${formatMoney2({ amount: warning.expectedMinor, currency: order.currency })}` : `Store total ${formatMoney2({ amount: warning.serverMinor, currency: order.currency })} vs POS ${formatMoney2({ amount: warning.expectedMinor, currency: order.currency })}` }) }, index))
|
|
12433
12441
|
] });
|
|
12434
12442
|
}
|
|
12435
|
-
function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer, stuck, history, onOpen }) {
|
|
12443
|
+
function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer, stuck, history, onOpen, onReopen, onResume }) {
|
|
12436
12444
|
const formatMoney2 = useFormatMoney25();
|
|
12437
12445
|
const hintId = useId4();
|
|
12438
12446
|
const retrying = useRef26(/* @__PURE__ */ new Set());
|
|
12439
12447
|
const [retryingIds, setRetryingIds] = useState56(/* @__PURE__ */ new Set());
|
|
12448
|
+
const reopening = useRef26(/* @__PURE__ */ new Set());
|
|
12449
|
+
const [reopens, setReopens] = useState56(/* @__PURE__ */ new Map());
|
|
12450
|
+
const setReopen = (id, state) => setReopens((current) => {
|
|
12451
|
+
const next = new Map(current);
|
|
12452
|
+
if (state) next.set(id, state);
|
|
12453
|
+
else next.delete(id);
|
|
12454
|
+
return next;
|
|
12455
|
+
});
|
|
12456
|
+
async function reopen(order, options) {
|
|
12457
|
+
if (!onReopen || reopening.current.has(order.id)) return;
|
|
12458
|
+
reopening.current.add(order.id);
|
|
12459
|
+
setReopen(order.id, { ...reopens.get(order.id), busy: true });
|
|
12460
|
+
try {
|
|
12461
|
+
await onReopen(order, options);
|
|
12462
|
+
setReopen(order.id);
|
|
12463
|
+
} catch (error) {
|
|
12464
|
+
const reason = error?.reason;
|
|
12465
|
+
const toCollectMinor = error?.toCollectMinor;
|
|
12466
|
+
setReopen(order.id, reason === "coupon_carry_inexact" && typeof toCollectMinor === "number" ? { toCollectMinor } : { failed: typeof reason === "string" ? reason : null });
|
|
12467
|
+
} finally {
|
|
12468
|
+
reopening.current.delete(order.id);
|
|
12469
|
+
}
|
|
12470
|
+
}
|
|
12440
12471
|
const [expanded, setExpanded] = useState56(/* @__PURE__ */ new Set());
|
|
12441
12472
|
useEffect24(() => {
|
|
12442
12473
|
for (const id of retrying.current) {
|
|
@@ -12485,6 +12516,9 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
12485
12516
|
const refundDueMinor = refundDueOf(order);
|
|
12486
12517
|
const key = `${section.title}:${order.id}`;
|
|
12487
12518
|
const isExpanded = expanded.has(key);
|
|
12519
|
+
const attention = section.title === "Needs attention";
|
|
12520
|
+
const reopenable = attention && !!onReopen && order.syncStatus === "rejected" && REOPENABLE_CODES.includes(order.error?.code ?? "") && order.storeOrderId === void 0 && order.reopenedAt === void 0;
|
|
12521
|
+
const reopenState = reopens.get(order.id);
|
|
12488
12522
|
return /* @__PURE__ */ jsxs124(View116, { className: "gap-1 rounded-md border border-border bg-card p-3", children: [
|
|
12489
12523
|
/* @__PURE__ */ jsx188(Text57, { id: `${hintId}-${sectionIndex}-${order.id}`, className: "hidden", children: "Shows the items and payments of this sale" }),
|
|
12490
12524
|
/* @__PURE__ */ jsxs124(
|
|
@@ -12531,15 +12565,56 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
12531
12565
|
refundDueMinor > 0 ? /* @__PURE__ */ jsx188(Text57, { testID: `order-refund-due-${order.id}`, className: "text-foreground", children: `Refund due ${formatMoney2({ amount: refundDueMinor, currency: order.currency })}` }) : null,
|
|
12532
12566
|
order.note ? /* @__PURE__ */ jsx188(Text57, { testID: `order-note-${order.id}`, className: "text-foreground", children: `Customer note: ${order.note}` }) : null
|
|
12533
12567
|
] }) : null,
|
|
12534
|
-
/* @__PURE__ */
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
if (await onRetry([order.id]) === 0) {
|
|
12539
|
-
retrying.current.delete(order.id);
|
|
12568
|
+
/* @__PURE__ */ jsxs124(OrderSyncNotices, { order, stuck, children: [
|
|
12569
|
+
section.title === "Needs attention" && isRequeueableOrder(order) ? /* @__PURE__ */ jsx188(Pressable55, { accessibilityRole: "button", disabled: retryingIds.has(order.id), onPress: async () => {
|
|
12570
|
+
if (retrying.current.has(order.id)) return;
|
|
12571
|
+
retrying.current.add(order.id);
|
|
12540
12572
|
setRetryingIds(new Set(retrying.current));
|
|
12541
|
-
|
|
12542
|
-
|
|
12573
|
+
if (await onRetry([order.id]) === 0) {
|
|
12574
|
+
retrying.current.delete(order.id);
|
|
12575
|
+
setRetryingIds(new Set(retrying.current));
|
|
12576
|
+
}
|
|
12577
|
+
}, className: "rounded-md bg-primary px-4 py-2", children: /* @__PURE__ */ jsx188(Text57, { className: "text-center font-semibold text-primary-foreground", children: "Retry" }) }) : null,
|
|
12578
|
+
attention && order.reopenedAt !== void 0 ? /* @__PURE__ */ jsxs124(Fragment48, { children: [
|
|
12579
|
+
/* @__PURE__ */ jsx188(Text57, { testID: `order-${order.id}-reopened`, className: "text-muted-foreground", children: "Reopened as a parked sale." }),
|
|
12580
|
+
onResume ? /* @__PURE__ */ jsx188(
|
|
12581
|
+
Pressable55,
|
|
12582
|
+
{
|
|
12583
|
+
accessibilityRole: "button",
|
|
12584
|
+
accessibilityLabel: `Resume order ${orderReference(order)}`,
|
|
12585
|
+
testID: `order-${order.id}-resume`,
|
|
12586
|
+
onPress: () => onResume(order),
|
|
12587
|
+
className: "rounded-md bg-primary px-4 py-2",
|
|
12588
|
+
children: /* @__PURE__ */ jsx188(Text57, { className: "text-center font-semibold text-primary-foreground", children: "Resume" })
|
|
12589
|
+
}
|
|
12590
|
+
) : null
|
|
12591
|
+
] }) : null,
|
|
12592
|
+
reopenable && reopenState?.failed !== void 0 ? /* @__PURE__ */ jsx188(Text57, { testID: `order-${order.id}-reopen-error`, className: "text-muted-foreground", children: reopenState.failed ? `This sale can't be reopened here (${reopenState.failed}).` : "This sale can't be reopened here." }) : reopenable ? /* @__PURE__ */ jsxs124(Fragment48, { children: [
|
|
12593
|
+
/* @__PURE__ */ jsx188(
|
|
12594
|
+
Pressable55,
|
|
12595
|
+
{
|
|
12596
|
+
accessibilityRole: "button",
|
|
12597
|
+
accessibilityLabel: `Reopen order ${orderReference(order)}`,
|
|
12598
|
+
testID: `order-${order.id}-reopen`,
|
|
12599
|
+
disabled: reopenState?.busy,
|
|
12600
|
+
onPress: () => reopen(order),
|
|
12601
|
+
className: "rounded-md bg-primary px-4 py-2",
|
|
12602
|
+
children: /* @__PURE__ */ jsx188(Text57, { className: "text-center font-semibold text-primary-foreground", children: "Reopen" })
|
|
12603
|
+
}
|
|
12604
|
+
),
|
|
12605
|
+
reopenState?.toCollectMinor !== void 0 ? /* @__PURE__ */ jsx188(
|
|
12606
|
+
Pressable55,
|
|
12607
|
+
{
|
|
12608
|
+
accessibilityRole: "button",
|
|
12609
|
+
testID: `order-${order.id}-reopen-without-coupon`,
|
|
12610
|
+
disabled: reopenState.busy,
|
|
12611
|
+
onPress: () => reopen(order, { withoutCoupons: true }),
|
|
12612
|
+
className: "rounded-md border border-border px-4 py-2",
|
|
12613
|
+
children: /* @__PURE__ */ jsx188(Text57, { className: "text-center font-semibold text-foreground", children: `Reopen without the coupon: ${formatMoney2({ amount: reopenState.toCollectMinor, currency: order.currency })} to collect` })
|
|
12614
|
+
}
|
|
12615
|
+
) : null
|
|
12616
|
+
] }) : null
|
|
12617
|
+
] })
|
|
12543
12618
|
] }, order.id);
|
|
12544
12619
|
})
|
|
12545
12620
|
] }, section.title)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tallyui/components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Universal POS UI components for Tally UI",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"directory": "packages/components"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tallyui/core": "^4.
|
|
32
|
-
"@tallyui/primitives": "^4.
|
|
33
|
-
"@tallyui/theme": "^4.
|
|
31
|
+
"@tallyui/core": "^4.1.0",
|
|
32
|
+
"@tallyui/primitives": "^4.1.0",
|
|
33
|
+
"@tallyui/theme": "^4.1.0",
|
|
34
34
|
"react": ">=18",
|
|
35
35
|
"react-native": ">=0.74",
|
|
36
36
|
"react-native-svg": ">=15"
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"class-variance-authority": "^0.7.1",
|
|
40
40
|
"i18next": "^26.7.1",
|
|
41
41
|
"react-i18next": "^17.1.12",
|
|
42
|
-
"@tallyui/pos": "4.
|
|
42
|
+
"@tallyui/pos": "4.1.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@tallyui/connector-medusa": "4.
|
|
46
|
-
"@tallyui/connector-vendure": "4.
|
|
47
|
-
"@tallyui/connector-woocommerce": "4.
|
|
48
|
-
"@tallyui/mock-api": "4.
|
|
45
|
+
"@tallyui/connector-medusa": "4.1.0",
|
|
46
|
+
"@tallyui/connector-vendure": "4.1.0",
|
|
47
|
+
"@tallyui/connector-woocommerce": "4.1.0",
|
|
48
|
+
"@tallyui/mock-api": "4.1.0",
|
|
49
49
|
"@types/react": ">=18",
|
|
50
50
|
"react": "^19.2.4",
|
|
51
51
|
"react-native-svg": "15.12.1",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Order } from '@tallyui/pos';
|
|
2
|
+
|
|
3
|
+
/** Money taken before this sale was reopened, or that the store holds: the till never voids, removes or re-references it (desk 2026-11-21). */
|
|
4
|
+
export function heldTillLeg(order: Order, leg: Order['payments'][number]): boolean {
|
|
5
|
+
return !!leg.locked || !!leg.reopened || !!order.afterClose?.payments.some((p) => p.id === leg.id);
|
|
6
|
+
}
|
|
@@ -124,7 +124,8 @@ export function LinePopover({ kind, lineName, currency, value, onApply, quickDis
|
|
|
124
124
|
{mounted ? <Popover.Portal forceMount>
|
|
125
125
|
<Popover.Overlay testID={`${kind}-popover-overlay`} style={StyleSheet.absoluteFill} />
|
|
126
126
|
<Popover.Content forceMount testID={`${kind}-popover`} align={price ? 'end' : 'start'} sideOffset={4}
|
|
127
|
-
aria-labelledby={titleId} aria-describedby={undefined} onEscapeKeyDown={() => { discard.current = true; }}
|
|
127
|
+
aria-labelledby={titleId} aria-describedby={undefined} onEscapeKeyDown={() => { discard.current = true; }}
|
|
128
|
+
pointerEvents={open ? 'auto' : 'none'}>
|
|
128
129
|
<Animated.View className="w-64 rounded-md border border-border bg-popover p-4 shadow-md"
|
|
129
130
|
style={{ opacity: panel, transform: Platform.OS === 'web' ? [{ translateY: panel.interpolate({ inputRange: [0, 1], outputRange: [-6, 0] }) }] : undefined }}
|
|
130
131
|
pointerEvents={open ? 'auto' : 'none'}>
|
package/src/sale/orders-list.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useId, useRef, useState, type ReactNode } from 'react';
|
|
2
2
|
import { Pressable, ScrollView, Text, View } from 'react-native';
|
|
3
3
|
import { useFormatMoney, knownWarnings } from '@tallyui/core';
|
|
4
|
-
import { extrasNotSent, isRequeueableOrder, needsAttention, noteDelivery, refundDueOf, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE, type OutboxState, type PosOrder } from '@tallyui/pos';
|
|
4
|
+
import { extrasNotSent, isRequeueableOrder, needsAttention, noteDelivery, refundDueOf, REOPENABLE_CODES, 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
7
|
|
|
@@ -29,6 +29,8 @@ const REFUSAL_SENTENCES = new Map([
|
|
|
29
29
|
['invalid_quantity', "The online store refused this sale: a quantity or a discount on it isn't allowed."],
|
|
30
30
|
['underpaid', 'The online store refused this sale: the payments add up to less than the total.'],
|
|
31
31
|
['unsupported_currency', "The online store refused this sale: the store doesn't take this currency."],
|
|
32
|
+
['coupon_invalid', "The online store refused this sale: a coupon on it isn't valid now. Reopen it to sell it again."],
|
|
33
|
+
['total_mismatch', "The online store refused this sale: its total didn't match the store's. Reopen it to sell it again."],
|
|
32
34
|
]);
|
|
33
35
|
// Any other code, or none: platform_error's sentence, as the generic fallback (approved by the Front desk, 2026-09-30).
|
|
34
36
|
const refusalSentence = (code: string | undefined) => REFUSAL_SENTENCES.get(code ?? '') ?? REFUSAL_SENTENCES.get('platform_error')!;
|
|
@@ -103,17 +105,47 @@ export function OrderSyncNotices({ order, stuck, children }: OrderSyncNoticesPro
|
|
|
103
105
|
* (medusapos: the feedback link). The router and session redirect stay in the app. `stuck` is the outbox's
|
|
104
106
|
* `state.stuck` (`useOrderOutbox`): those pending orders need attention too, each with its own entry's reason and since.
|
|
105
107
|
* `onOpen` adds an Open button to each row that passes its order to the app.
|
|
106
|
-
* `history` adds read-only store order rows to Recent (ADR-052 amendment 1).
|
|
107
|
-
|
|
108
|
+
* `history` adds read-only store order rows to Recent (ADR-052 amendment 1).
|
|
109
|
+
* `onReopen` adds Reopen to a Needs attention row the store refused with a reopenable code (`REOPENABLE_CODES`), not yet
|
|
110
|
+
* reopened and with no store order: the app wires `reopenRefusedOrder`. When it refuses `coupon_carry_inexact` with a
|
|
111
|
+
* `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 }: {
|
|
108
114
|
orders: PosOrder[]; onRetry(orderIds: string[]): Promise<number>; formatDate?: (iso: string) => string; footer?: ReactNode;
|
|
109
115
|
stuck?: OutboxState['stuck'];
|
|
110
116
|
history?: OrderHistoryRow[];
|
|
111
117
|
onOpen?: (row: PosOrder | OrderHistoryRow) => void;
|
|
118
|
+
onReopen?: (order: PosOrder, options?: { withoutCoupons: true }) => Promise<void>;
|
|
119
|
+
onResume?: (order: PosOrder) => void;
|
|
112
120
|
}) {
|
|
113
121
|
const formatMoney = useFormatMoney();
|
|
114
122
|
const hintId = useId();
|
|
115
123
|
const retrying = useRef(new Set<string>());
|
|
116
124
|
const [retryingIds, setRetryingIds] = useState(new Set<string>());
|
|
125
|
+
/** Each row's Reopen: in flight, the inexact refusal's amount to collect, or the reason it was refused (null: none given). */
|
|
126
|
+
const reopening = useRef(new Set<string>());
|
|
127
|
+
const [reopens, setReopens] = useState(new Map<string, { busy?: true; toCollectMinor?: number; failed?: string | null }>());
|
|
128
|
+
const setReopen = (id: string, state?: { busy?: true; toCollectMinor?: number; failed?: string | null }) => setReopens((current) => {
|
|
129
|
+
const next = new Map(current);
|
|
130
|
+
if (state) next.set(id, state); else next.delete(id);
|
|
131
|
+
return next;
|
|
132
|
+
});
|
|
133
|
+
async function reopen(order: PosOrder, options?: { withoutCoupons: true }) {
|
|
134
|
+
if (!onReopen || reopening.current.has(order.id)) return;
|
|
135
|
+
reopening.current.add(order.id);
|
|
136
|
+
setReopen(order.id, { ...reopens.get(order.id), busy: true });
|
|
137
|
+
try {
|
|
138
|
+
await onReopen(order, options);
|
|
139
|
+
setReopen(order.id);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
const reason = (error as { reason?: unknown } | undefined)?.reason;
|
|
142
|
+
const toCollectMinor = (error as { toCollectMinor?: unknown } | undefined)?.toCollectMinor;
|
|
143
|
+
setReopen(order.id, reason === 'coupon_carry_inexact' && typeof toCollectMinor === 'number' ? { toCollectMinor }
|
|
144
|
+
: { failed: typeof reason === 'string' ? reason : null });
|
|
145
|
+
} finally {
|
|
146
|
+
reopening.current.delete(order.id);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
117
149
|
const [expanded, setExpanded] = useState(new Set<string>());
|
|
118
150
|
useEffect(() => {
|
|
119
151
|
for (const id of retrying.current) {
|
|
@@ -151,6 +183,10 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
|
|
|
151
183
|
const refundDueMinor = refundDueOf(order);
|
|
152
184
|
const key = `${section.title}:${order.id}`;
|
|
153
185
|
const isExpanded = expanded.has(key);
|
|
186
|
+
const attention = section.title === 'Needs attention';
|
|
187
|
+
const reopenable = attention && !!onReopen && order.syncStatus === 'rejected' && REOPENABLE_CODES.includes(order.error?.code ?? '')
|
|
188
|
+
&& order.storeOrderId === undefined && order.reopenedAt === undefined;
|
|
189
|
+
const reopenState = reopens.get(order.id);
|
|
154
190
|
return (
|
|
155
191
|
<View key={order.id} className="gap-1 rounded-md border border-border bg-card p-3">
|
|
156
192
|
{/* RN-web drops accessibilityHint; aria-describedby carries it on web. */}
|
|
@@ -193,6 +229,29 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
|
|
|
193
229
|
}} className="rounded-md bg-primary px-4 py-2">
|
|
194
230
|
<Text className="text-center font-semibold text-primary-foreground">Retry</Text>
|
|
195
231
|
</Pressable> : null}
|
|
232
|
+
{/* Reopen needs a reopenable code, which Retry never resends (NOT_REQUEUEABLE), so the two never show together. */}
|
|
233
|
+
{attention && order.reopenedAt !== undefined ? <>
|
|
234
|
+
<Text testID={`order-${order.id}-reopened`} className="text-muted-foreground">Reopened as a parked sale.</Text>
|
|
235
|
+
{onResume ? <Pressable accessibilityRole="button" accessibilityLabel={`Resume order ${orderReference(order)}`}
|
|
236
|
+
testID={`order-${order.id}-resume`} onPress={() => onResume(order)} className="rounded-md bg-primary px-4 py-2">
|
|
237
|
+
<Text className="text-center font-semibold text-primary-foreground">Resume</Text>
|
|
238
|
+
</Pressable> : null}
|
|
239
|
+
</> : null}
|
|
240
|
+
{reopenable && reopenState?.failed !== undefined ? <Text testID={`order-${order.id}-reopen-error`} className="text-muted-foreground">
|
|
241
|
+
{reopenState.failed ? `This sale can't be reopened here (${reopenState.failed}).` : "This sale can't be reopened here."}
|
|
242
|
+
</Text> : reopenable ? <>
|
|
243
|
+
<Pressable accessibilityRole="button" accessibilityLabel={`Reopen order ${orderReference(order)}`} testID={`order-${order.id}-reopen`}
|
|
244
|
+
disabled={reopenState?.busy} onPress={() => reopen(order)} className="rounded-md bg-primary px-4 py-2">
|
|
245
|
+
<Text className="text-center font-semibold text-primary-foreground">Reopen</Text>
|
|
246
|
+
</Pressable>
|
|
247
|
+
{/* The inexact carry's choice is offered, never taken (desk 2026-11-21): its amount is the refusal's toCollectMinor. */}
|
|
248
|
+
{reopenState?.toCollectMinor !== undefined ? <Pressable accessibilityRole="button" testID={`order-${order.id}-reopen-without-coupon`}
|
|
249
|
+
disabled={reopenState.busy} onPress={() => reopen(order, { withoutCoupons: true })} className="rounded-md border border-border px-4 py-2">
|
|
250
|
+
<Text className="text-center font-semibold text-foreground">
|
|
251
|
+
{`Reopen without the coupon: ${formatMoney({ amount: reopenState.toCollectMinor, currency: order.currency })} to collect`}
|
|
252
|
+
</Text>
|
|
253
|
+
</Pressable> : null}
|
|
254
|
+
</> : null}
|
|
196
255
|
</OrderSyncNotices>
|
|
197
256
|
</View>
|
|
198
257
|
);
|
|
@@ -10,6 +10,7 @@ import { canVoidLeg, countsTowardPaid, legStatus, type PaymentLegStatus, type us
|
|
|
10
10
|
import { cn } from '@tallyui/theme';
|
|
11
11
|
import { useT } from '../i18n';
|
|
12
12
|
import { ConfirmDialog } from '../ui/confirm-dialog';
|
|
13
|
+
import { heldTillLeg } from './held-leg';
|
|
13
14
|
import { offeredMethods } from './offered-methods';
|
|
14
15
|
|
|
15
16
|
/** v2 labels.ts statusLabel, as catalogue keys. */
|
|
@@ -59,7 +60,7 @@ export function TenderLedger({ sale, methods, closing = false, confirmVoid = fal
|
|
|
59
60
|
</View>
|
|
60
61
|
{leg.reference ? <Text className="text-sm text-muted-foreground">{leg.reference}</Text> : null}
|
|
61
62
|
{leg === firstPending ? <Text className="text-sm text-muted-foreground">{t('pos_checkout.next_leg')}</Text> : null}
|
|
62
|
-
{descriptor && canVoidLeg(leg, descriptor) ? <Pressable testID={`tender-leg-${leg.id}-void`} accessibilityRole="button" accessibilityLabel={t('pos_checkout.cancel_payment')}
|
|
63
|
+
{descriptor && canVoidLeg(leg, descriptor) && !heldTillLeg(order, leg) ? <Pressable testID={`tender-leg-${leg.id}-void`} accessibilityRole="button" accessibilityLabel={t('pos_checkout.cancel_payment')}
|
|
63
64
|
onPress={() => (confirmVoid ? setAsking(leg.id) : sale.voidTender(leg.id))} className="self-start min-h-11 justify-center px-2">
|
|
64
65
|
<Text className="text-destructive">{t('pos_checkout.cancel_payment')}</Text>
|
|
65
66
|
</Pressable> : null}
|
package/src/sale/tender-pane.tsx
CHANGED
|
@@ -17,6 +17,7 @@ import { QUICK_CASH_STEPS } from '../checkout/cash-tendered';
|
|
|
17
17
|
import { useT } from '../i18n';
|
|
18
18
|
import { DIGIT_ROWS, Keypad } from '../input/keypad';
|
|
19
19
|
import { offeredMethods, tenderOf } from './offered-methods';
|
|
20
|
+
import { heldTillLeg } from './held-leg';
|
|
20
21
|
import { TenderLedger } from './tender-ledger';
|
|
21
22
|
import { pickFigure } from './use-tender';
|
|
22
23
|
import { BanknoteIcon } from '../ui/icon/banknote-icon';
|
|
@@ -105,7 +106,8 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
105
106
|
const balanceChip = method !== null && !givesChange && state.entryMode !== 'percent' ? dueMinor : null;
|
|
106
107
|
const [onlyLeg] = order.payments;
|
|
107
108
|
// startTender('external') records the card leg for the total: its reference is edited in place, as before.
|
|
108
|
-
const cardReference = order.payments.length === 1 && onlyLeg.method === 'external' && legStatus(onlyLeg) === 'captured' && balance === 0
|
|
109
|
+
const cardReference = order.payments.length === 1 && onlyLeg.method === 'external' && legStatus(onlyLeg) === 'captured' && balance === 0
|
|
110
|
+
&& !heldTillLeg(order, onlyLeg);
|
|
109
111
|
const hint = partPick ? (pickRefused || entry === target ? t('pos_checkout.pick_amount_due', { amount: money(target) })
|
|
110
112
|
: givesChange && entry > target ? t('pos_checkout.change_due', { amount: money(entry - target) }) : '')
|
|
111
113
|
: pickRefused ? t('pos_checkout.pick_amount_due', { amount: money(figures.roundedDueMinor) })
|
|
@@ -240,7 +242,7 @@ export function TenderPane({ sale, state, dispatch, methods, ledger = true, back
|
|
|
240
242
|
|
|
241
243
|
{refused.length > 0 ? <>
|
|
242
244
|
<Text testID="tender-store-holds" className="text-foreground">{t('pos_checkout.store_holds_payment', { amount: money(refusedMinor) })}</Text>
|
|
243
|
-
{refused.map((id) => <Pressable key={id} testID={`tender-leg-${id}-remove`} accessibilityRole="button" onPress={() => sale.removeTender(id)} className={button}>
|
|
245
|
+
{refused.filter((id) => !order.payments.some((leg) => leg.id === id && heldTillLeg(order, leg))).map((id) => <Pressable key={id} testID={`tender-leg-${id}-remove`} accessibilityRole="button" onPress={() => sale.removeTender(id)} className={button}>
|
|
244
246
|
<Text className="text-center text-foreground">{t('pos_checkout.remove_payment')}</Text>
|
|
245
247
|
</Pressable>)}
|
|
246
248
|
</> : null}
|