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 ); 
 | 
  *] 
 | 
} 
 |