taxjar / taxjar-node

Sales Tax API Client for Node
https://developers.taxjar.com/api/reference/?javascript
MIT License
54 stars 24 forks source link

Differences between node api and rest api #10

Closed dantedubonc closed 6 years ago

dantedubonc commented 7 years ago

I have an issue when I try to use the Node API and the Rest API because they give me different tax calculations. With Node This is my request:

_this.provider.taxForOrder({
                from_country: ‘US’,
                from_zip: “80120”,
                from_state: “CO”,
                to_country: “US”,
                to_zip: “80001",
                to_state: “CO”,
                amount: 454.97000000000014,
                shipping: “0",
                line_items: [{
                        id: 0,
                        quantity: 1,
                        unit_price: 454.97000000000014
                }],
 }).

And this is my response:

{  
   "tax":{  
      "order_total_amount":454.97,
      "shipping":0,
      "taxable_amount":454.97,
      "amount_to_collect":18.2,
      "rate":0.04,
      "has_nexus":true,
      "freight_taxable":true,
      "tax_source":"modified-origin",
      "breakdown":{  
         "taxable_amount":454.97,
         "tax_collectable":18.2,
         "combined_tax_rate":0.04,
         "state_taxable_amount":454.97,
         "state_tax_rate":0.029,
         "state_tax_collectable":13.19,
         "county_taxable_amount":0,
         "county_tax_rate":0,
         "county_tax_collectable":0,
         "city_taxable_amount":0,
         "city_tax_rate":0,
         "city_tax_collectable":0,
         "special_district_taxable_amount":454.97,
         "special_tax_rate":0.011,
         "special_district_tax_collectable":5,
         "shipping":{  
            "taxable_amount":0,
            "tax_collectable":0,
            "combined_tax_rate":0.04,
            "state_taxable_amount":0,
            "state_sales_tax_rate":0.029,
            "state_amount":0,
            "county_taxable_amount":0,
            "county_tax_rate":0,
            "county_amount":0,
            "city_taxable_amount":0,
            "city_tax_rate":0,
            "city_amount":0,
            "special_taxable_amount":0,
            "special_tax_rate":0.011,
            "special_district_amount":0
         },
         "line_items":[  
            {  
               "id":"0",
               "taxable_amount":454.97,
               "tax_collectable":18.2,
               "combined_tax_rate":0.04,
               "state_taxable_amount":454.97,
               "state_sales_tax_rate":0.029,
               "state_amount":13.19,
               "county_taxable_amount":0,
               "county_tax_rate":0,
               "county_amount":0,
               "city_taxable_amount":0,
               "city_tax_rate":0,
               "city_amount":0,
               "special_district_taxable_amount":454.97,
               "special_tax_rate":0.011,
               "special_district_amount":5
            }
         ]
      }
   }
}

With Rest

This is my Post Request to https://api.taxjar.com/v2/taxes

{
    “to_city”: “Louisville”,
    “to_state”: “CO”,
    “to_zip”: “80001",
    “to_country”: “US”,
    “from_city”: “Littleton”,
    “from_state”: “CO”,
    “from_zip”: “80120",
    “from_country”: “US”,
    “amount”: 454.97000000000014,
    “shipping”: 0,
    “line_items”: [
      {
        “id”: “0”,
        “quantity”: 1,
        “unit_price”: 454.97000000000014
      }
    ]
  }

And this is my response:

{
  “tax”: {
    “order_total_amount”: 454.97,
    “shipping”: 0,
    “taxable_amount”: 454.97,
    “amount_to_collect”: 13.19,
    “rate”: 0.029,
    “has_nexus”: true,
    “freight_taxable”: true,
    “tax_source”: “modified-origin”,
    “breakdown”: {
      “taxable_amount”: 454.97,
      “tax_collectable”: 13.19,
      “combined_tax_rate”: 0.029,
      “state_taxable_amount”: 454.97,
      “state_tax_rate”: 0.029,
      “state_tax_collectable”: 13.19,
      “county_taxable_amount”: 0,
      “county_tax_rate”: 0,
      “county_tax_collectable”: 0,
      “city_taxable_amount”: 0,
      “city_tax_rate”: 0,
      “city_tax_collectable”: 0,
      “special_district_taxable_amount”: 0,
      “special_tax_rate”: 0,
      “special_district_tax_collectable”: 0,
      “shipping”: {
        “taxable_amount”: 0,
        “tax_collectable”: 0,
        “combined_tax_rate”: 0.029,
        “state_taxable_amount”: 0,
        “state_sales_tax_rate”: 0.029,
        “state_amount”: 0,
        “county_taxable_amount”: 0,
        “county_tax_rate”: 0,
        “county_amount”: 0,
        “city_taxable_amount”: 0,
        “city_tax_rate”: 0,
        “city_amount”: 0,
        “special_taxable_amount”: 0,
        “special_tax_rate”: 0,
        “special_district_amount”: 0
      },
      “line_items”: [
        {
          “id”: “0”,
          “taxable_amount”: 454.97,
          “tax_collectable”: 13.19,
          “combined_tax_rate”: 0.029,
          “state_taxable_amount”: 454.97,
          “state_sales_tax_rate”: 0.029,
          “state_amount”: 13.19,
          “county_taxable_amount”: 0,
          “county_tax_rate”: 0,
          “county_amount”: 0,
          “city_taxable_amount”: 0,
          “city_tax_rate”: 0,
          “city_amount”: 0,
          “special_district_taxable_amount”: 0,
          “special_tax_rate”: 0,
          “special_district_amount”: 0
        }
      ]
    }
  }
}

The difference between both responses is:

Why this is happening?

Thanks in advance

fastdivision commented 7 years ago

Hi @dantedubon,

It looks like the REST request is passing "to_city": "Louisville" and the Node request is not. Arvada, CO falls within zip code 80001 and not Louisville, CO. So when you pass Louisville as the city, we're omitting the "retailer's use tax" under the special_ breakdown response attributes and only collecting the CO state rate at 2.9%.

Passing Arvada as the to_city should return the same response as Node. If you're interested, we also have a blog post on address validation APIs.