Skip to content

Move the strange refunding logic from Spree::TaxRate into the default tax calculator#980

Merged
gmacdougall merged 3 commits intomasterfrom
unknown repository
Apr 5, 2016
Merged

Move the strange refunding logic from Spree::TaxRate into the default tax calculator#980
gmacdougall merged 3 commits intomasterfrom
unknown repository

Conversation

@mamhoff
Copy link
Copy Markdown
Contributor

@mamhoff mamhoff commented Mar 11, 2016

When reviewing #904, we realized that we can not change the logic of
Spree::TaxRate#compute_amount if we want the migration included there to
always to the right thing. Because that method modifies the tax amount of things,
it should actually be in a calculator. I now moved that logic to the default tax
calculator, with the intention of deprecating use of that calculator entirely.

There is code for pre-Spree-2.2 order-based taxation in there, as well as code for
generating tax refunds, which in the future we won't need either.

@mamhoff mamhoff changed the title Move the strange refunding logic from into the default tax calculator Move the strange refunding logic from Spree::TaxRate into the default tax calculator Mar 11, 2016
@gmacdougall
Copy link
Copy Markdown
Member

I'd like to see the unit tests for default_tax.rb improved, covering the new functionality and providing better tests for the existing logic.

We also need to make the default_tax handle currencies that do not have two decimal places, but I'm fine with leaving that for another PR.

@mamhoff
Copy link
Copy Markdown
Contributor Author

mamhoff commented Mar 11, 2016

Currencies with more than two decimal places are not supported at all in Solidus, I think that's an entirely different issue. And yeah, I'll provide unit tests for default tax.

@gmacdougall
Copy link
Copy Markdown
Member

I was thinking more currencies without decimal places like JPY or KRW which are generally supported, aside from some bad rounding logic here and there.

@mamhoff
Copy link
Copy Markdown
Contributor Author

mamhoff commented Mar 11, 2016

Ha. Yeah, I hear you.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the first parameter one step more than the start of the previous line.

@mamhoff
Copy link
Copy Markdown
Contributor Author

mamhoff commented Mar 14, 2016

Refactored the specs and added specs for some of the refunding logic @gmacdougall

@mamhoff
Copy link
Copy Markdown
Contributor Author

mamhoff commented Mar 14, 2016

The failing spec on 6990e65 is due to a PhantomJS crash, I'm quite sure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like stubbing methods on the file that we're writing the spec for. I don't think that this test provides value.

@mamhoff mamhoff mentioned this pull request Mar 16, 2016
23 tasks
mamhoff added 2 commits March 17, 2016 10:37
When reviewing #904, we realized that we can not change the logic of
Spree::TaxRate#compute_amount if we want the migration included there to
always to the right thing. Because that method modifies the tax amount of things,
it should actually be in a calculator. I now moved that logic to the default tax
calculator, with the intention of deprecating use of that calculator entirely.

There is code for pre-Spree-2.2 order-based taxation in there, as well as code for
generating tax refunds, which in the future we won't need either.
This improves the default tax calculator spec in the following ways:

- Remove the number of `let!` calls so that the specs do not leak into
each other and do not create unnecessary objects.

- Reorder specs so that they make some more sense.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line detected.

Previously, there was no specs for when to refund VATs.

This adds a spec for turning a VAT into a discount when the
order's tax zone has nothing in common with the default or rates VAT zone.

Furthermore, this breaks out the specs for how to tax a taxable item
into a `shared_examples_for` block and tests it with line items,
shipments and shipping rates.
@mamhoff
Copy link
Copy Markdown
Contributor Author

mamhoff commented Mar 17, 2016

Rebased and added specs for the actual behaviour of the calculator when called with line item, shipment or shipping rate. I think this is good to go now. @gmacdougall @jhawthorn

@adammathys
Copy link
Copy Markdown
Member

👍 Looks good to me.

@mamhoff
Copy link
Copy Markdown
Contributor Author

mamhoff commented Mar 23, 2016

@gmacdougall If you have a minute, this should be good to go.

@mamhoff
Copy link
Copy Markdown
Contributor Author

mamhoff commented Mar 31, 2016

Please please review this, it's base work for #904, which is also ripe.

@jhawthorn
Copy link
Copy Markdown
Contributor

👍 Looks good to me

@gmacdougall
Copy link
Copy Markdown
Member

👍

@gmacdougall gmacdougall merged commit 53d4358 into solidusio:master Apr 5, 2016
@mamhoff mamhoff deleted the move-tax-refunds-to-legacy-tax-calculator branch May 24, 2016 19:46
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.

5 participants