Quintiq file version 2.0 
 | 
#parent: #root 
 | 
FunctionOverride CalcQuantity 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    // edz1 Aug-31-2016 (created) 
 | 
     
 | 
    value := this.InventorySpecification().QuantityToMove(); 
 | 
     
 | 
     
 | 
    // If we are below target, the quantity will be positive, if we are below target the quantity will be negative 
 | 
    // If this is a decrease move, then we need to flip the sign since we want to make a move if we are above target 
 | 
    if( not this.IsIncrease() ) 
 | 
    { 
 | 
      value := -value; 
 | 
    } 
 | 
     
 | 
    // To make sure that an increase move actually increases the target inventory and a decrease move actually decreases it, we must make sure that the quantity is not negative 
 | 
    // If it is non positve, we take 10% of the current target inventory instead 
 | 
    targetinquantity := this.InventorySpecification().TargetInQuantity_DELETED_Nov19(); 
 | 
    if( value <= 0 ) 
 | 
    { 
 | 
      value := 0.1 * targetinquantity; 
 | 
    } 
 | 
     
 | 
    if( not this.IsIncrease() ) 
 | 
    { 
 | 
      // If we are very close to 100% fulfillment, the number of stockingpoints with a shortage becomes very small and the proposed decrease may even exceed 100% 
 | 
      // Therefore, we take the minimum between the suggested value and 25% of the current value 
 | 
      value := minvalue( value, 0.25 * targetinquantity ); 
 | 
    } 
 | 
     
 | 
    this.Quantity( value ); 
 | 
  *] 
 | 
} 
 |