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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Quintiq file version 2.0
#parent: #root
Method Update (
  Real quantity,
  Boolean hasuser,
  LibOpt_Scope scope
)
{
  Description: 'Update period task quantity and set all corresponding dd to manual'
  TextBody:
  [*
    // This method is used for user actions on UI, not intended to be used by optimizer to update the value
    
    this.HasUserQuantity( hasuser );
    
    if( hasuser )
    {
      this.UserQuantity( quantity );
      
      traverse( this, DependentDemand, dd ) 
      {                            
        qty := 0.0;
    
        //dd has been set by user, update dd qty base on the pt changes ratio
        //e.g. old pt qty 20 -> 200, factor = 10.
        //we increase dd qty by factor of 10
        if( dd.HasUserQuantity() )
        {
          factor := guard( quantity / this.Quantity(), 1.0 );
          qty := factor * dd.Quantity();      
        }
        //if dd has been set by optimizer derive the qty based on period quantity to be planned on period task.
        //similar to DD.CalcQuantity when there is no manaul plan
        else
        {    
          qty := PeriodTaskOperation::GetDependentDemandQuantity( quantity, dd.ProcessInput(), dd.RelativeDuration() );
        }
        dd.HasUserQuantity( true );
        dd.UserQuantity( qty );
      }
    }
    else
    {
      this.OptimizerQuantity( quantity );
    }
    
    this.ResetDependentDemandInputGroupOptimizerFulfillment( scope );
    
    
    this.SetTimeStamp();
  *]
  InterfaceProperties { Accessibility: 'Module' }
}