-
-
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
Support for Colorado Delivery Fee (flat fee and order-level taxes) #4491
Support for Colorado Delivery Fee (flat fee and order-level taxes) #4491
Conversation
Hey @adammathys, it looks nice. How is it going? Do you need any help? |
1c50314
to
ac1faf2
Compare
@waiting-for-dev I haven't had much time to work on this as of late, but I should be able to wrap up the remaining TODO items next week. |
927b48c
to
f160208
Compare
055d51a
to
e9b55d9
Compare
e9b55d9
to
7d2fc19
Compare
@@ -0,0 +1,21 @@ | |||
# frozen_string_literal: true | |||
|
|||
require_dependency 'spree/calculator' |
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.
require_dependency
has been deprecated. Anyway, why do we need it? 🤔
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.
Oh, I see it's also used in the other calculators. I wonder if it can be removed safely. However, feel free to ignore the comment as it's outside this PR's scope.
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.
That's impressive work, @adammathys!
I've tried it locally with the data generated from the new task, and it looks like it applies the Colorado tax twice:
Do you have an idea what might be going on?
Also, do you think it'd be challenging to update the label rendered if somebody sets "show_rate_in_label" to true?
@waiting-for-dev The double render is fixed by my two other PRs in the frontend repos. (solidusio/solidus_starter_frontend#242 and solidusio/solidus_frontend#11) It's a longstanding issue with the code where it'll double render any order-level tax adjustments. I believe it had gone unnoticed until now because we typically didn't have any. I don't think it'd be too difficult to update the label if |
Oh, sorry, I missed that. Thanks for pointing this out.
What do you think of doing it as part of this PR to make the work complete here? Otherwise, we can follow up. BTW, it'd be nice to add information about this change in the CHANGELOG, including the available task. |
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.
👏 great work Adam! I left a question about a possible small change.
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 for the excellent work @adammathys! I left a question but am super in favor of merging this.
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 @adammathys! Approving, I'm fine even without that last comment, but not merging yet.
Very simple calculator that will always return the same amount. Will hopefully be useful for the Colorado Delivery Fee, but might also be usable for different fees that come up.
We unfortunately need to introduce the concept of order-level tax rates to handle the Colorado Delivery fee. (And maybe other similar things?) The simplest solution is to add an enum to our TaxRate model to help distinguish between rates that should be applied on an order-level and our regular item-level taxes. Co-Authored-By: Andrew Stewart <andrew@super.gd>
Updates TaxHelpers#rates_for_item to use our new enum to filter for rates that only apply to items. Co-Authored-By: Andrew Stewart <andrew@super.gd>
Looks for all order-level tax rates and computes order taxes based on the ones matching the order's ship address and tax categories.
Just a simple radio input to help set the value in the admin.
Adds the translation entry for the class and makes a small tweak to the tax rate calculator hint to explain the difference between the two calculators.
Now that this field can be used in two different ways, as a percentage or as a flat amount, we want to ensure the explanation is still helpful for users.
Simple task that can be used to help setup all of the records necessary for calculating the new Colorado Delivery Fee in stores.
Skips the logic for deciding if the "rate" should be shown in the label, since that never makes sense for flat fee tax rates.
7d2fc19
to
d762e2e
Compare
Codecov Report
@@ Coverage Diff @@
## master #4491 +/- ##
==========================================
+ Coverage 85.55% 85.58% +0.02%
==========================================
Files 569 570 +1
Lines 14653 14675 +22
==========================================
+ Hits 12537 12559 +22
Misses 2116 2116
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Thanks, @adammathys, that's great. It would be great to update the Changelog if you have the time, even if in a separate PR. I think this change is worth it. |
❗ TODO
Summary
Add support for the new Colorado Delivery Fee. This is achieved by making two small changes to the existing tax system:
Spree::Calculator::FlatFee
calculator. Can be used to return a fixed amount that comes from an associatedSpree::TaxRate
.Spree::TaxRate#level
enum to distinguish between item- and order-level tax rates. Item-level taxes remain the default, since we very rarely if ever want to use order-level tax rates.These changes in additional to the recent work to support order-level taxes in
Spree::OrderTaxation
(#4477), makes it possible to configure a tax rate for the Colorado Delivery Fee.Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed (
cross them outif they are not):I have attached screenshots to demo visual changes.I have updated the readme to account for my changes.