Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

How to apply sales tax amount fetched from an external API to Sales Order Lines using AL Language

(1) ShareShare
ReportReport
Posted on by 5
Hello all,
Thanks in advance.
I am customizing Business Central. I have stuck on a point that I do not want to use BC internal sales tax engine. I am fetching sales tax amount from some external API and now I want to apply this sales tax amount on the lines of sales order. Is it possible by using AL programing or not. If yes how we can perform that.
 
Thanks  
  • Suggested answer
    Greg Kujawa Profile Picture
    352 on at
    How to apply sales tax amount fetched from an external API to Sales Order Lines using AL Language
    When it comes to our use case, we have a retail location in Tennessee. And that state collects single article sales tax against specific sale line items that fall within a certain dollar threshold. Out of the box BC 365 couldn't handle this. And we thought that the ISV solutions were cost-prohibitive. Since we are primarily looking at just Sales Orders and Sales Invoices, I believe that I have deployed an AL extension codeunit that handles this properly. Conditionally just for any Sales Line items that are associated with our one Tennessee location code.
     
    The two event subscribers I attached to were:
     
    • Database::"Sales Line", 'OnAfterSalesTaxCalculate'
    • Codeunit::"Sales Tax Calculate", 'OnBeforeApplyTaxDifference'

    Testing out some transactions all initially appears to be working fine. Of course it will take more testing and working through many scenarios. This codeunit manually calculates sales tax, and doesn't make an external third-party API call. When it comes to BC 365 SaaS at least, I'm not positive if that's doable or not. When we tested out BC 365 on-prem last year I know I was able to compile my own .NET assemblies and call them to perform actions such as that. I believe that SaaS doesn't allow compiled .NET assemblies to be added, and I can't recall if you can create a REST API client in AL code to call out to a third-party external API endpoint.    
  • Greg Kujawa Profile Picture
    352 on at
    How to apply sales tax amount fetched from an external API to Sales Order Lines using AL Language
    We too have run into this challenge. A custom AL extension could accomplish this, but it can get rather complicated. Since there are numerous event triggers that occur when it comes to sales tax being hit. If you search this forum you will see similar posts. There is apparently a free Microsoft extension called Tax Engine that allows for business logic to be defined for specific use cases. Flexibly enough to handle most needs. But it's India-only, so I can't try it out in our US SaaS tenant. And the third party solutions such as Avalara and Vertex seem to be cost-prohibitive.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,255 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,984 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans