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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Quintiq file version 2.0
#parent: #root
StaticMethod Update (
  Units units_i,
  Boolean isBatchEditValidity,
  Boolean isBatchEditGIS,
  Boolean isBatchEditMisc,
  Boolean isBatchEditNote,
  Boolean isBatchEditUseShiftOptimization,
  String id,
  String name,
  Unit parent,
  String capacitytype,
  Group group,
  UnitOfMeasure_MP unitofmeasure,
  Currency_MP currency,
  Date startdate,
  Date enddate,
  Duration campaigntypeduration,
  Boolean isplannedinfinite,
  Real minimumquantity,
  Boolean hasmaximumquantity,
  Real maximumquantity,
  Real lotsize,
  String usericonname,
  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
)
{
  Description: 'update methods for web client, with support of batch editing'
  TextBody:
  [*
    // gdn1 Aug-17-2018 (created)
    traverse( units_i, Elements, unit )
    {
      // Exception on batch edit 
      if( units_i.Size() > 1 )
      {
        // attributes that has no change on batch editing
        id          := unit.ID();
        name        := unit.Name();
        parent      := unit.Parent();
        capacitytype:= unit.CapacityType();
        group       := unit.Group();
        unitofmeasure:= unit.UnitOfMeasure_MP();
        currency    := unit.Currency_MP();
        isplannedinfinite := unit.IsPlannedInfinite();
        minimumquantity   := unit.MinimumQuantity();
        hasmaximumquantity:= unit.HasMaximumQuantity();
        maximumquantity   := unit.MaximumQuantity();
        lotsize           := unit.LotSize();
        usericonname      := unit.IconName();
        quantitytoprocess := unit.QuantityToProcess();
        
        hascapacitysmoothing            := unit.HasCapacitySmoothing();
        issmoothcapacityoverallperiods  := unit.IsSmoothCapacityOverAllPeriods();
        usercapacitysmoothinglength     := unit.UserCapacitySmoothingLength();
        capacitysmoothingpercentagedelta:= unit.CapacitySmoothingPercentageDelta();
        isoverlapcapacitysmoothing      := unit.IsOverlapCapacitySmoothing();
        
        //if no batch edit, set it with original unit's value
        if( not isBatchEditValidity )
        {
          startdate := unit.StartDate();
          enddate   := unit.EndDate();
        }
    
        if( not isBatchEditGIS )
        {
          giscity         := unit.GISCity();
          giscountrycode  := unit.GISCountryCode();
          gispostalcode   := unit.GISPostalCode();
        }                                                   
    
        if( not isBatchEditMisc )
        {
          campaigntypeduration        := unit.CampaignTypeDuration();
          hasuserfrozenfutureduration := unit.HasUserFrozenFutureDuration();
          userfrozenfutureduration    := unit.UserFrozenFutureDuration();
          isincludedinsupplyspec      := unit.IsIncludedInSupplySpecification();
          issupplier                  := unit.IsSupplier();
        }
        
        if( not isBatchEditNote )
        {
          notes := unit.Notes();
        }
        
        if( not isBatchEditUseShiftOptimization )
        {
          useshiftoptimization := unit.UseShiftOptimization();
        }
      }
      
      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 
                 );
    }
  *]
}