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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Purchase accruel, purchase expenditure un-invoiced on purchase order

(6) ShareShare
ReportReport
Posted on by 115
 
Hello,
Please can someone tell me where those 2 entries are inserted from code in visual studio? I have been debugging the code but have not found the class or functions which populates the entries in voucher transactions page.
Thank you in advance.​​​​​​​
Categories:
I have the same question (0)
  • Suggested answer
    Saif Ali Sabri Profile Picture
    2,351 Super User 2025 Season 2 on at

    You need to debug the code related to Accounts Payable and Purchase Order posting logic. 

    1. Understand the Transaction Types

    • Purchase Accrual: This is typically posted when goods or services are received but not yet invoiced. It is part of the accrual accounting process.

    • Purchase Expenditure Un-Invoiced: This represents expenses incurred but not yet invoiced, often related to purchase orders.


    2. Key Classes and Methods to Investigate

    The posting of these transactions is usually handled in the Accounts Payable module, specifically in classes related to vendor invoice posting and purchase order posting. Here are the key areas to focus on:

    • Vendor Invoice Posting:

      • Class: VendInvoicePost

      • Method: run() or postInvoice()

      • This class handles the posting of vendor invoices and may include logic for accruals.

    • Purchase Order Posting:

      • Class: PurchTable

      • Method: update() or postInvoice()

      • This class handles the posting of purchase orders and may include logic for un-invoiced expenditures.

    • Ledger Posting Framework:

      • Class: LedgerJournalTrans

      • Method: postJournal()

      • This class handles the posting of journal entries, including accruals and expenditures.


    3. Debugging Steps

    Follow these steps to locate the code responsible for inserting the entries:

    a. Set Breakpoints in Key Classes

    • Open Visual Studio and navigate to the classes mentioned above (VendInvoicePost, PurchTable, LedgerJournalTrans).

    • Set breakpoints in the run(), postInvoice(), or update() methods.

    b. Run the Process

    • Perform the action that triggers the posting (e.g., post a vendor invoice or purchase order).

    • The debugger will stop at the breakpoints, allowing you to trace the flow of execution.

    c. Trace the Code

    • Step through the code to identify where the Purchase Accrual and Purchase Expenditure Un-Invoiced entries are created.

    • Look for methods or logic that create ledger transactions with the posting types Purchase, accrual and Purchase expenditure, un-invoiced.

    d. Check Subledger Journal Logic

    • The subledger journal entries are often created in the LedgerJournalTrans class or related classes.

    • Look for methods that handle the creation of voucher transactions.


    4. Common Methods to Investigate

    Here are some specific methods to look for:

    • Accrual Logic:

      • Method: createAccrualTrans()

      • This method may be responsible for creating accrual entries.

    • Un-Invoiced Expenditure Logic:

      • Method: createUninvoicedExpenditure()

      • This method may handle the creation of un-invoiced expenditure entries.

    • Ledger Posting:

      • Method: postLedger()

      • This method posts the transactions to the ledger.


    5. Example Code Snippet

    Below is an example of where you might find the logic for creating these entries:

    x++
    Copy
    // Example: Purchase Accrual Logic
    if (purchLine.QtyReceived > 0 && purchLine.Invoiced == false)
    {
        // Create accrual entry
        ledgerJournalTrans.clear();
        ledgerJournalTrans.AccountNum = purchLine.VendAccount;
        ledgerJournalTrans.AmountCur = purchLine.LineAmount;
        ledgerJournalTrans.PostingType = LedgerPostingType::PurchaseAccrual;
        ledgerJournalTrans.insert();
    }
    
    // Example: Un-Invoiced Expenditure Logic
    if (purchLine.QtyReceived > 0 && purchLine.Invoiced == false)
    {
        // Create un-invoiced expenditure entry
        ledgerJournalTrans.clear();
        ledgerJournalTrans.AccountNum = purchLine.VendAccount;
        ledgerJournalTrans.AmountCur = purchLine.LineAmount;
        ledgerJournalTrans.PostingType = LedgerPostingType::PurchaseExpenditureUninvoiced;
        ledgerJournalTrans.insert();
    }

    6. Additional Tips

    • Use the Dynamics 365 FO Trace Parser to trace the execution flow and identify the exact methods being called.

    • Check the Event Log in Visual Studio for any errors or warnings related to the posting process.

    • Refer to the D365FO Documentation or Microsoft Learn for more details on the posting framework.


    7. Conclusion

    The Purchase Accrual and Purchase Expenditure Un-Invoiced entries are likely created in the VendInvoicePost or PurchTable classes, specifically in methods related to posting vendor invoices or purchase orders. By setting breakpoints and tracing the code execution, you should be able to locate the exact logic responsible for these entries.

  • CU03091226-0 Profile Picture
    115 on at
    Hello,
    Unfortunately i was unable to find the proposed functions, are you sure these are the correct ones. My scenario is happening when i receive products from a purchase order. A new value is inserted in subledger journal entries not yet invoiced and I transfer them, however, to my knowledge i do not think these lines are inserted when i transfer those values to voucher transactions.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans