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

Function to use custom sales tax rates #41

Open markusrempfer opened 3 years ago

markusrempfer commented 3 years ago

Can you add a function that replaces and overrides the 'sales_tax_rates.json' ?

So instead of using the ...

var tax_rates = require("../res/sales_tax_rates.json");

... in your 'sales_tax.js', someone can define and use a function at the beginning that replaces the 'sales_tax_rates.json' and use a custom file?! E.g:

SalesTax.setSalesTaxRates("./helpers/sales_tax_rates_custom.json")

And as a plus, just/only overrides/adds indiviual objects of the 'sales_tax_rates.json' if country/state exist/does not exist?! So e.g. :

SalesTax.setSalesTaxRates("./helpers/sales_tax_rates_custom.json", "override")

I've notice that the Value-added tax (VAT) rates from PwC are in some cases a bit different ... e.g.

China (CN): You: 16 PWC: 13, 9, or 6

Kenya (KE): You: 14 PWC: 16

Nigeria (NG) You: 5 PWC: 7.5

...

Or is this already possible?

It would be great to have this so we don't have to wait till you update it! And given the complexity adding their individual rates.

I also think that would help with other existing and probably incoming request.