-
-
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
Let people customise which shipping methods are available to customers on order cycles #9262
Let people customise which shipping methods are available to customers on order cycles #9262
Conversation
a56d192
to
89d3e12
Compare
89d3e12
to
a476e22
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.
Wow, great work! ✨
It's a huge chunk of work in one commit though. Would you mind splitting it up? For example, there are some refactors which make it harder to see which logic changed at the same time. And if you have the database migrations in a previous commit then reading the rest of the code makes more sense.
At this stage, I'm still happy to incorporate changes by rewriting the git history.
There are some style violations that need to be address as well.
Your work looks really good and thorough but I didn't read every line. My brain can't keep the whole thing in memory at once.
db/migrate/20220429092052_create_order_cycle_shipping_methods.rb
Outdated
Show resolved
Hide resolved
db/migrate/20220429092052_create_order_cycle_shipping_methods.rb
Outdated
Show resolved
Hide resolved
db/migrate/20220429092052_create_order_cycle_shipping_methods.rb
Outdated
Show resolved
Hide resolved
So exciting to see this awesome work @cillian 🎉 |
7e9e396
to
53b6c15
Compare
👋 @mkllnk I have changed things so all shipping methods are available if none are specifically selected in the database, it's a lot simpler now. I broke it up into smaller commits too, but it might be good to squash some of them again later. |
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 reviewed most of this PR but didn't get quite through. I still made quite a few comments below. So maybe let me know what you think about that feedback and then we go from there. It's a big change. 😄
c0ab024
to
2b1ad3a
Compare
f45b73e
to
0fdb5bd
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.
Great work! I know it's taking some time but I hope that you find it as satisfying as me to produce simpler, more maintainable code. I got a few more comments below.
@@ -71,7 +71,9 @@ | |||
%li | |||
= shared_payment_method.name | |||
%p | |||
= "—<em>#{shared_payment_method.distributors.where(id: @order_cycle.distributor_ids).map(&:name).join(", ")}</em>".html_safe | |||
— | |||
%em |
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.
Do you need the space around the dash? Above, I added the >
to the %em
because I thought that you wanted to avoid the space. But the syntax is much easier if we omit it like here and have the space in there. I haven't checked how it looks and I'm a poor judge of that. Up to you. 😉
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 with the space is probably slightly better.
@mkllnk 👍 definitely nice to see the size of this PR has been chopped down a good bit since the first draft. |
db/migrate/20220429092052_create_order_cycles_shipping_methods.rb
Outdated
Show resolved
Hide resolved
db/migrate/20220429092052_create_order_cycles_shipping_methods.rb
Outdated
Show resolved
Hide resolved
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.
💪
A few more comments.
db/migrate/20220429092052_create_order_cycles_shipping_methods.rb
Outdated
Show resolved
Hide resolved
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! It looks all good to me. 😄
@mkllnk great, thank you 🎉 |
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.
What an awesome work you've done here! Congrats! 💪 🙏
Very well broken into atomic commit, nice comment on each one.
I don't see anything wrong, this looks good to me ;)
Hi @cillian, This is a big and complex one. So I decided to take separate testing notes in a document here: https://docs.google.com/document/d/1UhiVRpqWcOZ0HvwDdTBVoGxSS0iiwSL1czd_lBkJE_M/edit?usp=sharing So far everything seems good. I only was confused by the way the shared payment methods are displayed (see no. 4 in the document). I am asking our @openfoodfoundation/train-drivers-product-owners team to comment on this one. I have to stop for now, there is still a lot more to test. This is just to let you know your contribution is very much appreciated and we are working on testing it! 👍 |
Thanks for all the dev, review and testing on this. I'm afraid that when the spec changed half way through this introduced some differences in understanding between the spec and what was developed. This is totally my fault. I'm going to go through the PR now to better understand where we are at and what's possible and then have a chat with @cillian to work out the best route forward. For now, let's pause. Sorry to delay this everyone. |
The spec was failing from time to time. I hope that this will fix it. ``` Failures: 1) As an administrator I want to create/update complex order cycles with a specific time creating an order cycle with full interface Failure/Error: fill_in 'order_cycle_outgoing_exchange_0_pickup_time', with: 'pickup time' Capybara::ElementNotFound: Unable to find field "order_cycle_outgoing_exchange_0_pickup_time" that is not disabled # ./spec/system/admin/order_cycles/complex_creating_specific_time_spec.rb:138:in `add_distributor_with_fees' # ./spec/system/admin/order_cycles/complex_creating_specific_time_spec.rb:66:in `block (2 levels) in <main>' # ./spec/system/support/cuprite_setup.rb:39:in `block (2 levels) in <main>' # -e:1:in `<main>' ```
…checked This means the code to set the initial value in the view template isn't needed.
…reating_specific_time_spec.rb Not sure if this is correct but it removes the Rubocop violations.
…form" This reverts commit 0dddaa6.
…tions form, any shared shipping methods are to be displayed for each distributor e.g. if they belong to multiple distributors they will be displayed multiple times
…ows instead of same one, the select all checkboxes still need to be added back later This is the new design from openfoodfoundation#9262 (comment)
…ing methods instead of order cycles to shipping methods
…hippingMethods Before if a shipping method was shared between multiple distributors it could only be disabled/enabled on that order cycle for all the distributors which have that shipping method e.g. you couldn't select that shipping method for one distributor but disable it for another.
…ones by default per distributor, not per all distributors
…ecord::Relation sometimes and Array other times Now it will return ActiveRecord::Relation consistently.
…into account Note, this doesn't test checking/unchecking some distributor shipping methods and not others because that is tested in order_cycles/complex_creating_time_specific_spec.rb.
… as :expect_fees_saved
…account that DistributorShippingMethods instead of ShippingMethods are connected to OrderCycles now
… the :schedule_ids was not specified in the parameters Before this schedules were being deleted when the Checkout Options step of editing order cycles was saved because this step wasn't sending the :schedule_ids parameter. It's more awkard for API users if they always need to explicity send the :schedule_ids parameter even if they don't want to add/remove any of the schedules, for example if they just want to update an order cycle name.
478a519
to
f9e29f3
Compare
@filipefurtad0 yes I think that should work. Although the old The other option would be to checkout the commit which contained the old migration and roll the migration back, then checkout the latest commit and re-run the migration again. That would remove the old table so you wouldn't need to delete it manually. |
find("body").send_keys(:escape) | ||
def select_opening_and_closing_times | ||
select_time("#order_cycle_orders_open_at", order_cycle_opening_time) | ||
select_time("#order_cycle_orders_close_at", order_cycle_opening_time) |
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.
This is causing this spec to fail:
https://github.com/openfoodfoundation/openfoodnetwork/actions/runs/3158670190/jobs/5140966992
It should be order_cycle_closing_time
.
It does not influence the PR, so I'll continue testing 👍
Ok! Everything looks good now: Migration
Which corresponds to: Behavior and acceptance criteria
Screencast.from.30-09-2022.14.30.26.webm
I think these were the pending issues! Thanks so much all the work and patience on this one @cillian |
What? Why?
Closes #8974
This adds a new step 4. Checkout options to editing order cycles. This only applies to order cycles for distributors e.g. sells = 'any'. For 'simple', direct sales, order cycles where :sells = 'own' all shipping methods are to be available by default like they are currently.
This is a bit different from the spec because updating step 3. Outgoing would have be done in Angular and that would have taken a lot longer. I believe the plan is to convert the edit order cycle form to StimulusJs as soon as possible anyway so it was quicker and easier to do this in plain Rails.
Note, the screenshot includes a 'back office only' shipping method which is disabled and cannot be selected. It also includes a shared shipping method which is shared by two enterprises.
The 'Ready for' and 'Customer instructions' fields haven't been moved yet. It might be best to do those in separate PRs are this one is already big enough.
This adds a :shipping_methods_customisable flag to the order cycles table in order to have a record of which order cycles which were created before this feature i.e. order cycles on which it was not possible to customise shipping methods. This excludes active or upcoming order cycles at the time of the migration because shipping methods on these should be customisable so the :shipping_methods_customisable flag will be set to true for these.What should we test?
See Acceptance criteria & tests in #8974
It would be good to test the migration on a staging instance too.
Release notes
Changelog Category: User facing changes
Documentation updates
The Order Cycles (for hubs) page in the user guide will probably need to be updated.