lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
Quintiq file version 2.0
#parent: #root
Method InitializeNonEntitiesDataAfterImport (
  Boolean importsalesdemands,
  Boolean importcustomerorder,
  Boolean importproducts,
  Boolean importentities,
  Boolean importroutings,
  Boolean importperiods
)
{
  Description: 'Create data after import from external'
  TextBody:
  [*
    // cye1 Apr-26-2016 (created)
    // Create product in stockingpoint
    this.InitializeProductInStockingPoint();
    
    haschangesonrouting := importroutings or importproducts or importentities;
    
    if( haschangesonrouting )
    {
      // Rouitng needs to be snchornized when user import unit/product/stockingpoint/routing
      // So instead of acalling them in seperate method and cause a multi synchronize call, we will just call it once here
      // Synchronize operation links within a routing
      // Propagate the relation Operation to Routing Step and the Systems relations
      Transaction::Transaction().Propagate();
      traverse( this, Routing, r )
      {
        r.SynchronizeAfterImport();
      }
    }
    
    // Relation is empty after execute import broker, need to propagate
    Transaction::Transaction().Propagate( relation( MacroPlan, SalesDemand ) );
    if ( importcustomerorder )
    {
      traverse( this, SalesDemand.astype( CustomerOrder ), co )
      {
        // Customer order don't had an end date, set it to start date
        co.EndDate( co.StartDate() );
      }
    }
    
    this.CreateProductInStockingPointInPeriod( true /*iscreateall*/ );
    
    if( importsalesdemands or importperiods or importcustomerorder )
    {
      this.InitializeSalesDemandsAfterImport();
    }
  *]
}