Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method VerifyDependentDemand ( 
 | 
  MacroPlan macroplan, 
 | 
  PeriodTask_MP periodTask, 
 | 
  ProductInStockingPoint_MP ingredientPisp 
 | 
) 
 | 
{ 
 | 
  Description: 'Verify period task has expected dependent demand and whether the dependent demand is adhered to recipe configuration minimum and maximum bound.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Verify period task has correct ratio for each input ingredient. 
 | 
    epsilon := 0.00025; 
 | 
     
 | 
    if( this.Run().AssertNotIsNull( periodTask ) ) 
 | 
    { 
 | 
      /* Note: min & max bound for metal demo 
 | 
      Verification method for the min ratio of input ingredient  
 | 
      Si = [ input quantity of Si in La Quinta  
 | 
              + Input quantity of Scrap 3xxx in La Quinta * Minimum ratio of Si in recipe 3xxx  
 | 
              + Input quantity of Scrap 5xxx in La Quinta * Minimum ratio of Si in recipe 5xxx  
 | 
              + Input quantity of Prime in La Quinta * Minimum ratio of Si in recipe Prime ] /Total input quantity 
 | 
       
 | 
       Verification method for the max ratio of input ingredient  
 | 
      Si = [ input quantity of Si in La Quinta  
 | 
              + Input quantity of Scrap 3xxx in La Quinta * Maximum ratio of Si in recipe 3xxx  
 | 
              + Input quantity of Scrap 5xxx in La Quinta * Maximum ratio of Si in recipe 5xxx  
 | 
              + Input quantity of Prime in La Quinta * Maximum ratio of Si in recipe Prime ] /Total input quantity 
 | 
      */ 
 | 
      // Get total supply of periodtask 
 | 
      totalInputQty := sum( periodTask, NewSupply, d, true, d.Quantity() ); 
 | 
       
 | 
      // Get recipe-ingredient ratio for input ingredient 
 | 
      recipe3xxx := macroplan.FindRecipe( '3XXX' ).FindRecipeIngredient( '3XXX', ingredientPisp.ProductID() ); 
 | 
      recipe5xxx := macroplan.FindRecipe( '5XXX' ).FindRecipeIngredient( '5XXX', ingredientPisp.ProductID() ); 
 | 
      recipePrime := macroplan.FindRecipe( 'Prime' ).FindRecipeIngredient( 'Prime', ingredientPisp.ProductID() ); 
 | 
       
 | 
      scrap3xxxInPT:= this.GetDependentDemand( periodTask, macroplan.GetProduct( 'Scrap 3XXX' ) ); 
 | 
      scrap5xxxInPT := this.GetDependentDemand( periodTask, macroplan.GetProduct( 'Scrap 5XXX' ) ); 
 | 
      primeInPT := this.GetDependentDemand( periodTask, macroplan.GetProduct( 'Prime' ) ); 
 | 
       
 | 
      // Verify the actual ratio is between expected min & expected max 
 | 
      dd := this.GetDependentDemand( periodTask, ingredientPisp ); 
 | 
      actualRatio := guard( dd.Quantity() / totalInputQty, 0.0 ); 
 | 
       
 | 
      scrap3xxx :=  guard( scrap3xxxInPT.Quantity()* recipe3xxx.Minimum(), 0.0 ); 
 | 
      scrap5xxx := guard( scrap5xxxInPT.Quantity() * recipe5xxx.Minimum(), 0.0 ); 
 | 
      prime :=  guard( primeInPT.Quantity() * recipePrime.Minimum(), 0.0 ); 
 | 
       
 | 
      expectedMin := ( dd.Quantity() + scrap3xxx + scrap5xxx + prime ) / totalInputQty; 
 | 
       
 | 
      scrap3xxx :=  guard( scrap3xxxInPT.Quantity() * recipe3xxx.Maximum(), 0.0 ); 
 | 
      scrap5xxx :=  guard( scrap5xxxInPT.Quantity() * recipe5xxx.Maximum(), 0.0 ); 
 | 
      prime :=  guard( primeInPT.Quantity() * recipePrime.Maximum(), 0.0 ); 
 | 
       
 | 
      expectedMax := ( dd.Quantity() + scrap3xxx + scrap5xxx + prime ) / totalInputQty; 
 | 
       
 | 
      this.Run().AssertGreaterOrEqual( expectedMin, actualRatio, epsilon, 'Verify minimum ratio for ' + ingredientPisp.Name() ) 
 | 
      this.Run().AssertLessOrEqual( expectedMax, actualRatio, epsilon, 'Verify maximum ratio for ' + ingredientPisp.Name() ); 
 | 
    } 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |