admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
54
55
56
57
58
59
Quintiq file version 2.0
#parent: #root
Method Update (
  Product_MP owner,
  StockingPoint_MP stockingpoint,
  Date start,
  Boolean hastargetindays,
  Real targetindays,
  Real targetinquantity,
  Boolean iscalculated,
  Boolean hasUserTarget,
  Boolean isfromdb
)
{
  Description: 'Update safety stock'
  TextBody:
  [*
    // Update type index of safetystock
    this.UpdateTypeIndex( owner.ID(), stockingpoint.ID(), start );
    needsync := this.Product_MP() <> owner or this.StockingPoint_MP() <> stockingpoint;
    
    // Check if there are any changes to product/stocking point
    if( needsync )
    {
      owner.SafetyStock( relmove, this );
      // create pisp when there is changes to product / stocking point
      owner.AddToStockingPoint( stockingpoint );
    }
    this.HasTargetInDays( hastargetindays )
    
    // If TargetInQuantity is not changed on the dialog then IsCalculated value should not be updated.
    // iscalculated parameter is always send as false from the dialog and always send as true from the generate safety stock method. 
    if( not ( ( this.TargetInQuantity() = targetinquantity ) and not iscalculated ) )
    {
      this.IsCalculated( iscalculated );
    }
    
    if ( iscalculated and not hasUserTarget )
    {
      this.OptimizerTargetInQuantity( targetinquantity );  
    }
    if ( hasUserTarget )
    {
      if( hastargetindays )
      {
        this.UserTargetInQuantity( 0 );
        this.UserTargetInDays( targetindays );
      }
      else
      {
        this.UserTargetInQuantity( targetinquantity );
        this.UserTargetInDays( 0 );
      }
    }
    
    this.HasUserTarget( hasUserTarget );
    this.IsManuallyConfigured( not isfromdb );
  *]
}