@ticketboothapp/booking 1.2.148 → 1.2.149

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.148",
3
+ "version": "1.2.149",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -43,6 +43,15 @@ function hasTaxLine(lines: PriceSummaryLine[]): boolean {
43
43
  );
44
44
  }
45
45
 
46
+ function amendmentLineOrder(line: PriceSummaryLine): number {
47
+ if (line.kind === 'ticket') return 0;
48
+ const type = String(line.type ?? '').toUpperCase();
49
+ if (type === 'TICKET') return 0;
50
+ if (type === 'RETURN_OPTION' || type === 'CANCELLATION_UPGRADE') return 1;
51
+ if (type === 'FEE' || type === 'ADD_ON') return 2;
52
+ return 3;
53
+ }
54
+
46
55
  export function AdminChangeReceiptComparison({
47
56
  originalReceipt,
48
57
  amendmentLines,
@@ -69,12 +78,13 @@ export function AdminChangeReceiptComparison({
69
78
  0,
70
79
  ) ?? 0;
71
80
  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
- ]
81
+ ? amendmentLines
82
+ .filter(
83
+ (line) => line.kind !== 'line' || String(line.type ?? '').toUpperCase() !== 'TAX',
84
+ )
85
+ .map((line, index) => ({ line, index }))
86
+ .sort((a, b) => amendmentLineOrder(a.line) - amendmentLineOrder(b.line) || a.index - b.index)
87
+ .map(({ line }) => line)
78
88
  : [];
79
89
  const amendmentSubtotal = amendmentNonTaxLines.reduce(
80
90
  (sum, line) => sum + (line.kind === 'ticket' ? line.itemTotal : line.amount),
@@ -84,7 +94,12 @@ export function AdminChangeReceiptComparison({
84
94
  ? [
85
95
  ...amendmentNonTaxLines,
86
96
  ...(Math.abs(amendmentTax) >= 0.005
87
- ? [{ kind: 'line' as const, label: 'Additional tax', amount: amendmentTax, type: 'TAX' }]
97
+ ? [{
98
+ kind: 'line' as const,
99
+ label: amendmentTax < 0 ? 'Refunded tax' : 'Additional tax',
100
+ amount: amendmentTax,
101
+ type: 'TAX',
102
+ }]
88
103
  : []),
89
104
  ]
90
105
  : [];