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
Quintiq file version 2.0
#parent: #root
Method UpdateTypeIndex (
  String name
)
{
  Description: 'Update UOM TypeIndex and the linked instances'
  TextBody:
  [*
    // Update UOM TypeIndex and the linked instances if the new Name is not the same as the old Name
    if( this.Name() <> name )
    {
      // Update foreign key of all linked Units
      traverse( this, Unit, unit )
      {
        unit.UpdateForeignKey( unit.CurrencyID(),
                               unit.GroupName(),
                               unit.ParentUnitID(),
                               name );
      }
    
      // Update foreign key of all linked Product_MPs
      traverse( this, Product_MP, product )
      {
        product.UpdateForeignKey( product.ParentID(),
                                  name );
      }         
      
      // Update foreign key of all linked StockingPoint_MPs
      traverse( this, StockingPoint_MP, sp )
      {
        sp.UpdateForeignKey( name,
                             sp.CurrencyID(),
                             sp.GroupName(),
                             sp.UnitID() );
      }
      
      // Update foreign key of all linked PISPSpecifications
      traverse( this, PISPSpecification, spec )
      {
        spec.UpdateForeignKey( name );
      }
      
      // Update type index of all linked SourceUnitOfMeasures
      traverse( this, AsSourceUnitOfMeasure.astype( BaseConversionFactor ), bc )
      {
        bc.UpdateTypeIndex( name, bc.TargetUnitOfMeasureName(), bc.ProductID() );
      }
    
      // Update type index of all linked TargetUnitOfMeasures
      traverse( this, AsTargetUnitOfMeasure.astype( BaseConversionFactor ), bc )
      {
        bc.UpdateTypeIndex( bc.SourceUnitOfMeasureName(), name, bc.ProductID() );
      }
    
      // Update foreign key of all linked SalesDemands
      traverse( this, SalesDemand, sd )
      {
        sd.UpdateForeignKey( sd.ProductID(),
                             sd.StockingPointID(),
                             sd.SalesSegmentName(),
                             sd.PriorityName(),
                             sd.CurrencyID(),
                             name );
      }
      
      // Update type index of this UnitOfMeasure
      this.IsManuallyConfigured( true );
      UnitOfMeasure_MP::ChangeKeyUnitOfMeasureTypeIndex( this, name );
    }
  *]
}