#779 Received state for orders (PR #789, #779)

This commit is contained in:
lentschi 2021-02-03 20:57:53 +01:00 committed by GitHub
parent 67ad202859
commit 085562dbf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 8 deletions

View file

@ -132,8 +132,12 @@ class OrdersController < ApplicationController
unless request.post?
@order_articles = @order.order_articles.ordered_or_member.includes(:article).order('articles.order_number, articles.name')
else
s = update_order_amounts
flash[:notice] = (s ? I18n.t('orders.receive.notice', :msg => s) : I18n.t('orders.receive.notice_none'))
Order.transaction do
s = update_order_amounts
@order.update_attribute(:state, 'received') if @order.state != 'received'
flash[:notice] = (s ? I18n.t('orders.receive.notice', :msg => s) : I18n.t('orders.receive.notice_none'))
end
if current_user.role_orders? || current_user.role_finance?
redirect_to @order
elsif current_user.role_pickup?