Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Function CalcMaxQuantityFactor 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    // The factor is defined as the input max quantity in PISP uom divided by the output quantity in PISP uom. 
 | 
    targetuom := this.PISPUnitOfMeasurement(); 
 | 
    uomconversion := this.Operation().GetUOMConversionFactor( targetuom ); 
 | 
     
 | 
    // Not using QuantityToProcess as the attribute is affected if we exclude some output from unit utilization 
 | 
    outputbased := this.Operation().Unit().IsQuantityToProcessAsOut(); 
 | 
    outputqtyinspuom := uomconversion * ifexpr( outputbased, this.Operation().OutputQuantity(), this.Operation().InputQuantity() ); 
 | 
     
 | 
    // The default MaxQuantityFactor is 1 
 | 
    value := 1.0; 
 | 
    // If the output quantity is not zero, then the factor is equal to the ratio of the max quantity and the output quantity 
 | 
    if( outputqtyinspuom <> 0.0 ) 
 | 
    { 
 | 
      value := this.MaxQuantity() / outputqtyinspuom ; 
 | 
    } 
 | 
     
 | 
    this.MaxQuantityFactor( value ); 
 | 
  *] 
 | 
} 
 |