mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Add paid flag to email subject, check receipt date in tests
This commit is contained in:
parent
82c048b316
commit
235ef9ba3e
5 changed files with 32 additions and 5 deletions
|
@ -1,9 +1,10 @@
|
|||
class InvoiceMailer < ApplicationMailer
|
||||
def invoice_email(invoice:, recipient:)
|
||||
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
|
||||
attachments["invoice-#{invoice.number}.pdf"] = invoice.as_pdf
|
||||
mail(to: recipient, subject: subject)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -101,7 +101,8 @@ class Registrar < ApplicationRecord
|
|||
)
|
||||
|
||||
unless payable
|
||||
InvoiceMailer.invoice_email(invoice: invoice, recipient: billing_email).deliver_now
|
||||
InvoiceMailer.invoice_email(invoice: invoice, recipient: billing_email, paid: !payable)
|
||||
.deliver_later(wait: 1.minute)
|
||||
end
|
||||
|
||||
SendEInvoiceJob.perform_later(invoice.id, payable)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue