haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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 );
  *]
}