| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GetTargetPeriod ( | 
|   const OutgoingShelfLifeDay oslday | 
| ) const as const Period_MP | 
| { | 
|   Description: 'if a trip leaves from this pispip with lead time oslday.ShelfLifeDays what period does it arrive - this is what we compute' | 
|   TextBody: | 
|   [* | 
|     period := this.Period_MP();  | 
|      | 
|     if ( oslday.ShelfLifeDays() > 0 )  | 
|     { | 
|       arbitrarypitdeparting := select( this, Demand_MP.astype( DependentDemand ).ProductInTrip, pit, pit.Trip().GetShelfLifeAgeToAdd() = oslday.ShelfLifeDays() ); | 
|       if ( not isnull( arbitrarypitdeparting ) )  | 
|       { | 
|         period := guard( arbitrarypitdeparting.Trip().ArrivalUnitPeriod().Period_MP(), constnull( Period_MP ) ); | 
|          | 
|         // special case with end period lead time logic. Example: A trip with arrival date time 4 Jan 0:00, will have arrival period start end = (Jan 3 0.00 - Jan 4 0.00). | 
|         // in this case we should take the next period.  | 
|         if ( not isnull( period )  | 
|              and this.ProductInStockingPoint_MP().Product_MP().MacroPlan().GlobalParameters_MP().LaneLeadTimeLogic() = Translations::MP_GlobalParameter_LeadTimeLogic_From_End_Period()   | 
|              and guard( arbitrarypitdeparting.Trip().Departure() = arbitrarypitdeparting.Trip().DepartureUnitPeriod().Start(), false ) | 
|               )  | 
|         { | 
|           period := period.NextPeriod();  | 
|         }  | 
|          | 
|       } | 
|     } | 
|     return period; | 
|   *] | 
| } |