yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
StaticMethod UpdateIsIncluded (
  MacroPlan macroplan,
  Strings conversionfactorsinstrings,
  Boolean isenabled
)
{
  Description: 'Update the flag is included, create the base conversion factor instance(s) first if the instance(s) are not created yet.'
  TextBody:
  [*
    // Adhi Aug-02-2016
    // Cannot pass in shadow instances to editor, so we needed a different approach.
    // Each element in the strings is actually a conversion factor instance
    // Need to tokenize the strings to get the information, and create/update conversion factors
    // Refer to FormUnitsOfMeasurement.EnableDisableConversionFactors
    
    traverse( conversionfactorsinstrings, Elements, cf )
    {
      cfelement := cf.Tokenize( ';' );
      if( cfelement.Size() = 3 )
      {
        sourceuom := select( macroplan, UnitOfMeasure_MP, uom, uom.Name() = cfelement.Element( 0 ) );
        targetuom := select( macroplan, UnitOfMeasure_MP, uom, uom.Name() = cfelement.Element( 1 ) );
        factor := [Real] cfelement.Element( 2 );
      
        BaseConversionFactor::CreateUpdate( sourceuom,
                                            targetuom ,
                                            factor,
                                            null( Product_MP ),
                                            isenabled );  
      }
    }
  *]
}