-
-
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
Remove tax refunds #2196
Remove tax refunds #2196
Conversation
55603b8
to
5318a36
Compare
I'm really curious, what's a "Franken-adjustment"? I couldn't find that term on Google (but lots of references to American Senator Al Franken and tax reform). Is than an accounting term? Or do you just mean like "frankenstein," like a "big messy thing?" |
jasonfb: It's a reference to Frankenstein the movie, and yeah, it's a messy thing. It's an |
Since Solidus 1.3, these code paths are not touched anymore. They can safely be deleted.
5318a36
to
083545e
Compare
@@ -16,7 +16,6 @@ def compute_order(order) | |||
line_items_total = matched_line_items.sum(&:discounted_amount) | |||
if rate.included_in_price | |||
order_tax_amount = round_to_two_places(line_items_total - ( line_items_total / (1 + rate.amount) ) ) | |||
refund_if_necessary(order_tax_amount, order.tax_address) |
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.
Is this going to do the right thing with this removed? If so, the assignment on the previous line should be removed to make it more obvious that it is just being returned.
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.
Yeah, it will. And also, yes the assignment is unnecessary. I'm not sure we need to ship this entire method any longer, either, as it we don't do taxation on orders since Spree 2.2.
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.
Amended!
083545e
to
4c8dc43
Compare
end | ||
|
||
(rates_for_order(order) + default_rates_with_unmatched_tax_category).uniq | ||
rates_for_order(order) |
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.
Could we reduce the number of methods here or are these semi-public interfaces? In terms of private
, but widely used by extensions/shops?
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.
We can reduce them. I chose to keep applicable_rates
, because that's what's being used in calculators, and remove rates_for_order
. Thank you!
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.
Thanks, but I think we can remove even more.
applicable_rates
is never called outside of this helper. The calculators only use rates_for_item
.
If we also move sum_of_included_tax_rates
into Spree::Calculator::DefaultTax
(the only place where this is called) we can reduce the module to:
module Spree
module Tax
module TaxHelpers
private
def rates_for_item(item)
rates = Spree::TaxRate.for_address(item.order.tax_address)
rates.select do |rate|
rate.tax_categories.map(&:id).include?(item.tax_category_id)
end
end
end
end
end
WDYT?
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.
And maybe we should rename the method to something meaningful then
tax_rates_for(item)
maybe?
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 did not realize the module is only called via rates_for_item
by now, good catch! However, I did not change the name of the method. While it's not grammatically perfect, it conveys what the method does, and this way I don't have to change the calling code.
I kept the ivar caching, but removed the two superfluous methods.
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.
Perfect! Thanks
This code has not been in use since Solidus 1.3. It can safely be deleted.
We don't create shipping rate taxes with negative amounts any longer.
This method has not been used since Solidus 1.3. It's been deprecated long enough and can safely be deleted.
…ntains? All of these methods have not been in use since Solidus 1.3. They can safely be deleted.
No new tax refunds can be created since Solidus 1.4, and the strings generated here are by now stored in the database.
This commit has not been relevant since Solidus 1.3
This column has been empty since Solidus 1.3.
4c8dc43
to
bfc0412
Compare
We only call Spree::Tax::TaxHelpers#rates_for_item from multiple places, so this commit reduces the module to one private method. I chose to keep the instance variable caching to reduce database requests.
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.
Looks good to me, looks like all the code removed isn't anything we'd ever want people to run. (aka the old tax system)
This takes inspiration from #2194 - if we can remove that migratory task because we assume people have run it when they were on 1.3 or 1.4, we must also be able to remove all the code paths around tax "refunds" that are only run when a default tax zone is present.
For a bit of background: In versions of Solidus pre-1.3, a "default tax zone" existed. If that zone had a VAT-style tax rate, all prices in the system were assumed to include VAT, making it necessary to refund that via a Franken-adjustment.
We have sinced moved to a system where we have country-dependent prices, and the default tax zone doesn't exist anymore or mean anything.
I'll rebase on master once #2194 is merged.