admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;
  *]
}