jetsgit / spree_tax_cloud

Spree Interface for TaxCloud SOAP API
19 stars 32 forks source link

Old sales tax persists when cart changes #49

Closed brchristian closed 10 years ago

brchristian commented 10 years ago

When I put one item in my cart and go down the checkout flow, on the way to the payment step, I see the correct tax being applied.

When I go back to the cart page and update the contents of my cart, Spree throws out the old shipping charges but spree_tax_cloud doesn't throw out the old sales tax charges. Thus I have an odd situation where I've got many more items in my cart but am seeing, on the cart page, outdated tax.

Furthermore, it appears that going down the checkout funnel again will trigger a TaxCloud lookup event, which returns an updated tax figure, but it does not actually update the tax adjustment for the order.

brchristian commented 10 years ago

Looking into this further, it appears that the problem is happening at https://github.com/jetsgit/spree_tax_cloud/blob/2-0-stable/app/models/spree/order_decorator.rb#L15

Here we can see that if there's already a tax_cloud_transaction, it calls lookup but does nothing with that information.

@jetsgit My suggestion here would be that lookup_tax_cloud consistently function as follows:

  1. Destroy any existing TaxCloud adjustments
  2. Lookup the rate for the items
  3. Create a new adjustment based on the rates retrieved

Also, any change to the contents of the cart should destroy tax-related adjustments (as it does to shipping-related adjustments)

If this sounds good to you, I can craft a PR.

jetsgit commented 10 years ago

@brchristian, believe that is in accordance with our discussion. Please submit a PR, or if you feel you have enough on your plate you can pass it back to me.

brchristian commented 10 years ago

@jetsgit You're right, this should iron out given our upcoming work with @bbuchalter. I'll see if I can make progress on this one!

jetsgit commented 10 years ago

working in 2-2-stable