fix tiny issue where flash alert not shown

This commit is contained in:
Viehlieb 2021-12-24 13:17:45 +01:00
parent 06eb56acf4
commit f592b27f92

View file

@ -5,7 +5,7 @@ class Finance::BalancingController < Finance::BaseController
def new def new
@order = Order.find(params[:order_id]) @order = Order.find(params[:order_id])
flash.now.alert = t('finance.balancing.new.alert') if @order.closed? flash.now.alert = t('finance.balancing.new.alert') if @order.closed? && flash[:alert].blank?
@comments = @order.comments @comments = @order.comments
@articles = @order.order_articles.ordered_or_member.includes(:article, :article_price, @articles = @order.order_articles.ordered_or_member.includes(:article, :article_price,
@ -83,8 +83,10 @@ class Finance::BalancingController < Finance::BaseController
@order.close!(@current_user, @type) @order.close!(@current_user, @type)
note = t('finance.balancing.close.notice') note = t('finance.balancing.close.notice')
if @order.closed? if @order.closed?
if FoodsoftConfig[:group_order_invoices]&.[](:use) && FoodsoftConfig[:contact]&.[](:tax_number) alert = t('finance.balancing.close.alert')
if FoodsoftConfig[:group_order_invoices]&.[](:use)
@order.group_orders.each do |go| @order.group_orders.each do |go|
alert = t('finance.balancing.close.settings_not_set')
goi = GroupOrderInvoice.find_or_create_by!(group_order_id: go.id) goi = GroupOrderInvoice.find_or_create_by!(group_order_id: go.id)
if goi.save! if goi.save!
NotifyGroupOrderInvoiceJob.perform_later(goi) NotifyGroupOrderInvoiceJob.perform_later(goi)
@ -93,9 +95,10 @@ class Finance::BalancingController < Finance::BaseController
end end
end end
end end
alert ||= t('finance.balancing.close.alert')
redirect_to finance_order_index_url, notice: note redirect_to finance_order_index_url, notice: note
rescue => error rescue => error
redirect_to new_finance_order_url(order_id: @order.id), notice: note, alert: t('finance.balancing.close.alert', message: error.message) redirect_to new_finance_order_url(order_id: @order.id), notice: note, alert: alert, msg: error.message
end end
# Close the order directly, without automaticly updating ordergroups account balances # Close the order directly, without automaticly updating ordergroups account balances