foodsoft/plugins/automatic_invoices/app/overrides/mailers/mailer_override.rb
2023-10-12 12:47:44 +02:00

20 lines
862 B
Ruby

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
@group_order = group_order_invoice.group_order
@supplier = @group_order.order.supplier.name
@group = @group_order.ordergroup
add_group_order_invoice_attachments(group_order_invoice)
mail to: user,
subject: I18n.t('mailer.group_order_invoice.subject', group: @group.name, supplier: @supplier)
end
end
end