haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
42
43
44
45
46
47
48
49
50
51
52
Quintiq file version 2.0
#parent: #root
StaticMethod CreateOrUpdate (
  MacroPlan owner,
  String id,
  String name,
  String parentunitid,
  String capacitytype,
  String unitofmeasurename
) as Unit
{
  TextBody:
  [*
    // Administrator Sep-5-2023 (created)
    //Set the Default values
    currencyid := "CNY";
    startdate := Date::Date( 1900, 1, 1 );
    enddate := Date::Date( 9999, 12, 31 );
    
    // Get the unit
    unit := Unit::FindById( owner, id );
    
    if( id="天马集团" and isnull( unit ) ){
      unit := owner.Unit( relnew, 
                 ID := id, 
                 Name := name, 
                 UnitOfMeasureName := unitofmeasurename, 
                 CurrencyID := currencyid, 
                 StartDate := startdate, 
                 EndDate := enddate, 
                 CapacityType := capacitytype );
      }else{
      if( isnull( unit ) ){
        unit := owner.Unit( relnew, ID := id, 
                   Name := name, 
                   ParentUnitID := parentunitid, 
                   CapacityType := capacitytype, 
                   UnitOfMeasureName := unitofmeasurename,
                   CurrencyID := currencyid, 
                   StartDate := startdate, 
                   EndDate := enddate );
        }else{
          unit.Name( name );
          unit.ParentUnitID( parentunitid );
          unit.CapacityType( capacitytype );
          unit.UnitOfMeasureName( unitofmeasurename );
          }
        }
    
    return unit;
  *]
}