-
-
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
TaxHelpers#rates_for_item now respects the validity period of tax rates #3768
TaxHelpers#rates_for_item now respects the validity period of tax rates #3768
Conversation
As suggested in #3766, I have opened a PR and moved the change to the I am currently still unsure about two things:
I'm very open for suggestions and improvements. |
@jugglinghobo thanks for this! Answers to your concerns below:
Yes, I think it would be useful. 🙂 Feel free to do it in this PR!
Yes, I think the test for this should be on the |
@aldesantis @jugglinghobo I think this is actually a pretty important fix functionality-wise. I appreciate wanting to have very good specs that respect all the things, and maybe also a scope, but can we make issues for that and get this in? I'm seeing clients write workarounds in their exporter code for tax advisors because this doesn't work. I'd also be happy to take this over if necessary. (cc @tvdeyen @mntmn). |
@mamhoff @aldesantis I'm sorry this fell off my radar. If you can wait, I'll try to finish this tonight or tomorrow. If you don't hear back until sunday or if you need a solution quicker, feel free to take over, and if you leave out anything (e.g. scope), feel free to assign an issue to me or whatever you'd like. Does that work for you, or would you like me to do anything else? This is my first solidus / open source contribution. |
@jugglinghobo even if this was merged today, it still wouldn't be available until the next Solidus release, so tonight/tomorrow works perfectly. Thanks for your help on this one! |
I just didn't want this to sit for another couple of weeks. If you're on it, great! 👍 |
TaxHelpers#rates_for_item considers the validity period of tax rates and only returns tax rates that are currently valid. * Added specs for TaxHelpers#rates_for_item * Removed specs from DefaultTaxCalculator spec because they don't belong there
* remove trailing whitespace * remove extra line at beginning of block
This scope returns all tax rates that are currently active according to their start date and expiry date, i.e. if the current time is after the start date and before the expiry date.
* add space between brackets
As discussed I've added a spec for Please suggest improvements and advise on how to proceed. I didn't squash yet because I thought maybe you'd like to add the scope in a separate PR. PS: AFAICT there are no specs for |
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.
@jugglinghobo thanks, the tests are okay except for one minor thing. After that, GTM!
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 great, thanks so much! 🙏
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.
Nicely done!
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!
Thank you guys! |
Description
When calculating the tax for line items whose tax is included in the price, solidus uses TaxRates in the calculation even though they are invalid according to their start_date and/or end_date. This results in incorrect tax calculations if there are multiple tax rates for the same tax category and only some of them are currently valid.
This PR ensures that
TaxHelpers#rates_for_item
only returns tax rates that are currently valid. Before, it would return any tax rate that matched the items' tax category.This addresses #3766
Checklist: