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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Override sales tax on each sales order line through X++ code

(0) ShareShare
ReportReport
Posted on by 2,488

Hello experts,

I have a requirement to override the sales tax for each sales line while sales invoice posting.

can someone please help?

I have the same question (0)
  • nmaenpaa Profile Picture
    101,166 Moderator on at

    What exactly do you mean by "overriding sales tax"? Could you share your actual business requirement?

    You can impact the tax calculation with tax setup.

  • Mohammad Raziq Ali Profile Picture
    2,488 on at

    Thanks for the reply Nikolaos,

    Sales tax amount value coming from POS which I am saving on sales line through extension and this sales tax must be considered/overridden with the existing sales tax amount (through sales tax code on each sales line) while posting retail statement which then creates a sales order and invoices it.

    I have sales tax amount ready on each line. I just need code and place to write the code.

    Best regards,

    Raziq.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Perhaps the easiest solution (which would also not require customization of tax calculation) would be to let D365 calculate the same tax for you by setting up the tax setup correctly. Your integration needs to simply tell which tax code applies to each sales line, and whether tax is included in the price or not.

    Wouldn't this produce the outcome that you need?

  • Mohammad Raziq Ali Profile Picture
    2,488 on at

    No, the problem here is the transaction coming from POS does not have a sales tax code and the sales amount must be overridden with the existing sales tax amount.

  • WillWU Profile Picture
    22,363 on at

    Hi Mohammad,

    Please see the updateTaxRegulationAmount method in the class TaxRegulationDetail .

    And have a look at this old thread:

    community.dynamics.com/.../sales-tax-override-on-pending-vendor-invoice-lines

  • Mohammad Raziq Ali Profile Picture
    2,488 on at

    Hello Will WU,

    thanks for providing the link.

    This is not of much help as my requirement at the time of sales invoice.

    This link does show which object to modify but I need a place where should I write the code.

    Regards,

    Raziq

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Mohammad,

    I'm not sure if you can adjust taxes for each line independently, but you can adjust taxes for the whole order.

    Check TaxRegulation::adjustTaxInvoice method, it's used when credit note is created and tax is adjusted from original invoice. You can probably develop something similar.

  • Pavel Vorontsov Profile Picture
    20 on at

    I had similar requirements - POS receipt lines were calculated line by line, and rounded tax from each small quantity, but it was sent to tax authorities and resulting AX sales invoice didnt match, because it was created for summary amount and summary tax. To solve this I created class something like TaxRetail, which created tmpTaxWorkTrans in calc method based on data from RetailStatement table. Tables name are not exact, but anyway - the idea is to create class which is inherited from tax - and create your own calculation.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans