add mailer relevant files, add pdf relevant files and confgurations for invoice generation and sending

This commit is contained in:
Viehlieb 2021-12-23 01:50:06 +01:00
parent 0fa696cfdd
commit 817c680c28
5 changed files with 183 additions and 0 deletions

View file

@ -51,6 +51,19 @@ class Mailer < ActionMailer::Base
subject: I18n.t('mailer.welcome.subject')
end
# Sends automatically generated invoicesfor group orders to ordergroup members
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
# Sends order result for specific Ordergroup
def order_result(user, group_order)
@order = group_order.order
@ -168,6 +181,11 @@ class Mailer < ActionMailer::Base
attachments['order.csv'] = OrderCsv.new(order, options).to_csv
end
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
# separate method to allow plugins to mess with the text
def additonal_welcome_text(user)
end