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

Avoid duplicate queries when running estimator taxation. #2219

Merged
merged 1 commit into from
Oct 4, 2017

Conversation

jhawthorn
Copy link
Contributor

@jhawthorn jhawthorn commented Sep 12, 2017

Fix for #2204

Instead of loading the tax rates for the order for each rate which needs taxing, we can perform the SQL queries only once.

This is done by building a single instance of the shipping_rate_tax_calculator_class for a shipment, and calling calculate on that object for each rate, allowing it to cache the order rates.

This removes the shipping_rate_taxer_class config option, which was necessary to use shipping_rate_tax_calculator_class directly from the estimator.

I'm not sure this is the best way to achieve this, but I hope it illustrates the issue and one solution to it.

Instead of loading the tax rates for the order for each rate which needs
taxing, we can perform the SQL queries only once.

This is done by building a single instance of the
shipping_rate_tax_calculator_class for a shipment, and calling
`calculate` on that object for each rate, allowing it to cache the order
rates.
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.

Looks good to me. Nice and simple solution.

Copy link
Member

@adammathys adammathys 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 changed the title [RFC] Avoid duplicate queries when running estimator taxation. Avoid duplicate queries when running estimator taxation. Oct 4, 2017
@gmacdougall gmacdougall merged commit 909f2a1 into solidusio:master Oct 4, 2017
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