| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod GetOperationDependentDemandPeriods ( | 
|   const Period_MP ptperiod, | 
|   const Process_MP process, | 
|   constcontent output owning Period_MPs periods_o, | 
|   Boolean getfromperiodtask | 
| ) const | 
| { | 
|   Description: 'Return the periods of dependent demand of period task.' | 
|   TextBody: | 
|   [* | 
|     macroplan := ptperiod.MacroPlan();  | 
|      | 
|     if ( getfromperiodtask )  | 
|     { | 
|       pto := select(  process.astype( Operation ), PeriodTaskOperation, pto, pto.UnitPeriod().Period_MP() = ptperiod );  | 
|       traverse( pto, DependentDemand, dd )  | 
|       { | 
|         periods_o.Add( dd.ProductInStockingPointInPeriodPlanningLeaf().Period_MP() );  | 
|       } | 
|       periods_o := periods_o.Unique();  | 
|     } | 
|     else | 
|     { | 
|       if ( process.HasLeadTime() )  | 
|       { | 
|         startofdd := Process_MP::GetDependentDemandEarliestStart( ptperiod, process.LeadTime(), macroplan.GlobalParameters_MP(), process ); | 
|         endofdd := Process_MP::GetDependentDemandEnd( startofdd, ptperiod, process ); | 
|        | 
|         periodstart := ptperiod;  | 
|         done := false; | 
|         hitinperiod := false;   | 
|        | 
|         while( not done and periodstart.End() >= startofdd ) // once end < start we definitable know we will not hit periods with overlap anymore | 
|         { | 
|           if ( periodstart.IsInPeriod( startofdd, endofdd ) ) | 
|           { | 
|             hitinperiod := true; // once we go out of period again we know we will be done    | 
|             periods_o.Add( periodstart );  | 
|           } | 
|           else | 
|           { | 
|             done := hitinperiod | 
|           } | 
|           periodstart := periodstart.PreviousPlanningPeriod();  | 
|           done := done or isnull( periodstart );  | 
|         } | 
|       } | 
|       else // no lead time process | 
|       { | 
|         periods_o.Add( ptperiod );  | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |