@ticketboothapp/booking 1.2.130 → 1.2.131

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.130",
3
+ "version": "1.2.131",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -112,10 +112,21 @@ export function useStandardBookingPriceSummary({
112
112
  return Math.max(0, selectedReturnOption.vacancies ?? 0);
113
113
  }, [selectedReturnOption]);
114
114
 
115
+ const pricingAvailability = useMemo(() => {
116
+ if (!selectedAvailability || !selectedReturnOption?.rates?.length) return selectedAvailability;
117
+ const outboundVacancies = Math.max(0, selectedAvailability.vacancies ?? 0);
118
+ const returnVacancies = Math.max(0, selectedReturnOption.vacancies ?? 0);
119
+ return {
120
+ ...selectedAvailability,
121
+ vacancies: Math.min(outboundVacancies, returnVacancies),
122
+ rates: selectedReturnOption.rates,
123
+ };
124
+ }, [selectedAvailability, selectedReturnOption?.rates, selectedReturnOption?.vacancies]);
125
+
115
126
  const pricing = useMemo(
116
127
  () =>
117
128
  buildPricingFromAvailability(
118
- selectedAvailability,
129
+ pricingAvailability,
119
130
  activeOptions,
120
131
  precomputedPricesByOption,
121
132
  currency,
@@ -124,7 +135,7 @@ export function useStandardBookingPriceSummary({
124
135
  isSimplifiedPricingView,
125
136
  ),
126
137
  [
127
- selectedAvailability,
138
+ pricingAvailability,
128
139
  activeOptions,
129
140
  precomputedPricesByOption,
130
141
  currency,
@@ -145,7 +156,7 @@ export function useStandardBookingPriceSummary({
145
156
  const selectedOption = activeOptions.find(
146
157
  (option) =>
147
158
  option.optionId ===
148
- (selectedAvailability ? getAvailabilityOptionId(selectedAvailability) : ''),
159
+ (pricingAvailability ? getAvailabilityOptionId(pricingAvailability) : ''),
149
160
  );
150
161
  const basePriceCAD = selectedOption?.pricing?.[category.toUpperCase()] ?? 0;
151
162
  return computePriceBreakdown(
@@ -160,7 +171,7 @@ export function useStandardBookingPriceSummary({
160
171
  isSimplifiedPricingView,
161
172
  );
162
173
  },
163
- [pricingConfig, activeOptions, selectedAvailability, currency, hasFees, isSimplifiedPricingView],
174
+ [pricingConfig, activeOptions, pricingAvailability, currency, hasFees, isSimplifiedPricingView],
164
175
  );
165
176
 
166
177
  const orderSummary = useMemo(
@@ -352,7 +363,7 @@ export function useStandardBookingPriceSummary({
352
363
  totalPrice,
353
364
  } = useStandardBookingPromoDiscount({
354
365
  appliedPromoCode,
355
- selectedAvailability,
366
+ selectedAvailability: pricingAvailability,
356
367
  totalQuantity,
357
368
  productCompanyId,
358
369
  envCompanyId,
@@ -11,6 +11,8 @@ import type {
11
11
  import type { Currency } from './CurrencySwitcher';
12
12
  import { getAvailabilityOptionId } from './standard-booking-availability';
13
13
 
14
+ const normalizeMoneyZero = (value: number) => (Math.abs(value) < 0.005 ? 0 : value);
15
+
14
16
  interface UseStandardBookingPromoDiscountParams {
15
17
  appliedPromoCode: string | null;
16
18
  selectedAvailability: Availability | null;
@@ -188,9 +190,9 @@ export function useStandardBookingPromoDiscount({
188
190
  const taxOnSubtotal = isTaxIncludedInPrice ? 0 : effectiveSubtotal * (pricingConfig?.taxRate ?? 0);
189
191
  const effectiveTax =
190
192
  effectivePromoDiscountAmount > 0 && !isGiftCard && !isVoucher
191
- ? (effectiveSubtotal - effectivePromoDiscountAmount) * (pricingConfig?.taxRate ?? 0)
192
- : taxOnSubtotal;
193
- const totalPrice = effectiveSubtotal + effectiveTax - effectivePromoDiscountAmount;
193
+ ? normalizeMoneyZero((effectiveSubtotal - effectivePromoDiscountAmount) * (pricingConfig?.taxRate ?? 0))
194
+ : normalizeMoneyZero(taxOnSubtotal);
195
+ const totalPrice = normalizeMoneyZero(effectiveSubtotal + effectiveTax - effectivePromoDiscountAmount);
194
196
 
195
197
  return {
196
198
  promoDiscountAmount,
@@ -1669,6 +1669,8 @@ export interface ReturnOption {
1669
1669
  bookedCapacity?: number;
1670
1670
  pricesByCategory?: { retailPrices: Array<{ category: string; price: number }> };
1671
1671
  priceAdjustmentByCurrency?: Record<string, number>;
1672
+ /** Ticket rates priced using this specific return option's capacity floor. */
1673
+ rates?: AvailabilityRate[];
1672
1674
  returnLocation: string;
1673
1675
  mostPopular?: boolean;
1674
1676
  }