nik-christou / tax-calculator

Tax calculator for multiple countries
Apache License 2.0
1 stars 0 forks source link

Need a better design to load json files and calculate tax per country #13

Closed nik-christou closed 4 years ago

nik-christou commented 4 years ago

Every country seems to have a different way of calculation tax and therefore a different json structure. Right now the loading mechanism and calculation is fixed for cyprus. We need implementations for loading and calculating tax per country -> this will also affect the country-select component it just needs the country id + country name instead of the full country json.

Country.js entity should only contain {id, name, locale, currency} without any tax information since this entity is used for the country dropdown and for creating the localized NumberFormat.

After user has selected a country we can use that information to:

nik-christou commented 4 years ago

Example: Australia Tax

Current Resident Tax Rates 2018 - 2019 and 2019 - 2020: $0 – $18,200 | Nil $18,201– $37,000 | 19c for each $1 over $18,200 $37,001 - $90,000 | $3,572 plus 32.5c for each $1 over $37,000 $90,001 - $180,000 | $20,797 plus 37c for each $1 over $90,000 $180,001 and over | $54,097 plus 45c for every $1 over $180,000

Non-Resident Tax Rates 2018 - 2019 and 2019 - 2020: $0 - $90,000 | 32.5c for each $1 $90,001 - $180,000 | $29,250 plus 37c for each $1 over $90,000 $180,001 and over | $62,550 plus 45c for every $1 over $180,000

Note that these tax rates do not include the Medicare Levy or Medicare Levy Surcharge, with the former increasing to a rate of 2% from 1 July, 2014

minas1 commented 4 years ago

Will countries other than Cyprus be included in the first release?

nik-christou commented 4 years ago

nice question :-) Its up to us but I believe that the code should be structure in a way that in the future when we want to add a country will be just:

minas1 commented 4 years ago

I think that if other countries are included in the first release, this should be done. If not, we might design the mechanism in a way that is not really correct and we will need to make more changes in the future. However, since this seems to be an easy task, it can be done now as well.

nik-christou commented 4 years ago

Good idea. I will spend some time to see if this can be done without to much difficulty, otherwise we can leave it for later :-)