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,
) as ActorTime,
) as JourneyItem;
const passengerDepartureActorTime =
const passengerDepartureActorTime: ActorTime =
passengerDepartureJourneyItem.actorTimes.find(
(actorTime: ActorTime) =>
actorTime.role == Role.PASSENGER && actorTime.target == Target.START,
) as ActorTime;
const driverNeutralActorTime =
passengerDepartureJourneyItem.actorTimes.find(
(actorTime: ActorTime) =>
actorTime.role == Role.DRIVER && actorTime.target == Target.NEUTRAL,
) as ActorTime;
const driverActorTime = passengerDepartureJourneyItem.actorTimes.find(
(actorTime: ActorTime) => actorTime.role == Role.DRIVER,
) as ActorTime;
return (
(passengerDepartureActorTime.firstMinDatetime <=
driverNeutralActorTime.firstMaxDatetime &&
driverNeutralActorTime.firstMaxDatetime <=
driverActorTime.firstMaxDatetime &&
driverActorTime.firstMaxDatetime <=
passengerDepartureActorTime.firstMaxDatetime) ||
(passengerDepartureActorTime.firstMinDatetime <=
driverNeutralActorTime.firstMinDatetime &&
driverNeutralActorTime.firstMinDatetime <=
driverActorTime.firstMinDatetime &&
driverActorTime.firstMinDatetime <=
passengerDepartureActorTime.firstMaxDatetime)
);
};