admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
Method Update (
  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 unit'
  TextBody:
  [*
    // Update Unit
    oldcapacitytype := this.CapacityType();
    hasnewparent := this.ParentUnitID() <> guard( parent.ID(), '' );
    isroot := isnull( parent );
    
    this.UpdateTypeIndex( id );
    
    this.UnitOfMeasureName( unitofmeasure.Name() );
    this.CurrencyID( currency.ID() );
    this.Name( name );
    this.CapacityType( capacitytype );
    this.StartDate( startdate );
    this.EndDate( enddate );
    this.CampaignTypeDuration( campaigntypeduration );
    this.AddToGroup( group );
    
    this.IsPlannedInfinite( isplannedinfinite );
    this.MinimumQuantity( minimumquantity );
    this.HasMaximumQuantity( hasmaximumquantity );
    this.MaximumQuantity( maximumquantity );
    this.LotSize( lotsize );
    this.QuantityToProcess( quantitytoprocess );
    this.GISCountryCode( giscountrycode );
    this.GISCity( giscity )
    this.GISPostalCode( gispostalcode );
    this.Notes( notes );
    this.HasCapacitySmoothing( hascapacitysmoothing );
    this.IsSmoothCapacityOverAllPeriods( issmoothcapacityoverallperiods );
    this.UserCapacitySmoothingLength( usercapacitysmoothinglength );
    this.CapacitySmoothingPercentageDelta( capacitysmoothingpercentagedelta );
    this.IsOverlapCapacitySmoothing( isoverlapcapacitysmoothing );
    this.IsIncludedInSupplySpecification( isincludedinsupplyspec );
    this.IsSupplier( issupplier );
    
    this.HasUserFrozenFutureDuration( hasuserfrozenfutureduration );
    this.UserFrozenFutureDuration( userfrozenfutureduration );
    
    this.UseShiftOptimization( useshiftoptimization );
    
    this.IsManuallyConfigured( not isfromdb );
    
    this.UpdateIcon( usericonname );
    
    //Update the parent relations
    if( hasnewparent )
    {
      this.AssignParent( parent );
    }
    else if( isroot )
    {
      this.SetRootUnit();
    }
    
    // create new unit period
    if( oldcapacitytype <> capacitytype )
    {
      this.DeleteOldPeriodCapacity();
      this.CreateUnitPeriods();
      this.UnitAvailability( relflush );
      this.UnitCapacity( relflush );
      this.TransportAvailability( relflush );
      this.TransportCapacity( relflush );
      
      // Update unitshiftpatterns if the capacity changes
      timecapacity := GlobalParameters_MP::GetCapacityTypeTime();
      if( oldcapacitytype = timecapacity )
      {
        this.UnitShiftPattern( relflush );
      }
      if( capacitytype = timecapacity )
      {
        this.CreateUnitShiftPatterns();
      }
    }
  *]
}