fix journey value object : useless driver neutral target for passenger start

This commit is contained in:
Sylvain Briat 2023-11-02 17:13:16 +01:00
parent 62e4015ea7
commit 5ca5200f1a
1 changed files with 8 additions and 10 deletions

View File

@ -38,24 +38,22 @@ export class Journey extends ValueObject<JourneyProps> {
actorTime.target == Target.START, actorTime.target == Target.START,
) as ActorTime, ) as ActorTime,
) as JourneyItem; ) as JourneyItem;
const passengerDepartureActorTime = const passengerDepartureActorTime: ActorTime =
passengerDepartureJourneyItem.actorTimes.find( passengerDepartureJourneyItem.actorTimes.find(
(actorTime: ActorTime) => (actorTime: ActorTime) =>
actorTime.role == Role.PASSENGER && actorTime.target == Target.START, actorTime.role == Role.PASSENGER && actorTime.target == Target.START,
) as ActorTime; ) as ActorTime;
const driverNeutralActorTime = const driverActorTime = passengerDepartureJourneyItem.actorTimes.find(
passengerDepartureJourneyItem.actorTimes.find( (actorTime: ActorTime) => actorTime.role == Role.DRIVER,
(actorTime: ActorTime) =>
actorTime.role == Role.DRIVER && actorTime.target == Target.NEUTRAL,
) as ActorTime; ) as ActorTime;
return ( return (
(passengerDepartureActorTime.firstMinDatetime <= (passengerDepartureActorTime.firstMinDatetime <=
driverNeutralActorTime.firstMaxDatetime && driverActorTime.firstMaxDatetime &&
driverNeutralActorTime.firstMaxDatetime <= driverActorTime.firstMaxDatetime <=
passengerDepartureActorTime.firstMaxDatetime) || passengerDepartureActorTime.firstMaxDatetime) ||
(passengerDepartureActorTime.firstMinDatetime <= (passengerDepartureActorTime.firstMinDatetime <=
driverNeutralActorTime.firstMinDatetime && driverActorTime.firstMinDatetime &&
driverNeutralActorTime.firstMinDatetime <= driverActorTime.firstMinDatetime <=
passengerDepartureActorTime.firstMaxDatetime) passengerDepartureActorTime.firstMaxDatetime)
); );
}; };