Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

X++. How Voucher lines created when Invoice is posted?

(0) ShareShare
ReportReport
Posted on by 120

Hi Experts,

Need advice.

I am trying to understand technically (X++) how voucher lines created when purchase order or sales order or invoice journals are posted.

The relation between Posting Profile and PostingType when Voucher lines created, Is it possible to determine how many voucher lines will be created using Posting Profile?

If we consider process of PO being invoiced, there several voucher lines created. These are identified by PostingType.

Can you please help to understand, classes and conditions I should check to determine number of lines created in Voucher?

If I decide to, customise, when every voucher line is being created, to manipulate voucher line information (keeping the voucher balance intact), then can this be done in one central place?

Look forward to your inputs and suggestion.

*This post is locked for comments

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,516 Super User 2025 Season 1 on at
    RE: X++. How Voucher lines created when Invoice is posted?

    Hi Osmhn,

    If you can tell the purpose of the other main account and why, we can try to help you if there is a feature out of the box. A customization would be very different for sales and purchase as the posting method is different. So, please tell a bit more about the business requirement as I don't like to provide incorrect information on a complex topic like this.

  • MSKAX Profile Picture
    MSKAX 120 on at
    RE: X++. How Voucher lines created when Invoice is posted?

    Hi Andre,

    Yes, that was a typo, should be 100 and not 10.

    Intention is to split the amount and post it to a different MainAccount.

    InventMovement and InventUpdate are creating one type of Voucher lines. I am trying to work out all scenarios that will make InventMovement and InventUpdate to post Financials and that are creating Voucher lines. Your guidance on this please.

  • Suggested answer
    Hossein.K Profile Picture
    Hossein.K 6,646 on at
    RE: X++. How Voucher lines created when Invoice is posted?

    Hi OSMHN,

    Journal contents of voucher or number of voucher so you can create General Journal using the code like in below

    static void VendPaymJournalCreate(Args _args)

    {
    LedgerJournalTable jourTable;
    LedgerJournalTrans jourTrans;
    LedgerJournalTableData jourTableData;
    LedgerJournalTransData jourTransData;
    LedgerJournalStatic jourStatic;
    DimensionDynamicAccount ledgerDim;
    DimensionDynamicAccount offsetLedgerDim;
    ttsBegin;
    ledgerDim = DimensionStorage::getDynamicAccount(
    '1001',
    LedgerJournalACType::Vend);
    offsetLedgerDim = DimensionStorage::getDynamicAccount(
    'USA OPER',
    LedgerJournalACType::Bank);
    jourTableData = JournalTableData::newTable(jourTable);
    jourTable.JournalNum = jourTableData.nextJournalId();
    jourTable.JournalType = LedgerJournalType::Payment;
    jourTable.JournalName = 'APPay';
    jourTableData.initFromJournalName(
    LedgerJournalName::find(jourTable.JournalName));
    jourStatic = jourTableData.journalStatic();
    jourTransData = jourStatic.newJournalTransData(
    jourTrans,
    jourTableData);
    jourTransData.initFromJournalTable();
    
    jourTrans.CurrencyCode = 'USD';
    jourTrans.initValue();
    jourTrans.TransDate = systemDateGet();
    jourTrans.AccountType = LedgerJournalACType::Vend;
    jourTrans.LedgerDimension = ledgerDim;
    jourTrans.Txt = 'Vendor payment journal demo';
    jourTrans.OffsetAccountType = LedgerJournalACType::Bank;
    jourTrans.OffsetLedgerDimension = offsetLedgerDim;
    jourTrans.AmountCurDebit = 1000;
    jourTransData.create();
    jourTable.insert();
    ttsCommit;
    info(strFmt(
    "Journal '%1' has been created", jourTable.JournalNum));
    }
    
     
    
    --> then you should make your post via this code
    
    static void LedgerJournalPost(Args _args)
    {
    LedgerJournalCheckPost jourPost;
    LedgerJournalTable jourTable;
    jourTable = LedgerJournalTable::find('000420_010');
    jourPost = LedgerJournalCheckPost::newLedgerJournalTable(
    jourTable,
    NoYes::Yes);
    jourPost.run();
    }


  • Suggested answer
    Hossein.K Profile Picture
    Hossein.K 6,646 on at
    RE: X++. How Voucher lines created when Invoice is posted?

    Hi OSMHN,

    This link is useful for create voucher:

    community.dynamics.com/.../how-to-generate-ledger-vouchers-using-dataentities-and-x-in-dynamics-365-for-operations

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,516 Super User 2025 Season 1 on at
    RE: X++. How Voucher lines created when Invoice is posted?

    Hi Osmhn,

    Can you tell also why you are doing this? What is the difference between one original or the splitted lines? You mentioned shortly a reporting amount, but what is the business requirement here?  I do think you have a typo in the first amount. I do assume you wanted to display 100 instead of 10?

    In the past I had some requirements to change the behavior of some postings, but that was only for summarizing ledger transactions instead of splitting.

  • MSKAX Profile Picture
    MSKAX 120 on at
    RE: X++. How Voucher lines created when Invoice is posted?

    Thanks Andre for your time and comments.

    I totally accept it is dangerous. Inputs from expert community are very valuable here.

    I am thinking, when voucher line is created, if conditions meet then split value and create two voucher lines instead of one.

    E.g. Original would have created one voucher line - Amount - 10.

    Now create two voucher lines. Line - 1: Amount - 80. Line - 2: Amount - 20.

    Hence the voucher balances overall.

    class - LedgerVoucherObject, method - addTrans(). calls transactionCollection.add(_transaction), and Adds voucher lines.

    so, based on condition, I call this twice, manipulate the ReportingCurrencyAmount (80+20)

    transactionCollection.add(_transaction);

    transactionCollection.add(_transaction);

    Voucher overall will balance.

    Want to try this in a prototype.

    Do comment your view please.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,516 Super User 2025 Season 1 on at
    RE: X++. How Voucher lines created when Invoice is posted?

    Hi Osmhn,

    You are now going into a core application part which is very dangerous. The logic is different for sales and purchase invoices. Purchase invoices are posted using the subledger framework; sales order invoices using ledger posing classes directly.

    What exact manipulation do you have in mind? Can you elaborate?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans