Quintiq file version 2.0
#parent: #root
Method OnOK () id:Method_DialogCreateEditFulfillmentTarget_OnOK
{
  #keys: '[139394.0.1862531610]'
  Body:
  [*
    // On ok
    this.ApplyChanges();
    
    data := DataHolderDialogData.Data();
    
    // New
    if( isnull( data.WrappedInstance() ) )
    {
      FulfillmentTarget::Create( MacroPlan,
                                 '', // id, auto generated by system
                                 data.IsEnabled(),
                                 data.Name(),
                                 data.Product_MP(),
                                 data.StockingPoint_MP(),
                                 data.SalesSegment_MP(),
                                 data.TargetPercentage(),
                                 data.Start(),
                                 data.End(),
                                 false, /*isusedforsafetystockcalc*/
                                 true,  /*isusedforplanningfulfillment*/
                                 false  /*isfromdb*/ );
    }
    else
    {
      data.WrappedInstance().Update( data.IsEnabled(),
                                     data.Name(),
                                     data.Product_MP(),
                                     data.StockingPoint_MP(),
                                     data.SalesSegment_MP(),
                                     data.TargetPercentage(),
                                     DateSelectorStart.Date(), // data wont be applied on disabled component
                                     DateSelectorEnd.Date(),
                                     data.IsUsedForSafetyStockCalculation(),
                                     data.IsUsedForPlanningFulfillment(),
                                     false /*isfromdb*/ );
    }
    
    this.Close();
  *]
}
