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
StaticMethod GetDependentDemandEnd (
  DateTime start,
  const Period_MP period,
  const Process_MP process
) const declarative as DateTime
{
  TextBody:
  [*
    value := Process_MP::GetOperationEnd( period, start );
    gp := period.MacroPlan().GlobalParameters_MP(); 
    
    if( not gp.IsOperationLeadTimeLogicProportional() ) 
    {
      //get period of start 
      ddstartperiod := select( gp.MacroPlan(), PlanningPeriod, pp, pp.Start() <= start and pp.End() > start );
      
      // if not start from middle and leadtime < period task period duration, make sure dependent demand end before period start
      periodstart :=  ifexpr( not gp.IsOperationLeadTimeLogicFromMiddle() and period.Duration() < process.LeadTime(), period.Start(), DateTime::MaxDateTime() );
      
      value := minvalue( start + process.LeadTime(), start + ddstartperiod.Duration(), periodstart ); 
    }
    
    return value;
  *]
}