@roomstay/frontend 2.6.56 → 2.6.57
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/dist/370.bundle.js +1 -1
- package/dist/978.bundle.js +1 -1
- package/dist/main.bundle.js +1 -1
- package/dist/src/api/AvailabilityAPI.js +5 -0
- package/dist/src/api/AvailabilityAPI.js.map +1 -1
- package/dist/src/components/navigation/Header.js +21 -12
- package/dist/src/components/navigation/Header.js.map +1 -1
- package/dist/src/components/steps/addons/AddonCard.js +2 -1
- package/dist/src/components/steps/addons/AddonCard.js.map +1 -1
- package/dist/src/components/steps/common/CommonAddonSummary/CommonAddonSummary.js +2 -2
- package/dist/src/components/steps/common/CommonAddonSummary/CommonAddonSummary.js.map +1 -1
- package/dist/src/components/steps/common/ItemisedFeesListing/ItemisedFeesListing.d.ts +6 -0
- package/dist/src/components/steps/common/ItemisedFeesListing/ItemisedFeesListing.js +47 -0
- package/dist/src/components/steps/common/ItemisedFeesListing/ItemisedFeesListing.js.map +1 -0
- package/dist/src/components/steps/common/ItemisedFeesSummary/ItemisedFeesSummary.d.ts +6 -0
- package/dist/src/components/steps/common/ItemisedFeesSummary/ItemisedFeesSummary.js +44 -0
- package/dist/src/components/steps/common/ItemisedFeesSummary/ItemisedFeesSummary.js.map +1 -0
- package/dist/src/components/steps/room/roomDetails/roomRates/PriceBreakdownBlock.js +13 -2
- package/dist/src/components/steps/room/roomDetails/roomRates/PriceBreakdownBlock.js.map +1 -1
- package/dist/src/components/summary/BEMobileSummaryModal.js +6 -2
- package/dist/src/components/summary/BEMobileSummaryModal.js.map +1 -1
- package/dist/src/components/summary/BESummary.js +19 -3
- package/dist/src/components/summary/BESummary.js.map +1 -1
- package/dist/src/components/summary/BESummaryAddonRow.js +14 -5
- package/dist/src/components/summary/BESummaryAddonRow.js.map +1 -1
- package/dist/src/components/summary/BESummaryRoomRow.js +7 -3
- package/dist/src/components/summary/BESummaryRoomRow.js.map +1 -1
- package/dist/src/contexts/BasketContext/BasketContextType.d.ts +5 -0
- package/dist/src/contexts/BasketContext/BasketContextType.js.map +1 -1
- package/dist/src/contexts/BasketContext/BasketContextWrapper.js +179 -1
- package/dist/src/contexts/BasketContext/BasketContextWrapper.js.map +1 -1
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js +2 -0
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js.map +1 -1
- package/dist/src/contexts/Members/AuthenticationContext/AuthenticationContextProvider.js +5 -2
- package/dist/src/contexts/Members/AuthenticationContext/AuthenticationContextProvider.js.map +1 -1
- package/dist/src/contexts/Members/RoomstayMemberContext/RoomstayMemberContextProvider.js +45 -5
- package/dist/src/contexts/Members/RoomstayMemberContext/RoomstayMemberContextProvider.js.map +1 -1
- package/dist/src/hooks/UpdateQueryParameters.d.ts +1 -1
- package/dist/src/hooks/UpdateQueryParameters.js +8 -3
- package/dist/src/hooks/UpdateQueryParameters.js.map +1 -1
- package/dist/src/models/Addon/Addon.d.ts +11 -1
- package/dist/src/models/Addon/Addon.js.map +1 -1
- package/dist/src/models/Api/HotelDTO.d.ts +2 -1
- package/dist/src/models/Api/HotelDTO.js.map +1 -1
- package/dist/src/models/Api/ReservationsDTO.d.ts +7 -0
- package/dist/src/models/Api/ReservationsDTO.js.map +1 -1
- package/dist/src/models/BasketAddonRow.d.ts +2 -0
- package/dist/src/models/BasketAddonRow.js +25 -1
- package/dist/src/models/BasketAddonRow.js.map +1 -1
- package/dist/src/models/BasketRow.d.ts +1 -1
- package/dist/src/models/BasketRow.js +21 -10
- package/dist/src/models/BasketRow.js.map +1 -1
- package/dist/src/models/Client/Hotel/Hotel.d.ts +4 -0
- package/dist/src/models/Client/Hotel/Hotel.js.map +1 -1
- package/dist/src/models/Fee.d.ts +32 -0
- package/dist/src/models/Fee.js +50 -0
- package/dist/src/models/Fee.js.map +1 -0
- package/dist/src/models/Room/RoomRate.d.ts +2 -0
- package/dist/src/models/Room/RoomRate.js +11 -0
- package/dist/src/models/Room/RoomRate.js.map +1 -1
- package/dist/src/models/Room/RoomRateNight.d.ts +3 -0
- package/dist/src/models/Room/RoomRateNight.js +3 -0
- package/dist/src/models/Room/RoomRateNight.js.map +1 -1
- package/dist/src/pages/findReservation/FindReservationResults.js +8 -0
- package/dist/src/pages/findReservation/FindReservationResults.js.map +1 -1
- package/dist/src/pages/findReservation/ReservationRow.js +3 -3
- package/dist/src/pages/findReservation/ReservationRow.js.map +1 -1
- package/dist/src/pages/steps/StepThanks/StepThanksComponent.js +6 -0
- package/dist/src/pages/steps/StepThanks/StepThanksComponent.js.map +1 -1
- package/dist/src/util/TotalCalculator.d.ts +1 -0
- package/dist/src/util/TotalCalculator.js +47 -9
- package/dist/src/util/TotalCalculator.js.map +1 -1
- package/dist/test.bundle.js +1 -1
- package/dist/vendors.bundle.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasketAddonRow.js","sourceRoot":"/","sources":["src/models/BasketAddonRow.ts"],"names":[],"mappings":";;AAAA,gDAAiH;AACjH,4DAAmE;AAEnE,MAAqB,cAAc;IAc/B,YAAmB,KAAa;QAC5B,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;QAED,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QAEvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAEtE,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAA6C,CAAC,CAAC,MAAM,CAAC;IAC9G,CAAC;IAEM,QAAQ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IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7B,CAAC;IAEM,eAAe,CAAC,IAAa;QAChC,IAAI,CAAC,YAAY,GAAG,IAAc,CAAC;IACvC,CAAC;IAEM,WAAW,CAAC,QAAgB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAEM,QAAQ,CAAC,KAAY;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAtLD,iCAsLC","sourcesContent":["import { Addon, ADDON_PER_NIGHT_TYPES, AddonPricingType, BasketAddonDTO, PriceInfo } from '@/models/Addon/Addon';\nimport { calculateBasketAddonTotal } from '@/util/TotalCalculator';\n\nexport default class BasketAddonRow {\n private readonly uniqId: string;\n\n private addon!: Addon;\n\n private quantity: number;\n private adultQuantity: number;\n private childQuantity: number;\n\n private selectedDate!: string;\n private selectedTime!: string;\n\n private numberOfAvailableNights: number;\n\n public constructor(addon?: Addon) {\n if (addon) {\n this.setAddon(addon);\n }\n\n this.quantity = 1;\n this.adultQuantity = 1;\n this.childQuantity = 0;\n\n this.uniqId = btoa(((Date.now() % 1000) / 1000) * Math.random() + '');\n\n this.numberOfAvailableNights = Object.values(addon?.availability as { [date: string]: PriceInfo }).length;\n }\n\n public getAddon() {\n return this.addon;\n }\n\n public getSelectedDate() {\n return this.selectedDate;\n }\n\n public getSelectedTime() {\n return this.selectedTime;\n }\n\n public getQuantity() {\n return this.quantity;\n }\n\n public getAdultQuantity(): number {\n return this.adultQuantity;\n }\n\n public getNumberOfAvailableNights() {\n return this.numberOfAvailableNights;\n }\n\n private getCalculationParams(): BasketAddonDTO {\n const addon = this.getAddon();\n const date = this.getSelectedDate();\n const priceInfo = addon.availability[date];\n\n return {\n availability: this.getAddon().availability,\n code: addon.code,\n inclusive: false,\n quantity: this.getQuantity(),\n adultQuantity: this.getAdultQuantity(),\n childQuantity: this.getChildQuantity(),\n description: addon.description,\n name: addon.name,\n category: addon.category,\n image: addon.image as any,\n price: priceInfo.price ?? 0,\n fee: priceInfo.fee ?? 0,\n adultPrice: priceInfo.adultPrice,\n childPrice: priceInfo.childPrice,\n adultFee: priceInfo.adultFee,\n childFee: priceInfo.childFee,\n pricingType: addon.pricingType,\n nights: addon.nights,\n };\n }\n\n public getTotalFees(): number {\n return calculateBasketAddonTotal(this.getCalculationParams()).totalFees;\n }\n\n public getTotalPrice(): number {\n return calculateBasketAddonTotal(this.getCalculationParams()).total;\n }\n\n /**\n * Returns the subtotal of an addon (without taking into account the nights modifier)\n */\n public getAddonSubtotal(): number {\n const addon = this.getAddon();\n const date = this.getSelectedDate();\n const priceInfo = addon.availability[date];\n\n let price = 0;\n if (priceInfo.price && this.getQuantity() > 0) {\n price += this.getQuantity() * priceInfo.price;\n }\n\n if (priceInfo.adultPrice && this.getAdultQuantity() > 0) {\n price += this.getAdultQuantity() * priceInfo.adultPrice;\n }\n\n if (priceInfo.childPrice && this.getChildQuantity() > 0) {\n price += this.getChildQuantity() * priceInfo.childPrice;\n }\n\n return price;\n }\n\n public getTotalQuantity(): number {\n const addon = this.getAddon();\n const date = this.getSelectedDate();\n const priceInfo = addon.availability[date];\n\n let quantity = 0;\n if (priceInfo.price) {\n quantity += this.getQuantity();\n }\n\n if (priceInfo.adultPrice || addon.pricingType === AddonPricingType.PER_ADULT_OCCUPANCY_PER_NIGHT) {\n quantity += this.getAdultQuantity();\n }\n\n if (priceInfo.childPrice || addon.pricingType === AddonPricingType.PER_CHILD_OCCUPANCY_PER_NIGHT) {\n quantity += this.getChildQuantity();\n }\n\n return quantity;\n }\n\n /**\n * This function returns a value that should multiply the total price of the addon for one (assumed) night\n * Depending on the pricing type\n * @returns number\n */\n public getNightModifier(): number {\n const modifier = 1;\n\n if (ADDON_PER_NIGHT_TYPES.includes(this.addon.pricingType)) {\n return this.addon.checkOutDate.diff(this.addon.checkInDate, 'day');\n } else {\n return modifier;\n }\n }\n\n public setAdultQuantity(value: number) {\n this.adultQuantity = value;\n }\n\n public getChildQuantity(): number {\n return this.childQuantity;\n }\n\n public setChildQuantity(value: number) {\n this.childQuantity = value;\n }\n\n public getID() {\n return this.uniqId;\n }\n\n public isValid() {\n return this.selectedDate && this.addon && this.quantity > 0;\n }\n\n public setSelectedDate(date: string) {\n this.selectedDate = date;\n }\n\n public setSelectedTime(time?: string) {\n this.selectedTime = time as string;\n }\n\n public setQuantity(quantity: number) {\n this.quantity = quantity;\n }\n\n public setAddon(addon: Addon) {\n this.addon = addon;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BasketAddonRow.js","sourceRoot":"/","sources":["src/models/BasketAddonRow.ts"],"names":[],"mappings":";;AAAA,gDAAiH;AACjH,sCAAiH;AACjH,4DAAmE;AAEnE,MAAqB,cAAc;IAc/B,YAAmB,KAAa;QAC5B,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;QAED,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QAEvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAEtE,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAA6C,CAAC,CAAC,MAAM,CAAC;IAC9G,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAEM,eAAe;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAEM,eAAe;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAEM,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IAC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QAChC,IAAI,CAAC,YAAY,GAAG,IAAc,CAAC;IACvC,CAAC;IAEM,WAAW,CAAC,QAAgB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAEM,QAAQ,CAAC,KAAY;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AArND,iCAqNC","sourcesContent":["import { Addon, ADDON_PER_NIGHT_TYPES, AddonPricingType, BasketAddonDTO, PriceInfo } from '@/models/Addon/Addon';\nimport { accumulateFees, feeMapToArray, HotelFee, ItemisedFee, mapSimpleFeesToItemisedFees } from '@/models/Fee';\nimport { calculateBasketAddonTotal } from '@/util/TotalCalculator';\n\nexport default class BasketAddonRow {\n private readonly uniqId: string;\n\n private addon!: Addon;\n\n private quantity: number;\n private adultQuantity: number;\n private childQuantity: number;\n\n private selectedDate!: string;\n private selectedTime!: string;\n\n private numberOfAvailableNights: number;\n\n public constructor(addon?: Addon) {\n if (addon) {\n this.setAddon(addon);\n }\n\n this.quantity = 1;\n this.adultQuantity = 1;\n this.childQuantity = 0;\n\n this.uniqId = btoa(((Date.now() % 1000) / 1000) * Math.random() + '');\n\n this.numberOfAvailableNights = Object.values(addon?.availability as { [date: string]: PriceInfo }).length;\n }\n\n public getAddon() {\n return this.addon;\n }\n\n public getSelectedDate() {\n return this.selectedDate;\n }\n\n public getSelectedTime() {\n return this.selectedTime;\n }\n\n public getQuantity() {\n return this.quantity;\n }\n\n public getAdultQuantity(): number {\n return this.adultQuantity;\n }\n\n public getNumberOfAvailableNights() {\n return this.numberOfAvailableNights;\n }\n\n private getCalculationParams(): BasketAddonDTO {\n const addon = this.getAddon();\n const date = this.getSelectedDate();\n const priceInfo = addon.availability[date];\n\n return {\n availability: this.getAddon().availability,\n code: addon.code,\n inclusive: false,\n quantity: this.getQuantity(),\n adultQuantity: this.getAdultQuantity(),\n childQuantity: this.getChildQuantity(),\n description: addon.description,\n name: addon.name,\n category: addon.category,\n image: addon.image as any,\n\n price: priceInfo.price ?? 0,\n adultPrice: priceInfo.adultPrice,\n childPrice: priceInfo.childPrice,\n\n fee: priceInfo.fee ?? 0,\n adultFee: priceInfo.adultFee,\n childFee: priceInfo.childFee,\n\n fees: priceInfo.fees,\n adultFees: priceInfo.adultFees,\n childFees: priceInfo.childFees,\n\n pricingType: addon.pricingType,\n nights: addon.nights,\n };\n }\n\n public getTotalFees(): number {\n return calculateBasketAddonTotal(this.getCalculationParams()).totalFees;\n }\n\n public getTotalPrice(): number {\n return calculateBasketAddonTotal(this.getCalculationParams()).total;\n }\n\n public getItemisedFees(hotelFees: HotelFee[]): ItemisedFee[] {\n const addon = this.getAddon();\n const date = this.getSelectedDate();\n const priceInfo = addon.availability[date];\n const feeMap = new Map<HotelFee, number>();\n\n if (priceInfo.fees?.length && this.getQuantity() > 0) {\n const fees = mapSimpleFeesToItemisedFees(priceInfo.fees, hotelFees);\n accumulateFees(feeMap, fees, this.getQuantity(), this.getNightModifier());\n }\n\n if (priceInfo.adultFees?.length && this.getAdultQuantity() > 0) {\n const fees = mapSimpleFeesToItemisedFees(priceInfo.adultFees, hotelFees);\n accumulateFees(feeMap, fees, this.getAdultQuantity(), this.getNightModifier());\n }\n\n if (priceInfo.childFees?.length && this.getChildQuantity() > 0) {\n const fees = mapSimpleFeesToItemisedFees(priceInfo.childFees, hotelFees);\n accumulateFees(feeMap, fees, this.getChildQuantity(), this.getNightModifier());\n }\n\n return feeMapToArray(feeMap);\n }\n\n /**\n * Returns the subtotal of an addon (without taking into account the nights modifier)\n */\n public getAddonSubtotal(): number {\n const addon = this.getAddon();\n const date = this.getSelectedDate();\n const priceInfo = addon.availability[date];\n\n let price = 0;\n if (priceInfo.price && this.getQuantity() > 0) {\n price += this.getQuantity() * priceInfo.price;\n }\n\n if (priceInfo.adultPrice && this.getAdultQuantity() > 0) {\n price += this.getAdultQuantity() * priceInfo.adultPrice;\n }\n\n if (priceInfo.childPrice && this.getChildQuantity() > 0) {\n price += this.getChildQuantity() * priceInfo.childPrice;\n }\n\n return price;\n }\n\n public getTotalQuantity(): number {\n const addon = this.getAddon();\n const date = this.getSelectedDate();\n const priceInfo = addon.availability[date];\n\n let quantity = 0;\n if (priceInfo.price) {\n quantity += this.getQuantity();\n }\n\n if (priceInfo.adultPrice || addon.pricingType === AddonPricingType.PER_ADULT_OCCUPANCY_PER_NIGHT) {\n quantity += this.getAdultQuantity();\n }\n\n if (priceInfo.childPrice || addon.pricingType === AddonPricingType.PER_CHILD_OCCUPANCY_PER_NIGHT) {\n quantity += this.getChildQuantity();\n }\n\n return quantity;\n }\n\n /**\n * This function returns a value that should multiply the total price of the addon for one (assumed) night\n * Depending on the pricing type\n * @returns number\n */\n public getNightModifier(): number {\n const modifier = 1;\n\n if (ADDON_PER_NIGHT_TYPES.includes(this.addon.pricingType)) {\n return this.addon.checkOutDate.diff(this.addon.checkInDate, 'day');\n } else {\n return modifier;\n }\n }\n\n public setAdultQuantity(value: number) {\n this.adultQuantity = value;\n }\n\n public getChildQuantity(): number {\n return this.childQuantity;\n }\n\n public setChildQuantity(value: number) {\n this.childQuantity = value;\n }\n\n public getID() {\n return this.uniqId;\n }\n\n public isValid() {\n return this.selectedDate && this.addon && this.quantity > 0;\n }\n\n public setSelectedDate(date: string) {\n this.selectedDate = date;\n }\n\n public setSelectedTime(time?: string) {\n this.selectedTime = time as string;\n }\n\n public setQuantity(quantity: number) {\n this.quantity = quantity;\n }\n\n public setAddon(addon: Addon) {\n this.addon = addon;\n }\n}\n"]}
|
|
@@ -82,7 +82,7 @@ export default class BasketRow {
|
|
|
82
82
|
code?: string | undefined;
|
|
83
83
|
price?: number | undefined;
|
|
84
84
|
} | undefined;
|
|
85
|
-
getTotalPrice(
|
|
85
|
+
getTotalPrice(getCost?: boolean): number | undefined;
|
|
86
86
|
checkDiffFromReservation(res: ReservationDTO): false | BasketRowDifferences;
|
|
87
87
|
setAuxiliaryFilter(value: {
|
|
88
88
|
[id: string]: any;
|
|
@@ -28,9 +28,8 @@ class BasketRow {
|
|
|
28
28
|
this.enableRoomCodeFilter = false; // Enable room code filter when the the URL's room parameter is present
|
|
29
29
|
this.roomCode = ''; // Indicates availability for a specific room extracted from the URL's room parameter
|
|
30
30
|
/*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
31
|
+
* Rate is optional since we can create row entries on first step, where there is no ability to select rate.
|
|
32
|
+
*/
|
|
34
33
|
if (rate) {
|
|
35
34
|
this.setRate(rate);
|
|
36
35
|
}
|
|
@@ -210,17 +209,29 @@ class BasketRow {
|
|
|
210
209
|
getUpsellPrevRoom() {
|
|
211
210
|
return this.upsellPrevRoom;
|
|
212
211
|
}
|
|
213
|
-
getTotalPrice(
|
|
212
|
+
getTotalPrice(getCost = false) {
|
|
214
213
|
var _a;
|
|
215
|
-
return (_a = this.getRate()) === null || _a === void 0 ? void 0 : _a.getTotalPrice(
|
|
214
|
+
return (_a = this.getRate()) === null || _a === void 0 ? void 0 : _a.getTotalPrice(getCost);
|
|
216
215
|
}
|
|
217
216
|
checkDiffFromReservation(res) {
|
|
218
217
|
const differences = {};
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
218
|
+
if (res.total.beforeFees) {
|
|
219
|
+
// This beforeFees field will be included when we're using Itemised Fees. Because fees can be a part of
|
|
220
|
+
// rates, we'll just confirm that the price excluding fees is correct for now.
|
|
221
|
+
if (Number(res.total.beforeFees).toFixed(2) !== Number(this.getTotalPrice(true)).toFixed(2)) {
|
|
222
|
+
differences.totalPrice = {
|
|
223
|
+
before: this.getTotalPrice(true),
|
|
224
|
+
after: res.total.beforeFees,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
if (Number(res.total.afterTax).toFixed(2) !== Number(this.getTotalPrice()).toFixed(2)) {
|
|
230
|
+
differences.totalPrice = {
|
|
231
|
+
before: this.getTotalPrice(),
|
|
232
|
+
after: res.total.afterTax,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
224
235
|
}
|
|
225
236
|
if (Object.keys(differences).length) {
|
|
226
237
|
differences.id = this.getID();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasketRow.js","sourceRoot":"/","sources":["src/models/BasketRow.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAO1B,0DAA8D;AAC9D,wCAAqC;AACrC,oEAA4D;AAE5D,6DAA2D;AAC3D,MAAqB,SAAS;IA8C1B;;;;;;OAMG;IACH,YAAmB,IAAe,EAAE,MAAe,EAAE,0BAA0B,GAAG,IAAI;;QA5C9E,mBAAc,GAMlB;YACA,MAAM,EAAE,CAAC;YACT,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,IAAA,eAAK,GAAE;YAClB,OAAO,EAAE,IAAA,eAAK,GAAE;SACnB,CAAC;QAMM,yBAAoB,GAAG,KAAK,CAAC,CAAC,uEAAuE;QACrG,aAAQ,GAAG,EAAE,CAAC,CAAC,qFAAqF;QA0BxG;;;UAGE;QACF,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB;QAED,IAAI,CAAC,MAAM,GAAG,MAAA,oCAAc,CAAC,MAAM,mCAAI,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,MAAA,oCAAc,CAAC,QAAQ,mCAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,MAAA,oCAAc,CAAC,OAAO,mCAAI,CAAC,CAAC;QAE3C,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,0BAA0B,EAAE;YAC5B,MAAM,QAAQ,GAAG,IAAA,sCAAqB,EAAC,wCAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,uCAAuC;YACzG,IAAI,CAAC,oBAAo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AC,WAAW,CAAC,CAAC,MAAM,EAAE;YACjC,WAAW,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAE9B,OAAO,WAAW,CAAC;SACtB;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;IAEM,kBAAkB,CAAC,KAA4B;QAClD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IACjC,CAAC;IAEM,kBAAkB;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEM,uBAAuB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAEM,uBAAuB,CAAC,MAAe;QAC1C,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC;IACvC,CAAC;IAEM,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IAC/B,CAAC;IAEM,WAAW,CAAC,QAAgB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ;AA5UD,4BA4UC","sourcesContent":["import { IBookingQuoteResponse } from '@roomstay/core';\nimport dayjs from 'dayjs';\n\nimport { ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport BasketRowDifferences from '@/models/BasketRowDifferences';\nimport type { Room } from '@/models/Room/Room';\nimport type { RoomRate } from '@/models/Room/RoomRate';\nimport UserProfile from '@/models/UserProfile';\nimport { getQueryParamFromHash } from '@/util/CalendarHelper';\nimport { Color } from '@/util/Color';\nimport { DEFAULT_VALUES } from '@/util/DefaultValueManager';\n\nimport { EAppQueryParameters } from './AppQueryParameters';\nexport default class BasketRow {\n private uniqId: string;\n\n private room!: Room;\n private rate!: RoomRate | null;\n private isStale!: boolean;\n private adults: number;\n private children: number;\n private infants: number;\n private preGuestsState: {\n adults: number;\n children: number;\n infants: number;\n startDate: dayjs.Dayjs;\n endDate: dayjs.Dayjs;\n } = {\n adults: 0,\n children: 0,\n infants: 0,\n startDate: dayjs(),\n endDate: dayjs(),\n };\n\n private promoCode: string;\n private promoCodeStatus: 'valid' | 'invalid' | 'new';\n private manualInputPromoCode: boolean;\n\n private enableRoomCodeFilter = false; // Enable room code filter when the the URL's room parameter is present\n private roomCode = ''; // Indicates availability for a specific room extracted from the URL's room parameter\n\n private startDate!: dayjs.Dayjs;\n private endDate!: dayjs.Dayjs;\n\n private promoOnly: boolean;\n\n private upsellPrevRoom?: {\n code?: string;\n price?: number;\n };\n\n public quoteDetails?: NonNullable<IBookingQuoteResponse>['rows'][number];\n\n public checkoutDefaults?: Partial<UserProfile>;\n\n public auxiliaryFilter?: { [id: string]: string | number };\n\n /**\n *\n * @param rate - Optional `RoomRate` object associated with the basket row.\n * @param uniqId - Optional unique identifier for this basket row instance.\n * @param shouldEnableRoomCodeFilter - Whether to check the URL for a room code and enable filtering accordingly.\n * Defaults to `true`.\n */\n public constructor(rate?: RoomRate, uniqId?: string, shouldEnableRoomCodeFilter = true) {\n /*\n Rate is optional since we can create row entries\n on first step, where there is no ability to select rate.\n */\n if (rate) {\n this.setRate(rate);\n }\n\n this.adults = DEFAULT_VALUES.ADULTS ?? 1;\n this.children = DEFAULT_VALUES.CHILDREN ?? 0;\n this.infants = DEFAULT_VALUES.INFANTS ?? 0;\n\n this.promoCode = '';\n this.promoCodeStatus = 'new';\n this.promoOnly = false;\n if (shouldEnableRoomCodeFilter) {\n const roomCode = getQueryParamFromHash(EAppQueryParameters.Room); // Extract the the URL's room parameter\n this.enableRoomCodeFilter = !!roomCode;\n this.roomCode = roomCode || '';\n }\n\n this.manualInputPromoCode = false;\n\n this.uniqId = uniqId ? uniqId : btoa(((Date.now() % 1000) / 1000) * Math.random() + '');\n }\n\n public getStale() {\n return this.isStale;\n }\n\n public getRate() {\n return this.rate;\n }\n\n public getPromoCode(memberOnlyPromoCode?: string) {\n if (!memberOnlyPromoCode) {\n return this.promoCode.toUpperCase();\n }\n\n if (memberOnlyPromoCode !== this.promoCode.toUpperCase() || this.isManualInputPromoCode()) {\n return this.promoCode.toUpperCase();\n }\n\n return '';\n }\n\n public getPromoOnly() {\n return this.promoOnly;\n }\n\n public getPromoCodeColour() {\n if (this.promoCodeStatus === 'valid') {\n return Color.Success;\n } else if (this.promoCodeStatus === 'invalid') {\n return Color.Alert;\n }\n\n return Color.Navy;\n }\n\n public isPromoCodeValid() {\n const rate = this.getRate();\n\n return (rate?.getAveragePrice(true) as number) < (rate?.getAveragePriceBeforeDiscount(true) as number) && this.getPromoCode() && this.getPromoCodeStatus() === 'valid';\n }\n\n public isManualInputPromoCode() {\n return this.manualInputPromoCode;\n }\n\n public setManualInputPromoCode(value: boolean) {\n this.manualInputPromoCode = value;\n }\n\n public getNumberOfDays() {\n if (this.endDate && this.startDate) {\n return this.endDate.diff(this.startDate, 'day');\n }\n\n return 0;\n }\n\n public getRoom() {\n return this.room;\n }\n\n public getStartDate() {\n return this.startDate;\n }\n\n public getEndDate() {\n return this.endDate;\n }\n\n public getArrivalDate() {\n if (this.startDate) {\n return this.startDate.format('D MMM');\n }\n\n return null;\n }\n\n public getDepartureDate() {\n if (this.endDate) {\n return this.endDate.format('D MMM');\n }\n\n return null;\n }\n\n public getStayDateRange(format = 'ddd D MMM', separator = ',') {\n if (this.startDate && this.endDate) {\n return `${this.startDate.format(format)}${separator} ${this.endDate.format(format)}`;\n }\n }\n\n public getAdults() {\n return this.adults;\n }\n\n public getChildren() {\n return this.children;\n }\n\n public getInfants() {\n return this.infants;\n }\n\n public getPreGuestsState() {\n return this.preGuestsState;\n }\n\n public getID() {\n return this.uniqId;\n }\n\n public getPromoCodeStatus() {\n return this.promoCodeStatus;\n }\n\n public isValid(): boolean {\n return this.startDate && this.endDate && !!this.rate;\n }\n\n public setPromoCode(code: string) {\n if (this.promoCode !== code.toUpperCase()) {\n this.setPromoCodeStatus('new');\n this.promoOnly = false;\n }\n\n this.promoCode = code.toUpperCase();\n }\n\n public setPromoOnly(value: boolean) {\n this.promoOnly = value;\n }\n\n public setStale(status: boolean) {\n this.isStale = status;\n }\n\n public setPromoCodeStatus(status: 'valid' | 'invalid' | 'new') {\n this.promoCodeStatus = this.promoCode ? status : 'new';\n }\n\n public setStartDate(date: dayjs.Dayjs) {\n if (date?.isValid() || date === undefined) {\n this.startDate = date;\n }\n }\n\n public setEndDate(date: dayjs.Dayjs) {\n if (date?.isValid() || date === undefined) {\n this.endDate = date;\n }\n }\n\n public setAdults(adults: number) {\n this.adults = adults;\n }\n\n public setChildren(children: number) {\n this.children = children;\n }\n\n public setInfants(infants: number) {\n this.infants = infants;\n }\n\n public setPreGuestsState() {\n this.preGuestsState.adults = this.adults;\n this.preGuestsState.children = this.children;\n this.preGuestsState.infants = this.infants;\n this.preGuestsState.startDate = this.startDate;\n this.preGuestsState.endDate = this.endDate;\n }\n\n public discardGuestsState() {\n this.setAdults(this.preGuestsState.adults);\n this.setChildren(this.preGuestsState.children);\n this.setInfants(this.preGuestsState.infants);\n this.setStartDate(this.preGuestsState.startDate);\n this.setEndDate(this.preGuestsState.endDate);\n }\n\n public setRate(rate: RoomRate | null, upsellEnabled?: boolean) {\n if (upsellEnabled) {\n this.upsellPrevRoom = {\n code: this.room.code,\n price: this.rate?.getTotalPrice(),\n };\n }\n\n this.rate = rate;\n\n if (rate) {\n this.room = rate.getRoom();\n this.roomCode = this.room.code!; // [step/room] Update Indicates availability for a specific room\n }\n }\n\n public setUpsellPrevRoom(roomCode: string, price: number) {\n this.upsellPrevRoom = {\n code: roomCode,\n price,\n };\n }\n\n public getUpsellPrevRoom() {\n return this.upsellPrevRoom;\n }\n\n public getTotalPrice(beforeTax = false) {\n return this.getRate()?.getTotalPrice(beforeTax);\n }\n\n public checkDiffFromReservation(res: ReservationDTO) {\n const differences: BasketRowDifferences = {};\n\n if (Number(res.total.afterTax).toFixed(2) !== Number(this.getTotalPrice()).toFixed(2)) {\n differences.totalPrice = {\n before: this.getTotalPrice(),\n after: res.total.afterTax,\n };\n }\n\n if (Object.keys(differences).length) {\n differences.id = this.getID();\n\n return differences;\n } else {\n return false;\n }\n }\n\n public setAuxiliaryFilter(value: { [id: string]: any }) {\n this.auxiliaryFilter = value;\n }\n\n public getAuxiliaryFilter() {\n return this.auxiliaryFilter;\n }\n\n public getEnableRoomCodeFilter() {\n return this.enableRoomCodeFilter;\n }\n\n public setEnableRoomCodeFilter(enable: boolean) {\n this.enableRoomCodeFilter = enable;\n }\n\n public getRoomCode() {\n return this.roomCode || '';\n }\n\n public setRoomCode(roomCode: string) {\n this.roomCode = roomCode;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BasketRow.js","sourceRoot":"/","sources":["src/models/BasketRow.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAO1B,0DAA8D;AAC9D,wCAAqC;AACrC,oEAA4D;AAE5D,6DAA2D;AAC3D,MAAqB,SAAS;IA8C1B;;;;;;OAMG;IACH,YAAmB,IAAe,EAAE,MAAe,EAAE,0BAA0B,GAAG,IAAI;;QA5C9E,mBAAc,GAMlB;YACA,MAAM,EAAE,CAAC;YACT,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,IAAA,eAAK,GAAE;YAClB,OAAO,EAAE,IAAA,eAAK,GAAE;SACnB,CAAC;QAMM,yBAAoB,GAAG,KAAK,CAAC,CAAC,uEAAuE;QACrG,aAAQ,GAAG,EAAE,CAAC,CAAC,qFAAqF;QA0BxG;;WAEG;QACH,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB;QAED,IAAI,CAAC,MAAM,GAAG,MAAA,oCAAc,CAAC,MAAM,mCAAI,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,MAAA,oCAAc,CAAC,QAAQ,mCAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,MAAA,oCAAc,CAAC,OAAO,mCAAI,CAAC,CAAC;QAE3C,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IA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B,CAAC;CACJ;AAtVD,4BAsVC","sourcesContent":["import { IBookingQuoteResponse } from '@roomstay/core';\nimport dayjs from 'dayjs';\n\nimport { ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport BasketRowDifferences from '@/models/BasketRowDifferences';\nimport type { Room } from '@/models/Room/Room';\nimport type { RoomRate } from '@/models/Room/RoomRate';\nimport UserProfile from '@/models/UserProfile';\nimport { getQueryParamFromHash } from '@/util/CalendarHelper';\nimport { Color } from '@/util/Color';\nimport { DEFAULT_VALUES } from '@/util/DefaultValueManager';\n\nimport { EAppQueryParameters } from './AppQueryParameters';\nexport default class BasketRow {\n private uniqId: string;\n\n private room!: Room;\n private rate!: RoomRate | null;\n private isStale!: boolean;\n private adults: number;\n private children: number;\n private infants: number;\n private preGuestsState: {\n adults: number;\n children: number;\n infants: number;\n startDate: dayjs.Dayjs;\n endDate: dayjs.Dayjs;\n } = {\n adults: 0,\n children: 0,\n infants: 0,\n startDate: dayjs(),\n endDate: dayjs(),\n };\n\n private promoCode: string;\n private promoCodeStatus: 'valid' | 'invalid' | 'new';\n private manualInputPromoCode: boolean;\n\n private enableRoomCodeFilter = false; // Enable room code filter when the the URL's room parameter is present\n private roomCode = ''; // Indicates availability for a specific room extracted from the URL's room parameter\n\n private startDate!: dayjs.Dayjs;\n private endDate!: dayjs.Dayjs;\n\n private promoOnly: boolean;\n\n private upsellPrevRoom?: {\n code?: string;\n price?: number;\n };\n\n public quoteDetails?: NonNullable<IBookingQuoteResponse>['rows'][number];\n\n public checkoutDefaults?: Partial<UserProfile>;\n\n public auxiliaryFilter?: { [id: string]: string | number };\n\n /**\n *\n * @param rate - Optional `RoomRate` object associated with the basket row.\n * @param uniqId - Optional unique identifier for this basket row instance.\n * @param shouldEnableRoomCodeFilter - Whether to check the URL for a room code and enable filtering accordingly.\n * Defaults to `true`.\n */\n public constructor(rate?: RoomRate, uniqId?: string, shouldEnableRoomCodeFilter = true) {\n /*\n * Rate is optional since we can create row entries on first step, where there is no ability to select rate.\n */\n if (rate) {\n this.setRate(rate);\n }\n\n this.adults = DEFAULT_VALUES.ADULTS ?? 1;\n this.children = DEFAULT_VALUES.CHILDREN ?? 0;\n this.infants = DEFAULT_VALUES.INFANTS ?? 0;\n\n this.promoCode = '';\n this.promoCodeStatus = 'new';\n this.promoOnly = false;\n if (shouldEnableRoomCodeFilter) {\n const roomCode = getQueryParamFromHash(EAppQueryParameters.Room); // Extract the the URL's room parameter\n this.enableRoomCodeFilter = !!roomCode;\n this.roomCode = roomCode || '';\n }\n\n this.manualInputPromoCode = false;\n\n this.uniqId = uniqId ? uniqId : btoa(((Date.now() % 1000) / 1000) * Math.random() + '');\n }\n\n public getStale() {\n return this.isStale;\n }\n\n public getRate() {\n return this.rate;\n }\n\n public getPromoCode(memberOnlyPromoCode?: string) {\n if (!memberOnlyPromoCode) {\n return this.promoCode.toUpperCase();\n }\n\n if (memberOnlyPromoCode !== this.promoCode.toUpperCase() || this.isManualInputPromoCode()) {\n return this.promoCode.toUpperCase();\n }\n\n return '';\n }\n\n public getPromoOnly() {\n return this.promoOnly;\n }\n\n public getPromoCodeColour() {\n if (this.promoCodeStatus === 'valid') {\n return Color.Success;\n } else if (this.promoCodeStatus === 'invalid') {\n return Color.Alert;\n }\n\n return Color.Navy;\n }\n\n public isPromoCodeValid() {\n const rate = this.getRate();\n\n return (rate?.getAveragePrice(true) as number) < (rate?.getAveragePriceBeforeDiscount(true) as number) && this.getPromoCode() && this.getPromoCodeStatus() === 'valid';\n }\n\n public isManualInputPromoCode() {\n return this.manualInputPromoCode;\n }\n\n public setManualInputPromoCode(value: boolean) {\n this.manualInputPromoCode = value;\n }\n\n public getNumberOfDays() {\n if (this.endDate && this.startDate) {\n return this.endDate.diff(this.startDate, 'day');\n }\n\n return 0;\n }\n\n public getRoom() {\n return this.room;\n }\n\n public getStartDate() {\n return this.startDate;\n }\n\n public getEndDate() {\n return this.endDate;\n }\n\n public getArrivalDate() {\n if (this.startDate) {\n return this.startDate.format('D MMM');\n }\n\n return null;\n }\n\n public getDepartureDate() {\n if (this.endDate) {\n return this.endDate.format('D MMM');\n }\n\n return null;\n }\n\n public getStayDateRange(format = 'ddd D MMM', separator = ',') {\n if (this.startDate && this.endDate) {\n return `${this.startDate.format(format)}${separator} ${this.endDate.format(format)}`;\n }\n }\n\n public getAdults() {\n return this.adults;\n }\n\n public getChildren() {\n return this.children;\n }\n\n public getInfants() {\n return this.infants;\n }\n\n public getPreGuestsState() {\n return this.preGuestsState;\n }\n\n public getID() {\n return this.uniqId;\n }\n\n public getPromoCodeStatus() {\n return this.promoCodeStatus;\n }\n\n public isValid(): boolean {\n return this.startDate && this.endDate && !!this.rate;\n }\n\n public setPromoCode(code: string) {\n if (this.promoCode !== code.toUpperCase()) {\n this.setPromoCodeStatus('new');\n this.promoOnly = false;\n }\n\n this.promoCode = code.toUpperCase();\n }\n\n public setPromoOnly(value: boolean) {\n this.promoOnly = value;\n }\n\n public setStale(status: boolean) {\n this.isStale = status;\n }\n\n public setPromoCodeStatus(status: 'valid' | 'invalid' | 'new') {\n this.promoCodeStatus = this.promoCode ? status : 'new';\n }\n\n public setStartDate(date: dayjs.Dayjs) {\n if (date?.isValid() || date === undefined) {\n this.startDate = date;\n }\n }\n\n public setEndDate(date: dayjs.Dayjs) {\n if (date?.isValid() || date === undefined) {\n this.endDate = date;\n }\n }\n\n public setAdults(adults: number) {\n this.adults = adults;\n }\n\n public setChildren(children: number) {\n this.children = children;\n }\n\n public setInfants(infants: number) {\n this.infants = infants;\n }\n\n public setPreGuestsState() {\n this.preGuestsState.adults = this.adults;\n this.preGuestsState.children = this.children;\n this.preGuestsState.infants = this.infants;\n this.preGuestsState.startDate = this.startDate;\n this.preGuestsState.endDate = this.endDate;\n }\n\n public discardGuestsState() {\n this.setAdults(this.preGuestsState.adults);\n this.setChildren(this.preGuestsState.children);\n this.setInfants(this.preGuestsState.infants);\n this.setStartDate(this.preGuestsState.startDate);\n this.setEndDate(this.preGuestsState.endDate);\n }\n\n public setRate(rate: RoomRate | null, upsellEnabled?: boolean) {\n if (upsellEnabled) {\n this.upsellPrevRoom = {\n code: this.room.code,\n price: this.rate?.getTotalPrice(),\n };\n }\n\n this.rate = rate;\n\n if (rate) {\n this.room = rate.getRoom();\n this.roomCode = this.room.code!; // [step/room] Update Indicates availability for a specific room\n }\n }\n\n public setUpsellPrevRoom(roomCode: string, price: number) {\n this.upsellPrevRoom = {\n code: roomCode,\n price,\n };\n }\n\n public getUpsellPrevRoom() {\n return this.upsellPrevRoom;\n }\n\n public getTotalPrice(getCost = false) {\n return this.getRate()?.getTotalPrice(getCost);\n }\n\n public checkDiffFromReservation(res: ReservationDTO) {\n const differences: BasketRowDifferences = {};\n\n if (res.total.beforeFees) {\n // This beforeFees field will be included when we're using Itemised Fees. Because fees can be a part of\n // rates, we'll just confirm that the price excluding fees is correct for now.\n if (Number(res.total.beforeFees).toFixed(2) !== Number(this.getTotalPrice(true)).toFixed(2)) {\n differences.totalPrice = {\n before: this.getTotalPrice(true),\n after: res.total.beforeFees,\n };\n }\n } else {\n if (Number(res.total.afterTax).toFixed(2) !== Number(this.getTotalPrice()).toFixed(2)) {\n differences.totalPrice = {\n before: this.getTotalPrice(),\n after: res.total.afterTax,\n };\n }\n }\n\n if (Object.keys(differences).length) {\n differences.id = this.getID();\n\n return differences;\n } else {\n return false;\n }\n }\n\n public setAuxiliaryFilter(value: { [id: string]: any }) {\n this.auxiliaryFilter = value;\n }\n\n public getAuxiliaryFilter() {\n return this.auxiliaryFilter;\n }\n\n public getEnableRoomCodeFilter() {\n return this.enableRoomCodeFilter;\n }\n\n public setEnableRoomCodeFilter(enable: boolean) {\n this.enableRoomCodeFilter = enable;\n }\n\n public getRoomCode() {\n return this.roomCode || '';\n }\n\n public setRoomCode(roomCode: string) {\n this.roomCode = roomCode;\n }\n}\n"]}
|
|
@@ -12,6 +12,7 @@ import type { HotelDataSource } from './HotelDataSource.types';
|
|
|
12
12
|
import type { HotelPerk } from './HotelPerk';
|
|
13
13
|
import type { HotelRoomOverwrite } from './HotelRoomOverwrite';
|
|
14
14
|
import type { WeekdayStartsOn } from './WeekdayStartsOn.types';
|
|
15
|
+
import { HotelFee } from '../../Fee';
|
|
15
16
|
import type { Language } from '../../../providers/LanguageProvider';
|
|
16
17
|
import { RoomSort } from '../../../providers/RoomSortProvider';
|
|
17
18
|
export declare enum EPaymentCardType {
|
|
@@ -77,6 +78,7 @@ export interface AdminHotelConfig {
|
|
|
77
78
|
roomGroups: HotelRoomGroupsDTO;
|
|
78
79
|
cardProcessor: EHotelCardProcessor;
|
|
79
80
|
requireDeposit?: boolean;
|
|
81
|
+
/** @deprecated Use the new Fees model instead */
|
|
80
82
|
enableCreditCardSurcharge?: boolean;
|
|
81
83
|
availableCountries?: {
|
|
82
84
|
name: string;
|
|
@@ -104,6 +106,8 @@ export interface AdminHotelConfig {
|
|
|
104
106
|
memberOnlyImage?: string;
|
|
105
107
|
captureChildAge?: boolean;
|
|
106
108
|
itineraryNote: string;
|
|
109
|
+
fees?: HotelFee[];
|
|
110
|
+
addDepositFeeToBookingTotal?: boolean;
|
|
107
111
|
company: {
|
|
108
112
|
url?: string;
|
|
109
113
|
logo?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hotel.js","sourceRoot":"/","sources":["src/models/Client/Hotel/Hotel.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Hotel.js","sourceRoot":"/","sources":["src/models/Client/Hotel/Hotel.ts"],"names":[],"mappings":";;;AAmBA,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IACxB,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,8BAAU,CAAA;IACV,0CAAsB,CAAA;IACtB,qCAAiB,CAAA;IACjB,mCAAe,CAAA;AACnB,CAAC,EAPW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAO3B","sourcesContent":["import { EnvironmentName } from '@planpay/web/src/lib/shared-lib-duplicates';\nimport { EBookingPaymentMethod, EHotelCardProcessor, EHotelStateFieldConfiguration, EIntegration, IHotelColorScheme } from '@roomstay/core';\nimport { Property } from 'csstype';\nimport type { ReactChild } from 'react';\n\nimport type { InternalMemberSignInInputs } from '@/components/members/SignInModal/InternalMemberSignInModal.types';\nimport type { HotelRoomGroupsDTO, HotelRoomsDTO, HotelServiceDTO } from '@/models/Api/HotelDTO';\nimport type { TransportDistances } from '@/models/Api/HotelOverrideDTO';\nimport type { HasDatalayerTags } from '@/models/Client/Hotel/Company';\nimport type { DistanceUnitType } from '@/models/Client/Hotel/DistanceUnitType.types';\nimport type HotelAddress from '@/models/Client/Hotel/HotelAddress';\nimport type { HotelDataSource } from '@/models/Client/Hotel/HotelDataSource.types';\nimport type { HotelPerk } from '@/models/Client/Hotel/HotelPerk';\nimport type { HotelRoomOverwrite } from '@/models/Client/Hotel/HotelRoomOverwrite';\nimport type { WeekdayStartsOn } from '@/models/Client/Hotel/WeekdayStartsOn.types';\nimport { HotelFee } from '@/models/Fee';\nimport type { Language } from '@/providers/LanguageProvider';\nimport { RoomSort } from '@/providers/RoomSortProvider';\n\nexport enum EPaymentCardType {\n Visa = 'VI',\n Mastercard = 'MC',\n JCB = 'JC',\n AmericanExpress = 'AX',\n DinersClub = 'DN',\n UnionPay = 'UP',\n}\n\nexport interface IVGSVaultNames {\n standard: string;\n members: string;\n}\n\n/**\n * This config comes from admin\n */\nexport interface AdminHotelConfig {\n hotelID: string;\n name: string;\n address?: HotelAddress;\n latitude?: number;\n longitude?: number;\n phone?: string;\n email?: string;\n checkInTime?: string;\n checkOutTime?: string;\n paymentCardTypes?: EPaymentCardType[];\n description?: string;\n locationDescription?: string;\n policies?: string;\n hotelServices: HotelServiceDTO[];\n businessServices: HotelServiceDTO[];\n rooms: HotelRoomsDTO;\n hasLoadedDetails?: boolean;\n dataSource: HotelDataSource;\n defaultCurrency: string;\n paymentMethods: EBookingPaymentMethod[];\n planpay?: {\n username: string;\n minDaysShowPlanpay: number;\n env: EnvironmentName;\n };\n hotelUrl: string;\n heroImage: string;\n memberOnlyModalImage?: string;\n memberOnlyModalImageSize: Property.ObjectFit;\n images?: string[];\n logo: string | ReactChild;\n colors: IHotelColorScheme;\n distanceUnitType: DistanceUnitType;\n startsWeekOnDay?: WeekdayStartsOn;\n crossSellHotelIds?: string[];\n maxOccupancy?: number;\n minAdultAge?: number;\n maxAdultAge?: number;\n maxAdults?: number;\n maxChildren?: number;\n maxInfants?: number;\n countInfantsInOccupancy?: boolean;\n hideByLine?: boolean;\n transportDistances?: TransportDistances;\n roomGroups: HotelRoomGroupsDTO;\n cardProcessor: EHotelCardProcessor;\n\n requireDeposit?: boolean;\n /** @deprecated Use the new Fees model instead */\n enableCreditCardSurcharge?: boolean;\n availableCountries?: { name: string; value: string }[];\n\n childConfiguration?: {\n supportChildren?: boolean;\n supportInfants: boolean;\n childRange: { min: number; max: number };\n infantRange: { min: number; max: number };\n };\n preventCancellation?: boolean;\n\n perks?: HotelPerk[];\n perkTitle?: string;\n\n stateFieldConfiguration?: EHotelStateFieldConfiguration;\n\n countryPrefix?: string;\n quoteImageDesktop?: string;\n quoteImageMobile?: string;\n memberOnlyImage?: string;\n captureChildAge?: boolean;\n itineraryNote: string;\n\n fees?: HotelFee[];\n addDepositFeeToBookingTotal?: boolean;\n\n company: {\n url?: string;\n logo?: string;\n };\n}\n\n/**\n * This config comes from hard static local file\n */\nexport interface ClientHotelConfig {\n providerHotelID: string;\n shortName?: string;\n defaultDatepickerType?: 'Month' | 'Week';\n // TODO: need to do magic to see if we need to append / prepend stuff, for now we assume that it's only used while on the site.\n checkoutUrl?: string;\n defaultLanguage: Language;\n privacyPolicyUrl: string;\n bookNowPayLaterUrl?: string;\n bestRateNoBSUrl?: string;\n\n memberOnlyRates?: string[];\n memberOnlyPromoCode?: string;\n memberOnlyRenderRateLast?: boolean;\n memberOnlySignupInputs?: InternalMemberSignInInputs;\n googleMapsImage?: string;\n /**\n * Whether to show the Breakfast / Lunch / Dinner included\n */\n showMealPill?: boolean;\n perks?: HotelPerk[];\n perkTitle?: string;\n /**\n * Hide perks on room row\n */\n perksHideOnRoomRow?: boolean;\n /**\n * Hide perks on room detail modal\n */\n perksHideOnRoomDetail?: boolean;\n perksShowDisclaimer?: boolean;\n /** @deprecated Use the vgs.vaultNames.standard property now */\n vgsVaultName?: string;\n vgs?: {\n vaultNames: IVGSVaultNames;\n };\n showAddonLoader: boolean;\n overwrites?: { [code: string]: Partial<HotelRoomOverwrite> };\n forwardFindReservationToSynxis?: boolean;\n additionalOptions?: { [name: string]: any };\n googleReCaptcha?: {\n loadForMembers?: boolean;\n siteKey?: string;\n };\n /**\n * Show description on RoomDetails\n */\n showDescriptionOnRoomDetails?: boolean;\n /**\n * Customize the Member modal colours. Specifically replacing the green (success) with the primary color of hotel (accent)\n */\n memberOnlyModalUsePrimaryColor?: boolean;\n /**\n * Callback to trigger specific events on load of a hotel.\n *\n * This is where you can specify custom fields, language overrides, feature toggles etc.\n */\n onLoad?: () => void;\n currentRoomSort?: RoomSort; //override default room sort\n maxAdults?: number; //fixed from frontend\n}\n\nexport interface ConfigHotel extends ClientHotelConfig, AdminHotelConfig, HasDatalayerTags {}\n\nexport type Hotel = ConfigHotel & {\n lowestPrice?: {\n value: number;\n isLoading: boolean;\n };\n integrations?: EIntegration[];\n};\n\n/**\n * Used for DetailsHotel event\n */\nexport type InitialHotelDetailsEventPayload = {\n name: string;\n hotelID: number | string;\n hotelUrl: string;\n currency: string;\n language: Language;\n address?: HotelAddress;\n};\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EFeeType, IFeeConfigurationOptions } from '@roomstay/core';
|
|
2
|
+
/**
|
|
3
|
+
* Availability and Itinerary responses will include fees using this type.
|
|
4
|
+
*/
|
|
5
|
+
export type SimpleItemisedFee = {
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
amount: number;
|
|
9
|
+
};
|
|
10
|
+
export type HotelFee = {
|
|
11
|
+
name: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
amount: number;
|
|
14
|
+
feeType: EFeeType;
|
|
15
|
+
} & IFeeConfigurationOptions;
|
|
16
|
+
export type ItemisedFee = {
|
|
17
|
+
hotelFee: HotelFee;
|
|
18
|
+
amount: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Helper function to accumulate given fees into the given feeMap.
|
|
22
|
+
*/
|
|
23
|
+
export declare function accumulateFees(feeMap: Map<HotelFee, number>, fees: ItemisedFee[], quantity?: number, nightsModifier?: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Converts an accumulated Map of fees into an array of ItemisedFee objects.
|
|
26
|
+
*/
|
|
27
|
+
export declare function feeMapToArray(feeMap: Map<HotelFee, number>): ItemisedFee[];
|
|
28
|
+
/**
|
|
29
|
+
* Sorts an array of ItemisedFee objects based on their position in hotelFees array.
|
|
30
|
+
*/
|
|
31
|
+
export declare function sortFees(fees: ItemisedFee[], hotelFees: HotelFee[]): ItemisedFee[];
|
|
32
|
+
export declare function mapSimpleFeesToItemisedFees(fees: SimpleItemisedFee[], hotelFees: HotelFee[]): ItemisedFee[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapSimpleFeesToItemisedFees = exports.sortFees = exports.feeMapToArray = exports.accumulateFees = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to accumulate given fees into the given feeMap.
|
|
6
|
+
*/
|
|
7
|
+
function accumulateFees(feeMap, fees, quantity = 1, nightsModifier = 1) {
|
|
8
|
+
fees.forEach((itemisedFee) => {
|
|
9
|
+
const currentAmount = feeMap.get(itemisedFee.hotelFee) || 0;
|
|
10
|
+
feeMap.set(itemisedFee.hotelFee, currentAmount + itemisedFee.amount * quantity * nightsModifier);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.accumulateFees = accumulateFees;
|
|
14
|
+
/**
|
|
15
|
+
* Converts an accumulated Map of fees into an array of ItemisedFee objects.
|
|
16
|
+
*/
|
|
17
|
+
function feeMapToArray(feeMap) {
|
|
18
|
+
return Array.from(feeMap.entries()).map(([hotelFee, amount]) => ({
|
|
19
|
+
hotelFee,
|
|
20
|
+
amount,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
exports.feeMapToArray = feeMapToArray;
|
|
24
|
+
/**
|
|
25
|
+
* Sorts an array of ItemisedFee objects based on their position in hotelFees array.
|
|
26
|
+
*/
|
|
27
|
+
function sortFees(fees, hotelFees) {
|
|
28
|
+
return [...fees].sort((a, b) => {
|
|
29
|
+
const indexA = hotelFees.findIndex((f) => f.name === a.hotelFee.name);
|
|
30
|
+
const indexB = hotelFees.findIndex((f) => f.name === b.hotelFee.name);
|
|
31
|
+
return indexA - indexB;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.sortFees = sortFees;
|
|
35
|
+
function mapSimpleFeesToItemisedFees(fees, hotelFees) {
|
|
36
|
+
return fees
|
|
37
|
+
.map((fee) => {
|
|
38
|
+
const hotelFee = hotelFees.find((f) => f.name === fee.name);
|
|
39
|
+
if (!hotelFee) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
hotelFee,
|
|
44
|
+
amount: fee.amount,
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
.filter((fee) => fee !== null);
|
|
48
|
+
}
|
|
49
|
+
exports.mapSimpleFeesToItemisedFees = mapSimpleFeesToItemisedFees;
|
|
50
|
+
//# sourceMappingURL=Fee.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fee.js","sourceRoot":"/","sources":["src/models/Fee.ts"],"names":[],"mappings":";;;AAuBA;;GAEG;AACH,SAAgB,cAAc,CAAC,MAA6B,EAAE,IAAmB,EAAE,QAAQ,GAAG,CAAC,EAAE,cAAc,GAAG,CAAC;IAC/G,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QACzB,MAAM,a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AAI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC;QAE5D,IAAI,CAAC,QAAQ,EAAE;YACX,OAAO,IAAI,CAAC;SACf;QAED,OAAO;YACH,QAAQ;YACR,MAAM,EAAE,GAAG,CAAC,MAAM;SACrB,CAAC;IACN,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,CAAkB,CAAC;AACxD,CAAC;AAfD,kEAeC","sourcesContent":["import { EFeeType, IFeeConfigurationOptions } from '@roomstay/core';\n\n/**\n * Availability and Itinerary responses will include fees using this type.\n */\nexport type SimpleItemisedFee = {\n name: string;\n description?: string;\n amount: number;\n};\n\nexport type HotelFee = {\n name: string;\n description?: string;\n amount: number;\n feeType: EFeeType;\n} & IFeeConfigurationOptions;\n\nexport type ItemisedFee = {\n hotelFee: HotelFee;\n amount: number;\n};\n\n/**\n * Helper function to accumulate given fees into the given feeMap.\n */\nexport function accumulateFees(feeMap: Map<HotelFee, number>, fees: ItemisedFee[], quantity = 1, nightsModifier = 1): void {\n fees.forEach((itemisedFee) => {\n const currentAmount = feeMap.get(itemisedFee.hotelFee) || 0;\n feeMap.set(itemisedFee.hotelFee, currentAmount + itemisedFee.amount * quantity * nightsModifier);\n });\n}\n\n/**\n * Converts an accumulated Map of fees into an array of ItemisedFee objects.\n */\nexport function feeMapToArray(feeMap: Map<HotelFee, number>): ItemisedFee[] {\n return Array.from(feeMap.entries()).map(([hotelFee, amount]) => ({\n hotelFee,\n amount,\n }));\n}\n\n/**\n * Sorts an array of ItemisedFee objects based on their position in hotelFees array.\n */\nexport function sortFees(fees: ItemisedFee[], hotelFees: HotelFee[]): ItemisedFee[] {\n return [...fees].sort((a, b) => {\n const indexA = hotelFees.findIndex((f) => f.name === a.hotelFee.name);\n const indexB = hotelFees.findIndex((f) => f.name === b.hotelFee.name);\n return indexA - indexB;\n });\n}\n\nexport function mapSimpleFeesToItemisedFees(fees: SimpleItemisedFee[], hotelFees: HotelFee[]): ItemisedFee[] {\n return fees\n .map((fee) => {\n const hotelFee = hotelFees.find((f) => f.name === fee.name);\n\n if (!hotelFee) {\n return null;\n }\n\n return {\n hotelFee,\n amount: fee.amount,\n };\n })\n .filter((fee) => fee !== null) as ItemisedFee[];\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { HotelFee, ItemisedFee } from '../Fee';
|
|
2
3
|
import type { Room } from './Room';
|
|
3
4
|
import RoomRateNight, { IRoomRateNight } from './RoomRateNight';
|
|
4
5
|
import type RoomRateSortable from './RoomRateSortable';
|
|
@@ -97,6 +98,7 @@ export declare class RoomRate implements RoomRateSortable, Serializable<RoomRate
|
|
|
97
98
|
getAveragePrice: (getCost?: boolean) => number;
|
|
98
99
|
getAveragePriceBeforeDiscount: (getCost?: boolean) => number;
|
|
99
100
|
getTotalFees: () => number;
|
|
101
|
+
getItemisedFees: (hotelFees: HotelFee[]) => ItemisedFee[];
|
|
100
102
|
getTotalTaxes: () => number;
|
|
101
103
|
getPriceType: () => RoomRatePriceInclusion;
|
|
102
104
|
getGuaranteePolicy: () => string;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.RoomRate = exports.RoomRatePriceInclusion = void 0;
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
8
|
const AvailabilityAPI_1 = __importDefault(require("../../api/AvailabilityAPI"));
|
|
9
|
+
const Fee_1 = require("../Fee");
|
|
9
10
|
const RoomRateNight_1 = __importDefault(require("./RoomRateNight"));
|
|
10
11
|
const StaticContextProvider_1 = __importDefault(require("../../providers/StaticContextProvider"));
|
|
11
12
|
var RoomRatePriceInclusion;
|
|
@@ -60,6 +61,16 @@ class RoomRate {
|
|
|
60
61
|
return Number(night.fee);
|
|
61
62
|
});
|
|
62
63
|
};
|
|
64
|
+
this.getItemisedFees = (hotelFees) => {
|
|
65
|
+
const feeMap = new Map();
|
|
66
|
+
this.getNightRateArray().forEach((night) => {
|
|
67
|
+
if (night.fees) {
|
|
68
|
+
const fees = (0, Fee_1.mapSimpleFeesToItemisedFees)(night.fees, hotelFees);
|
|
69
|
+
(0, Fee_1.accumulateFees)(feeMap, fees);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return (0, Fee_1.feeMapToArray)(feeMap);
|
|
73
|
+
};
|
|
63
74
|
this.getTotalTaxes = () => {
|
|
64
75
|
return this.nightRateTotal((night) => {
|
|
65
76
|
return Number(night.tax);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoomRate.js","sourceRoot":"/","sources":["src/models/Room/RoomRate.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAqC;AAErC,4EAAoD;AAEpD,gFAA4E;AAG5E,8FAAsE;AAEtE,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAC9B,yDAA+B,CAAA;IAC/B,2DAAiC,CAAA;IACjC,4EAAkD,CAAA;IAClD,4EAAkD,CAAA;AACtD,CAAC,EALW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAKjC;AA8DD,MAAa,QAAQ;IA8BjB;QAbO,kBAAa,GAIhB;YACA,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,KAAK;SAChB,CAAC;QAoCK,kBAAa,GAAG,CAAC,OAAO,GAAG,KAAK,EAAE,EAAE;YACvC,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACrD,aAAa,CAAC,OAAO,CAAC,CAAC,KAAoB,EAAE,EAAE;gBAC3C,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;YACH,OAAO,KAAK,CAAC;QACjB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IAAI,CAAC;IAChB,CAAC;CA6VJ;AA/iBD,4BA+iBC","sourcesContent":["import dayjs, { Dayjs } from 'dayjs';\n\nimport AvailabilityAPI from '@/api/AvailabilityAPI';\nimport type { Room } from '@/models/Room/Room';\nimport RoomRateNight, { IRoomRateNight } from '@/models/Room/RoomRateNight';\nimport type RoomRateSortable from '@/models/Room/RoomRateSortable';\nimport type { Serializable } from '@/models/Serializable';\nimport StaticContextProvider from '@/providers/StaticContextProvider';\n\nexport enum RoomRatePriceInclusion {\n ExcludingFees = 'Fees Excluded',\n ExcludingTaxes = 'Taxes Excluded',\n ExcludingFeesAndTaxes = 'Excluding Fees and Taxes',\n IncludingFeesAndTaxes = 'Including Fees and Taxes',\n}\n\nexport interface IRoomRate {\n name: string;\n code: string;\n description: string;\n longDescription?: string;\n\n isMemberOnly?: boolean;\n guaranteeCode: string;\n cancelPolicyCode: string;\n nightRates: { [date: string]: IRoomRateNight };\n\n lowestPrice: number;\n promoCode: string;\n promoCodeName: string;\n\n mealsIncluded?: {\n breakfast: boolean;\n lunch: boolean;\n dinner: boolean;\n };\n rateOverrides?: RateOverride[];\n}\n\nexport type RateLabelsByDay = {\n Monday: boolean;\n Tuesday: boolean;\n Wednesday: boolean;\n Thursday: boolean;\n Friday: boolean;\n Saturday: boolean;\n Sunday: boolean;\n};\n\nexport type RateOverride = {\n name: string;\n shortDescription: string;\n longDescription: string;\n enabledPerDay: RateLabelsByDay;\n startDate: string;\n endDate: string;\n queryStartDate: string;\n queryEndDate: string;\n};\n\nexport type RateOverrideKeys = 'name' | 'shortDescription' | 'longDescription';\n\ninterface RequestedDate {\n startDate: Dayjs;\n endDate: Dayjs;\n}\n\ninterface DisplayRate {\n name: string;\n shortDescription: string;\n longDescription: string;\n startDate?: Dayjs;\n endDate?: Dayjs;\n override: RateOverride;\n}\n\nexport class RoomRate implements RoomRateSortable, Serializable<RoomRate, IRoomRate> {\n public name!: string;\n public code!: string;\n\n public description!: string;\n public longDescription!: string;\n\n public isMemberOnly!: boolean;\n\n public guaranteeCode!: string;\n\n public cancelPolicyCode!: string;\n\n public nightRates: { [date: string]: RoomRateNight };\n public lowestPrice!: number;\n public promoCode?: string;\n public promoCodeName?: string;\n public mealsIncluded?: {\n breakfast: boolean;\n lunch: boolean;\n dinner: boolean;\n } = {\n breakfast: false,\n lunch: false,\n dinner: false,\n };\n private nightRatesArray: RoomRateNight[];\n private room!: Room;\n public rateOverrides?: RateOverride[];\n\n public constructor() {\n this.nightRates = {};\n this.nightRatesArray = [];\n }\n\n public static fromData(data: Partial<{ code: string }> | any) {\n const rate = new this();\n\n rate.applyData(data);\n\n if (StaticContextProvider.MemberOnlyRateCodes?.includes(data.code)) {\n rate.isMemberOnly = true;\n }\n\n return rate;\n }\n\n public applyData(data: any) {\n Object.keys(data).map((key: any) => {\n (this as any)[key] = (data as any)[key];\n }, this);\n }\n\n public setRoom(room: Room) {\n this.room = room;\n }\n\n public getRoom(): Room {\n return this.room;\n }\n\n public getTotalPrice = (getCost = false) => {\n let total = 0;\n const nightsAsArray = Object.values(this.nightRates);\n nightsAsArray.forEach((night: RoomRateNight) => {\n total += Number(getCost ? night.cost : night.total);\n });\n return total;\n };\n\n public getTotalPriceBeforeDiscount = (getCost = false) => {\n let total = 0;\n const nightsAsArray = Object.values(this.nightRates);\n nightsAsArray.forEach((night: RoomRateNight) => {\n total += Number(getCost ? night.cost : night.total) + Number(night.discount);\n });\n return total;\n };\n\n public getTotalDiscount = () => {\n return this.nightRateTotal((night: RoomRateNight) => {\n return Number(night.discount);\n });\n };\n\n public getAveragePrice = (getCost = false): number => {\n const total = this.getTotalPrice(getCost);\n\n return total / Object.keys(this.nightRates).length;\n };\n\n public getAveragePriceBeforeDiscount = (getCost = false) => {\n let total = 0;\n const nightsAsArray = Object.values(this.nightRates);\n nightsAsArray.forEach((night: RoomRateNight) => {\n total += Number(getCost ? night.cost : night.total) + Number(night.discount);\n });\n\n return total / nightsAsArray.length;\n };\n\n public getTotalFees = () => {\n return this.nightRateTotal((night: RoomRateNight) => {\n return Number(night.fee);\n });\n };\n\n public getTotalTaxes = () => {\n return this.nightRateTotal((night: RoomRateNight) => {\n return Number(night.tax);\n });\n };\n\n public getPriceType = () => {\n let hasFees = false;\n let hasTax = false;\n\n Object.values(this.nightRates).forEach((night) => {\n if (night.fee && night.fee !== '0') {\n hasFees = true;\n }\n\n if (night.tax && night.tax !== '0') {\n hasTax = true;\n }\n });\n\n if (hasFees && hasTax) {\n return RoomRatePriceInclusion.ExcludingFeesAndTaxes;\n } else if (hasFees) {\n return RoomRatePriceInclusion.ExcludingTaxes;\n } else if (hasTax) {\n return RoomRatePriceInclusion.ExcludingFees;\n } else {\n return RoomRatePriceInclusion.IncludingFeesAndTaxes;\n }\n };\n\n public getGuaranteePolicy = () => {\n return AvailabilityAPI.policyMappings.guarantee[this.guaranteeCode] ?? '';\n };\n\n public getCancellationPolicy = () => {\n return AvailabilityAPI.policyMappings.cancel[this.cancelPolicyCode] ?? '';\n };\n\n public getPriceSortValue = () => {\n return this.getAveragePrice();\n };\n\n /**\n * Not implemented\n */\n public getRecommendedSortValue() {\n return 0;\n }\n\n public serialize() {\n const serializedNightRates: any = {};\n Object.keys(this.nightRates).forEach((date) => {\n serializedNightRates[date] = this.nightRates[date].serialize();\n });\n\n const toSerialize: IRoomRate = {\n name: this.name,\n code: this.code,\n description: this.description,\n longDescription: this.longDescription,\n isMemberOnly: this.isMemberOnly,\n guaranteeCode: this.guaranteeCode,\n cancelPolicyCode: this.cancelPolicyCode,\n nightRates: serializedNightRates,\n lowestPrice: this.lowestPrice,\n promoCode: this.promoCode,\n promoCodeName: this.promoCodeName,\n mealsIncluded: this.mealsIncluded,\n rateOverrides: this.rateOverrides,\n } as IRoomRate;\n\n return toSerialize;\n }\n\n public unSerialize(data: IRoomRate) {\n const { name, code, description, longDescription, isMemberOnly, guaranteeCode, cancelPolicyCode, lowestPrice, promoCode, promoCodeName, mealsIncluded } = data;\n\n const unSerializedNightRates: any = {};\n\n if (data.nightRates) {\n Object.keys(data.nightRates)?.forEach((date) => {\n const nightRate = new RoomRateNight();\n unSerializedNightRates[date] = nightRate.unSerialize(data.nightRates[date]);\n });\n }\n\n this.name = name;\n this.code = code;\n this.description = description;\n this.longDescription = longDescription as string;\n this.isMemberOnly = isMemberOnly as boolean;\n this.guaranteeCode = guaranteeCode;\n this.cancelPolicyCode = cancelPolicyCode;\n this.lowestPrice = lowestPrice;\n this.promoCode = promoCode;\n this.promoCodeName = promoCodeName;\n this.mealsIncluded = mealsIncluded;\n this.nightRates = unSerializedNightRates;\n this.nightRatesArray = [];\n this.rateOverrides = data.rateOverrides;\n\n return this;\n }\n\n private getNightRateArray = () => {\n if (!this.nightRatesArray.length) {\n this.nightRatesArray = Object.values(this.nightRates);\n }\n\n return this.nightRatesArray;\n };\n\n private reduceNightData = (reducer: (sum: number, rate: RoomRateNight) => number) => {\n return this.getNightRateArray().reduce<number>(reducer, 0) ?? 0;\n };\n\n private nightRateTotal = (value: (rate: RoomRateNight) => number) => {\n return this.reduceNightData((sum: number, redNight: RoomRateNight) => {\n const summingValue = value(redNight);\n\n return sum ? sum + summingValue : summingValue;\n });\n };\n\n public datesOverlap = (startDate1: Dayjs, endDate1: Dayjs, startDate2: Dayjs, endDate2: Dayjs): boolean => {\n const overlap1 = startDate1.isSameOrBefore(endDate2) && startDate2.isSameOrBefore(endDate1);\n const overlap2 = startDate1.isSameOrAfter(endDate2) && startDate2.isSameOrAfter(endDate1);\n return overlap1 || overlap2;\n };\n\n public getDefaultLabelsByDate = (requestedDate: RequestedDate) => {\n const days: { label: string; alternateLabel: string }[] = [];\n let currentDate = requestedDate.startDate.clone();\n while (currentDate.isSameOrBefore(requestedDate.endDate)) {\n days.push({\n label: currentDate.format('dddd, MMM DD, YYYY'),\n alternateLabel: '', // No rate label available\n });\n currentDate = currentDate.add(1, 'day');\n }\n return days;\n };\n\n public getPossiblyOverwrittenDetails = (requestedDate: RequestedDate) => {\n const rateOverrides: RateOverride[] = this.getAvailableRateOverrides();\n if (!rateOverrides.length) return { name: this.name, shortDescription: this.description, longDescription: this.longDescription };\n\n const originalRequestedStartDate = requestedDate.startDate;\n\n let shortDescription = this.description;\n let longDescription = this.longDescription;\n let name = this.name;\n\n // Loop through all overrides and check for any matching the booking dates\n rateOverrides.forEach((override) => {\n const queryStartDate = dayjs(override.queryStartDate);\n const queryEndDate = dayjs(override.queryEndDate);\n\n const overlap =\n (!override.queryStartDate || queryStartDate.isSameOrBefore(originalRequestedStartDate, 'date')) &&\n (!override.queryEndDate || queryEndDate.isSameOrAfter(originalRequestedStartDate, 'date'));\n\n const stayDay = originalRequestedStartDate.format('dddd');\n\n if (overlap && override.enabledPerDay[stayDay as keyof RateLabelsByDay] === true) {\n name = override.name;\n shortDescription = override.shortDescription;\n longDescription = override.longDescription;\n }\n });\n\n return { name, shortDescription, longDescription };\n };\n\n public getAvailableRateOverrides = (): RateOverride[] => {\n if (!this.rateOverrides?.length) return [];\n\n const now = dayjs();\n //startDate/endDate/queryStartDate/queryEndDate must not empty\n const rateOverrides: RateOverride[] = this.rateOverrides.filter((override) => {\n // Check if the override can apply to this query in current time.\n // We don't require any of the filter fields, so if they are set we should check that they apply.\n if (override.startDate) {\n if (!dayjs(override.startDate).isSameOrBefore(now)) {\n return false;\n }\n\n if (override.endDate && !dayjs(override.endDate).isSameOrAfter(now)) {\n return false;\n }\n }\n\n return true;\n });\n return rateOverrides;\n };\n\n public hasRateVariesByDay = (requestedDate: RequestedDate): boolean => {\n const rateOverrides: RateOverride[] = this.getAvailableRateOverrides();\n if (!rateOverrides.length) false;\n\n const originalRequestedStartDate = dayjs(requestedDate.startDate);\n const originalRequestedEndDate = dayjs(requestedDate.endDate);\n\n // Loop through all overrides and check for any matching the booking dates\n return rateOverrides.some((override) => {\n const overrideStartDate = dayjs(override.startDate);\n const overrideEndDate = dayjs(override.endDate);\n const queryStartDate = dayjs(override.queryStartDate);\n const queryEndDate = dayjs(override.queryEndDate);\n\n if (override.startDate && overrideStartDate.isAfter(originalRequestedEndDate)) {\n return false;\n }\n\n if (override.endDate && overrideEndDate.isBefore(originalRequestedStartDate)) {\n return false;\n }\n\n if (override.queryStartDate && queryStartDate.isAfter(originalRequestedEndDate)) {\n return false;\n }\n if (override.queryEndDate && queryEndDate.isBefore(originalRequestedStartDate)) {\n return false;\n }\n\n return true;\n });\n };\n\n public getDisplayRates = (requestedDate: RequestedDate): DisplayRate[] => {\n const rateOverrides: RateOverride[] = this.getAvailableRateOverrides();\n if (!rateOverrides.length) return [];\n\n const originalRequestedStartDate = dayjs(requestedDate.startDate);\n const originalRequestedEndDate = dayjs(requestedDate.endDate);\n\n const displayRates: DisplayRate[] = [\n {\n name: this.name,\n shortDescription: this.description,\n longDescription: this.longDescription,\n override: {\n name: this.name,\n shortDescription: this.description,\n longDescription: this.longDescription,\n enabledPerDay: {\n Monday: true,\n Tuesday: true,\n Wednesday: true,\n Thursday: true,\n Friday: true,\n Saturday: true,\n Sunday: true,\n },\n startDate: '',\n endDate: '',\n queryStartDate: '',\n queryEndDate: '',\n },\n },\n ];\n // Loop through all overrides and check for any matching the booking dates\n rateOverrides.forEach((override) => {\n const overrideStartDate = dayjs(override.startDate);\n const overrideEndDate = dayjs(override.endDate);\n const queryStartDate = dayjs(override.queryStartDate);\n const queryEndDate = dayjs(override.queryEndDate);\n //requestedStartDate & requestedEndDate must be in date range of override's startDate/endDate\n const requestedStartDate = originalRequestedStartDate.isBefore(overrideStartDate) ? overrideStartDate : originalRequestedStartDate;\n const requestedEndDate = originalRequestedEndDate.isAfter(overrideEndDate) ? overrideEndDate : originalRequestedEndDate;\n const overlap = this.datesOverlap(requestedStartDate, requestedEndDate, queryStartDate, queryEndDate);\n if (overlap) {\n if (requestedStartDate.isBefore(queryStartDate, 'date')) {\n if (queryEndDate.isBefore(requestedEndDate, 'date')) {\n displayRates.push({\n override: override,\n name: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n startDate: queryStartDate,\n endDate: queryEndDate,\n });\n } else {\n displayRates.push({\n override: override,\n name: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n startDate: queryStartDate,\n endDate: requestedEndDate,\n });\n }\n } else {\n if (queryEndDate.isBefore(requestedEndDate, 'date')) {\n displayRates.push({\n override: override,\n name: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n startDate: requestedStartDate,\n endDate: queryEndDate,\n });\n } else {\n displayRates.push({\n override: override,\n name: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n startDate: requestedStartDate,\n endDate: requestedEndDate,\n });\n }\n }\n }\n });\n\n return displayRates;\n };\n\n public displayRateToDayLabel = (displayRate: DisplayRate): string => {\n if (!displayRate.startDate || !displayRate.endDate) return '';\n\n const dayDayLabels: Record<string, string> = {};\n const startDayLabel = displayRate.startDate.format('MMM DD, YYYY');\n const endDayLabel = displayRate.endDate.format('MMM DD, YYYY');\n dayDayLabels[startDayLabel] = startDayLabel;\n dayDayLabels[endDayLabel] = endDayLabel;\n return `${Object.values(dayDayLabels).join(' - ')}`;\n };\n\n public displayRateToDayName = (displayRate: DisplayRate): string => {\n if (!displayRate.startDate || !displayRate.endDate) return '';\n\n const dayNames: Record<string, string> = {};\n const startDayName = displayRate.startDate.format('dddd');\n const endDayName = displayRate.endDate.format('dddd');\n dayNames[startDayName] = startDayName;\n dayNames[endDayName] = endDayName;\n return `${Object.values(dayNames).join(' - ')}`;\n };\n\n public getLabelsByDate = (requestedDate: RequestedDate): { label: string; alternateLabel: string; shortDescription?: string; longDescription?: string }[] => {\n const overrides: RateOverride[] = this.getAvailableRateOverrides();\n if (!overrides.length) {\n // If overrides are null or empty, return an empty rateLabelByDay for the whole date range\n return this.getDefaultLabelsByDate(requestedDate);\n }\n\n const labelsByDate: Record<string, { label: string; alternateLabel: string; shortDescription?: string; longDescription?: string; date: string }> = {};\n let dayOneOverride: RateOverride | null = null;\n\n overrides.forEach((override) => {\n const overrideStartDate = dayjs(override.startDate);\n const overrideEndDate = dayjs(override.endDate);\n const overrideQueryStartDate = dayjs(override.queryStartDate);\n const overrideQueryEndDate = dayjs(override.queryEndDate);\n\n const isApplicableForStayDate = () => {\n if (overrideStartDate && overrideStartDate.isAfter(stayDate)) {\n return false;\n }\n\n if (overrideEndDate && overrideEndDate.isBefore(stayDate)) {\n return false;\n }\n\n if (overrideQueryStartDate && overrideQueryStartDate.isAfter(stayDate)) {\n return false;\n }\n\n if (overrideQueryEndDate && overrideQueryEndDate.isBefore(stayDate)) {\n return false;\n }\n\n return true;\n };\n\n let stayDate = requestedDate.startDate.clone();\n while (stayDate.isSameOrBefore(requestedDate.endDate, 'date')) {\n const dayIndex = stayDate.format('YYYY-MM-DD');\n const dayLabel = stayDate.format('dddd, MMM DD, YYYY');\n const stayDay = stayDate.format('dddd');\n //stayDate must be in date range of override's startDate/endDate and queryStartDate/queryEndDate\n if (isApplicableForStayDate()) {\n if (override.enabledPerDay[stayDay as keyof RateLabelsByDay] === true) {\n // Keep setting the dayOneOverride until the first day of the stay is reached, this will tell us\n // what is the initial rate label for the stay\n if (stayDate.isSame(requestedDate.startDate, 'date')) {\n dayOneOverride = override;\n }\n\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n };\n }\n } else if (!labelsByDate[dayIndex]?.label) {\n // No rate label override\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: '',\n };\n }\n\n if (dayOneOverride === override) {\n // If the first day of the stay is an override, the user thinks all dates are the same, so we\n // need to remove the override from this day, and specify the default for the remaining empty days.\n\n if (labelsByDate[dayIndex]?.label === dayLabel && labelsByDate[dayIndex]?.alternateLabel === override.name) {\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: '',\n shortDescription: '',\n longDescription: '',\n };\n } else if (labelsByDate[dayIndex]?.alternateLabel === '') {\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: this.name,\n shortDescription: this.description,\n longDescription: this.longDescription,\n };\n }\n }\n\n // If label dates aren't populated, they're the originl rate labels.\n if (!labelsByDate[dayIndex]?.label) {\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: dayOneOverride === override ? this.name : '',\n shortDescription: this.description,\n longDescription: this.longDescription,\n };\n }\n\n stayDate = stayDate.add(1, 'day');\n }\n });\n\n return Object.values(labelsByDate).sort((a, b) => {\n return a.date > b.date ? 1 : -1;\n });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RoomRate.js","sourceRoot":"/","sources":["src/models/Room/RoomRate.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAqC;AAErC,4EAAoD;AACpD,sCAAiH;AAEjH,gFAA4E;AAG5E,8FAAsE;AAEtE,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAC9B,yDAA+B,CAAA;IAC/B,2DAAiC,CAAA;IACjC,4EAAkD,CAAA;IAClD,4EAAkD,CAAA;AACtD,CAAC,EALW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAKjC;AA8DD,MAAa,QAAQ;IA8BjB;QAbO,kBAAa,GAIhB;YACA,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,KAAK;SAChB,CAAC;QAoCK,kBAAa,GAAG,CAAC,OAAO,GAAG,KAAK,EAAE,EAAE;YACvC,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACrD,aAAa,CAAC,OAAO,CAAC,CAAC,KAAoB,EAAE,EAAE;gBAC3C,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;YACH,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC;QAEK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AAG,YAAuB,CAAC;QAC5C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,sBAAsB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAExC,OAAO,IAAI,CAAC;IAChB,CAAC;CA6VJ;AA5jBD,4BA4jBC","sourcesContent":["import dayjs, { Dayjs } from 'dayjs';\n\nimport AvailabilityAPI from '@/api/AvailabilityAPI';\nimport { accumulateFees, feeMapToArray, HotelFee, ItemisedFee, mapSimpleFeesToItemisedFees } from '@/models/Fee';\nimport type { Room } from '@/models/Room/Room';\nimport RoomRateNight, { IRoomRateNight } from '@/models/Room/RoomRateNight';\nimport type RoomRateSortable from '@/models/Room/RoomRateSortable';\nimport type { Serializable } from '@/models/Serializable';\nimport StaticContextProvider from '@/providers/StaticContextProvider';\n\nexport enum RoomRatePriceInclusion {\n ExcludingFees = 'Fees Excluded',\n ExcludingTaxes = 'Taxes Excluded',\n ExcludingFeesAndTaxes = 'Excluding Fees and Taxes',\n IncludingFeesAndTaxes = 'Including Fees and Taxes',\n}\n\nexport interface IRoomRate {\n name: string;\n code: string;\n description: string;\n longDescription?: string;\n\n isMemberOnly?: boolean;\n guaranteeCode: string;\n cancelPolicyCode: string;\n nightRates: { [date: string]: IRoomRateNight };\n\n lowestPrice: number;\n promoCode: string;\n promoCodeName: string;\n\n mealsIncluded?: {\n breakfast: boolean;\n lunch: boolean;\n dinner: boolean;\n };\n rateOverrides?: RateOverride[];\n}\n\nexport type RateLabelsByDay = {\n Monday: boolean;\n Tuesday: boolean;\n Wednesday: boolean;\n Thursday: boolean;\n Friday: boolean;\n Saturday: boolean;\n Sunday: boolean;\n};\n\nexport type RateOverride = {\n name: string;\n shortDescription: string;\n longDescription: string;\n enabledPerDay: RateLabelsByDay;\n startDate: string;\n endDate: string;\n queryStartDate: string;\n queryEndDate: string;\n};\n\nexport type RateOverrideKeys = 'name' | 'shortDescription' | 'longDescription';\n\ninterface RequestedDate {\n startDate: Dayjs;\n endDate: Dayjs;\n}\n\ninterface DisplayRate {\n name: string;\n shortDescription: string;\n longDescription: string;\n startDate?: Dayjs;\n endDate?: Dayjs;\n override: RateOverride;\n}\n\nexport class RoomRate implements RoomRateSortable, Serializable<RoomRate, IRoomRate> {\n public name!: string;\n public code!: string;\n\n public description!: string;\n public longDescription!: string;\n\n public isMemberOnly!: boolean;\n\n public guaranteeCode!: string;\n\n public cancelPolicyCode!: string;\n\n public nightRates: { [date: string]: RoomRateNight };\n public lowestPrice!: number;\n public promoCode?: string;\n public promoCodeName?: string;\n public mealsIncluded?: {\n breakfast: boolean;\n lunch: boolean;\n dinner: boolean;\n } = {\n breakfast: false,\n lunch: false,\n dinner: false,\n };\n private nightRatesArray: RoomRateNight[];\n private room!: Room;\n public rateOverrides?: RateOverride[];\n\n public constructor() {\n this.nightRates = {};\n this.nightRatesArray = [];\n }\n\n public static fromData(data: Partial<{ code: string }> | any) {\n const rate = new this();\n\n rate.applyData(data);\n\n if (StaticContextProvider.MemberOnlyRateCodes?.includes(data.code)) {\n rate.isMemberOnly = true;\n }\n\n return rate;\n }\n\n public applyData(data: any) {\n Object.keys(data).map((key: any) => {\n (this as any)[key] = (data as any)[key];\n }, this);\n }\n\n public setRoom(room: Room) {\n this.room = room;\n }\n\n public getRoom(): Room {\n return this.room;\n }\n\n public getTotalPrice = (getCost = false) => {\n let total = 0;\n const nightsAsArray = Object.values(this.nightRates);\n nightsAsArray.forEach((night: RoomRateNight) => {\n total += Number(getCost ? night.cost : night.total);\n });\n return total;\n };\n\n public getTotalPriceBeforeDiscount = (getCost = false) => {\n let total = 0;\n const nightsAsArray = Object.values(this.nightRates);\n nightsAsArray.forEach((night: RoomRateNight) => {\n total += Number(getCost ? night.cost : night.total) + Number(night.discount);\n });\n return total;\n };\n\n public getTotalDiscount = () => {\n return this.nightRateTotal((night: RoomRateNight) => {\n return Number(night.discount);\n });\n };\n\n public getAveragePrice = (getCost = false): number => {\n const total = this.getTotalPrice(getCost);\n\n return total / Object.keys(this.nightRates).length;\n };\n\n public getAveragePriceBeforeDiscount = (getCost = false) => {\n let total = 0;\n const nightsAsArray = Object.values(this.nightRates);\n nightsAsArray.forEach((night: RoomRateNight) => {\n total += Number(getCost ? night.cost : night.total) + Number(night.discount);\n });\n\n return total / nightsAsArray.length;\n };\n\n public getTotalFees = () => {\n return this.nightRateTotal((night: RoomRateNight) => {\n return Number(night.fee);\n });\n };\n\n public getItemisedFees = (hotelFees: HotelFee[]): ItemisedFee[] => {\n const feeMap = new Map<HotelFee, number>();\n\n this.getNightRateArray().forEach((night) => {\n if (night.fees) {\n const fees = mapSimpleFeesToItemisedFees(night.fees, hotelFees);\n accumulateFees(feeMap, fees);\n }\n });\n\n return feeMapToArray(feeMap);\n };\n\n public getTotalTaxes = () => {\n return this.nightRateTotal((night: RoomRateNight) => {\n return Number(night.tax);\n });\n };\n\n public getPriceType = () => {\n let hasFees = false;\n let hasTax = false;\n\n Object.values(this.nightRates).forEach((night) => {\n if (night.fee && night.fee !== '0') {\n hasFees = true;\n }\n\n if (night.tax && night.tax !== '0') {\n hasTax = true;\n }\n });\n\n if (hasFees && hasTax) {\n return RoomRatePriceInclusion.ExcludingFeesAndTaxes;\n } else if (hasFees) {\n return RoomRatePriceInclusion.ExcludingTaxes;\n } else if (hasTax) {\n return RoomRatePriceInclusion.ExcludingFees;\n } else {\n return RoomRatePriceInclusion.IncludingFeesAndTaxes;\n }\n };\n\n public getGuaranteePolicy = () => {\n return AvailabilityAPI.policyMappings.guarantee[this.guaranteeCode] ?? '';\n };\n\n public getCancellationPolicy = () => {\n return AvailabilityAPI.policyMappings.cancel[this.cancelPolicyCode] ?? '';\n };\n\n public getPriceSortValue = () => {\n return this.getAveragePrice();\n };\n\n /**\n * Not implemented\n */\n public getRecommendedSortValue() {\n return 0;\n }\n\n public serialize() {\n const serializedNightRates: any = {};\n Object.keys(this.nightRates).forEach((date) => {\n serializedNightRates[date] = this.nightRates[date].serialize();\n });\n\n const toSerialize: IRoomRate = {\n name: this.name,\n code: this.code,\n description: this.description,\n longDescription: this.longDescription,\n isMemberOnly: this.isMemberOnly,\n guaranteeCode: this.guaranteeCode,\n cancelPolicyCode: this.cancelPolicyCode,\n nightRates: serializedNightRates,\n lowestPrice: this.lowestPrice,\n promoCode: this.promoCode,\n promoCodeName: this.promoCodeName,\n mealsIncluded: this.mealsIncluded,\n rateOverrides: this.rateOverrides,\n } as IRoomRate;\n\n return toSerialize;\n }\n\n public unSerialize(data: IRoomRate) {\n const { name, code, description, longDescription, isMemberOnly, guaranteeCode, cancelPolicyCode, lowestPrice, promoCode, promoCodeName, mealsIncluded } = data;\n\n const unSerializedNightRates: any = {};\n\n if (data.nightRates) {\n Object.keys(data.nightRates)?.forEach((date) => {\n const nightRate = new RoomRateNight();\n unSerializedNightRates[date] = nightRate.unSerialize(data.nightRates[date]);\n });\n }\n\n this.name = name;\n this.code = code;\n this.description = description;\n this.longDescription = longDescription as string;\n this.isMemberOnly = isMemberOnly as boolean;\n this.guaranteeCode = guaranteeCode;\n this.cancelPolicyCode = cancelPolicyCode;\n this.lowestPrice = lowestPrice;\n this.promoCode = promoCode;\n this.promoCodeName = promoCodeName;\n this.mealsIncluded = mealsIncluded;\n this.nightRates = unSerializedNightRates;\n this.nightRatesArray = [];\n this.rateOverrides = data.rateOverrides;\n\n return this;\n }\n\n private getNightRateArray = () => {\n if (!this.nightRatesArray.length) {\n this.nightRatesArray = Object.values(this.nightRates);\n }\n\n return this.nightRatesArray;\n };\n\n private reduceNightData = (reducer: (sum: number, rate: RoomRateNight) => number) => {\n return this.getNightRateArray().reduce<number>(reducer, 0) ?? 0;\n };\n\n private nightRateTotal = (value: (rate: RoomRateNight) => number) => {\n return this.reduceNightData((sum: number, redNight: RoomRateNight) => {\n const summingValue = value(redNight);\n\n return sum ? sum + summingValue : summingValue;\n });\n };\n\n public datesOverlap = (startDate1: Dayjs, endDate1: Dayjs, startDate2: Dayjs, endDate2: Dayjs): boolean => {\n const overlap1 = startDate1.isSameOrBefore(endDate2) && startDate2.isSameOrBefore(endDate1);\n const overlap2 = startDate1.isSameOrAfter(endDate2) && startDate2.isSameOrAfter(endDate1);\n return overlap1 || overlap2;\n };\n\n public getDefaultLabelsByDate = (requestedDate: RequestedDate) => {\n const days: { label: string; alternateLabel: string }[] = [];\n let currentDate = requestedDate.startDate.clone();\n while (currentDate.isSameOrBefore(requestedDate.endDate)) {\n days.push({\n label: currentDate.format('dddd, MMM DD, YYYY'),\n alternateLabel: '', // No rate label available\n });\n currentDate = currentDate.add(1, 'day');\n }\n return days;\n };\n\n public getPossiblyOverwrittenDetails = (requestedDate: RequestedDate) => {\n const rateOverrides: RateOverride[] = this.getAvailableRateOverrides();\n if (!rateOverrides.length) return { name: this.name, shortDescription: this.description, longDescription: this.longDescription };\n\n const originalRequestedStartDate = requestedDate.startDate;\n\n let shortDescription = this.description;\n let longDescription = this.longDescription;\n let name = this.name;\n\n // Loop through all overrides and check for any matching the booking dates\n rateOverrides.forEach((override) => {\n const queryStartDate = dayjs(override.queryStartDate);\n const queryEndDate = dayjs(override.queryEndDate);\n\n const overlap =\n (!override.queryStartDate || queryStartDate.isSameOrBefore(originalRequestedStartDate, 'date')) &&\n (!override.queryEndDate || queryEndDate.isSameOrAfter(originalRequestedStartDate, 'date'));\n\n const stayDay = originalRequestedStartDate.format('dddd');\n\n if (overlap && override.enabledPerDay[stayDay as keyof RateLabelsByDay] === true) {\n name = override.name;\n shortDescription = override.shortDescription;\n longDescription = override.longDescription;\n }\n });\n\n return { name, shortDescription, longDescription };\n };\n\n public getAvailableRateOverrides = (): RateOverride[] => {\n if (!this.rateOverrides?.length) return [];\n\n const now = dayjs();\n //startDate/endDate/queryStartDate/queryEndDate must not empty\n const rateOverrides: RateOverride[] = this.rateOverrides.filter((override) => {\n // Check if the override can apply to this query in current time.\n // We don't require any of the filter fields, so if they are set we should check that they apply.\n if (override.startDate) {\n if (!dayjs(override.startDate).isSameOrBefore(now)) {\n return false;\n }\n\n if (override.endDate && !dayjs(override.endDate).isSameOrAfter(now)) {\n return false;\n }\n }\n\n return true;\n });\n return rateOverrides;\n };\n\n public hasRateVariesByDay = (requestedDate: RequestedDate): boolean => {\n const rateOverrides: RateOverride[] = this.getAvailableRateOverrides();\n if (!rateOverrides.length) false;\n\n const originalRequestedStartDate = dayjs(requestedDate.startDate);\n const originalRequestedEndDate = dayjs(requestedDate.endDate);\n\n // Loop through all overrides and check for any matching the booking dates\n return rateOverrides.some((override) => {\n const overrideStartDate = dayjs(override.startDate);\n const overrideEndDate = dayjs(override.endDate);\n const queryStartDate = dayjs(override.queryStartDate);\n const queryEndDate = dayjs(override.queryEndDate);\n\n if (override.startDate && overrideStartDate.isAfter(originalRequestedEndDate)) {\n return false;\n }\n\n if (override.endDate && overrideEndDate.isBefore(originalRequestedStartDate)) {\n return false;\n }\n\n if (override.queryStartDate && queryStartDate.isAfter(originalRequestedEndDate)) {\n return false;\n }\n if (override.queryEndDate && queryEndDate.isBefore(originalRequestedStartDate)) {\n return false;\n }\n\n return true;\n });\n };\n\n public getDisplayRates = (requestedDate: RequestedDate): DisplayRate[] => {\n const rateOverrides: RateOverride[] = this.getAvailableRateOverrides();\n if (!rateOverrides.length) return [];\n\n const originalRequestedStartDate = dayjs(requestedDate.startDate);\n const originalRequestedEndDate = dayjs(requestedDate.endDate);\n\n const displayRates: DisplayRate[] = [\n {\n name: this.name,\n shortDescription: this.description,\n longDescription: this.longDescription,\n override: {\n name: this.name,\n shortDescription: this.description,\n longDescription: this.longDescription,\n enabledPerDay: {\n Monday: true,\n Tuesday: true,\n Wednesday: true,\n Thursday: true,\n Friday: true,\n Saturday: true,\n Sunday: true,\n },\n startDate: '',\n endDate: '',\n queryStartDate: '',\n queryEndDate: '',\n },\n },\n ];\n // Loop through all overrides and check for any matching the booking dates\n rateOverrides.forEach((override) => {\n const overrideStartDate = dayjs(override.startDate);\n const overrideEndDate = dayjs(override.endDate);\n const queryStartDate = dayjs(override.queryStartDate);\n const queryEndDate = dayjs(override.queryEndDate);\n //requestedStartDate & requestedEndDate must be in date range of override's startDate/endDate\n const requestedStartDate = originalRequestedStartDate.isBefore(overrideStartDate) ? overrideStartDate : originalRequestedStartDate;\n const requestedEndDate = originalRequestedEndDate.isAfter(overrideEndDate) ? overrideEndDate : originalRequestedEndDate;\n const overlap = this.datesOverlap(requestedStartDate, requestedEndDate, queryStartDate, queryEndDate);\n if (overlap) {\n if (requestedStartDate.isBefore(queryStartDate, 'date')) {\n if (queryEndDate.isBefore(requestedEndDate, 'date')) {\n displayRates.push({\n override: override,\n name: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n startDate: queryStartDate,\n endDate: queryEndDate,\n });\n } else {\n displayRates.push({\n override: override,\n name: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n startDate: queryStartDate,\n endDate: requestedEndDate,\n });\n }\n } else {\n if (queryEndDate.isBefore(requestedEndDate, 'date')) {\n displayRates.push({\n override: override,\n name: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n startDate: requestedStartDate,\n endDate: queryEndDate,\n });\n } else {\n displayRates.push({\n override: override,\n name: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n startDate: requestedStartDate,\n endDate: requestedEndDate,\n });\n }\n }\n }\n });\n\n return displayRates;\n };\n\n public displayRateToDayLabel = (displayRate: DisplayRate): string => {\n if (!displayRate.startDate || !displayRate.endDate) return '';\n\n const dayDayLabels: Record<string, string> = {};\n const startDayLabel = displayRate.startDate.format('MMM DD, YYYY');\n const endDayLabel = displayRate.endDate.format('MMM DD, YYYY');\n dayDayLabels[startDayLabel] = startDayLabel;\n dayDayLabels[endDayLabel] = endDayLabel;\n return `${Object.values(dayDayLabels).join(' - ')}`;\n };\n\n public displayRateToDayName = (displayRate: DisplayRate): string => {\n if (!displayRate.startDate || !displayRate.endDate) return '';\n\n const dayNames: Record<string, string> = {};\n const startDayName = displayRate.startDate.format('dddd');\n const endDayName = displayRate.endDate.format('dddd');\n dayNames[startDayName] = startDayName;\n dayNames[endDayName] = endDayName;\n return `${Object.values(dayNames).join(' - ')}`;\n };\n\n public getLabelsByDate = (requestedDate: RequestedDate): { label: string; alternateLabel: string; shortDescription?: string; longDescription?: string }[] => {\n const overrides: RateOverride[] = this.getAvailableRateOverrides();\n if (!overrides.length) {\n // If overrides are null or empty, return an empty rateLabelByDay for the whole date range\n return this.getDefaultLabelsByDate(requestedDate);\n }\n\n const labelsByDate: Record<string, { label: string; alternateLabel: string; shortDescription?: string; longDescription?: string; date: string }> = {};\n let dayOneOverride: RateOverride | null = null;\n\n overrides.forEach((override) => {\n const overrideStartDate = dayjs(override.startDate);\n const overrideEndDate = dayjs(override.endDate);\n const overrideQueryStartDate = dayjs(override.queryStartDate);\n const overrideQueryEndDate = dayjs(override.queryEndDate);\n\n const isApplicableForStayDate = () => {\n if (overrideStartDate && overrideStartDate.isAfter(stayDate)) {\n return false;\n }\n\n if (overrideEndDate && overrideEndDate.isBefore(stayDate)) {\n return false;\n }\n\n if (overrideQueryStartDate && overrideQueryStartDate.isAfter(stayDate)) {\n return false;\n }\n\n if (overrideQueryEndDate && overrideQueryEndDate.isBefore(stayDate)) {\n return false;\n }\n\n return true;\n };\n\n let stayDate = requestedDate.startDate.clone();\n while (stayDate.isSameOrBefore(requestedDate.endDate, 'date')) {\n const dayIndex = stayDate.format('YYYY-MM-DD');\n const dayLabel = stayDate.format('dddd, MMM DD, YYYY');\n const stayDay = stayDate.format('dddd');\n //stayDate must be in date range of override's startDate/endDate and queryStartDate/queryEndDate\n if (isApplicableForStayDate()) {\n if (override.enabledPerDay[stayDay as keyof RateLabelsByDay] === true) {\n // Keep setting the dayOneOverride until the first day of the stay is reached, this will tell us\n // what is the initial rate label for the stay\n if (stayDate.isSame(requestedDate.startDate, 'date')) {\n dayOneOverride = override;\n }\n\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: override.name,\n shortDescription: override.shortDescription,\n longDescription: override.longDescription,\n };\n }\n } else if (!labelsByDate[dayIndex]?.label) {\n // No rate label override\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: '',\n };\n }\n\n if (dayOneOverride === override) {\n // If the first day of the stay is an override, the user thinks all dates are the same, so we\n // need to remove the override from this day, and specify the default for the remaining empty days.\n\n if (labelsByDate[dayIndex]?.label === dayLabel && labelsByDate[dayIndex]?.alternateLabel === override.name) {\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: '',\n shortDescription: '',\n longDescription: '',\n };\n } else if (labelsByDate[dayIndex]?.alternateLabel === '') {\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: this.name,\n shortDescription: this.description,\n longDescription: this.longDescription,\n };\n }\n }\n\n // If label dates aren't populated, they're the originl rate labels.\n if (!labelsByDate[dayIndex]?.label) {\n labelsByDate[dayIndex] = {\n label: dayLabel,\n date: dayIndex,\n alternateLabel: dayOneOverride === override ? this.name : '',\n shortDescription: this.description,\n longDescription: this.longDescription,\n };\n }\n\n stayDate = stayDate.add(1, 'day');\n }\n });\n\n return Object.values(labelsByDate).sort((a, b) => {\n return a.date > b.date ? 1 : -1;\n });\n };\n}\n"]}
|