Quintiq file version 2.0
#parent: #root
Method NewUnitCapacity (
  internal[GUIComponent] parent
) as UnitCapacity id:Method_DialogCreateEditUnitCapacity_NewUnitCapacity
{
  #keys: '[107528.0.125617835]'
  Body:
  [*
    // New unit capacity
    
    Dialog.ShowHideComponentForBatchEdit( false, true, false );
    
    unit := select( MacroPlan, Unit, unit, unit.HasCapacityTypeQuantity() );
    
    data := unit.UnitCapacity( relshadow, UnitID := unit.ID(), Start := MacroPlan.StartOfPlanning() );
    
    Dialog.Data( data );
    Dialog.SetDefaultValue( null( UnitPeriodQuantity ) );
    
    result := Dialog.DoModal( parent );
    newobj := null( UnitCapacity );
    
    if( result > 0 )
    {
      newobj := UnitCapacity::Create( data.Unit(),
                                      data.Start(),
                                      data.TimeUnit(),
                                      data.MinCapacity(),
                                      data.MaxCapacity(),
                                      data.MaximumLoadPercentage(),
                                      data.NrOfUnitsOpen(),
                                      false );
    }
    
    return newobj;
  *]
}
