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