Quintiq file version 2.0
#parent: #root
Method NewConversionFactor (
  internal[GUIComponent] parent,
  UnitOfMeasure_MP sourceunitofmeasure,
  UnitOfMeasure_MP targetunitofmeasure,
  Boolean isproductdependent
) as ConversionFactor id:Method_DialogCreateEditConversionFactor_NewConversionFactor
{
  #keys: '[113694.1.905854087]'
  Body:
  [*
    // Create new conversion factor
    data := sourceunitofmeasure.BaseConversionFactor( relshadow,
                                                      SourceUnitOfMeasureName := guard( sourceunitofmeasure.Name(), '' ),
                                                      TargetUnitOfMeasureName := guard( targetunitofmeasure.Name(), '' ),
                                                      ProductID := '',
                                                      SourceUnitOfMeasure := sourceunitofmeasure,
                                                      TargetUnitOfMeasure := targetunitofmeasure );
    
                                                   
    Dialog.Data( data );
    
    Dialog.SetDefaultValues( isproductdependent );
    
    result := Dialog.DoModal( parent );
    newobj := null( ConversionFactor );
    
    if( result > 0 )
    {
      newobj := BaseConversionFactor::CreateUpdate( SelectionSourceUnitOfMeasure.Data(),
                                                    SelectionTargetUnitOfMeasure.Data(),
                                                    data.Factor(),
                                                    data.Product_MP(),
                                                    true  );
    }
    
    return newobj;
  *]
}
