陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
26
27
28
29
30
31
32
33
34
35
36
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 );
  *]
}