Merged in fix/SW-1353-and-SW-2497-tracking-fixes (pull request #1977)
fix: tracking fixes SW-1353 and SW-2497 * fix: tracking fixes * fix: remove console log and rename variable Approved-by: Michael Zetterberg Approved-by: Arvid Norlin
This commit is contained in:
@@ -94,7 +94,7 @@ export function getTracking(
|
||||
.join("|"),
|
||||
country: hotel?.address.country,
|
||||
departureDate: format(departureDate, "yyyy-MM-dd"),
|
||||
discount: rooms.reduce((total, room, idx) => {
|
||||
discount: storedRooms.reduce((total, { room }, idx) => {
|
||||
const isMainRoom = idx === 0
|
||||
if (
|
||||
hasMemberPrice(room.roomRate) &&
|
||||
@@ -184,8 +184,8 @@ export function getTracking(
|
||||
rewardNight: booking.searchType === REDEMPTION ? "yes" : "no",
|
||||
rewardNightAvailability:
|
||||
booking.searchType === REDEMPTION ? "true" : "false",
|
||||
roomPrice: calcTotalRoomPrice(rooms, isMember),
|
||||
totalPrice: calcTotalPrice(rooms, isMember),
|
||||
roomPrice: calcTotalRoomPrice(storedRooms, isMember),
|
||||
totalPrice: calcTotalPrice(storedRooms, isMember),
|
||||
points:
|
||||
// @ts-expect-error - redemption object doesn't exist error
|
||||
rooms.find((room) => "redemption" in room.roomRate)?.roomRate.redemption
|
||||
@@ -286,17 +286,23 @@ function hasBreakfast(entry: RoomEntry): entry is RoomEntry & {
|
||||
)
|
||||
}
|
||||
|
||||
function calcTotalPrice(rooms: Room[], isMember: boolean) {
|
||||
function calcTotalPrice(rooms: RoomState[], isMember: boolean) {
|
||||
const totalRoomPrice = calcTotalRoomPrice(rooms, isMember)
|
||||
const totalPackageSum = rooms.reduce((total, room) => {
|
||||
const packageSum = sumPackages(room.packages)
|
||||
return (total += packageSum.price ?? 0)
|
||||
const totalPackageSum = rooms.reduce((total, { room }) => {
|
||||
if (room.breakfast) {
|
||||
total += Number(room.breakfast.localPrice.totalPrice) * room.adults
|
||||
}
|
||||
if (room.roomFeatures?.length) {
|
||||
const packageSum = sumPackages(room.roomFeatures)
|
||||
total += packageSum.price
|
||||
}
|
||||
return total
|
||||
}, 0)
|
||||
return totalRoomPrice + totalPackageSum
|
||||
}
|
||||
|
||||
function calcTotalRoomPrice(rooms: Room[], isMember: boolean) {
|
||||
return rooms.reduce((total, room, idx) => {
|
||||
function calcTotalRoomPrice(rooms: RoomState[], isMember: boolean) {
|
||||
return rooms.reduce((total, { room }, idx) => {
|
||||
// When it comes special rates, only redemption has additional price and that should be added
|
||||
// other special rates like voucher, corporateCheck should be added as 0 according to Priyanka
|
||||
if ("redemption" in room.roomRate) {
|
||||
|
||||
Reference in New Issue
Block a user