mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 14:08:11 +00:00
Fare engine updates, seat class amount updates
This commit is contained in:
@@ -105,10 +105,16 @@ export class FareEngineService {
|
||||
|
||||
if (segmentOverride) {
|
||||
baseFarePerPassengerMinor = segmentOverride.baseFareMinor;
|
||||
if (nationalityType === 'INTERNATIONAL' && !segmentOverride.nationality) {
|
||||
baseFarePerPassengerMinor *= 2;
|
||||
}
|
||||
ratePerKmMinor = totalDistanceKm > 0 ? Math.round(baseFarePerPassengerMinor / totalDistanceKm) : 0;
|
||||
fareSource = 'SEGMENT_FARE_RULE';
|
||||
} else if (fareRule?.tripId) {
|
||||
baseFarePerPassengerMinor = fareRule.baseFareMinor;
|
||||
if (nationalityType === 'INTERNATIONAL' && !fareRule.nationality) {
|
||||
baseFarePerPassengerMinor *= 2;
|
||||
}
|
||||
ratePerKmMinor = totalDistanceKm > 0 ? Math.round(baseFarePerPassengerMinor / totalDistanceKm) : 0;
|
||||
fareSource = 'SCHEDULE_FARE_RULE';
|
||||
} else {
|
||||
@@ -165,7 +171,7 @@ export class FareEngineService {
|
||||
|
||||
const calculation = [
|
||||
`Distance: ${totalDistanceKm} km (${originStation?.name} → ${destStation?.name})`,
|
||||
`Nationality: ${dto.nationality ?? 'unspecified'} → ${nationalityType} → ${nationalitySeatClass.name}`,
|
||||
`Nationality: ${dto.nationality ?? 'unspecified'} → ${nationalityType}${nationalityType === 'INTERNATIONAL' ? ' (2× surcharge applied)' : ''} → ${nationalitySeatClass.name}`,
|
||||
`Rate per km: ${nationalitySeatClass.baseFareMinor} minor → ${nationalitySeatClass.baseFareMinor / 100} ETB/km`,
|
||||
`Insurance: ${nationalitySeatClass.insuranceFeeMinor} minor → factor ${insuranceFactor}${insuranceAlreadyInBase ? ' (baked into base fare)' : ''}`,
|
||||
`USD→ETB rate: ${usdToEtbRate}`,
|
||||
|
||||
Reference in New Issue
Block a user