2023-10-10 23:11:34 +02:00
|
|
|
if FoodsoftAutomaticInvoices.enabled?
|
|
|
|
Mailer.class_eval do
|
|
|
|
# Sends automatically generated invoicesfor group orders to ordergroup members
|
2023-10-12 12:47:44 +02:00
|
|
|
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
|
|
|
|
|
2023-10-10 23:11:34 +02:00
|
|
|
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
|