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

Calculate taxes in OrderContents instead of in a LineItem callback #1463

Merged

Conversation

jordan-brough
Copy link
Contributor

And mark Tax::ItemAdjuster as api-private (to discourage stores &
extensions from calling it outside of the context of
Tax::OrderAdjuster).

This PR may result in a little more load because we're now calling
Tax::OrderAdjuster at some times when previously we would've just
called Tax::ItemAdjuster.

Also, we're now always calling Tax::OrderAdjuster after
OrderContents#update_cart, instead of only when the location changes.

Benefits:

  • It gets rid of an ActiveRecord callback
  • It seems safer to call this in more cases
  • It moves toward performing tax calculations at the order level
    instead of at the line level.

See also #1252

And mark Tax::ItemAdjuster as api-private (to discourage stores &
extensions from calling it outside of the context of
Tax::OrderAdjuster).

This PR may result in a little more load because we're now calling
Tax::OrderAdjuster at some times when previously we would've just
called Tax::ItemAdjuster.

Also, we're now _always_ calling Tax::OrderAdjuster after
OrderContents#update_cart, instead of only when the location changes.

Benefits:
- It gets rid of an ActiveRecord callback
- It seems safer to call this in more cases
- It moves toward performing tax calculations at the order level
instead of at the line level.
@mamhoff
Copy link
Contributor

mamhoff commented Sep 22, 2016

I'm 👍 on this.

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@bbuchalter
Copy link
Contributor

First let me say, the change looks great from a technical level. Always happy to see more red than green. 👍

Wanted to comment on this:

It moves toward performing tax calculations at the order level instead of at the line level.

I'll say one challenge with this is refunds, at least with TaxCloud, because you don't get any line item breakdown of the tax calculation. If a customer makes a partial refund of an order, without line item records of how much tax was collected, it's impossible to create tax-accurate refunds. This topic hasn't yet been broached in #1252, so perhaps that's a better forum for it?

@jordan-brough
Copy link
Contributor Author

without line item records of how much tax was collected

@bbuchalter to be clear -- the idea is still for taxes to be calculated and recorded in Solidus at the line level. But we need the tax calculation to be invoked at the order level (i.e. calculate taxes on all the order's items at the same time). Does that address your concern at all?

@bbuchalter
Copy link
Contributor

Yes, absolutely. Thank you. Will be very interested to see how that is done in a performant way! Thanks for all your work and making the work so visible. ❤️

@bbuchalter
Copy link
Contributor

I'll say one challenge with this is refunds, at least with TaxCloud, because you don't get any line item breakdown of the tax calculation.

This turns out not to be true. For TaxCloud the individual taxes are recorded in the CartItem#amount field. Thanks Jordan for following up on this with me.

Copy link
Contributor

@cbrunsdon cbrunsdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much behind this, great step forward. 👍

@jordan-brough jordan-brough merged commit 2ce184c into solidusio:master Sep 23, 2016
@jordan-brough jordan-brough deleted the tax-invocation-updates branch September 23, 2016 11:08
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

Successfully merging this pull request may close these issues.

4 participants