-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
[Vouchers] Flat rate of any amount #10761
[Vouchers] Flat rate of any amount #10761
Conversation
e6b77fb
to
b8d25de
Compare
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.
Nice work!
@@ -0,0 +1,5 @@ | |||
class AddAmountToVouchers < ActiveRecord::Migration[7.0] | |||
def change | |||
add_column :vouchers, :amount, :decimal, precision: 10, scale: 2, null: false, default: 0 |
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.
Hm, the default is 0
but the Rails validation requires it to be greater than that. It's contradictory but I don't have any better ideas either. 🤷
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 a default necessary? If an amount isn't provided, then we want an error to be thrown don't we?
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 think you are right, my thinking was a voucher with an amount 0 is probably not a big problem, the worse than can happen is you apply a voucher that won't change the order amount..
4e0e0c6
to
08927e6
Compare
New commit start here : 2da76b2 |
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. Thank you for addressing it all.
I noticed that I get weird results in db/schema.rb on master as well. I think that something must have gotten wrong when merging. I'll open a PR to correct master.
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 think this is fine as-is, but have a few comments to potentially improve.
.checkout-input | ||
%span.formError.standalone | ||
= t("split_checkout.step2.voucher.warning_forfeit_remaining_amount") | ||
- else | ||
= text_field_tag "[order][voucher_code]", params.dig(:order, :voucher_code), data: { action: "input->toggle-button-disabled#inputIsChanged", }, placeholder: t("split_checkout.step2.voucher.placeholder") , class: "voucher" | ||
= submit_tag t("split_checkout.step2.voucher.apply"), name: "apply_voucher", disabled: true, class: "button cancel voucher", "data-disable-with": false, data: { "toggle-button-disabled-target": "button" } | ||
= submit_tag t("split_checkout.step2.voucher.apply"), name: "apply_voucher", disabled: true, class: "button cancel voucher", "data-disable-with": false, data: { "toggle-button-disabled-target": "button" } |
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.
Oops, a couple of spaces were added at end of line here.
@@ -0,0 +1,5 @@ | |||
class AddAmountToVouchers < ActiveRecord::Migration[7.0] | |||
def change | |||
add_column :vouchers, :amount, :decimal, precision: 10, scale: 2, null: false, default: 0 |
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 a default necessary? If an amount isn't provided, then we want an error to be thrown don't we?
This will need to be rebased on https://github.com/rioug/openfoodnetwork/tree/10432-vouchers-bare-minimum-checkout (or master if 10432-vouchers-bare-minimum-checkout has been merged) |
Change value to amount to be more consistent
As vouchers are getting more complicated, it makes sense to use a factory to simplify writing test.
It should have already been the case...
Speed up testing by removing unnecessarily created record
74fee33
to
abf2105
Compare
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 think we should still change the random value in the factory.
Yes, I would be happy with a fixed value. |
Hi @rioug and @mkllnk, General remark after staging
Positive test cases
Proposed adjustments of backoffice design
Proposed adjustments for backoffice functionality
Proposed adjustments for checkout
Negative test cases
Peek.2023-05-19.15-48.mp4
Peek.2023-05-19.15-42.mp4
Peek.2023-05-19.16-40.mp4ResultThe requested feature has been implemented according to specification. We can merge this one here. I will open issues for the negative test cases and some of the improvements. Thanks! 🙏 |
Thank you, excellent testing. Definitely some edge cases to work out before it can be released. |
What? Why?
Add the ability to have a flat rate voucher of any amount
What should we test?
In the backoffice logged as an enterprise user:
--> It should redirect you to the vouchers page on the enterprise edit page
--> You should now see a list of vouchers with the one you just created, included the entered amount
On the website logged as a customer :
--> You should see a "$xx Voucher" box where xx is the amount you entered when creating a voucher
--> you should see the voucher applied to the order in the order summary column, with the correct amount
--> you should see the voucher applied to the order in the order summary with the correct amount
Release notes
Changelog Category: User facing changes
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates