Quintiq file version 2.0
#parent: #root
Method Copy (
  FormUnitCosts formUnitCosts,
  UnitCost unitCost
) id:Method_DialogCreateEditUnitCost_Copy
{
  #keys: '[144528.2.67597210]'
  Body:
  [*
    // Copy unit cost (only allow one)
    DataHolderForm.Data( formUnitCosts ); // Form that opens the dialog, to select the newly created object in list
    
    // Unit for the cost we are copying
    unit := unitCost.Unit();
    
    // Create new shadow based on the UnitCost we are copying
    shadowUnitCost := unit.UnitCost( relshadow,
                                     ID := MacroPlan.IDHolder().GetUnitCostID(),
                                     AccountName := unitCost.AccountName(),
                                     Account_MP := unitCost.Account_MP(),
                                     CostDriver := unitCost.CostDriver(),
                                     Cost := unitCost.Cost(),
                                     LengthOfTime := unitCost.LengthOfTime(),
                                     TimeUnit := unitCost.TimeUnit(),
                                     Start := unitCost.Start() );
    
    DataHolderDialogData.Data( &shadowUnitCost );
    
    unitForUnitCost := construct( Units );
    unitForUnitCost.Add( unit );
    DataHolderUnits.Data( &unitForUnitCost );
    
    this.Initialize();
  *]
}
