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
Quintiq file version 2.0
#parent: #root
Method SetShadowOperationCostWithDefaultAccountInfo (
  Operation operation_i,
  Account_MP account_i
) id:Method_DialogCreateEditOperationCost_SetShadowOperationCostWithDefaultAccountInfo
{
  #keys: '[145730.0.2099470506]'
  Body:
  [*
    // Create unit cost shadow object & set default values from Account_MP
    createCostForSingleUnit := DataHolderOperations.Data().Size() = 1;
    
    obj := operation_i.OperationCost( relshadow,
                                      ID := MacroPlan.IDHolder().GetOperationCostID(),
                                      AccountName := account_i.Name(),
                                      Account_MP := account_i,
                                      CostDriver := account_i.DefaultCostDriver(),
                                      Cost := account_i.DefaultCost(),
                                      LengthOfTime := account_i.DefaultLengthOfTime(),
                                      TimeUnit := account_i.DefaultTimeUnit(),
                                      Start := MacroPlan.StartOfPlanning().Date() );
                            
    DataHolderDialogData.Data( & obj );
    
    // Only if single unit cost creation, we want to replace the unit in dataholder (e.g on change unit in dropdown)
    if( createCostForSingleUnit )
    {
      DataHolderOperations.Data().Flush();
      DataHolderOperations.Data().Add( operation_i );
    }
  *]
}