valeriansaliou / node-sales-tax

:moneybag: International sales tax calculator for Node (offline, but provides optional online VAT number fraud check). Tax rates are kept up-to-date.
https://www.npmjs.com/package/sales-tax
MIT License
306 stars 48 forks source link

Update some Canadian tax rates #32

Closed stephankaag closed 4 years ago

stephankaag commented 4 years ago

It looks like some Canadian rates are incorrect.

Source: https://www.advalorem.ca/en/canada-vat-rates/

valeriansaliou commented 4 years ago

Thanks a lot!

sboichon commented 4 years ago

@valeriansaliou Sorry but I think this is not correct. As a canadian I have been using your awesome library for quite some time , and the tax rates as retuned by the function: getSalesTax('CA', provinceCode) have always been correct. It is my assumption that the above method sums the federal GST (5%) and the provincial part of the HST.

With the changes of @stephankaag getSalesTax is now returning GST + (GST + HST) which is off by 5%.

Could you please revert ? Thank you very much

valeriansaliou commented 4 years ago

@sboichon I've verified, and you're right. This PR did not take into account the calculation trick I initially used to adjust the calculation system to HST: for the states using HST, I've "emulated" their tax rates by substracting the GST from their actual HST, and saying that the calculated (smaller) rate was HST.

It means that for a state that has 15% HST, in the JSON configuration that should be stored as HST = 10%, given that GST is 5%. GST + HST would give the real HST which is 15%.

This PR would produce incorrect final HST values as all original HST values would be added to the GST, giving out eg. 5% + 15% = 20% which is invalid.

Released v2.2.3 to address this, also bumped a state tax rate that was changed in 2019 (Manitoba; ref a139c0a20c212aafe5b77fc6e46d6c1745b75ca8).