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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Getting Null Value for ITaxDocumentLine in PO Invoice Report Despite Correct Tax Calculation

(6) ShareShare
ReportReport
Posted on by 12

Hi everyone,

We are working on a PO invoice report where we're trying to fetch tax-related information from vendor invoice transactions by constructing a TaxableDocumentObject. However, for some invoices, we are getting a null value for the ITaxDocumentLine field, even though the taxes are calculated correctly and the postings for the invoice are accurate.

Below is the code snippet


vendInvoiceInfoTable = VendInvoiceInfoTable::findPurchInvFromVendInvoiceJour(vendInvoiceJour.PurchId,vendInvoiceJour.InvoiceId,vendInvoiceJour.ParmId);



PurchTotals localPurchTotals = PurchTotals::newParmTable(vendInvoiceInfoTable, PurchUpdate::All, vendInvoiceInfoTable.ParmId, '', DocumentStatus::Invoice);

localPurchTotals.calc(true);

taxableDocument = TaxableDocumentObject::construct(localPurchTotals.parmTaxableDocumentDescriptor());

taxDocumentObject =TaxBusinessService::calculateTax(taxableDocument);



if (taxDocumentObject)

{

taxDocumentLine = taxDocumentObject.findLineBySource(tableNum(VendInvoiceTrans), _vendInvoiceTrans.RecId); //returning null for some invoices



// Calculation of Tax amount for Tax type GST and Tax component SGST

if(taxDocumentLine)

{



}

}

Has anyone faced a similar issue or can provide insights into why this might be happening? Any suggestions on how to resolve this would be greatly appreciated!

Thanks in advance!

I have the same question (0)
  • Suggested answer
    SajeedMullaji Profile Picture
    847 on at

    @TS-14020551-0 
    the null return from findlinebysource happens because of a context mismatch between the source document used for recalculation and the actual posted transaction state. when taxbusinessservice::calculatetax is called using vendInvoiceinfoTable or parm-based purchtotals, it generates an in-memory tax document where the line keys point to staging and parm table references — not the permanent vendInvoicetrans recid. for invoices that are already posted the vendInvoiceinfoTable records are often cleared, so the lookup fails silently and returns null.

    two solutions depending on your scenario:

    solution 1 — use the posted invoice context. instead of vendInvoiceinfoTable use taxeditabledocumentobject::construct passing the vendInvoiceJour directly. then call gettaxdocument and use findlinebysource against the permanent vendInvoicetrans recid. this resolves the context mismatch for posted invoices.

    solution 2 — query taxtrans directly. for reporting on posted transactions dynamic recalculation via taxbusinessservice is unnecessary and prone to this exact mismatch. query taxtrans directly using vendInvoiceJour.ledgervoucher, vendInvoiceJour.invoiceid, and vendInvoiceJour.invoicedate. this gives you the tax amounts, codes, and components without any findlinebysource mapping dependency.

    for a po invoice report querying posted transactions solution 2 is the cleaner and more reliable approach — taxbusinessservice::calculatetax is designed for transactional staging during order entry and invoice parking, not for reporting on historical posted records.

    hope that helps — feel free to mark as verified if it resolves the issue.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 341 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 312

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 262 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans