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
299 stars 45 forks source link

Tax details are generated for regions in Spain with tax exemptions. #35

Closed lfalck closed 3 years ago

lfalck commented 3 years ago

Hi, great project! 🙂

I think i found an issue. For regions in Spain with tax exemption, rate and total are correctly calculated, but the tax details still contain the country tax:

SalesTax.getAmountWithSalesTax("ES", "GC", 1000.00)
  .then((amountWithTax) => {
    console.log(amountWithTax);
  });
{
    type: 'vat',
    rate: 0,
    price: 1000,
    total: 1000,
    area: 'worldwide',
    exchange: 'consumer',
    charge: {
        direct: true,
        reverse: false
    },
    details: [{
            type: 'vat',
            rate: 0.21,
            amount: 210
        }
    ]
}
valeriansaliou commented 3 years ago

Hello there!

Given that the area returned is worldwide, you may not have set your legal tax origin (ie. your company location), thus VATMOSS is not being applied in calculations.

See: https://github.com/valeriansaliou/node-sales-tax#white_check_mark-specify-the-country-you-charge-from

lfalck commented 3 years ago

Ah sorry, I should have done that in the example. Results are the same though:

SalesTax.setTaxOriginCountry("FR");

SalesTax.getAmountWithSalesTax("ES", "GC", 1000.00)
  .then((amountWithTax) => {
    console.log(amountWithTax);
  });
{
    type: 'vat',
    rate: 0,
    price: 1000,
    total: 1000,
    area: 'regional',
    exchange: 'consumer',
    charge: {
        direct: true,
        reverse: false
    },
    details: [{
            type: 'vat',
            rate: 0.21,
            amount: 210
        }
    ]
}