Invoice forward saves email

This commit is contained in:
Vladimir Krylov 2015-12-01 01:17:28 +02:00
parent 5d1f691967
commit fa7cf13bf4
2 changed files with 4 additions and 3 deletions

View file

@ -1,8 +1,9 @@
class InvoiceMailer < ApplicationMailer class InvoiceMailer < ApplicationMailer
include Que::Mailer include Que::Mailer
def invoice_email(invoice_id, html) def invoice_email(invoice_id, html, billing_email)
@invoice = Invoice.find_by(id: invoice_id) @invoice = Invoice.find_by(id: invoice_id)
billing_email ||= @invoice.billing_email
return unless @invoice return unless @invoice
return if whitelist_blocked?(@invoice.billing_email) return if whitelist_blocked?(@invoice.billing_email)
@ -11,6 +12,6 @@ class InvoiceMailer < ApplicationMailer
invoice = @invoice invoice = @invoice
attachments[invoice.pdf_name] = pdf attachments[invoice.pdf_name] = pdf
mail(to: format(invoice.billing_email), subject: invoice) mail(to: format(billing_email), subject: invoice)
end end
end end

View file

@ -117,7 +117,7 @@ class Invoice < ActiveRecord::Base
return false unless valid? return false unless valid?
return false unless billing_email.present? return false unless billing_email.present?
InvoiceMailer.invoice_email(id, html).deliver InvoiceMailer.invoice_email(id, html, billing_email).deliver
true true
end end