Quintiq file version 2.0
#parent: #root
Method EditSalesDemand (
  structured[Forecast] selection,
  internal[GUIComponent] parent
) id:Method_DialogCreateEditSalesDemand_EditSalesDemand
{
  #keys: '[11660.1.183230770]'
  Body:
  [*
    // Edit sales demands
    
    isbatchedit := selection.Size() > 1;
    Dialog.ShowHideComponentForBatchEdit( isbatchedit );
    salesdemand := selection.Element( 0 );
    data := shadow( salesdemand );
    Dialog.Data( data );
    
    result := this.DoModal( parent );
    
    if( result > 0 )
    {
      quantity := ApplicationLibMacroPlanner.FormatStringToReal( EditorQuantity.Text(), 0.0 );
    
      SalesDemandBase::Update( selection,
                               not isbatchedit or CheckBoxBatchEditProduct.Checked(),
                               SelectionProduct.Data(),
                               not isbatchedit or CheckBoxBatchEditStockingPoint.Checked(),
                               SelectionStockingPoint.Data(),
                               not isbatchedit or CheckBoxBatchEditStart.Checked(),
                               data.StartDate(),
                               not isbatchedit or CheckBoxBatchEditEnd.Checked(),
                               data.EndDate(),
                               not isbatchedit or CheckBoxBatchEditQuantity.Checked(),
                               quantity,
                               not isbatchedit or CheckBoxBatchEditPrice.Checked(),
                               data.Price(),
                               not isbatchedit or CheckBoxBatchEditPriority.Checked() or CheckBoxBatchEditIsExcludedFromFulfillmentKPI.Checked(),
                               data.Priority(),
                               not isbatchedit or CheckBoxBatchEditDemandUncertaintyPercentage.Checked(),
                               data.DemandUncertaintyPercentage(),
                               not isbatchedit or CheckBoxBatchEditSalesSegment.Checked(),
                               data.SalesSegment_MP(),
                               not isbatchedit or CheckBoxBatchEditCurrency.Checked(),
                               data.Currency_MP(),
                               not isbatchedit or CheckBoxBatchEditUnitOfMeasure.Checked(),
                               data.UnitOfMeasure_MP(),
                               not isbatchedit or CheckBoxBatchEditIsExcludedFromFulfillmentKPI.Checked(),
                               ifexpr( CheckBoxIsExcludedFromFulfillmentKPI.Enabled(), 
                                       CheckBoxIsExcludedFromFulfillmentKPI.Checked(),
                                       data.IsExcludedFromFulfillmentKPIUser() ),
                               true );
    }
  *]
}
