@ticketboothapp/booking 1.2.135 → 1.2.136

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticketboothapp/booking",
3
- "version": "1.2.135",
3
+ "version": "1.2.136",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -77,9 +77,15 @@ function mapOriginalReceiptLines(originalReceipt: OriginalReceipt): PriceSummary
77
77
  }
78
78
 
79
79
  function lineIdentity(line: PriceSummaryLine): string {
80
+ const normalizedLabel = (value: string) =>
81
+ value
82
+ .replace(/\s*\([^)]*(?:people|person|x\s*\d+)[^)]*\)\s*$/i, '')
83
+ .replace(/\s+/g, ' ')
84
+ .trim()
85
+ .toUpperCase();
80
86
  return line.kind === 'ticket'
81
87
  ? `ticket:${line.category.trim().toUpperCase()}`
82
- : `line:${String(line.type ?? '').trim().toUpperCase()}:${line.label.trim().toUpperCase()}`;
88
+ : `line:${String(line.type ?? '').trim().toUpperCase()}:${normalizedLabel(line.label)}`;
83
89
  }
84
90
 
85
91
  function lineAmount(line: PriceSummaryLine): number {
@@ -157,10 +163,25 @@ export function AdminChangeReceiptComparison({
157
163
  [originalReceipt],
158
164
  );
159
165
  const originalLinesIncludeTaxRow = hasTaxLine(originalReceiptLines);
160
- const changeLines = useMemo(
166
+ const calculatedChangeLines = useMemo(
161
167
  () => amendmentDeltaLines(originalReceiptLines, newPriceSummaryLines),
162
168
  [newPriceSummaryLines, originalReceiptLines],
163
169
  );
170
+ const receiptTaxDelta = roundMoney(newReceipt.tax - originalReceipt.tax);
171
+ const changeLines = useMemo(() => {
172
+ if (hasTaxLine(calculatedChangeLines) || Math.abs(receiptTaxDelta) < 0.005) {
173
+ return calculatedChangeLines;
174
+ }
175
+ return [
176
+ ...calculatedChangeLines,
177
+ {
178
+ kind: 'line' as const,
179
+ label: receiptTaxDelta >= 0 ? 'Additional tax' : 'Tax reduction',
180
+ amount: receiptTaxDelta,
181
+ type: 'TAX',
182
+ },
183
+ ];
184
+ }, [calculatedChangeLines, receiptTaxDelta]);
164
185
  const changeLinesIncludeTaxRow = hasTaxLine(changeLines);
165
186
  const changeTax = roundMoney(
166
187
  changeLines.reduce(
@@ -212,17 +233,24 @@ export function AdminChangeReceiptComparison({
212
233
  {formatCurrencyAmount(amountDue, currency, displayLocale)}
213
234
  </span>
214
235
  </div>
215
- <PriceSummary
216
- lines={changeLines}
217
- total={amountDue}
218
- currency={currency}
219
- locale={displayLocale}
220
- subtotal={changeSubtotal}
221
- taxAmount={!changeLinesIncludeTaxRow ? changeTax : 0}
222
- taxRate={taxRate}
223
- size="sm"
224
- t={t}
225
- />
236
+ {changeLines.length === 0 && Math.abs(amountDue) < 0.005 ? (
237
+ <div className="rounded-md border border-dashed border-stone-300 bg-white/70 px-3 py-4 text-center">
238
+ <p className="text-sm font-medium text-stone-700">No pricing changes</p>
239
+ <p className="mt-1 text-xs text-stone-500">The selected booking details match the existing purchase.</p>
240
+ </div>
241
+ ) : (
242
+ <PriceSummary
243
+ lines={changeLines}
244
+ total={amountDue}
245
+ currency={currency}
246
+ locale={displayLocale}
247
+ subtotal={changeSubtotal}
248
+ taxAmount={!changeLinesIncludeTaxRow ? changeTax : 0}
249
+ taxRate={taxRate}
250
+ size="sm"
251
+ t={t}
252
+ />
253
+ )}
226
254
  </section>
227
255
  </div>
228
256
  <section className="min-w-0 overflow-visible rounded-lg border border-stone-300 bg-white p-3 shadow-sm">