Hi all,
Today I will demonstrate a short piece of code that will help you to fetch sales Tax value for individual lines on a Purchase order.More often than not, we get such requirements , to show salesTax amount for each order lines on a ssrs reports, or to pass the sales tax information of each order line, to external system via XML, i had worked on such an requirements in the past, just thought of sharing the same with you all. Well below you find a short piece of code, that shows one of way achieving it.
static void PSI_SalesTax_per_POLine(Args _args)
{
TaxTmpWorkTransForm taxTmpWorkTransForm;
PurchTotals purchTotals;
TaxPurch taxPurch;
purchTotals = PurchTotals::newPurchTable(PurchTable::find(‘PO0000004CA’));
purchTotals.calc();
taxPurch = purchTotals.tax();
taxTmpWorkTransForm = TaxTmpWorkTransForm::construct();
taxTmpWorkTransForm.parmTaxObject(taxPurch);
taxTmpWorkTransForm.updateTaxShowTaxesSourceSingleLine(tableNum(PurchLine), PurchLine::find(‘PO0000004CA’,2,false).RecId, true);
info(strFmt(‘%1’,taxTmpWorkTransForm.parmTaxAmountCurTotal()));
}
This code is tested on AX2012 and AX2012 R2. As you can see in above piece of code, i have used Purchtotals , the object of this class is used for calculating totals from a PurchTable table record. Another important thing to notice is , the second parameter for , taxTmpWorkTransForm.updateTaxShowTaxesSourceSingleLine method, the parameter ‘PurchLine::find(‘000432′,90,false).RecId’ should be recid of the PurchLine table, ideally recid should be fetched based on the LineNumber, in the above piece of code line number 90 is used as an example.
Note: Please a make sufficient testing, before you make use of the code.
Keep sharing the knowledge…
Regards
Pradeep.SI
Good one Pradeep. Nicely explained. Keep sharing more.
Hi,
I need to get the TaxCode per line. How can do it?
do you still need the solution for this?
Hi Pradeep,
How should i get tax code from above code ?
Thanks in advance.
I am not able to see tax per line for a PO.
How to get it for each line PO? Total on per PO level is accessible
PurchLine purchLineRecord;
while select purchLineRecord
where purchLineRecord.PurchId == “PO006953”
{
Info(strfmt(“%1”, Tax::calcTaxAmount(purchLineRecord.TaxGroup,
purchLineRecord.TaxItemGroup,
Systemdateget(),
purchLineRecord.CurrencyCode,
purchLineRecord.LineAmount,
TaxModuleType::purch)));
}
thank you Jafferson.
Nice one. Helped me fulfill my requirement.
great!!!