@ticketboothapp/booking 1.2.140 → 1.2.141

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.140",
3
+ "version": "1.2.141",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -155,6 +155,7 @@ const checkoutPanelPropKeys = [
155
155
  'receiptTotal',
156
156
  'originalReceipt',
157
157
  'priceSummaryLinesIncludeTaxRow',
158
+ 'isServerAmendmentQuote',
158
159
  'isTaxIncludedInPrice',
159
160
  'taxRate',
160
161
  'currency',
@@ -971,6 +971,7 @@ export function AdminChangeBookingFlow({
971
971
  receiptTax: adminFeAuthoritativeReceipt.tax,
972
972
  receiptTotal: adminFeAuthoritativeReceipt.total,
973
973
  originalReceipt,
974
+ isServerAmendmentQuote: latestChangeQuote?.pricingVersion === 'booking-amendment-v1',
974
975
  ...{ priceSummaryLinesIncludeTaxRow, isTaxIncludedInPrice, showProviderPricingInlineEditor },
975
976
  taxRate: pricingConfig?.taxRate,
976
977
  ...{ providerPricingUi, providerQuotedLines },
@@ -30,6 +30,7 @@ export interface AdminChangeCheckoutPanelProps {
30
30
  receiptTotal: number;
31
31
  originalReceipt: ChangeBookingFlowProps['originalReceipt'];
32
32
  priceSummaryLinesIncludeTaxRow: boolean;
33
+ isServerAmendmentQuote?: boolean;
33
34
  isTaxIncludedInPrice: boolean;
34
35
  taxRate?: number;
35
36
  currency: Currency;
@@ -99,6 +100,7 @@ export function AdminChangeCheckoutPanel({
99
100
  receiptTotal,
100
101
  originalReceipt,
101
102
  priceSummaryLinesIncludeTaxRow,
103
+ isServerAmendmentQuote,
102
104
  isTaxIncludedInPrice,
103
105
  taxRate,
104
106
  currency,
@@ -188,6 +190,7 @@ export function AdminChangeCheckoutPanel({
188
190
  }}
189
191
  newPriceSummaryLines={priceSummaryLines}
190
192
  newPriceSummaryLinesIncludeTaxRow={priceSummaryLinesIncludeTaxRow}
193
+ isServerAmendmentQuote={isServerAmendmentQuote}
191
194
  amountDue={changeFlowAmountDue}
192
195
  amountDueLabel={totalSummaryLabel}
193
196
  currency={currency}
@@ -16,6 +16,7 @@ export interface AdminChangeReceiptComparisonProps {
16
16
  newReceipt: Pick<AdminFeAuthoritativeReceipt, 'subtotal' | 'tax' | 'total'>;
17
17
  newPriceSummaryLines: PriceSummaryLine[];
18
18
  newPriceSummaryLinesIncludeTaxRow: boolean;
19
+ isServerAmendmentQuote?: boolean;
19
20
  amountDue: number;
20
21
  amountDueLabel: string;
21
22
  currency: Currency;
@@ -124,6 +125,7 @@ export function AdminChangeReceiptComparison({
124
125
  originalReceipt,
125
126
  newReceipt,
126
127
  newPriceSummaryLines,
128
+ isServerAmendmentQuote = false,
127
129
  amountDueLabel,
128
130
  currency,
129
131
  locale,
@@ -137,10 +139,34 @@ export function AdminChangeReceiptComparison({
137
139
  [originalReceipt],
138
140
  );
139
141
  const originalLinesIncludeTaxRow = hasTaxLine(originalReceiptLines);
140
- const calculatedChangeLines = useMemo(
141
- () => amendmentDeltaLines(originalReceiptLines, newPriceSummaryLines),
142
- [newPriceSummaryLines, originalReceiptLines],
143
- );
142
+ const calculatedChangeLines = useMemo(() => {
143
+ if (!isServerAmendmentQuote) {
144
+ return amendmentDeltaLines(originalReceiptLines, newPriceSummaryLines);
145
+ }
146
+ const nonTax = newPriceSummaryLines.filter(
147
+ (line) => !(line.kind === 'line' && String(line.type ?? '').toUpperCase() === 'TAX'),
148
+ );
149
+ const tax = roundMoney(
150
+ newPriceSummaryLines.reduce(
151
+ (sum, line) =>
152
+ line.kind === 'line' && String(line.type ?? '').toUpperCase() === 'TAX'
153
+ ? sum + line.amount
154
+ : sum,
155
+ 0,
156
+ ),
157
+ );
158
+ return Math.abs(tax) < 0.005
159
+ ? nonTax
160
+ : [
161
+ ...nonTax,
162
+ {
163
+ kind: 'line' as const,
164
+ label: tax >= 0 ? 'Additional tax' : 'Tax reduction',
165
+ amount: tax,
166
+ type: 'TAX',
167
+ },
168
+ ];
169
+ }, [isServerAmendmentQuote, newPriceSummaryLines, originalReceiptLines]);
144
170
  const nonTaxChangeSubtotal = roundMoney(
145
171
  calculatedChangeLines.reduce(
146
172
  (sum, line) =>
@@ -151,7 +177,15 @@ export function AdminChangeReceiptComparison({
151
177
  ),
152
178
  );
153
179
  const receiptTaxDelta = roundMoney(
154
- taxRate != null && nonTaxChangeSubtotal > 0
180
+ isServerAmendmentQuote
181
+ ? calculatedChangeLines.reduce(
182
+ (sum, line) =>
183
+ line.kind === 'line' && String(line.type ?? '').toUpperCase() === 'TAX'
184
+ ? sum + line.amount
185
+ : sum,
186
+ 0,
187
+ )
188
+ : taxRate != null && nonTaxChangeSubtotal > 0
155
189
  ? nonTaxChangeSubtotal * taxRate
156
190
  : newReceipt.tax - originalReceipt.tax,
157
191
  );
@@ -274,12 +308,19 @@ export function AdminChangeReceiptComparison({
274
308
  </span>
275
309
  </div>
276
310
  <PriceSummary
277
- lines={[...originalReceiptLines, ...changeLines].map((line) => ({ ...line, editable: false, lineKey: undefined }))}
311
+ lines={[
312
+ ...originalReceiptLines.filter(
313
+ (line) => !(line.kind === 'line' && String(line.type ?? '').toUpperCase() === 'TAX'),
314
+ ),
315
+ ...changeLines.filter(
316
+ (line) => !(line.kind === 'line' && String(line.type ?? '').toUpperCase() === 'TAX'),
317
+ ),
318
+ ].map((line) => ({ ...line, editable: false, lineKey: undefined }))}
278
319
  total={displayedUpdatedTotal}
279
320
  currency={currency}
280
321
  locale={displayLocale}
281
322
  subtotal={displayedUpdatedSubtotal}
282
- taxAmount={!hasTaxLine([...originalReceiptLines, ...changeLines]) ? displayedUpdatedTax : 0}
323
+ taxAmount={displayedUpdatedTax}
283
324
  taxRate={taxRate}
284
325
  size="sm"
285
326
  t={t}
@@ -336,7 +336,7 @@ export function useAdminChangePriceSummary({
336
336
 
337
337
  const checkoutPriceSummaryLinesForCheckout = useMemo(() => {
338
338
  let raw: PriceSummaryLine[];
339
- if (!useAdminFeAuthoritativeQuote && suppressSelfServeCurrencyUi && selfServePricingConfirmed) {
339
+ if (suppressSelfServeCurrencyUi && selfServePricingConfirmed) {
340
340
  raw =
341
341
  latestServerPriceSummaryLines && latestServerPriceSummaryLines.length > 0
342
342
  ? latestServerPriceSummaryLines
@@ -366,7 +366,6 @@ export function useAdminChangePriceSummary({
366
366
  }, [
367
367
  suppressSelfServeCurrencyUi,
368
368
  selfServePricingConfirmed,
369
- useAdminFeAuthoritativeQuote,
370
369
  checkoutPriceSummaryLines,
371
370
  latestServerPriceSummaryLines,
372
371
  effectivePromoDiscountAmount,
@@ -261,9 +261,11 @@ export function useAdminChangeQuotePreview({
261
261
  hasChangesFromInitial: hasEffectiveChangeSelection,
262
262
  selectionTotal:
263
263
  originalReceipt
264
- ? suppressSelfServeCurrencyUi && !selfServePricingConfirmed && !useAdminFeAuthoritativeQuote
265
- ? null
266
- : displayChangeFlowProposedTotalWithEditableLines
264
+ ? selfServePricingConfirmed && latestChangeQuote?.serverPreview?.totalNewBooking != null
265
+ ? latestChangeQuote.serverPreview.totalNewBooking
266
+ : suppressSelfServeCurrencyUi
267
+ ? null
268
+ : displayChangeFlowProposedTotalWithEditableLines
267
269
  : totalPrice,
268
270
  selectionCurrency: currency,
269
271
  };
@@ -281,7 +283,7 @@ export function useAdminChangeQuotePreview({
281
283
  displayChangeFlowProposedTotalWithEditableLines,
282
284
  suppressSelfServeCurrencyUi,
283
285
  selfServePricingConfirmed,
284
- useAdminFeAuthoritativeQuote,
286
+ latestChangeQuote?.serverPreview?.totalNewBooking,
285
287
  ]);
286
288
 
287
289
  useEffect(() => {
@@ -188,7 +188,12 @@ export function useAdminChangeReceiptDerivation({
188
188
  });
189
189
  })();
190
190
  const changeFlowClientEstimateDue = normalizeNearZeroOwed(
191
- roundMoney(changeFlowClientEstimateDueBase + editableSummaryPreSubtotalDelta),
191
+ roundMoney(
192
+ changeFlowClientEstimateDueBase +
193
+ (latestChangeQuote?.pricingVersion === 'booking-amendment-v1'
194
+ ? 0
195
+ : editableSummaryPreSubtotalDelta),
196
+ ),
192
197
  );
193
198
  const changeFlowAmountDue = normalizeNearZeroOwed(changeFlowClientEstimateDue);
194
199