static void DIPSimularDepreciacionActivo()
{
TmpDateSum tmpDateSum;
AssetTable assetTable;
AssetBook assetBook;
AssetLedgerAccounts assetLedgerAccounts;
MainAccountNum mainAccountNum;
DIPSimulacionDepreciacion simulacion;
delete_from simulacion;
while select assetTable join assetBook where
assetTable.AssetId == assetBook.AssetId
&& assetBook.Depreciation == NoYes::Yes
&& assetBook.Status == AssetStatus::Open
&& assetTable.AssetId == "218-000063"
{
simulacion.clear();
assetLedgerAccounts = AssetLedgerAccounts::find(assetBook.BookId,AssetParameters::find().PostingProfile,enum2int(AssetTransType::Depreciation),TableGroupAll::GroupId,assetTable.AssetGroup);
mainAccountNum = MainAccount::find(DimensionAttributeValueCombination::find(assetLedgerAccounts.OffsetLedgerDimension).MainAccount).MainAccountId;
//Metodo de calculo utilizado por AX
tmpDateSum.setTmpData(assetBook.initDepreciationProfile());
//Datos comunes de linea
simulacion.AssetGroupId = assetTable.AssetGroup;
simulacion.AssetId = assetTable.AssetId;
simulacion.MainAccountId = mainAccountNum;
simulacion.ImporteAdquisicion = assetBook.AcquisitionPrice;
//Recorrer dataset depreciacion
while select tmpDateSum where tmpDateSum.TmpNumerals01 != 0
{
simulacion.Periodo = tmpDateSum.TransDate; // Fecha depreciacion
simulacion.Depreciacion = tmpDateSum.TmpNumerals01; // Importe depreciacion del periodo
simulacion.DepreciacionAcumulada = tmpDateSum.Total; // Importe depreciacion acumulada
simulacion.NetBookValue = tmpDateSum.TmpNumerals02; // Valor neto en libros
simulacion.insert();
}
}
info("Simulacion terminada");
}
Resultado:Espero que os sirva de ayuda
