@ticketboothapp/booking 1.2.147 → 1.2.148
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/package.json
CHANGED
|
@@ -61,6 +61,33 @@ export function AdminChangeReceiptComparison({
|
|
|
61
61
|
const existingLines = originalLines(originalReceipt);
|
|
62
62
|
const originalCurrency = originalReceipt.currency ?? currency;
|
|
63
63
|
const quoteReady = amendmentLines != null && amountDue != null && updatedTotal != null;
|
|
64
|
+
const amendmentTax = amendmentLines?.reduce(
|
|
65
|
+
(sum, line) =>
|
|
66
|
+
line.kind === 'line' && String(line.type ?? '').toUpperCase() === 'TAX'
|
|
67
|
+
? sum + line.amount
|
|
68
|
+
: sum,
|
|
69
|
+
0,
|
|
70
|
+
) ?? 0;
|
|
71
|
+
const amendmentNonTaxLines = amendmentLines
|
|
72
|
+
? [
|
|
73
|
+
...amendmentLines.filter((line) => line.kind === 'ticket'),
|
|
74
|
+
...amendmentLines.filter(
|
|
75
|
+
(line) => line.kind === 'line' && String(line.type ?? '').toUpperCase() !== 'TAX',
|
|
76
|
+
),
|
|
77
|
+
]
|
|
78
|
+
: [];
|
|
79
|
+
const amendmentSubtotal = amendmentNonTaxLines.reduce(
|
|
80
|
+
(sum, line) => sum + (line.kind === 'ticket' ? line.itemTotal : line.amount),
|
|
81
|
+
0,
|
|
82
|
+
);
|
|
83
|
+
const amendmentDisplayLines: PriceSummaryLine[] = amendmentLines
|
|
84
|
+
? [
|
|
85
|
+
...amendmentNonTaxLines,
|
|
86
|
+
...(Math.abs(amendmentTax) >= 0.005
|
|
87
|
+
? [{ kind: 'line' as const, label: 'Additional tax', amount: amendmentTax, type: 'TAX' }]
|
|
88
|
+
: []),
|
|
89
|
+
]
|
|
90
|
+
: [];
|
|
64
91
|
const amountDueClass =
|
|
65
92
|
amountDue != null && amountDue < -0.005
|
|
66
93
|
? 'text-emerald-700'
|
|
@@ -114,16 +141,17 @@ export function AdminChangeReceiptComparison({
|
|
|
114
141
|
<div className="rounded-md border border-dashed border-stone-300 bg-white/70 px-3 py-4 text-center">
|
|
115
142
|
<p className="text-sm font-medium text-stone-700">Waiting for server price…</p>
|
|
116
143
|
</div>
|
|
117
|
-
) :
|
|
144
|
+
) : amendmentDisplayLines.length === 0 && Math.abs(amountDue) < 0.005 ? (
|
|
118
145
|
<div className="rounded-md border border-dashed border-stone-300 bg-white/70 px-3 py-4 text-center">
|
|
119
146
|
<p className="text-sm font-medium text-stone-700">No pricing changes</p>
|
|
120
147
|
</div>
|
|
121
148
|
) : (
|
|
122
149
|
<PriceSummary
|
|
123
|
-
lines={
|
|
150
|
+
lines={amendmentDisplayLines}
|
|
124
151
|
total={amountDue}
|
|
125
152
|
currency={currency}
|
|
126
153
|
locale={displayLocale}
|
|
154
|
+
subtotal={amendmentSubtotal}
|
|
127
155
|
size="sm"
|
|
128
156
|
t={t}
|
|
129
157
|
/>
|
|
@@ -132,6 +132,19 @@ function breakdownFromPriceBasis(priceBasis: PriceBasisSnapshot | null | undefin
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
function finalUnitOnlyBreakdown(itemTotal: number, quantity: number) {
|
|
136
|
+
const finalUnitAmount = quantity > 0 ? roundMoney(itemTotal / quantity) : roundMoney(itemTotal);
|
|
137
|
+
return {
|
|
138
|
+
lineItems: [],
|
|
139
|
+
subtotalAfterAdjustments: finalUnitAmount,
|
|
140
|
+
feeLines: [],
|
|
141
|
+
taxRate: 0,
|
|
142
|
+
taxAmount: 0,
|
|
143
|
+
isTaxIncluded: false,
|
|
144
|
+
finalPrice: finalUnitAmount,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
135
148
|
function hasPaymentCreditLine(lines: PriceSummaryLine[]): boolean {
|
|
136
149
|
return lines.some((line) => {
|
|
137
150
|
if (line.kind !== 'line') return false;
|
|
@@ -193,7 +206,8 @@ export function mapQuoteLineItemsToPriceSummaryLines(
|
|
|
193
206
|
category,
|
|
194
207
|
qty: qty > 0 ? qty : 1,
|
|
195
208
|
itemTotal: amount,
|
|
196
|
-
breakdown:
|
|
209
|
+
breakdown:
|
|
210
|
+
breakdownFromPriceBasis(item.priceBasis) ?? finalUnitOnlyBreakdown(amount, qty > 0 ? qty : 1),
|
|
197
211
|
});
|
|
198
212
|
continue;
|
|
199
213
|
}
|
|
@@ -213,7 +227,8 @@ export function mapQuoteLineItemsToPriceSummaryLines(
|
|
|
213
227
|
category: lettersOnly,
|
|
214
228
|
qty,
|
|
215
229
|
itemTotal: amount,
|
|
216
|
-
breakdown:
|
|
230
|
+
breakdown:
|
|
231
|
+
breakdownFromPriceBasis(item.priceBasis) ?? finalUnitOnlyBreakdown(amount, qty),
|
|
217
232
|
});
|
|
218
233
|
continue;
|
|
219
234
|
}
|