finish and readd mailer
This commit is contained in:
parent
92b72fe786
commit
ac8281fd98
8 changed files with 35 additions and 191 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
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
/ replace_contents "#group-order-form"
|
||||
- if FoodsoftAutomaticInvoices.enabled?
|
||||
= render "form_override"
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
/ replace_contents "#group-order-form"
|
||||
- if FoodsoftAutomaticInvoices.enabled?
|
||||
= render "form_override"
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
if FoodsoftAutomaticInvoices.enabled?
|
||||
Mailer.class_eval do
|
||||
# Sends automatically generated invoicesfor group orders to ordergroup members
|
||||
def add_group_order_invoice_attachments(group_order_invoice)
|
||||
attachment_name = group_order_invoice.name + '.pdf'
|
||||
attachments[attachment_name] = GroupOrderInvoicePdf.new(group_order_invoice.load_data_for_invoice).to_pdf
|
||||
end
|
||||
|
||||
def group_order_invoice(group_order_invoice, user)
|
||||
@user = user
|
||||
@group_order_invoice = group_order_invoice
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue