Kevin Kok Khah Whey
2023-09-25 34d29be6a3eb0c025da50b77f2107c4ad259c6c0
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 SetShadowUnitCostWithDefaultAccountInfo (
  Unit unit_i,
  Account_MP account_i
) id:Method_DialogCreateEditUnitCost_SetShadowUnitCostWithDefaultAccountInfo
{
  #keys: '[145730.0.2099470506]'
  Body:
  [*
    // Create unit cost shadow object & set default values from Account_MP
    createCostForSingleUnit := DataHolderUnits.Data().Size() = 1;
    
    obj := unit_i.UnitCost( relshadow,
                            ID := MacroPlan.IDHolder().GetUnitCostID(),
                            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 )
    {
      DataHolderUnits.Data().Flush();
      DataHolderUnits.Data().Add( unit_i );
    }
  *]
}