chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Quintiq file version 2.0
#parent: #root
StaticMethod Create (
  String id,
  MacroPlan owner,
  String name,
  Unit parent,
  String capacitytype,
  Group group,
  UnitOfMeasure_MP unitofmeasure,
  Currency_MP currency,
  SupplyChainView view,
  Boolean isvisible,
  Number gridx,
  Number gridy,
  Date startdate,
  Date enddate,
  Duration campaigntypeduration,
  Boolean isplannedinfinite,
  Real minimumquantity,
  Boolean hasmaximumquantity,
  Real maximumquantity,
  Real lotsize,
  String usericonname,
  String textcolor,
  String namedisplaybehavior,
  String createstockingpointtype,
  String quantitytoprocess,
  String giscountrycode,
  String giscity,
  String gispostalcode,
  String notes,
  Boolean hascapacitysmoothing,
  Boolean issmoothcapacityoverallperiods,
  Number usercapacitysmoothinglength,
  Real capacitysmoothingpercentagedelta,
  Boolean isoverlapcapacitysmoothing,
  Boolean isincludedinsupplyspec,
  Boolean issupplier,
  Boolean hasuserfrozenfutureduration,
  Duration userfrozenfutureduration,
  Boolean useshiftoptimization,
  Boolean isfromdb
) as Unit
{
  Description: 'Create a unit base on its type'
  TextBody:
  [*
    // Create a unit
    unit := owner.Unit( relnew, ID := id );
    
    // Update the attributes of the newly created unit
    unit.Update( id, name, parent,
                 capacitytype,
                 group, unitofmeasure, currency,
                 startdate, enddate, campaigntypeduration,
                 isplannedinfinite,
                 minimumquantity, hasmaximumquantity, maximumquantity, lotsize,
                 usericonname,
                 quantitytoprocess,
                 giscountrycode, giscity, gispostalcode,
                 notes,
                 hascapacitysmoothing,
                 issmoothcapacityoverallperiods,
                 usercapacitysmoothinglength,
                 capacitysmoothingpercentagedelta,
                 isoverlapcapacitysmoothing,
                 isincludedinsupplyspec,
                 issupplier,
                 hasuserfrozenfutureduration,
                 userfrozenfutureduration,
                 useshiftoptimization,
                 isfromdb );
    
    // SynchronizeAfterCreation should have created a default unit node, update it
    unitnode := select( unit, UnitNode, n, n.SupplyChainView() = view )
    if( not isnull( unitnode ) )
    {
      unitnode.Update( gridx, gridy, isvisible, namedisplaybehavior, textcolor, '' );
    }
    
    // Creating default stocking points depending on what's the createstockingpointtype is
    if( createstockingpointtype = Translations::MP_Designer_DialogCreateUnitWizard_DefaultStockingPoint_Combined() )
    {
      unit.CreateDefaultInputOutputStockingPoint( view, gridx + 3, gridy, unit.Name(), false, true, isfromdb );
    }
    
    if( createstockingpointtype = Translations::MP_Designer_DialogCreateUnitWizard_DefaultStockingPoint_Input()
        or createstockingpointtype = Translations::MP_Designer_DialogCreateUnitWizard_DefaultStockingPoint_Separate() )
    {
      unit.CreateDefaultInputOutputStockingPoint( view, gridx - 3, gridy, 'Input SP for ' + unit.Name(), true, false, isfromdb );
    }
    
    if( createstockingpointtype = Translations::MP_Designer_DialogCreateUnitWizard_DefaultStockingPoint_Output()
        or createstockingpointtype = Translations::MP_Designer_DialogCreateUnitWizard_DefaultStockingPoint_Separate() )
    {
      unit.CreateDefaultInputOutputStockingPoint( view, gridx + 3, gridy, 'Output SP for ' + unit.Name(), false, false, isfromdb );
    }
    
    // Set all parents
    unit.SetAllParent();
    
    return unit;
  *]
}