coopcycle / coopcycle-web

Logistics & marketplace platform. Only for worker-owned business.
https://coopcycle.org
Other
565 stars 128 forks source link

API not respecting time slot "Same day cutoff" #2614

Open joel-shiftdelivery opened 3 years ago

joel-shiftdelivery commented 3 years ago

Describe the bug When placing an order via the API, it seems that the Same day cutoff is not respected for at least some time slots. With a 10am cutoff set for a 900-1700 time slot, Orders are still able to be places at 1600.

Similarly, for a 1800-2100 time slot with a 1600 cutoff, the time slot was returning as an option and allowed orders to be placed at 16:15.

To Reproduce Steps to reproduce the behavior:

  1. Create a new order via API for a store with time slots
  2. Make sure the cutoff time is set to some time before present, but the end of the time slot is not yet ended.
  3. Place an order
  4. See error

Expected behavior The Same day cutoff time should be respected for time slots via API

Screenshots Screenshot from 2021-07-09 08-22-29 Screenshot from 2021-07-09 08-24-34

Additional context The "Prior notice" seems to be working even though the same day cutoff does not.

vladimir-8 commented 3 years ago

It looks like the "Same day cutoff" is implemented only for "Mode avancé" https://github.com/coopcycle/coopcycle-web/blob/dc14efdd688aef4e0cdd71840d130f3749e1bac4/src/Form/Type/TimeSlotChoiceLoader.php#L122

And I see that the "Mode simple" is going to be deprecated (#2511) https://docs.coopcycle.org/en/admin/deliveries/timeslots/#delivery-time-slots is it possible for you to switch to using "Mode avancé"?

vladimir-8 commented 3 years ago

Actually, what I wrote applies to Obtaining time slots endpoint https://docs.coopcycle.org/en/developer/time-slots/

and it looks like the endpoint that creates deliveries https://docs.coopcycle.org/en/developer/deliveries/ does not perform any checks. I'm able to create a delivery in the past, for example. How do you see that the "Prior notice" is taken into account?