ulisses
ulisses

Reputation: 1569

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

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.

Upvotes: 1

Views: 960

Answers (2)

Binh Tam Ngo Vu
Binh Tam Ngo Vu

Reputation: 1

You should have your default offset account setup in the FA posting profile then you can use following snip to initialise the journal line with the default dimension from your FA book

LedgerJournalEngine LedgerJournalEngine = new LedgerJournalEngine();
LedgerJournalTrans.parmAccount(AssetBook.AssetId,LedgerJournalACType::FixedAssets);
LedgerJournalEngine.initFromAssetTable(LedgerJournalTrans,LedgerJournalTransAsset);
LedgerJournalEngine.assetBookIdModified(LedgerJournalTrans,LedgerJournalTransAsset);

Upvotes: 0

Alex Kwitny
Alex Kwitny

Reputation: 11564

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.

Upvotes: 4

Related Questions