internetee/registry

View on GitHub
app/mailers/invoice_mailer.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class InvoiceMailer < ApplicationMailer
  def invoice_email(invoice:, recipient:, paid: false)
    @invoice = invoice

    subject = default_i18n_subject(invoice_number: invoice.number)
    subject << I18n.t('invoice.already_paid') if paid
    subject << I18n.t('invoice.monthly_invoice') if invoice.monthly_invoice
    attachments["invoice-#{invoice.number}.pdf"] = invoice.as_pdf
    mail(to: recipient, subject: subject)
  end
end