-
Notifications
You must be signed in to change notification settings - Fork 146
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
Add option to automatically finish an order #495
Conversation
757cfed
to
5474569
Compare
Looking good! This idea has come up for me in the past several times, and I decided not to implement it, because there was always a manual step after the order was closed (sending the order to the supplier). So why bother closing automatically when it really depends on the next manual step? That gives people just a bit more time to order until it is really time. Having automated mails would make this more useful (but many foodcoops want to add manual notes to it about pickup arrangement etc.). Anyway, if there's use, let's include it. I would be careful to add many checkboxes for options like this, because it requires making more decisions in the normal flow. Anyway, I think it's fine now. |
Ah, this ties in to #488. |
yes, it's the first step for sending automatic mails to supplier. i think about a config option at the supplier with the followin entries: "send order manually", "send order if minimal amount has bern reached" and "send always" do you see additional use cases?
…--
Patrick Gansterer
On 21 Aug 2017, at 11:22, wvengen ***@***.***> wrote:
Ah, this ties in to #488.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
That sounds really good! |
5474569
to
6459c85
Compare
i've adopted this 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.
I love this feature :) Some small remarks, otherwise fine.
app/models/order.rb
Outdated
elsif auto_close_and_send_min_quantity? | ||
finish! created_by | ||
send_to_supplier created_by if order.sum >= order.supplier.min_order_quantity | ||
end |
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.
In many other places we use finish!(user)
, maybe here as well? (Also send_to_supplier
.)
app/models/order.rb
Outdated
update!(last_sent_mail: Time.now) | ||
end | ||
|
||
def do_end_action |
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.
Does this warrant an exclamation mark? (Since it calls finish!
, which changes the order).
app/models/order.rb
Outdated
@@ -263,6 +265,35 @@ def close_direct!(user) | |||
update_attributes! state: 'closed', updated_by: user | |||
end | |||
|
|||
def send_to_supplier(user) |
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.
Does this warrant an exclamation mark? (Since it sends a mail and calls update!
, which changes the order).
app/models/order.rb
Outdated
end | ||
end | ||
|
||
def self.finish_ended |
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.
same here
# Finish ended orders | ||
every 1.minute do | ||
rake "multicoops:run TASK=foodsoft:finish_ended_orders" | ||
end |
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.
Could it be that this task takes more than a minute to run? Would this interfere? Just to check.
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.
it's very unlikely that it takes so long (but i'll address this problem with the new time zone aware scheduler anyway later). it it really takes that long finish! will fail, because the order is already finished and nothing happens
6459c85
to
af35d2d
Compare
@@ -117,8 +117,7 @@ def finish | |||
# Send a order to the supplier. | |||
def send_result_to_supplier | |||
order = Order.find(params[:id]) | |||
Mailer.order_result_supplier(@current_user, order).deliver_now | |||
order.update!(last_sent_mail: Time.now) | |||
order.send_to_supplier(@current_user) |
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.
don't forget to change this!
This change allows us to implement automatic notifications
to the supplier in the next step.