Skip to content
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 TaxRate.match #536

Closed
wants to merge 4 commits into from
Closed

WIP: Remove TaxRate.match #536

wants to merge 4 commits into from

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Nov 24, 2015

This builds upon #530, and will remove two methods from TaxRate: TaxRate.match as well as TaxRate#potentially_applicable. I'm pushing already to get CI builds.

For now, I have not added any new functionality to Solidus' taxation system, it's more a Housekeeping thing to build on: Less terse code that is hard to reason about.

The other big upside of this PR is that the tests for VAT taxation where partly expecting the wrong things. I added new tests and ported those from the old tests that weren't covered, eventually allowing me to delete part of the old tests (which were ALSO very hard to understand).

Ready for review. (Maybe do #530 first, and then I rebase, though - less lines).

@mamhoff mamhoff changed the title WIP Remove TaxRate.match Remove TaxRate.match Dec 2, 2015
@mamhoff mamhoff mentioned this pull request Jan 4, 2016
@cbrunsdon
Copy link
Contributor

I poked @mamhoff in slack and the first thing we're going to try with this PR (which we all know is very scary) is try and pull out the general "spec improvement" commits from any serious change here.

The PR itself is so massive anything we can do to reduce noise would go a long way.

@mamhoff mamhoff mentioned this pull request Jan 5, 2016
This class method returns all those zones that have at least one member
in common (even via a state that is part of a country).
Both Spree::Zone.match and Spree::Zone.with_shared_members employ almost
the same SQL for doing what they need to do. Moved into a named scope to
reduce understanding effort.

Improve documentation, follow Rubocop recommendations
A scope that yields all tax rates that are valid for a particular zone.
This is intended to replace `Spree::TaxRate.match` in its entirety. I've
also refactored the specs for better readability and reduced scope of
the method.
@mamhoff mamhoff changed the title Remove TaxRate.match WIP: Remove TaxRate.match Jan 12, 2016
@mamhoff
Copy link
Contributor Author

mamhoff commented Jan 12, 2016

Rebased on current master in order to remove some noise. Still not yet ready for prime time as I'm waiting on comments regarding #685.

This looks like a very large commit, but it actually mostly removes lines.

The goal is to make somewhat more understandable what's currently going on in the Solidus
codebase: What rates apply to my order's zone? Those which have shared members with my zone.
When is there a refund? Whenever the store is sending stuff to a place outside the default zone
that does not have included taxes.

The refactoring now implies that a zone have members to be applicable. In the real world, that is
always the case.

There is an expectation for a negative included tax in the reimbursement tax calculator. That
expectation is IMO bogus, I have no idea why it should be there.
@mamhoff
Copy link
Contributor Author

mamhoff commented Jan 20, 2016

I'm also closing this one in favor of #685, which when integrated with #530 does everything done here in a much nicer way.

@mamhoff mamhoff closed this Jan 20, 2016
@mamhoff mamhoff deleted the remove-tax-rate-match branch May 24, 2016 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants