-
-
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
WIP remove Spree::Zone.default_tax and associated code paths #1537
Conversation
08fa704
to
105cf76
Compare
105cf76
to
e858943
Compare
Previously, Spree and Solidus had code paths for tax reimbursements: If an orders tax address was outside the "default tax zone" and value added tax applied from that default tax zone, Solidus would create negative tax adjustments, i.e. Reimbursements. Since Solidus 1.3, the taxation system has been overhauled and we do not need this hack anymore.
e858943
to
b27de36
Compare
Spree::Zone.match suffers of several shortcomings: 1. It's badly named. What's matching? 2. It returns arbitrary results (why does smaller match more?) 3. It's expensive database-wise. 4. It's only used in now deprecated `Spree::Order.tax_zone`. This commit deprecates it, too.
This method checks whether a zone is wholly contained in another zone. Since zones should really be used as auxiliary constructs for finding out which shipping methods or tax rates apply to a particular address, comparing zones to zones is unnecessary.
33b4cec
to
7ca8081
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.
Although I know that this code is dead and we've done a lot to prevent errors. But still I'm anxious to delete so much code (especially money related code).
Maybe we just should deprecate another round and remove this in 3.0 instead?
WDYT?
In versions prior to Solidus 1.3, instead of changing prices for | ||
different VAT territories, there was an assumption that backend | ||
prices would include VAT, and the tax system was tasked with "refunding" that. This has since been changed so we could now delete a lot of code paths that performed these "refunds". | ||
|
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 think it should be enough the link to the 1.3 blog post.
@@ -227,7 +227,7 @@ def backordered? | |||
# Returns the relevant zone (if any) to be used for taxation purposes. | |||
# Uses default tax zone unless there is a specific match |
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.
Please remove this outdated comment
@@ -42,13 +41,17 @@ class Zone < Spree::Base | |||
self.whitelisted_ransackable_attributes = ['description'] | |||
|
|||
def self.default_tax | |||
where(default_tax: true).first | |||
Spree::Deprecation.warn("There is no default tax zone anymore.", caller) | |||
all.detect { |zone| zone.try(:default_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.
If the column is gone, there is no need for this anymore, right? Maybe we should keep the column for at least one minor version instead?
if Spree::Zone.where(default_tax: true).any? | ||
raise DefaultTaxZonePresent, "Please run the the solidus:migrations:create_vat_prices rake task." | ||
end | ||
remove_column :spree_zones, :default_tax, :boolean, default: false |
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.
Maybe we keep the column for another round?
# Returns the most specific matching zone for an address. Specific means: | ||
# A State zone wins over a country zone, and a zone with few members wins | ||
# over one with many members. If there is no match, returns nil. | ||
def self.match(address) | ||
Spree::Deprecation.warn("Spree::Zone.match is deprecated. Please use Spree::Zone.for_adress instead.", caller) |
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.
small typo. should be Spree::Zone.for_address
public API does not change right? This cleans up so nicely :) I really like it. That being said, I think these kind of changes should be introduced very defensively. |
Closing in favour of #1586 . |
Previously, Spree and Solidus had code paths for tax reimbursements:
If an orders tax address was outside the "default tax zone" and value added tax
applied from that default tax zone, Solidus would create negative tax
adjustments, i.e. Reimbursements. Since Solidus 1.3, the taxation system
has been overhauled and we do not need this hack anymore. Taking it out is
roughly this commit. It can (and should) be broken up into smaller commits,
and we need to come up with a good deprecation plan for many of these methods.