Fix a broken caching strategy - #7
Open
rymai wants to merge 4 commits into
Open
Conversation
rymai
commented
Oct 5, 2018
rymai
commented
Oct 5, 2018
| # the taxjar_line_item is a hash of the API response | ||
| # the line_item is the Spree::LineItem object | ||
| line_item = Spree::LineItem.find(taxjar_line_item.id) | ||
| res = taxjar_line_item.tax_collectable |
Author
There was a problem hiding this comment.
This is where we would always use the last item's tax amount.
Previously, only the tax amount for the last line item would be used to calculate the taxes for an order. For instance if I had an item with a tax of 0.5 and an item with a tax of 1.2. The total tax would have been 2 * 1.2. Now, we cache the whole TaxJar response and properly pick the correct tax amount for each item. The cache key for the TaxJar response should make sure that any update to the items, address, or shipping will result in a new cache key, and thus an new TaxJar call to fetch up-to-date amounts. Signed-off-by: Rémy Coutable <remy@rymai.me>
rymai
force-pushed
the
rymai/1-3-stable/lineitem-discounts-fixes3
branch
from
October 5, 2018 15:58
19f5923 to
1792604
Compare
Signed-off-by: Rémy Coutable <remy@rymai.me>
Signed-off-by: Rémy Coutable <remy@rymai.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.