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

Add Tax extension point and merge tax updating code #1479

Merged
merged 5 commits into from
Oct 31, 2016

Conversation

jordan-brough
Copy link
Contributor

@jordan-brough jordan-brough commented Sep 28, 2016

To allow easier customization of tax calculation in extensions or
applications.

This should resolve (or get a lot closer to resolving) #1252.

See individual commits.

There is a possible performance hit here, as I've merged two sections of tax updating code, and used the more encompassing method in both places, and the more encompassing method is heavier weight. We could look into optimizing that code if we think we need to. (I've discussed some ideas with the core team around adding a sort of caching, though it's always scary to add caching.)

Previously we had two different sets of tax updating code.  One was
Order#create_tax_charge! and the other was the code in OrderUpdater.
The effect of the former encompasses the effect of the latter, so
functionally we can merge these.

This may result in increased load since we're now using the more
encompassing method which was more heavyweight.
We had several specs that manually created tax adjustments rather than
setting up a real tax rate to be applied to the order.  This fixes
that.
To allow easier customization of tax calculation in extensions or
applications.
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.

👍

@jhawthorn jhawthorn self-assigned this Oct 26, 2016
@jhawthorn jhawthorn force-pushed the tax-extension-point branch from 0b71211 to b3c81cc Compare October 31, 2016 22:06
@jhawthorn jhawthorn merged commit 4dd6680 into solidusio:master Oct 31, 2016
jhawthorn added a commit to jhawthorn/solidus that referenced this pull request Oct 31, 2016
As of solidusio#1479 we are doing more work inside of OrderUpdater. We're
doing additions and deletions of tax adjustments, which also causes more
touching of records.

This is all made faster by wrapping the entire update in a transaction.
All the writes can be queued together by the DB, and as of rails 5,
dependent touching is grouped together to the end of the transaction.
@jordan-brough jordan-brough deleted the tax-extension-point branch November 1, 2016 12:53
jhawthorn added a commit to jhawthorn/solidus that referenced this pull request Nov 7, 2016
Previously, ItemAdjuster#adjust! would always destroy all tax
adjustments on the item and recreate them. This was unnecessarily slow
in the common case of needing no changes (especially following solidusio#1479).

This changes ItemAdjuster#adjust! to instead update the adjustment for
a rate if it already exists, create adjustments if they are missing for
a matching rate, and destroy adjustments for rates which are no longer
matching.
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.

3 participants