hongji.li
2023-11-03 aefafd2142478d4fb07d6b8b45c3047e247389e0
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
Quintiq file version 2.0
#parent: #root
Method UpdateCommitLogic (
  Boolean isnew
)
{
  Description: 'Logic used in onCommit of Unit.'
  TextBody:
  [*
    // Commit logic
    isvisible           := true;
    textcolor           := 'Black';
    namedisplaybehavior := '';
    
    // Update unit
    this.Update( this.ID(), this.Name(), this.Parent(),
                 this.CapacityType(),
                 this.Group(), this.UnitOfMeasure_MP(), this.Currency_MP(),
                 this.StartDate(), this.EndDate(), this.CampaignTypeDuration(),
                 this.IsPlannedInfinite(),
                 this.MinimumQuantity(), this.HasMaximumQuantity(), this.MaximumQuantity(), this.LotSize(),
                 this.IconName(),
                 this.QuantityToProcess(),
                 this.GISCountryCode(), this.GISCity(), this.GISPostalCode(),
                 this.Notes(),
                 this.HasCapacitySmoothing(),
                 this.IsSmoothCapacityOverAllPeriods(),
                 this.UserCapacitySmoothingLength(),
                 this.CapacitySmoothingPercentageDelta(),
                 this.IsOverlapCapacitySmoothing(),
                 this.IsIncludedInSupplySpecification(),
                 this.IsSupplier(),
                 this.HasUserFrozenFutureDuration(), this.UserFrozenFutureDuration(),
                 this.UseShiftOptimization(),
                 false /*isfromdb*/ );
                 
    // Create stocking point after update             
    if( isnew )
    {
      // SynchronizeAfterCreation should have created a default unit node, update it
      view := select( this.MacroPlan(), ViewBase.astype( SupplyChainView ), scv, scv.User() = QuintiqUser::CurrentUser().ShortName() );
    
     // Reuse the logic from OnCreate
      this.SynchronizeAfterCreation();
    
      // Create default stocking points
      this.CreateDefaultStockingPoint( view );
    
      // Unit node is created in SynchronizeAfterCreation, update unit node
      unitnode := select( this, UnitNode, n, n.SupplyChainView() = view );
      if( not isnull( unitnode ) )
      {
        unitnode.Update( this.DefaultGridX(), this.DefaultGridY(), isvisible, namedisplaybehavior, textcolor, '' );
      }
    }
    
    // ---------------------- Quick fix ------------------------
    // Please remove after the proper fix #16515
    // The method in designer should be updated, setting relations/attribute will only done in one place.
    // create new unit period
    if( this.SynchronizeUnitPeriod() )
    {
      this.DeleteOldPeriodCapacity();
      this.CreateUnitPeriods();
      this.UnitAvailability( relflush );
      this.UnitCapacity( relflush );
      this.TransportAvailability( relflush );
      this.TransportCapacity( relflush );
    }
    // ----------------------------------------------------------
    
    this.SetAllParent();
  *]
}