move automatic invoices to plugin
changes on deposit calculation tiny changes on group order invoice pdf
This commit is contained in:
parent
42a1773a87
commit
e78d1ad072
67 changed files with 5579 additions and 69 deletions
|
|
@ -0,0 +1,27 @@
|
|||
if FoodsoftAutomaticInvoices.enabled?
|
||||
Finance::BalancingController.class_eval do
|
||||
def close
|
||||
@order = Order.find(params[:id])
|
||||
@type = FinancialTransactionType.find_by_id(params.permit(:type)[:type])
|
||||
@order.close!(@current_user, @type)
|
||||
note = t('finance.balancing.close.notice')
|
||||
if @order.closed?
|
||||
alert = t('finance.balancing.close.alert')
|
||||
if FoodsoftConfig[:group_order_invoices]&.[](:use_automatic_invoices)
|
||||
@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)
|
||||
if goi.save!
|
||||
NotifyGroupOrderInvoiceJob.perform_later(goi)
|
||||
note = t('finance.balancing.close.notice_mail')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
alert ||= t('finance.balancing.close.alert')
|
||||
redirect_to finance_order_index_url, notice: note
|
||||
rescue => error
|
||||
redirect_to new_finance_order_url(order_id: @order.id), notice: note, alert: alert, msg: error.message
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue