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, ...
Answered

How to Get Withholding Tax Amount for PurchLine (Open Order, Not Invoiced)

(6) ShareShare
ReportReport
Posted on by 666

Hi Experts,

I want to retrieve the Withholding tax amount shown under the Temporary withholding tax transactions form (as seen in the screenshot) for a Purchase Order line in open status (not yet invoiced).

This tax is correctly calculated in the UI, but I need to access this amount via X++ code, ideally from the PurchLine or related records before posting the invoice.

 

 

I have tried using:

Tax::calcTaxAmount(purchLine.TaxGroup, purchLine.TaxItemGroup, SystemDateGet(), purchLine.CurrencyCode, purchLine.LineAmount, TaxModuleType::Purch);

But this does not return the withholding tax amount.

Also, I found that this query is available, but it doesn’t support Open Orders
 
select TaxWithholdAmount, PURCHID, taxWithholdTransTable.DATAAREAID, taxWithholdTransTable.VOUCHER, taxWithholdTransTable.LINENUM, taxWithholdTransTable.PANSTATUS, taxWithholdTransTable.LINESTATUS, * from taxWithholdTrans_IN as taxWithholdTransTable
join TaxWithholdRegNumbers_IN as taxWithholdRegNumbers
on   taxWithholdTransTable.TaxWithholdRegNumber =  taxWithholdRegNumbers.RecId 
join taxWithholdHead_In as taxWithholdHead
on   taxWithholdTransTable.TaxWithholdSettlementPeriod  = taxWithholdHead.RecId and
taxWithholdTransTable.PURCHID = 'PO0000000xxx' and
taxWithholdTransTable.VENDACCOUNT = 'V0000000xxx' 
 

Could anyone guide me on:

     1. Where this withholding tax amount is stored or temporarily calculated?

     2. How can I programmatically fetch the same amount shown in the UI for a PO line before invoice posting?

Any help or sample code would be appreciated.

Thanks in advance,
– Saalim

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    Don't forget that you access to all the code, therefore if you want to know where a value on a form comes from, you can go and take a look.
     
    The form is TaxWithholdUncommitted form. The grid column you're talking about is bound to InvoiceTaxWithholdAmount field of TaxWithholdUncommitted
    table.
     
    Note that there is code adding filters to TaxWithholdUncommitted data source based on TableId and RecId of the record that the form was opened for.
     
    When you look at references of the form, you'll also find PurchTotals_ParmTrans::showWithholdTax() method. When you look inside, you'll see how the data gets calculated before displaying:
    PurchTotals purchTotals = PurchTotals::newParmTable(
        _parmTable,
        _specQty,
        _parmTable.ParmId,
        '',
        _parmTable.Ordering);
    
    purchTotals.parmIsWHTCalcNeeded(true);
    purchTotals.calc();
  • Raj Borad Profile Picture
    1,428 on at
    Hi,
     
    The withholding tax amount shown in the “Temporary withholding tax transactions” form is dynamically calculated at runtime and not stored in a table until the invoice is posted. This amount is based on the withholding tax setup defined under the vendor, tax authority, and tax codes. 
     
    To programmatically retrieve this amount before invoice posting, use the 'PurchCalcTax_IN' class which simulates the tax calculation logic. Specifically, you can use 'PurchCalcTax_IN::construct()', pass the relevant 'PurchTable', and call 'calcWithholdingTax()'. The results will be stored in a temporary table 'TaxWithholdTmp_IN', which holds the same data displayed in the UI. Iterating over this temp table gives you access to the calculated withholding tax amount per line item. 
     
    SQL queries or methods like 'Tax::calcTaxAmount()' won’t return withholding tax values, as they focus on standard sales/purchase taxes, not India-specific withholding tax (if you are referring Indian Tax system).
     
    Thanks.
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    I don't see any object called PurchCalcTax_IN in the standard application. The name suggests an Indian localization, 
  • Saalim Ansari Profile Picture
    666 on at
    Yes, I also didn’t find any object named PurchCalcTax_IN in the standard application.

    As the name suggests, it seems to be part of Indian localization, but it’s not present in the environment I checked.
  • Verified answer
    Saalim Ansari Profile Picture
    666 on at

    Hi  ,

    I tried the suggestion as per your advice and it worked for me.

    I ran the below query:

    SELECT TAXAMOUNT, TAXWITHHOLDVALUE, PurchId, * 
    FROM TaxWithholdUncommitted_IN  
    JOIN PURCHTABLE  
    ON TaxWithholdUncommitted_IN.HEADINGRECID = PURCHTABLE.RECID  
    WHERE PurchID = 'PO00000XXXX'
     
    And I successfully got the Tax Amount. Thank you for the help!

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans