@tallyui/pos 5.0.0 → 5.2.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 +209 -12
- package/dist/index.js +437 -55
- package/package.json +6 -6
- package/src/index.ts +5 -4
- package/src/order/types.ts +1 -1
- package/src/outbox/index.ts +1 -0
- package/src/outbox/order-outbox.ts +13 -6
- package/src/outbox/store-settlement.ts +206 -0
- package/src/outbox/use-order-outbox.ts +65 -1
- package/src/pos-order/attention-handled.ts +2 -0
- package/src/pos-order/command.ts +47 -24
- package/src/pos-order/finalize.ts +13 -8
- package/src/pos-order/index.ts +4 -1
- package/src/pos-order/needs-attention.ts +24 -7
- package/src/pos-order/reopen.ts +2 -2
- package/src/pos-order/schema.ts +27 -2
- package/src/pos-order/store-order-left.ts +21 -0
- package/src/pos-order/store-settlement.ts +75 -0
- package/src/pos-order/till-payments.ts +17 -0
- package/src/pos-order/types.ts +26 -0
- package/src/receipt/build-receipt-data.ts +2 -2
- package/src/receipt/reprint.ts +2 -2
- package/src/register/expected.ts +9 -8
- package/src/register/session-store.ts +7 -6
- package/src/reports/adapters.ts +2 -2
- package/src/sale/use-sale.ts +13 -6
- package/src/tax/taxed-lines.ts +8 -0
- package/src/tender/cash-rounding.ts +17 -9
- package/src/tender/index.ts +1 -1
|
@@ -36,17 +36,25 @@ export function roundedRemainder(balanceMinor: number, entriesMinor: number, rou
|
|
|
36
36
|
return unrounded <= 0 ? 0 : roundToIncrement(unrounded, rounding.incrementMinor, rounding.mode);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
/** ADR-094 (
|
|
40
|
-
export function roundedPickTarget(targetMinor: number, rounding: PaymentRounding | null | undefined): number {
|
|
41
|
-
|
|
39
|
+
/** ADR-094 item 7 (carry): a cash part pick rounds its target less `entriesMinor`, the live entries the pick carries against; it defaults to 0, the 5.0.0 per-pick rounding. 0 means cash cannot pay it. */
|
|
40
|
+
export function roundedPickTarget(targetMinor: number, rounding: PaymentRounding | null | undefined, entriesMinor = 0): number {
|
|
41
|
+
if (!rounding) return targetMinor;
|
|
42
|
+
const unrounded = targetMinor - entriesMinor;
|
|
43
|
+
return unrounded <= 0 ? 0 : roundToIncrement(unrounded, rounding.incrementMinor, rounding.mode);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** ADR-094 items 1 and 6: the live entries a remainder rounds against, every entry on the sale (cash-pick entries included since the carry rule). */
|
|
47
|
+
export function remainderEntriesMinor(order: { payments: readonly { id: string; method?: string; units?: Readonly<Record<string, number>> }[]; cashRoundings?: readonly { paymentId: string; minor: number }[] }): number {
|
|
48
|
+
return (order.cashRoundings ?? []).reduce((sum, entry) => sum + entry.minor, 0);
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
/**
|
|
52
|
+
* ADR-094 item 1 (#1365, amended by the carry rule 2026-11-26): the zero-remainder write-off's leg, the last counting leg with
|
|
53
|
+
* wire method 'cash', else the last counting leg. A later cash leg rounds against a non-cash leg's write-off; `cashVoidRefusal` keeps the entries a stack.
|
|
54
|
+
*/
|
|
55
|
+
export function writeOffLeg<L extends { id: string; method?: string; status?: PaymentLegStatus; units?: Readonly<Record<string, number>> }>(order: { payments: readonly L[] }): L | undefined {
|
|
56
|
+
const counted = order.payments.filter(countsTowardPaid);
|
|
57
|
+
return counted.filter((leg) => leg.method === 'cash').at(-1) ?? counted.at(-1);
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
/** Why a void is refused by ADR-094 item 6 (desk ruling (i), #1292): a later live cash leg's entry was computed against this leg's. */
|
package/src/tender/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { tenderFigures, runsWholeOrder } from './tender-figures';
|
|
|
7
7
|
export type { TenderFacts, TenderFigures } from './tender-figures';
|
|
8
8
|
export { tenderVoidSchema, tenderVoidCollection } from './tender-void';
|
|
9
9
|
export type { TenderVoid } from './tender-void';
|
|
10
|
-
export { cashVoidRefusal, type CashVoidRefusal, nearestPayableCash, roundedPickTarget, remainderEntriesMinor, roundedDue, tenderRounding } from './cash-rounding';
|
|
10
|
+
export { cashVoidRefusal, type CashVoidRefusal, nearestPayableCash, roundedPickTarget, remainderEntriesMinor, writeOffLeg, roundedDue, tenderRounding } from './cash-rounding';
|
|
11
11
|
export type { TenderRounding } from './cash-rounding';
|
|
12
12
|
export { legStatus, countsTowardPaid, isInMotion, capturedMinor, inMotionMinor, canMoveLeg, canVoidLeg } from './payment-legs';
|
|
13
13
|
export type { PaymentLegStatus } from './payment-legs';
|