mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 00:38:11 +00:00
Additional UAT issue resolutions
This commit is contained in:
@@ -144,22 +144,33 @@ export class GuestBookingService {
|
||||
});
|
||||
}
|
||||
|
||||
// Calculate fare
|
||||
const primaryNationality = passengersData[0]?.nationality;
|
||||
const baseFareMinor = await this.getBaseFare(
|
||||
dto.scheduleId,
|
||||
dto.seatClassId,
|
||||
segmentRoute,
|
||||
fullRoute,
|
||||
primaryNationality,
|
||||
dto.originStationId,
|
||||
dto.destinationStationId,
|
||||
);
|
||||
// Calculate fare — package bookings use the fixed tier price, bypassing the fare engine
|
||||
const isPackageOneway = !!dto.packageId && !!dto.priceTierId;
|
||||
let baseFareMinor: number;
|
||||
let paidChildrenCount: number;
|
||||
let childUnitFare: number;
|
||||
|
||||
if (isPackageOneway) {
|
||||
const tier = await this.prisma.packagePriceTier.findUniqueOrThrow({ where: { id: dto.priceTierId! } });
|
||||
baseFareMinor = tier.priceMinor;
|
||||
paidChildrenCount = childCount;
|
||||
childUnitFare = Math.round(baseFareMinor * 0.1);
|
||||
} else {
|
||||
const primaryNationality = passengersData[0]?.nationality;
|
||||
baseFareMinor = await this.getBaseFare(
|
||||
dto.scheduleId,
|
||||
dto.seatClassId,
|
||||
segmentRoute,
|
||||
fullRoute,
|
||||
primaryNationality,
|
||||
dto.originStationId,
|
||||
dto.destinationStationId,
|
||||
);
|
||||
paidChildrenCount = Math.max(0, childCount - 1);
|
||||
childUnitFare = baseFareMinor;
|
||||
}
|
||||
|
||||
const adultFareMinor = baseFareMinor * adultCount;
|
||||
const isPackageOneway = !!dto.packageId;
|
||||
const paidChildrenCount = isPackageOneway ? childCount : Math.max(0, childCount - 1);
|
||||
const childUnitFare = isPackageOneway ? Math.round(baseFareMinor * 0.1) : baseFareMinor;
|
||||
const childFareMinor = childUnitFare * paidChildrenCount;
|
||||
const totalBaseFareMinor = adultFareMinor + childFareMinor;
|
||||
|
||||
@@ -369,19 +380,34 @@ export class GuestBookingService {
|
||||
passengersData.push({ ...passenger, passengerName, dateOfBirth, category, verifaydaVerified, verifaydaData, nationality });
|
||||
}
|
||||
|
||||
// Calculate fares for both legs
|
||||
// Calculate fares for both legs — package bookings use the fixed tier price split across legs
|
||||
const returnSeatClassId = dto.returnSeatClassId || dto.seatClassId;
|
||||
const primaryNationality = passengersData[0]?.nationality;
|
||||
const isPackageRoundTrip = !!dto.packageId && !!dto.priceTierId;
|
||||
let outboundBaseFare: number;
|
||||
let returnBaseFare: number;
|
||||
let paidChildrenCount: number;
|
||||
let outboundChildUnitFare: number;
|
||||
let returnChildUnitFare: number;
|
||||
|
||||
const [outboundBaseFare, returnBaseFare] = await Promise.all([
|
||||
this.getBaseFare(dto.scheduleId, dto.seatClassId, outboundSegmentRoute, outboundFullRoute, primaryNationality, dto.originStationId, dto.destinationStationId),
|
||||
this.getBaseFare(dto.returnScheduleId, returnSeatClassId, returnSegmentRoute, returnFullRoute, primaryNationality, dto.returnOriginStationId, dto.returnDestinationStationId),
|
||||
]);
|
||||
|
||||
const isPackageRoundTrip = !!dto.packageId;
|
||||
const paidChildrenCount = isPackageRoundTrip ? childCount : Math.max(0, childCount - 1);
|
||||
const outboundChildUnitFare = isPackageRoundTrip ? Math.round(outboundBaseFare * 0.1) : outboundBaseFare;
|
||||
const returnChildUnitFare = isPackageRoundTrip ? Math.round(returnBaseFare * 0.1) : returnBaseFare;
|
||||
if (isPackageRoundTrip) {
|
||||
const tier = await this.prisma.packagePriceTier.findUniqueOrThrow({ where: { id: dto.priceTierId! } });
|
||||
// tier.priceMinor is the full round-trip price per adult; split evenly across legs
|
||||
const halfMinor = Math.round(tier.priceMinor / 2);
|
||||
outboundBaseFare = halfMinor;
|
||||
returnBaseFare = tier.priceMinor - halfMinor;
|
||||
paidChildrenCount = childCount;
|
||||
outboundChildUnitFare = Math.round(outboundBaseFare * 0.1);
|
||||
returnChildUnitFare = Math.round(returnBaseFare * 0.1);
|
||||
} else {
|
||||
const primaryNationality = passengersData[0]?.nationality;
|
||||
[outboundBaseFare, returnBaseFare] = await Promise.all([
|
||||
this.getBaseFare(dto.scheduleId, dto.seatClassId, outboundSegmentRoute, outboundFullRoute, primaryNationality, dto.originStationId, dto.destinationStationId),
|
||||
this.getBaseFare(dto.returnScheduleId, returnSeatClassId, returnSegmentRoute, returnFullRoute, primaryNationality, dto.returnOriginStationId, dto.returnDestinationStationId),
|
||||
]);
|
||||
paidChildrenCount = Math.max(0, childCount - 1);
|
||||
outboundChildUnitFare = outboundBaseFare;
|
||||
returnChildUnitFare = returnBaseFare;
|
||||
}
|
||||
const outboundTotalBase = outboundBaseFare * adultCount + outboundChildUnitFare * paidChildrenCount;
|
||||
const returnTotalBase = returnBaseFare * adultCount + returnChildUnitFare * paidChildrenCount;
|
||||
const combinedBaseFareMinor = outboundTotalBase + returnTotalBase;
|
||||
|
||||
Reference in New Issue
Block a user