Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method CapacityPlanningAlgorithmHandleFeasibleDelayedSalesDemand ( 
 | 
  BaseSalesDemandInPeriod salesdemandinperiod, 
 | 
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, 
 | 
  const RunContextForCapacityPlanning runcontext, 
 | 
  LibOpt_Scope scope, 
 | 
  Number optminpostponementperiod 
 | 
) 
 | 
{ 
 | 
  Description: 'Method for obtaining the delayed sales demand variable from the optimizer' 
 | 
  TextBody: 
 | 
  [* 
 | 
    pispip := salesdemandinperiod.AsPlanningBaseSalesDemandInPeriod(); 
 | 
     
 | 
    if( salesdemandinperiod.CanBePostponed() and salesdemandinperiod.NeedsToBePlanned() ) 
 | 
    { 
 | 
      nextpispip := pispip.NextPlanningPISPIP(); 
 | 
       
 | 
      for( i := 2; 
 | 
           i <= optminpostponementperiod 
 | 
           and not isnull( nextpispip ); 
 | 
           i++ 
 | 
         ) 
 | 
      { 
 | 
        nextpispip := nextpispip.NextPlanningPISPIP(); 
 | 
      } 
 | 
       
 | 
      for( i := optminpostponementperiod; 
 | 
           i <= salesdemandinperiod.MaxPostponementPeriod() // within the maximum number of postponement periods 
 | 
           and not isnull( nextpispip );                     // the next pispip exists 
 | 
           i++ ) 
 | 
      { 
 | 
        if( scope.Contains( nextpispip.PISPIPInOptimizerRun() ) ) 
 | 
        { 
 | 
          var := salesdemandinperiod.GetDelayedSalesDemandQtyVariable( program, nextpispip.Period_MP() ); 
 | 
           
 | 
          if( not isnull( var ) ) 
 | 
          { 
 | 
            postponedqty := this.GetOptimalValue( var ); 
 | 
             
 | 
            if( postponedqty > 0.0 ) 
 | 
            {       
 | 
              postponedsd := salesdemandinperiod.Postpone( postponedqty, false, nextpispip.astype( ProductInStockingPointInPeriodPlanningLeaf ) );  
 | 
              postponedsd.UpdateOptimizerFulfillment( true, postponedqty ); 
 | 
            } 
 | 
          } 
 | 
        } 
 | 
        nextpispip := nextpispip.NextPlanningPISPIP(); 
 | 
      } 
 | 
    } 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |