Quintiq file version 2.0
#parent: #root
Method New (
  internal[GUIComponent] parent
) as FulfillmentTarget id:Method_DialogCreateEditFulfillmentTarget_New
{
  #keys: '[127238.0.1975981168]'
  Body:
  [*
    // Create new service level
    
    salessegment := guard( DataHolderSalesSegments.Data().Element( 0 ),
                           select( MacroPlan, SalesSegment_MP, e, true ) );
    
    product := guard( DataHolderProducts.Data().Element( 0 ),
                      select( MacroPlan, Product_MP, e, true ) );
    
    stockingpoint := guard( DataHolderStockingPoints.Data().Element( 0 ),
                            select( MacroPlan, StockingPoint_MP, e, true ) );
    
    data := MacroPlan.FulfillmentTarget( relshadow,
                                         ID := MacroPlan.IDHolder().GetServiceLevelID(),
                                         SalesSegment_MP := salessegment,
                                         Product_MP := product,
                                         StockingPoint_MP := stockingpoint,
                                         Start := MacroPlan.Start().Date(),
                                        End := MacroPlan.End().Date() );
    
    Dialog.Data( data );
    
    this.EnableDisableComponents();
    
    result := this.DoModal( parent );
    
    fulfillmentTarget := null( FulfillmentTarget )
    
    if( result > 0 )
    {
      fulfillmentTarget := 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,
                                                      true,
                                                      false );
    
    }
    
    return fulfillmentTarget;
  *]
}
