web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Creating Invoice register jour through the code

(0) ShareShare
ReportReport
Posted on by

Hi

I need to Create an Invoice register jour through the code (AX2012 R3)

I'm confused .

1) There seems to be two approaches , some samples use AxLedgerJournalTable set of classes(like in TMSInvoiceApproval-> createLedgerJournalTrans), some use normal LedgerJournalTable. Our system is customised , we don't really used AIF (DIXF instead) and I'm afraid that AxLedgerJournalTable can miss some logic, so I think inserting directly into LedgerJournalTable/Trans tables would be more appropriate. Am I right?

2) I don't seem to find any consistency in the std. code. Especially in how we populate LedgerDimension, Account, OffsetAccount fields. For "Account" some code uses parmAccount(), some - direct Account assignment. The same for "ledgerDimension" : some use parmLedgerDimension(), some rely on  this.LedgerDimension = DimensionStorage::getDynamicAccount(_account, _accountType); hidden in parmAccount() method, some use DimensionStorage::accountNum2LedgerDimension. What's the difference between the latter/ What is correct?

I'm afraid to miss some necessary background dependant fields recalculation and thus introducing hard to reveal bugs.  

Examples:

CustInPaym_> createLedgerJournalTrans

LedgerJournalTrans.parmAccount(_ledgerJournalTransImport.accountNum(), LedgerJournalACType::Cust, curext());
ledgerJournalTrans.OffsetCompany = curext(); ledgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
// offset account = ledger account of the bank account
defaultAccount = BankAccountTable::find(offsetAccount).LedgerDimension;
ledgerJournalTrans.parmOffsetLedgerDimension(ledgerJournalTrans.getOffsetLedgerDimensionForLedgerType(defaultAccount, ledgerJournalTrans.getOffsetCompany()));

 

Whilst AssetLVPTransferProposal -> createTransLine:

    ledgerJournalTrans.parmAccount(_assetBook.AssetId, LedgerJournalACType::FixedAssets);
    ledgerJournalTrans.PostingProfile       = AssetTable::find(_assetBook.AssetId).postingProfile(_assetBook.BookId);
    ledgerJournalTrans.TransactionType      = LedgerTransType::FixedAssets;
    ....
ledgerJournalTrans.ExchRate = Currency::exchRate(ledgerJournalTrans.CurrencyCode, ledgerJournalTrans.TransDate); ledgerJournalTrans.DefaultDimension = AssetTable::find(_assetBook.AssetId).defaultDimension(_assetBook.BookId); ..
ledgerJournalTrans.Company = curext(); ledgerJournalTrans.OffsetCompany = curext(); ledgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger; ledgerJournalTrans.OffsetDefaultDimension = 0; defaultAccount = AssetTable::find(_assetBook.AssetId).assetOffsetLedgerDimension(ledgerJournalTrans.PostingProfile, AssetPost::assetTransTypeJournal2AssetTransType(_assetTransType), _assetBook.BookId); ledgerJournalTrans.parmOffsetLedgerDimension(ledgerJournalTrans.getOffsetLedgerDimensionForLedgerType(defaultAccount, ledgerJournalTrans.getOffsetCompany()));

And in TrvCreateLedger->createLedgerJournalTrans

    ledgerJournalTrans.parmAccount('', _trvLedgerInfo.parmAccountType());
    ledgerJournalTrans.parmLedgerDimension(_trvLedgerInfo.parmLedgerDimension());
    ledgerJournalTrans.parmOffsetAccount('',_trvLedgerInfo.parmOffsetAccountType());
    ledgerJournalTrans.parmOffsetLedgerDimension(_trvLedgerInfo.parmOffsetLedgerDimension(), curext());

    if(_trvLedgerInfo.parmAccountType() != LedgerJournalACType::Ledger)
    {
        ledgerJournalTrans.parmDefaultDimension(_trvLedgerInfo.parmDefaultDimension());
    }

    if(_trvLedgerInfo.parmOffsetAccountType() != LedgerJournalACType::Ledger)
    {
        ledgerJournalTrans.parmOffsetDefaultDimension(_trvLedgerInfo.parmOffsetDefaultDimension());
    }

    ledgerJournalTrans.AmountCurCredit      =   _trvLedgerInfo.parmAmountCurCredit();
    ...
    ledgerJournalTrans.DefaultDimension     =   _trvLedgerInfo.parmDefaultDimension();


and at the same time in LedgerJournalTrans->initFromTAMDeduction)  we use DimensionStorage::accountNum2LedgerDimension to populate LedgerDimension:

this.LedgerDimension = DimensionStorage::accountNum2LedgerDimension(_tamDeduction.AccountNum,LedgerJournalACType::Cust);

this.AccountType = LedgerJournalACType::Cust;

 

Could you please help to understand the above and write a correct code

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
imran ul haq Profile Picture

imran ul haq 8

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 4 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans