-
-
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
Make the default pricer country-aware #1125
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ca59cfe
Add country_iso relation to prices
mamhoff 02d2e69
Add reverse association Country#prices
mamhoff 223b3ed
Add Spree::Tax::TaxLocation.country
mamhoff 272a186
Add country_iso attribute to default pricing options
mamhoff ec7683c
Add country iso to pricing options factory .from_line_item
mamhoff 2f10a22
Add country_iso to pricing options factory .from_price
mamhoff 5343b53
Remove Default Rate Validator
mamhoff e04b076
Add Spree::Price#net_amount
mamhoff ca8324b
Migrate prices for default VAT zone to country-specific prices
mamhoff 99815f1
Add specs for not creating existing prices
mamhoff 1237156
Create all necessary prices for a variant before validation
mamhoff 8266182
Add upgrade task for country-dependent prices
mamhoff c2aa4b3
Add Comments to PriceMigrator
mamhoff 203c5dc
Add comments to PriceGenerator
mamhoff 513d8a9
Add comments for Variant pricer
mamhoff f76ee2f
Add comments for Variant pricing options
mamhoff 12a9d01
Add a for_country scope to TaxRate
mamhoff ec72bca
Variant: Move price setters to before_validation
mamhoff 7b7a819
Add country fields to admin pricing interface
mamhoff 192a056
Rename PriceGenerator to VatPriceGenerator
mamhoff 26e751d
Improve UX on the prices overview page
mamhoff 87d40b9
Only run the VatPriceGenerator when absolutely necessary
mamhoff 2b16884
Allow setting a product's tax category on creation
mamhoff 9af171f
Remove n+1 price query from product lists
mamhoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
12 changes: 12 additions & 0 deletions
12
backend/app/views/spree/admin/shared/_rebuild_vat_prices_checkbox.html.erb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div data-hook="admin_<%= model_name %>_form_generate_vat_prices" class="<%= wrapper_class %> checkbox"> | ||
<%= form.label :rebuild_vat_prices do %> | ||
<%= form.check_box :rebuild_vat_prices, checked: form.object.prices.size <= 1 %> | ||
<%= Spree::Variant.human_attribute_name(:rebuild_vat_prices) %> | ||
<% end %> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
$('#<%= model_name %>_price').on('change', function(e) { | ||
$('#<%= model_name %>_rebuild_vat_prices').prop('checked', true); | ||
}); | ||
</script> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Should we consider memoizing this?
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.
I wouldn't do it. The
Spree::Tax::TaxLocation
is usually a pretty throwaway object. The big reason why we need this method is that countries are referenced by ID rather that ISO code (in which case I could just use that and not use a DB lookup).Also: This query can return
nil
, in which case memoizing won't help.