-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Avoid re-creating tax adjustments #1570
Avoid re-creating tax adjustments #1570
Conversation
One potential issue I've spotted is that this has changed the behaviour of an existing tax rate which had an amount and then later became
|
This is done in the interest of having as few special cases as possible. Nothing in our test swite exposed this functionality, and it's probably not a case worth optimizing for.
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.
cbc7062
to
c661c04
Compare
I actually like the 0 amount better then no adjustment at all, there is a difference accounting-wise between 0 amount tax and no tax. |
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Nice work @jhawthorn !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The zero dollar adjustments might start showing up on peoples front ends when they display adjustments to people... but I can't think under what circumstance that would happen so I'm okay with the change.
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 #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.With this change, the speed of an
order.update!
which requires no changes is comparable to before #1479 🎉Comparison of queries run