yanyuan
2023-08-30 eb958a9c253061d89ea524fe124b326369678557
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Quintiq file version 2.0
#parent: #root
StaticMethod CreateOrUpdate (
  MacroPlan macroPlan,
  String sourceUnitOfMeasureName,
  String targetUnitOfMeasureName,
  Boolean isEnable,
  String productId,
  Real factor
) as ConversionFactor
{
  TextBody:
  [*
    // yypsybs Aug-14-2023 (created)
    
    source := UnitOfMeasure_MP::FindByName( macroPlan, sourceUnitOfMeasureName );
    target := UnitOfMeasure_MP::FindByName( macroPlan, targetUnitOfMeasureName );
    product := null( Product_MP );
    result := null(ConversionFactor );
    
    if( isnull( source ) or isnull( target ) ) {
        error( "can't find source or target unit of measure" )
    }
    info( source)
    if( productId <> "" ) {
        product := Product_MP::FindById( macroPlan, productId );
        info( productId)
    //    if( isnull( product ) ) {
    //      info( "invalid product id" )  
    //    }
    }
    info( product.ID()+"****")
    if( isnull( product ) ) {
          info( "invalid product id" )  
        }else{
          result := BaseConversionFactor::CreateUpdate( source, target, factor, product, isEnable );
        }
    
    return result;
  *]
}