Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxes no longer calculated (most of the time) after upgrading to Solidus 2.6 + solidus_avatax_certified 3.0.0 #106

Open
joshua-honig opened this issue Oct 10, 2018 · 1 comment

Comments

@joshua-honig
Copy link

I apologize for the vagueness of this, but that's essentially problem: I can't figure out why something isn't happening.

We have an existing production site current running Solidus 1.4 with solidus_avatax_certified v1.1.0. Taxes are recalculated at all the expected times, provided an address is on the order:

  • Whenever an item is added or removed
  • Whenever discounts are applied or removed
  • Whenever the ship address is changed
  • etc...

After a long upgrade process culminating in Solidus 2.6 + solidus_avatax_certified 3.0.0, taxes are no longer being calculated in many of these situations. The most confusing part is that sometimes they are calculated.

It's not a simple Avatax configuration issue. Our license key and account have not changed, and when the solidus_avatax_certified actually calls the Avatax API everything works. I can see the calls via the Avatax logs, specifically tracing to order_decorator.rb#avalara_capture:

def avalara_capture
logger.info "Start avalara_capture for order #{number}"
create_avalara_transaction if avalara_transaction.nil?
line_items.reload
avalara_transaction.commit_avatax('SalesOrder')
end

This method just doesn't get called at all many of the times we expect it to. Sometimes when I proceed from delivery to payment states, avalara_capture fires, sometimes it doesn't. Sometimes when I add or remove a line item avalara_capture fires, sometimes it doesn't.

I can see that new functionality in solidus_avatax_certified introduced since v1.1.0 would explicitly avoid recalculating taxes in cart, address, or delivery state:

module SolidusAvataxCertified
class OrderAdjuster < Spree::Tax::OrderAdjuster
def adjust!
if %w(cart address delivery).include?(order.state)
return (order.line_items + order.shipments)
end
super
end
end
end

# Tax Adjustments are not created or calculated until on payment page.
# 1. We do not want to calculate tax until address is filled in and shipment type has been selected.
# 2. VAT tax adjustments set included on adjustment creation, if the tax initially returns 0, included is set to false causing incorrect calculations.
def can_calculate_tax?(order)
address = order.tax_address
return false unless Spree::Avatax::Config.tax_calculation
return false if %w(address cart delivery).include?(order.state)
return false if address.nil?
return false unless calculable.zone.include?(address)
true
end

...but I don't know if this is actually what is preventing the taxes from being calculated, or whether this is functionality we even want.

So, have others reported similar challenges updating from earlier Solidus and solidus_avatax_certified versions?

In short, I expect taxes to always be recalculated when any applicable change to the order occurs, but observed behavior is that they are only calculated sporadically.

@aserafin
Copy link

aserafin commented Feb 7, 2019

@joshua-honig did you figure out the root cause? I'm seeing similar issues with tax calculation not being triggered in some situations and working fine in others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants