Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method CreateProductInStockingPointInPeriod ( 
 | 
  ProductInStockingPoint_MPs pisps, 
 | 
  Period_MPs periods, 
 | 
  Boolean isondelete 
 | 
) 
 | 
{ 
 | 
  Description: 'Create product in stocking point in period base on a set of pisps and periods' 
 | 
  TextBody: 
 | 
  [* 
 | 
    if( this.GetHasValidNrOfPISPIP() ) 
 | 
    { 
 | 
      traverse( pisps, Elements, pisp ) 
 | 
      { 
 | 
        firstplanning := guard( pisp.FirstPlanningPISPIP().Start(), this.StartOfPlanning() );  
 | 
         
 | 
        earlieststart := ifexpr( this.GetIsPeriodUpdateForShelfLifeOptimizer(),  
 | 
                                 pisp.EarliestManufactureDate().DateTime(),  
 | 
                                 DateTime::MaxDateTime() ); // no new periods for opt in this case (see below) 
 | 
         
 | 
        periodsforopt := selectset(  periods,  
 | 
                                     Elements,  
 | 
                                     p, p.Start() >= earlieststart  
 | 
                                     and p.Start() < firstplanning ); // only need extra historical periods 
 | 
         
 | 
        // If isondelete is true, it means the product is going to become leaf when 
 | 
        // it has only 1 child left, so we cannot use GetIsLeaf 
 | 
        isLeaf := ifexpr( not isondelete, pisp.Product_MP().GetIsLeaf(), pisp.Product_MP().Child( relsize ) = 1 ) 
 | 
     
 | 
        if ( not this.GetIsPeriodUpdateForShelfLifeOptimizer() )  
 | 
        { 
 | 
          pisp.CreateProductInStockingPointInPeriod( periods, isLeaf ); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
          Transaction::Transaction().Propagate( attribute( Period_MP, IsPlanning ) ); // need to know what kind of pispip to create 
 | 
          traverse( periodsforopt, Elements, period, period.IsPlanning() ) //only create for planning period 
 | 
          { 
 | 
            ProductInStockingPointInPeriod::Create( pisp, period, isLeaf ); 
 | 
          } 
 | 
        } 
 | 
      } 
 | 
    } 
 | 
  *] 
 | 
} 
 |