Skip to content
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

Automatically set status to "Delivered" for yesterday's orders #822

Closed
lamontfr opened this issue Dec 7, 2017 · 6 comments
Closed

Automatically set status to "Delivered" for yesterday's orders #822

lamontfr opened this issue Dec 7, 2017 · 6 comments

Comments

@lamontfr
Copy link
Contributor

lamontfr commented Dec 7, 2017

Expected Behaviour

  • The Billing only takes into account orders that have status equal to "Delivered".
  • The Dashboard shows the number of meals delivered so far this month based on the order status.
  • After midnight but before 8:00 AM, the Customer Manager wants the status to become "Delivered" for all orders for the preceding day (yesterday) that have the status "Ordered". The orders of yesterday that have any other status than "Ordered" will remain unchanged, for example the "No Charge" or the "Cancelled" orders.
  • Before running the Billing process, the user can manually change the status of some orders to exclude them from the Billing.

Actual Behaviour

  • I have to manually change the status to become "delivered" for each single order that was actually delivered to customers; this is a very tedious process.

Proposed solution

  • Add a script to the nightly cron jobs.
@JeanFrancoisFournier
Copy link
Contributor

Couldn't have said it better myself!

@lamontfr lamontfr self-assigned this Dec 9, 2017
@lamontfr
Copy link
Contributor Author

lamontfr commented Dec 9, 2017

I finished coding the solution. I will now document usage.

@lamontfr
Copy link
Contributor Author

@JeanFrancoisFournier @kousu I submitted the PR to be reviewed by Ling or Ernesto. I will wait a few days for their comments.

Here are the instructions concerning the new command :

  • The command syntax is : $ python3 manage.py setordersdelivered YYYY-mm-dd
  • This will set the status to "Delivered" for all orders that have the status "Ordered" for the specified (delivery) date.
  • Example :$ python3 manage.py setordersdelivered 2017-12-09
  • The command can be run manually or automatically.
  • If run automatically, the delivery date should be set as desired and calculated according the system date.
    • For example if the script is executed at night before midnight and we want to set the status for today's orders, then the delivery date equals the system date.
    • However if the script is executed at night after midnight and we want to set the status for yesterday's orders, then the delivery date equals the system date minus one day.

@kousu
Copy link

kousu commented Dec 12, 2017

This is related to #795 too, adding more work for #795.

@kousu
Copy link

kousu commented Dec 12, 2017

It would be a lot easier to deploy this reliably if the date had a default, so that it's calculated internally instead of in shell where quoting rules are a nightmare to get right. You could use datetime.date.today() - datetime.timedelta(1)

@lamontfr
Copy link
Contributor Author

@kousu @JeanFrancoisFournier I do not calculate the delivery date inside the command for one reason : I suspect that there is a date / timezone problem somewhere in Django / Docker (see Issue #820).
Therefore, specifying the date explicitly on the command line makes it safer for the time being,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants