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

how to handle portugal's VAT in autonomous region ? #39

Closed PandaaAgency closed 3 years ago

PandaaAgency commented 3 years ago

Hi there,

I would like to know how can I use this library with autonomous regions from portugal (from here) :

I've tried to add PT-20 (Azores ISO-Code from here) as a PT state but it seems that their VAT ared added to each other

  "PT": {
    "type": "vat",
    "rate": 0.23,
    "states": {
      "20": {
        "rate": 0.18,
        "type": "vat"
      }
    }
  },

results in a

// response
{
  type: 'vat+vat',
  rate: 0.41000000000000003,
  area: 'worldwide',
  exchange: 'consumer',
  charge: { direct: true, reverse: false },
  details: [ { type: 'vat', rate: 0.23 }, { type: 'vat', rate: 0.18 } ]
}

I cannot go with rate: -0.05 for the state because the details still contain the main PT VAT

Is there an existing solution/workaround ? Maybe we need PT-20 and PT-30 to be added as standalone countries within EU but it does not sound like the best solution

Thanks

PandaaAgency commented 3 years ago

Hi. Any news about this one ?

thx

valeriansaliou commented 3 years ago

Hello there!

This could be mapped the same way as done for Spain, where eg. Gran Canaria has no VAT.

The basic way to do that is to map a negative VAT for the region, which is then added to the main country VAT. So if the target region VAT is 18% where the country is 20% then mapping -2% would do.

I'm accepting PRs on to that.

PandaaAgency commented 3 years ago

Hi @valeriansaliou and thanks for your answer. I see your point and I just opened a PR.

Thanks