/ Microsoft / Calculate tax amount using x++

Calculate tax amount using x++

Learn, share and spread knowledge

I was finding the solution to calculate the tax on the purchase order lines. And I was excited to share with you once I found out the solution and tested it in my scenario. One line code will calculate tax amount using x++ of the sales, purchase or any other module in Microsoft Dynamics 365 for Finance and Operations and Microsoft Dynamics AX 2012.

This code needs four arguments. These arguments are mentioned as follows:

  • Tax group
  • Tax item group
  • Currency code
  • Module

Here is code below:

//You have to pass these values to the functions whether it comes from PurchLine or SalesLine or any other table.
//Store the result in variable

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

You have to pass these values to the functions, whether they come from SalesLine or PurchLine or any other table. It will return the tax value as TaxAmountCur extended data type.

The above code uses the values from PurchLine table. We have mentioned the module Purch because we are dealing with purchase module. If you are willing to calculate the tax form sales orders’ lines, then you will use SalesLine instead of PurchLine, and you will mention the module as Sales instead of Purch.

In this way you can calculate tax amount using x++. Moreover, if this helps you, please Like, Comment and Share to help other people.

If you found any ambiguity or a better solution, please feel free to ask.

Download code: Click here

Blog: Click here

YouTube: Click here

GitHub: Click here

If you fell down yesterday, stand up today. – H. G. Wells

0 POST COMMENT

Send Us A Message Here

Your email address will not be published. Required fields are marked *