jazkarta / jazkarta.shop

A web-based shop for Plone
GNU General Public License v2.0
4 stars 2 forks source link

WA Tax lookup error #21

Closed witekdev closed 8 years ago

witekdev commented 8 years ago

Discovered by chance If I supply an invalid address and/or zip for Washington state and select the state as WA I get this:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module jazkarta.shop.browser.checkout, line 44, in __call__
  Module jazkarta.shop.browser.checkout, line 53, in update
  Module jazkarta.shop.cart, line 249, in calculate_taxes
  Module jazkarta.shop.tax.wa_state, line 39, in get_tax_rates
  Module jazkarta.shop.tax.wa_state, line 74, in fetch_rate
  Module decimal, line 548, in __new__
  Module decimal, line 3872, in _raise_error
InvalidOperation: Invalid literal for Decimal: ''

after hitting the "Proceed to payment" button on the shipping view.

Not sure why the WA Tax API doesn't flag this as an error. Test: Street: any street City: Seattle State; WA Zip: 97201 (which is Portland, OR)

davisagli commented 8 years ago

It does flag it, but I guess we aren't detecting that correctly. Will fix when I get a chance.

witekdev commented 8 years ago

ok, might be a good for you to see if you have the same issue on mountaineers if you reused the code?

davisagli commented 8 years ago

Yep, will check whether it's a problem there too or if I just messed something up when moving things around.

davisagli commented 8 years ago

Just checked in a fix so this will return a tax of 0 rather than breaking.

Ideally we would show the user a validation error that their address isn't recognized, but that's not straightforward since the tax calculation is decoupled from the form where they enter their address (tax is calculated when the checkout form loads, not when shipping is selected).