@roomstay/frontend 2.6.56 → 2.6.58
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/493.bundle.js +1 -1
- package/dist/537.bundle.js +1 -0
- package/dist/978.bundle.js +1 -1
- package/dist/main.bundle.js +1 -1
- package/dist/src/api/AvailabilityAPI.js +13 -6
- package/dist/src/api/AvailabilityAPI.js.map +1 -1
- package/dist/src/components/generic/Event/EventCard.js +6 -2
- package/dist/src/components/generic/Event/EventCard.js.map +1 -1
- package/dist/src/components/generic/PaymentCard/PaymentCardInput.js +19 -4
- package/dist/src/components/generic/PaymentCard/PaymentCardInput.js.map +1 -1
- package/dist/src/components/generic/RadioButtonGroup/RadioButton.d.ts +1 -0
- package/dist/src/components/generic/RadioButtonGroup/RadioButton.js +2 -2
- package/dist/src/components/generic/RadioButtonGroup/RadioButton.js.map +1 -1
- package/dist/src/components/generic/RadioButtonGroup/RadioButtonGroup.d.ts +3 -2
- package/dist/src/components/generic/RadioButtonGroup/RadioButtonGroup.js +10 -10
- package/dist/src/components/generic/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
- package/dist/src/components/generic/date/DatePicker.d.ts +5 -0
- package/dist/src/components/generic/date/DatePicker.js +7 -3
- package/dist/src/components/generic/date/DatePicker.js.map +1 -1
- package/dist/src/components/generic/date/DatePickerDay.js +13 -3
- package/dist/src/components/generic/date/DatePickerDay.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/reservation/ReservationItem.js +5 -2
- package/dist/src/components/reservation/ReservationItem.js.map +1 -1
- package/dist/src/components/reservation/ReservationList.js +1 -1
- package/dist/src/components/reservation/ReservationList.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/confirmation/PaymentInformation.js +4 -1
- package/dist/src/components/steps/confirmation/PaymentInformation.js.map +1 -1
- 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/steps/room/roomDetails/roomRates/RoomRateDescriptionTab.js +7 -4
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateDescriptionTab.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRatePills.js +3 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRatePills.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 +180 -2
- package/dist/src/contexts/BasketContext/BasketContextWrapper.js.map +1 -1
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js +3 -0
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js.map +1 -1
- package/dist/src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.js +9 -7
- package/dist/src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.js.map +1 -1
- package/dist/src/contexts/DatePickerContext.d.ts +1 -0
- package/dist/src/contexts/DatePickerContext.js.map +1 -1
- package/dist/src/contexts/Members/AuthenticationContext/AuthenticationContextProvider.js +8 -2
- package/dist/src/contexts/Members/AuthenticationContext/AuthenticationContextProvider.js.map +1 -1
- package/dist/src/contexts/Members/RoomstayMemberContext/RoomstayMemberContextProvider.js +48 -8
- package/dist/src/contexts/Members/RoomstayMemberContext/RoomstayMemberContextProvider.js.map +1 -1
- package/dist/src/engines/InlineRoomMiniEngine/InlineRoomMiniEngineElement.js +1 -1
- package/dist/src/engines/InlineRoomMiniEngine/InlineRoomMiniEngineElement.js.map +1 -1
- package/dist/src/handlers/payment/PaymentHandler.d.ts +1 -0
- package/dist/src/handlers/payment/PaymentHandler.js.map +1 -1
- package/dist/src/handlers/payment/VGSMemberPaymentHandler.js +13 -35
- package/dist/src/handlers/payment/VGSMemberPaymentHandler.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 +4 -7
- package/dist/src/models/BasketRow.js +32 -25
- package/dist/src/models/BasketRow.js.map +1 -1
- package/dist/src/models/Client/Hotel/Hotel.d.ts +8 -0
- package/dist/src/models/Client/Hotel/Hotel.js.map +1 -1
- package/dist/src/models/Confirmation.d.ts +1 -2
- package/dist/src/models/Confirmation.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/Room.d.ts +7 -0
- package/dist/src/models/Room/Room.js +13 -0
- package/dist/src/models/Room/Room.js.map +1 -1
- package/dist/src/models/Room/RoomRate.d.ts +2 -0
- package/dist/src/models/Room/RoomRate.js +14 -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/account/Reservations/AccountReservationSinglePage.js.map +1 -1
- package/dist/src/pages/findReservation/FindReservationResults.js +18 -6
- 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/providers/RoomstayThemeEngine.d.ts +1 -1
- package/dist/src/providers/RoomstayThemeEngine.js +20 -5
- package/dist/src/providers/RoomstayThemeEngine.js.map +1 -1
- package/dist/src/stories/RadioButtonGroup.stories.d.ts +1 -1
- package/dist/src/util/Analytics/GoogleAnalytics4.js +27 -12
- package/dist/src/util/Analytics/GoogleAnalytics4.js.map +1 -1
- package/dist/src/util/Analytics/UniversalAnalytics.js +3 -3
- package/dist/src/util/Analytics/UniversalAnalytics.js.map +1 -1
- package/dist/src/util/DataLayer.d.ts +5 -1
- package/dist/src/util/DataLayer.js +9 -2
- package/dist/src/util/DataLayer.js.map +1 -1
- package/dist/src/util/EventsHelper.d.ts +4 -1
- package/dist/src/util/EventsHelper.js +15 -4
- package/dist/src/util/EventsHelper.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
- package/dist/586.bundle.js +0 -1
- package/dist/850.bundle.js +0 -1
|
@@ -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,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,WAAW,CAAC,MAAM,GAAG,QAAQ,GAAG,cAAc,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;AACP,CAAC;AALD,wCAKC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,MAA6B;IACvD,OAA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{ 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"]}
|
|
@@ -44,6 +44,13 @@ export declare class Room implements RoomRateSortable, Serializable<Room, IRoom>
|
|
|
44
44
|
applyData(data: Partial<IRoom>): void;
|
|
45
45
|
getLowestPriceType: (raw?: boolean) => RoomRatePriceInclusion;
|
|
46
46
|
getLowestPrice(raw?: boolean, rawPrice?: boolean): number;
|
|
47
|
+
/**
|
|
48
|
+
* Function for getting the lowest total price of the room from all the possible rates.
|
|
49
|
+
* @param includeAllRates If set to true will include all rates, otherwise will only include filtered rates
|
|
50
|
+
* @param getCost If set to true will return the cost of the rate, otherwise will return the average price see {@link RoomRate.getTotalPrice}
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
getLowestTotalPrice(includeAllRates?: boolean, getCost?: boolean): number;
|
|
47
54
|
getHighestPrice(raw?: boolean): number;
|
|
48
55
|
addRate(rate: RoomRate): void;
|
|
49
56
|
getImages(): string[];
|
|
@@ -52,6 +52,19 @@ class Room {
|
|
|
52
52
|
return sum < avrg && sum ? sum : avrg;
|
|
53
53
|
}, 0)) !== null && _b !== void 0 ? _b : 0);
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Function for getting the lowest total price of the room from all the possible rates.
|
|
57
|
+
* @param includeAllRates If set to true will include all rates, otherwise will only include filtered rates
|
|
58
|
+
* @param getCost If set to true will return the cost of the rate, otherwise will return the average price see {@link RoomRate.getTotalPrice}
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
getLowestTotalPrice(includeAllRates = false, getCost = false) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
return ((_b = (_a = (includeAllRates ? this.rates : this.filteredRates)) === null || _a === void 0 ? void 0 : _a.reduce((sum, rate) => {
|
|
64
|
+
const avrg = rate.getTotalPrice(getCost);
|
|
65
|
+
return sum < avrg && sum ? sum : avrg;
|
|
66
|
+
}, 0)) !== null && _b !== void 0 ? _b : 0);
|
|
67
|
+
}
|
|
55
68
|
getHighestPrice(raw = false) {
|
|
56
69
|
var _a, _b;
|
|
57
70
|
return ((_b = (_a = (raw ? this.rates : this.filteredRates)) === null || _a === void 0 ? void 0 : _a.reduce((sum, rate) => (sum > rate.getAveragePrice() && sum ? sum : rate.getAveragePrice()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,CAAC,EAAE,gBAAgB,CAAC,CAAC;SACrD;QACD,MAAM,iBAAiB,GAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,iBAAiB,EAAC,CAAC,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,iBAAiB,CAAC;QACrH,OAAO;YACH,iBAAiB,EAAE,iBAAiB;YACpC,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE;SAC7B,CAAC;IACN,CAAC;CACJ;AAhMD,oBAgMC","sourcesContent":["import { ConfigHotel, Hotel } from '@/models/Client/Hotel/Hotel';\nimport { HotelPerk } from '@/models/Client/Hotel/HotelPerk';\nimport { IRoomRate, RoomRate, RoomRatePriceInclusion } from '@/models/Room/RoomRate';\nimport RoomRateSortable from '@/models/Room/RoomRateSortable';\nimport { Serializable } from '@/models/Serializable';\n\nexport interface IRoom {\n id: number;\n\n code: string;\n name: string;\n longDescription: string;\n shortDescription: string;\n\n occupancy: number;\n\n images: string[];\n rates: IRoomRate[];\n roomGroupId?: string;\n auxiliaryValues: { [key: string]: (string | number)[] };\n order: number;\n\n prePerkDisclaimer?: string;\n perks?: ConfigHotel['perks'];\n}\n\nexport class Room implements RoomRateSortable, Serializable<Room, IRoom> {\n public id?: number;\n public code?: string;\n public name?: string;\n public longDescription?: string;\n public shortDescription?: string;\n\n public occupancy?: number;\n\n public images: string[];\n public roomGroupId?: string;\n public auxiliaryValues?: { [key: string]: (string | number)[] } = {};\n public filteredRates?: RoomRate[];\n private rates: RoomRate[];\n public order?: number;\n\n public prePerkDisclaimer?: string;\n public perks?: ConfigHotel['perks'];\n\n public constructor(props?: Partial<IRoom>) {\n this.rates = [];\n this.images = [];\n this.auxiliaryValues = {};\n\n if (props) {\n this.applyData(props);\n }\n }\n\n public static fromData(data: any) {\n const room = new this();\n\n if (!data.images && data.imageUrls) {\n data.images = data.imageUrls;\n }\n\n room.applyData(data);\n\n return room;\n }\n\n public getShortDescription(trim = true) {\n let shortDesc = this.shortDescription;\n\n if (trim) {\n shortDesc = (this.shortDescription?.length as number) > 97 ? this.shortDescription?.substr(0, 97) + '…' : this.shortDescription;\n }\n\n return shortDesc?.replace(/(<br>\\s*)+$/, '');\n }\n\n public getLongDescription() {\n return this.longDescription?.replace(/(<br>\\s*)+$/, '');\n }\n\n public applyData(data: Partial<IRoom>) {\n Object.keys(data).map((key: any) => {\n (this as any)[key] = (data as any)[key];\n }, this);\n\n this.filteredRates = this.rates;\n }\n\n public getLowestPriceType = (raw = false) => {\n return (\n ((raw ? this.rates : this.filteredRates) as RoomRate[])\n .reduce<RoomRate | null>((sum, rate) => {\n return sum && sum.getAveragePrice() < rate.getAveragePrice() ? sum : rate;\n }, null)\n ?.getPriceType() ?? RoomRatePriceInclusion.IncludingFeesAndTaxes\n );\n };\n\n public getLowestPrice(raw = false, rawPrice = false) {\n return (\n (raw ? this.rates : this.filteredRates)?.reduce<number>((sum: number, rate: RoomRate) => {\n const avrg = rate.getAveragePrice(rawPrice);\n return sum < avrg && sum ? sum : avrg;\n }, 0) ?? 0\n );\n }\n\n public getHighestPrice(raw = false) {\n return (\n (raw ? this.rates : this.filteredRates)?.reduce<number>((sum: number, rate: RoomRate) => (sum > rate.getAveragePrice() && sum ? sum : rate.getAveragePrice()), 0) ?? 0\n );\n }\n\n public addRate(rate: RoomRate) {\n rate.setRoom(this);\n this.rates.push(rate);\n }\n\n public getImages(): string[] {\n if (this.images && this.images.length) {\n return this.images;\n }\n\n return [];\n }\n\n public getOriginalRates(): RoomRate[] {\n return this.rates;\n }\n\n public getRates(): RoomRate[] {\n return (this.filteredRates as RoomRate[]).sort((a, b) => {\n return a.isMemberOnly ? -1 : b.isMemberOnly ? 1 : 0;\n });\n }\n\n public getRate(code: string): RoomRate | null {\n for (const rate in this.rates) {\n if (code === this.rates[rate].code) {\n return this.rates[rate];\n }\n }\n\n return null;\n }\n\n public getPriceSortValue() {\n return this.getLowestPrice();\n }\n\n public getRecommendedSortValue() {\n return this.order;\n }\n\n public serialize() {\n const toSerialize: IRoom = {\n id: this.id,\n code: this.code,\n images: this.images,\n longDescription: this.longDescription,\n name: this.name,\n occupancy: this.occupancy,\n rates: this.rates.map((rate) => rate.serialize()),\n shortDescription: this.shortDescription,\n roomGroupId: this.roomGroupId,\n auxiliaryValues: this.auxiliaryValues,\n order: this.order,\n } as IRoom;\n\n return toSerialize;\n }\n\n public unSerialize(data: IRoom) {\n const newRates: RoomRate[] = data.rates?.map((serializedRate) => {\n const roomRate = new RoomRate();\n roomRate.unSerialize(serializedRate);\n\n return roomRate;\n });\n\n this.code = data.code;\n this.id = data.id;\n this.images = data.images;\n this.longDescription = data.longDescription;\n this.name = data.name;\n this.occupancy = data.occupancy;\n this.shortDescription = data.shortDescription;\n this.filteredRates = newRates;\n this.rates = newRates;\n\n this.roomGroupId = data.roomGroupId;\n this.auxiliaryValues = data.auxiliaryValues;\n this.order = data.order;\n\n return this;\n }\n\n public getRoomPerks({ hotel, room, perksLimitNumber }: { hotel?: Hotel; room?: Room; perksLimitNumber?: number }): {\n prePerkDisclaimer?: string;\n roomPerks: HotelPerk[];\n } {\n if (!room || !hotel) {\n return {\n roomPerks: hotel?.perks ?? [],\n };\n }\n const roomOverride = hotel?.overwrites?.[room?.code as string];\n let roomPerks = roomOverride?.perks?.length ? roomOverride?.perks : hotel?.perks;\n if (perksLimitNumber) {\n roomPerks = roomPerks?.slice(0, perksLimitNumber);\n }\n const prePerkDisclaimer = roomOverride?.prePerkDisclaimer ? roomOverride.prePerkDisclaimer : room?.prePerkDisclaimer;\n return {\n prePerkDisclaimer: prePerkDisclaimer,\n roomPerks: roomPerks ?? [],\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Room.js","sourceRoot":"/","sources":["src/models/Room/Room.ts"],"names":[],"mappings":";;;AAEA,qDAAqF;AAwBrF,MAAa,IAAI;IAmBb,YAAmB,KAAsB;QARlC,oBAAe,GAA4C,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Z,YAAY,uBAAZ,YAAY,CAAE,KAAK,0CAAE,MAAM,EAAC,CAAC,CAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,CAAC,CAAC,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;QACjF,IAAI,gBAAgB,EAAE;YAClB,SAAS,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;SACrD;QACD,MAAM,iBAAiB,GAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,iBAAiB,EAAC,CAAC,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,iBAAiB,CAAC;QACrH,OAAO;YACH,iBAAiB,EAAE,iBAAiB;YACpC,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE;SAC7B,CAAC;IACN,CAAC;CACJ;AA/MD,oBA+MC","sourcesContent":["import { ConfigHotel, Hotel } from '@/models/Client/Hotel/Hotel';\nimport { HotelPerk } from '@/models/Client/Hotel/HotelPerk';\nimport { IRoomRate, RoomRate, RoomRatePriceInclusion } from '@/models/Room/RoomRate';\nimport RoomRateSortable from '@/models/Room/RoomRateSortable';\nimport { Serializable } from '@/models/Serializable';\n\nexport interface IRoom {\n id: number;\n\n code: string;\n name: string;\n longDescription: string;\n shortDescription: string;\n\n occupancy: number;\n\n images: string[];\n rates: IRoomRate[];\n roomGroupId?: string;\n auxiliaryValues: { [key: string]: (string | number)[] };\n order: number;\n\n prePerkDisclaimer?: string;\n perks?: ConfigHotel['perks'];\n}\n\nexport class Room implements RoomRateSortable, Serializable<Room, IRoom> {\n public id?: number;\n public code?: string;\n public name?: string;\n public longDescription?: string;\n public shortDescription?: string;\n\n public occupancy?: number;\n\n public images: string[];\n public roomGroupId?: string;\n public auxiliaryValues?: { [key: string]: (string | number)[] } = {};\n public filteredRates?: RoomRate[];\n private rates: RoomRate[];\n public order?: number;\n\n public prePerkDisclaimer?: string;\n public perks?: ConfigHotel['perks'];\n\n public constructor(props?: Partial<IRoom>) {\n this.rates = [];\n this.images = [];\n this.auxiliaryValues = {};\n\n if (props) {\n this.applyData(props);\n }\n }\n\n public static fromData(data: any) {\n const room = new this();\n\n if (!data.images && data.imageUrls) {\n data.images = data.imageUrls;\n }\n\n room.applyData(data);\n\n return room;\n }\n\n public getShortDescription(trim = true) {\n let shortDesc = this.shortDescription;\n\n if (trim) {\n shortDesc = (this.shortDescription?.length as number) > 97 ? this.shortDescription?.substr(0, 97) + '…' : this.shortDescription;\n }\n\n return shortDesc?.replace(/(<br>\\s*)+$/, '');\n }\n\n public getLongDescription() {\n return this.longDescription?.replace(/(<br>\\s*)+$/, '');\n }\n\n public applyData(data: Partial<IRoom>) {\n Object.keys(data).map((key: any) => {\n (this as any)[key] = (data as any)[key];\n }, this);\n\n this.filteredRates = this.rates;\n }\n\n public getLowestPriceType = (raw = false) => {\n return (\n ((raw ? this.rates : this.filteredRates) as RoomRate[])\n .reduce<RoomRate | null>((sum, rate) => {\n return sum && sum.getAveragePrice() < rate.getAveragePrice() ? sum : rate;\n }, null)\n ?.getPriceType() ?? RoomRatePriceInclusion.IncludingFeesAndTaxes\n );\n };\n\n public getLowestPrice(raw = false, rawPrice = false) {\n return (\n (raw ? this.rates : this.filteredRates)?.reduce<number>((sum: number, rate: RoomRate) => {\n const avrg = rate.getAveragePrice(rawPrice);\n return sum < avrg && sum ? sum : avrg;\n }, 0) ?? 0\n );\n }\n\n /**\n * Function for getting the lowest total price of the room from all the possible rates.\n * @param includeAllRates If set to true will include all rates, otherwise will only include filtered rates\n * @param getCost If set to true will return the cost of the rate, otherwise will return the average price see {@link RoomRate.getTotalPrice}\n * @returns\n */\n public getLowestTotalPrice(includeAllRates = false, getCost = false) {\n return (\n (includeAllRates ? this.rates : this.filteredRates)?.reduce<number>((sum: number, rate: RoomRate) => {\n const avrg = rate.getTotalPrice(getCost);\n return sum < avrg && sum ? sum : avrg;\n }, 0) ?? 0\n );\n }\n\n public getHighestPrice(raw = false) {\n return (\n (raw ? this.rates : this.filteredRates)?.reduce<number>((sum: number, rate: RoomRate) => (sum > rate.getAveragePrice() && sum ? sum : rate.getAveragePrice()), 0) ?? 0\n );\n }\n\n public addRate(rate: RoomRate) {\n rate.setRoom(this);\n this.rates.push(rate);\n }\n\n public getImages(): string[] {\n if (this.images && this.images.length) {\n return this.images;\n }\n\n return [];\n }\n\n public getOriginalRates(): RoomRate[] {\n return this.rates;\n }\n\n public getRates(): RoomRate[] {\n return (this.filteredRates as RoomRate[]).sort((a, b) => {\n return a.isMemberOnly ? -1 : b.isMemberOnly ? 1 : 0;\n });\n }\n\n public getRate(code: string): RoomRate | null {\n for (const rate in this.rates) {\n if (code === this.rates[rate].code) {\n return this.rates[rate];\n }\n }\n\n return null;\n }\n\n public getPriceSortValue() {\n return this.getLowestPrice();\n }\n\n public getRecommendedSortValue() {\n return this.order;\n }\n\n public serialize() {\n const toSerialize: IRoom = {\n id: this.id,\n code: this.code,\n images: this.images,\n longDescription: this.longDescription,\n name: this.name,\n occupancy: this.occupancy,\n rates: this.rates.map((rate) => rate.serialize()),\n shortDescription: this.shortDescription,\n roomGroupId: this.roomGroupId,\n auxiliaryValues: this.auxiliaryValues,\n order: this.order,\n } as IRoom;\n\n return toSerialize;\n }\n\n public unSerialize(data: IRoom) {\n const newRates: RoomRate[] = data.rates?.map((serializedRate) => {\n const roomRate = new RoomRate();\n roomRate.unSerialize(serializedRate);\n\n return roomRate;\n });\n\n this.code = data.code;\n this.id = data.id;\n this.images = data.images;\n this.longDescription = data.longDescription;\n this.name = data.name;\n this.occupancy = data.occupancy;\n this.shortDescription = data.shortDescription;\n this.filteredRates = newRates;\n this.rates = newRates;\n\n this.roomGroupId = data.roomGroupId;\n this.auxiliaryValues = data.auxiliaryValues;\n this.order = data.order;\n\n return this;\n }\n\n public getRoomPerks({ hotel, room, perksLimitNumber }: { hotel?: Hotel; room?: Room; perksLimitNumber?: number }): {\n prePerkDisclaimer?: string;\n roomPerks: HotelPerk[];\n } {\n if (!room || !hotel) {\n return {\n roomPerks: hotel?.perks ?? [],\n };\n }\n const roomOverride = hotel?.overwrites?.[room?.code as string];\n let roomPerks = roomOverride?.perks?.length ? roomOverride?.perks : hotel?.perks;\n if (perksLimitNumber) {\n roomPerks = roomPerks?.slice(0, perksLimitNumber);\n }\n const prePerkDisclaimer = roomOverride?.prePerkDisclaimer ? roomOverride.prePerkDisclaimer : room?.prePerkDisclaimer;\n return {\n prePerkDisclaimer: prePerkDisclaimer,\n roomPerks: roomPerks ?? [],\n };\n }\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);
|
|
@@ -178,6 +189,9 @@ class RoomRate {
|
|
|
178
189
|
return rateOverrides;
|
|
179
190
|
};
|
|
180
191
|
this.hasRateVariesByDay = (requestedDate) => {
|
|
192
|
+
// Validate startDate/endDate
|
|
193
|
+
if (!(requestedDate === null || requestedDate === void 0 ? void 0 : requestedDate.startDate) || !requestedDate.endDate)
|
|
194
|
+
return false;
|
|
181
195
|
const rateOverrides = this.getAvailableRateOverrides();
|
|
182
196
|
if (!rateOverrides.length)
|
|
183
197
|
false;
|
|
@@ -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,sBA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CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,eAAyB,CAAC;QACjD,IAAI,CAAC,YAAY,GAAG,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;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,8BAAs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'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 // Validate startDate/endDate\n if (!requestedDate?.startDate || !requestedDate.endDate) return false;\n\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,4 +1,5 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
+
import { SimpleItemisedFee } from '../Fee';
|
|
2
3
|
import { Serializable } from '../Serializable';
|
|
3
4
|
export interface IRoomRateNight {
|
|
4
5
|
date: string;
|
|
@@ -8,6 +9,7 @@ export interface IRoomRateNight {
|
|
|
8
9
|
fee: string;
|
|
9
10
|
total: string;
|
|
10
11
|
available: string;
|
|
12
|
+
fees?: SimpleItemisedFee[];
|
|
11
13
|
}
|
|
12
14
|
export default class RoomRateNight implements Serializable<RoomRateNight, IRoomRateNight> {
|
|
13
15
|
date: dayjs.Dayjs;
|
|
@@ -17,6 +19,7 @@ export default class RoomRateNight implements Serializable<RoomRateNight, IRoomR
|
|
|
17
19
|
fee: string;
|
|
18
20
|
total: string;
|
|
19
21
|
available: string;
|
|
22
|
+
fees: SimpleItemisedFee[];
|
|
20
23
|
serialize(): IRoomRateNight;
|
|
21
24
|
unSerialize(data: IRoomRateNight): this;
|
|
22
25
|
}
|
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
7
7
|
const RoomstaySession_1 = require("../RoomstaySession");
|
|
8
8
|
class RoomRateNight {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.fees = [];
|
|
11
|
+
}
|
|
9
12
|
serialize() {
|
|
10
13
|
const toSerialize = {
|
|
11
14
|
date: this.date.format(RoomstaySession_1.SERIALIZED_DATE_FORMAT),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoomRateNight.js","sourceRoot":"/","sources":["src/models/Room/RoomRateNight.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;
|
|
1
|
+
{"version":3,"file":"RoomRateNight.js","sourceRoot":"/","sources":["src/models/Room/RoomRateNight.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAG1B,8DAAkE;AAclE,MAAqB,aAAa;IAAlC;QAWW,SAAI,GAAwB,EAAE,CAAC;IA6B1C,CAAC;IA3BU,SAAS;QACZ,MAAM,WAAW,GAAmB;YAChC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,wCAAsB,CAAC;YAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC5B,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;IAEM,WAAW,CAAC,IAAoB;QACnC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAElE,IAAI,CAAC,IAAI,GAAG,IAAA,eAAK,EAAC,IAAI,EAAE,wCAAsB,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAxCD,gCAwCC","sourcesContent":["import dayjs from 'dayjs';\n\nimport { SimpleItemisedFee } from '@/models/Fee';\nimport { SERIALIZED_DATE_FORMAT } from '@/models/RoomstaySession';\nimport { Serializable } from '@/models/Serializable';\n\nexport interface IRoomRateNight {\n date: string;\n cost: string;\n tax: string;\n discount: string;\n fee: string;\n total: string;\n available: string;\n fees?: SimpleItemisedFee[];\n}\n\nexport default class RoomRateNight implements Serializable<RoomRateNight, IRoomRateNight> {\n public date!: dayjs.Dayjs;\n\n public cost!: string;\n public tax!: string;\n public discount!: string;\n public fee!: string;\n public total!: string;\n\n public available!: string;\n\n public fees: SimpleItemisedFee[] = [];\n\n public serialize() {\n const toSerialize: IRoomRateNight = {\n date: this.date.format(SERIALIZED_DATE_FORMAT),\n cost: this.cost,\n tax: this.tax,\n discount: this.discount,\n fee: this.fee,\n total: this.total,\n available: this.available,\n };\n\n return toSerialize;\n }\n\n public unSerialize(data: IRoomRateNight) {\n const { date, cost, tax, discount, fee, total, available } = data;\n\n this.date = dayjs(date, SERIALIZED_DATE_FORMAT);\n this.cost = cost;\n this.tax = tax;\n this.discount = discount;\n this.fee = fee;\n this.total = total;\n this.available = available;\n\n return this;\n }\n}\n"]}
|