Jump to content

WHMCS is doing VAT calculations wrong


Recommended Posts

TLDR;
WHMCS basically does tax calculations wrong if you've decided to configure your product prices with tax.
Does WHMCS has a setting to define prices without taxes but show them including taxes?
Or is there a hook that allows manipulation of product prices, without altering the actual total amount?

Kind of a clickbait title, I know.
The issue is that in WHMCS, you have the option to define prices with or without taxes. If you decide to include taxes in the prices you configure, the prices are also shown with taxes - and then WHMCS calculates backwards to get the subtotal and tax amount.
This causes issues in odd cases.
Example:

A product costs 29.32 inclusive 25% VAT.
WHMCS calculates VAT like this: 29.32 / (100 + 25) * 25 = 5.864 (which WHMCS rounds down to 5.86).
If we subtract this from the total, we get a subtotal of 23.46 - but if we try to calculate the VAT from this number (23.46 * 1.25), we get 29.325 (which would be rounded up to 29.33). Most economical systems calculate taxes based on the subtotal, so we end up with inconsistencies.

This may not be an issue to most, and there's always the option to just have all prices configured excluding taxes - because that would always use to subtotal to calculate the taxes, which would always result in the correct numbers... But, some countries have laws in place that requires you to show prices including VAT if you're dealing with private individuals. Most of us are.

The solution to this is to define prices without taxes and then manipulate the front end to display the correct values with taxes - but boy, is that a challenge. Currently, I have a few hundred lines of JavaScript that manipulates the Ajax calls that WHMCS. The most frustrating part is that WHMCS doesn't return the prices in a specific way. Sometimes, they're returned as JSON - that is very easy to work with. Sometimes, the output is returned as HTML. Other times, the response is returned as HTML in JSON.
The best part is that the template values are using the fully prefixed/suffixed totals - fx $10.00USD (for the most part, sometimes it's just using the actual price). It's a pain to work with this.

I've already spent a week trying to show the correct values and I keep finding new things that complicates everything.
Before I continue, I just want to make sure that there isn't a setting we can adjust or a hook that's better fit for this. We're using the ClientAreaPageCart hook to override all the relevant variables - but it's a huge mess of code, and I'm concerned it'll break with an update.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated