valeriansaliou/node-sales-tax

I get incorrect responses back, any idea why?

stijnvanlieshout opened this issue · 5 comments

Hi there,
I just installed this package and am sure it will help me a lot in handling VAT.

The problem I'm encountering is that the responses I get back are incorrect. I do exactly as instructed in the docs. Any idea why I'm getting invalid responses back?

Example from the documentation:

SalesTax.setTaxOriginCountry("FR")
SalesTax.getSalesTax("FR", null, "FR50833085806")
  .then((tax) => {
       console.log("tax", tax)
  });`

Expected response:

   {
        type     : "vat",
        rate     : 20.00,
        area     : "national",
        exchange : "business",

        charge   : {
          direct  : true,
          reverse : false
        }
   }

Actual response:
Screenshot 2020-01-07 at 10 42 36

Hello!

Can you try it this way:

SalesTax.setTaxOriginCountry("FR", false);

SalesTax.toggleEnabledTaxNumberValidation(false);
SalesTax.toggleEnabledTaxNumberFraudCheck(false);

And then:

SalesTax.getSalesTax("FR", null, "FR50833085806");

I just tried that but the result remains the same:

Screenshot 2020-01-07 at 11 32 46

I get this result regardless of the origin country/sales tax country arguments I feed in. So the result is the same for:

SalesTax.setTaxOriginCountry("IT", false);
SalesTax.getSalesTax("NL", null, null)

I just tested, and I'm not encountering any issue:

{
  "dependencies": {
    "sales-tax": "latest"
  }
}
var SalesTax = require("sales-tax");

console.log("Testing Sales Tax...");

SalesTax.setTaxOriginCountry("FR");

SalesTax.getSalesTax("FR", null, "FR50833085806")
  .then((tax) => {
    console.log("Done testing Sales Tax:", tax);
  });

Result in console:

Testing Sales Tax...
Done testing Sales Tax: { type: 'vat',
  rate: 0.2,
  area: 'national',
  exchange: 'business',
  charge: { direct: true, reverse: false } }

I just also made a create react app project, installed it there, and then it also works just fine for me.
Seems like something is going wrong in the build process for the other app... I will have a look and see if can solve it. Thanks for the help!

FYI: I've created an issue in the fusebox repo (the bundler that I use): fuse-box/fuse-box#1745.

EDIT: The resolution to the issue is in the ticket above. You can close this one.