Add paid flag to email subject, check receipt date in tests

This commit is contained in:
Alex Sherman 2021-05-28 13:53:14 +05:00
parent 82c048b316
commit 235ef9ba3e
5 changed files with 32 additions and 5 deletions

View file

@ -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

View file

@ -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)