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 );
    }
  *]
}
