-
-
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
TaxRate M-M TaxCategory #1851
TaxRate M-M TaxCategory #1851
Conversation
@@ -4,7 +4,10 @@ class TaxCategory < Spree::Base | |||
validates :name, presence: true | |||
validates_uniqueness_of :name, unless: :deleted_at | |||
|
|||
has_many :tax_rates, dependent: :destroy, inverse_of: :tax_category | |||
|
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.
Extra blank line detected.
@@ -4,7 +4,10 @@ class TaxCategory < Spree::Base | |||
validates :name, presence: true | |||
validates_uniqueness_of :name, unless: :deleted_at | |||
|
|||
has_many :tax_rates, dependent: :destroy, inverse_of: :tax_category | |||
|
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.
Extra blank line detected.
c3babf9
to
d8bb9e9
Compare
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.
This looks like a great improvement. One thing though: Would you mind moving the spec changes to be the first commit, mark them as pending
, and re-enable them once you're done with the refactoring? We want to make sure every single commit passes CI, and the way the commits are organized here they won't, unfortunately.
Also, please have a look at Chris Beams guide on commit messages. Some of your commit messages have very long headings, and almost none give any background as to why you did the change.
<td class="align-center"><%=tax_rate.tax_category.try(:name) || Spree.t(:not_available) %></td> | ||
<td class="align-center"> | ||
<% if tax_rate.tax_categories.any? %> | ||
<%= tax_rate.tax_categories.map(&:name).join(", ") %> |
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.
Here, you might want to use an internationalized separator, as not all locales will work with a comma separated list. Most will though, so I won't insist. :)
9487529
to
3293845
Compare
3293845
to
bdc504a
Compare
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.
Looking great! Left a couple minor comments.
TaxRate.find_each do |tax_rate| | ||
tax_category_ids = TaxRateTaxCategory.where(tax_rate_id: tax_rate.id).pluck(:tax_category_id) | ||
|
||
if tax_category_ids.count == 1 |
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.
Nitpick: Don't need this if
right? The logic in the else
would handle it?
@@ -4,7 +4,9 @@ class TaxCategory < Spree::Base | |||
validates :name, presence: true | |||
validates_uniqueness_of :name, unless: :deleted_at | |||
|
|||
has_many :tax_rates, dependent: :destroy, inverse_of: :tax_category | |||
has_many :tax_rate_tax_categories, class_name: Spree::TaxRateTaxCategory, dependent: :destroy |
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.
Since inverse_of
is currently broken in Solidus it's probably worth adding it to these since we're starting fresh with them?
bdc504a
to
877bd25
Compare
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.
👍 assuming specs are green
877bd25
to
a2f5206
Compare
9c6b3cb
to
9337dcc
Compare
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.
Good work! Thanks for addressing my feedback :)
solidusio#1851 will change the type of relation to a many to many so specs will temporarily need to be skipped until changes are made to the specs.
Implements solidusio#1836 The current relation between TaxRate and TaxCategory can lead to unnecessary tax rates if a store has multiple tax categories and if it supports countries (such as Australia) that have a standard tax rate. This means that for each TaxCategory, the store will have an extra tax rate even if the percent is the same. By transforming this relation to a M-M we can allow stores to create tax rates that have multiple tax categories.
Specs have been disabled until changes to the relation between TaxRate and TaxCategory have been updated.
7a66fff
to
8033843
Compare
solidusio#1851 will change the type of relation to a many to many so specs will temporarily need to be skipped until changes are made to the specs.
solidusio#1851 will change the type of relation to a many to many so specs will temporarily need to be skipped until changes are made to the specs.
solidusio#1851 will change the type of relation to a many to many so specs will temporarily need to be skipped until changes are made to the specs.
Related to issue #1836
tax_rate.tax_category_id
.tax_categories: []