yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
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;
  *]
}