Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method GetNewSupplyPeriod ( 
 | 
  DateTime newsupplyend 
 | 
) as Period_MP 
 | 
{ 
 | 
  Description: 'Returns the period in which the new supply will arrive that leaves from this period and arrives at the given time' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Check if the new supply will also arrive in this period 
 | 
    // If not, then if it arrives in the next period 
 | 
    // Continue until the period in which it arrives has been found 
 | 
    // Break the loop when either there is no next period or when the number of planning periods has been exceeded 
 | 
     
 | 
    nrofperiods := this.MacroPlan().PlanningPeriod( relsize ); 
 | 
    nsperiod := this; 
 | 
    for( i := 1; 
 | 
         not guard( nsperiod.IsInPeriod( newsupplyend, newsupplyend ), true ) 
 | 
         and i <= nrofperiods; 
 | 
         i++ ) 
 | 
    { 
 | 
      nsperiod := nsperiod.NextPlanningPeriod();   
 | 
    } 
 | 
     
 | 
    return nsperiod; 
 | 
  *] 
 | 
} 
 |