How to add OffsetLedgerDimension to Fixed Asset Journal by x++?

65 Views Asked by At

By x++, I would like to create a Fixed Asset Journal.

I'm facing to issue about populate LedgeJournalTrans.offsetDefaultDimension.

Part of my code:

ledgerJournalTrans.OffsetDefaultDimension = ledgerJournalTrans.getOffsetLedgerDimensionForLedgerType(
        AssetLedgerAccounts::assetOffsetLedgerDimension(AssetTable.AssetId, 
        'MyBook', AssetTransType::Depreciation ),curExt());

ledgerJournalTrans.insert();
    
ledgerJournalTrans_Asset.initValue();
ledgerJournalTrans_Asset.RefRecId    = ledgerJournalTrans.RecId;
ledgerJournalTrans_Asset.AssetId     = assetTable.assetId;
ledgerJournalTrans_Asset.TransType   = AssetTransTypeJournal::Depreciation;
ledgerJournalTrans_Asset.BookId      = 'MyBook';        
            
ledgerJournalTrans_asset.insert();

I used

ledgerJournalTrans.OffsetDefaultDimension = assetBook.DefaultDimension

but NOT work

I'm not able to get the FixedAsset default Offeset; I would like to copy the behaviour when I add the FixedAsset in Account field.

There is any way?

Example - I would like this behaviour by code:

enter image description here

I would like to copy in Offset the Fixed Asset Financial Dimension:

enter image description here

Thanks all.

1

There are 1 best solutions below

2
Alex Kwitny On

You're using the wrong field. You should be using LedgerJournalTrans.LedgerDimension/LedgerJournalTrans.OffsetLedgerDimension

Not - LedgerJournalTrans.DefaultDimension/LedgerJournalTrans.OffsetDefaultDimension

  • DefaultDimension - This is your normal financial dimensions, minus the ledger bit. In your case, something like 00000031-00000023-00000003

  • LedgerDimension - This is the ledger bit + the default dimension. In your case, something like BUIL-00000031-00000023-00000003, where the BUIL is some sort of account.

There are tons of resources online on how to create a LedgerDimension from a default dimension. You should look at AxdDimensionUtil and DimensionStorage. Here's one resource - https://www.schweda.net/blog_ax.php?bid=553&wdl=en

Your AssetBook has a DefaultDimension and you need to combine it with a main account to get a LedgerDimension.