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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

AP Account Statement report

(2) ShareShare
ReportReport
Posted on by 2,382
Hi Experts,
 
In Account Payable, I want to add PurchId in account statement report using below code.
 
But PuchId is not showing correct. Could you help me what missing in code.
internal final class AT_CustVendAccountStatementTmp_EventHandler
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [DataEventHandler(tableStr(CustVendAccountStatementIntTmp), DataEventType::Inserted)]
    public static void CustVendAccountStatementIntTmp_onInserted(Common sender, DataEventArgs e)
    {
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(classStr(VendAccountStatementIntDP), methodStr(VendAccountStatementIntDP, processReport))]
    public static void VendAccountStatementIntDP_Post_processReport(XppPrePostArgs args)
    {
        VendInvoiceJour     vendInvJr;
        VendAccountStatementIntDP dpInstance = args.getThis() as VendAccountStatementIntDP;
      
        CustVendAccountStatementIntTmp custVendAccountStatementIntTmp = dpInstance.getCustVendAccountStatementIntTmp();
        ttsbegin;
        while select forUpdate custVendAccountStatementIntTmp
        {
            select vendInvJr where vendInvJr.LedgerVoucher == custVendAccountStatementIntTmp.Voucher
                && vendInvJr.InvoiceDate == custVendAccountStatementIntTmp.TransDate && vendInvJr.InvoiceAccount == custVendAccountStatementIntTmp.AccountNum;

            custVendAccountStatementIntTmp.DocumentNum  =   vendinvjr.PurchId;
           
            custVendAccountStatementIntTmp.update();
        }
        ttscommit;
    }

}
 
 
Thanks,
Faiz
I have the same question (0)
  • faiz7049 Profile Picture
    2,382 on at
    Thank. Code is working only issue was there were different account for vendor account and invoice account in purchase order.
  • André Arnaud de Calavon Profile Picture
    301,482 Super User 2025 Season 2 on at
    Hi Faiz,

    When reading your reply, I wonder of you already found the culprit or is there a pending question?
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,605 Super User 2025 Season 2 on at
     
    Try this code :
    while select forUpdate custVendAccountStatementIntTmp
    {
        vendInvJr = VendInvoiceJour::findFromVendTrans(custVendAccountStatementIntTmp.Invoice, custVendAccountStatementIntTmp.TransDate, custVendAccountStatementIntTmp.AccountNum, false, custVendAccountStatementIntTmp.Voucher);
        if(!vendInvJr)
        {
            vendInvJr = VendInvoiceJour::findFromVendTrans(custVendAccountStatementIntTmp.Invoice, custVendAccountStatementIntTmp.TransDate, custVendAccountStatementIntTmp.InvoiceAccount, false, custVendAccountStatementIntTmp.Voucher);
        }
        custVendAccountStatementIntTmp.DocumentNum  =   vendinvjr.PurchId;
               
        custVendAccountStatementIntTmp.update();
    }
    Best regards,
    Mohamed Amine MAHMOUDI
  • Verified answer
    faiz7049 Profile Picture
    2,382 on at
    Hi Andre and Amine,
     
    Issue has been resolved. The problem was in Purchase order there the invoice account and vendor code were different from each other.

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

News and Announcements

Season of Giving Solutions is Here!

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 > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 258 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Sumit Singh Profile Picture

Sumit Singh 46

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans