1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

fix invoice attachement name

This commit is contained in:
Sylvain 2016-03-29 18:02:40 +02:00
parent 6f50d59054
commit 8a53ae2d2c
2 changed files with 7 additions and 3 deletions

View File

@ -28,12 +28,12 @@ class NotificationsMailer < NotifyWith::NotificationsMailer
end end
def notify_user_when_invoice_ready def notify_user_when_invoice_ready
attachments['facture.pdf'] = File.read(@attached_object.file) attachments[@attached_object.filename] = File.read(@attached_object.file)
mail(to: @recipient.email, subject: t('notifications_mailer.notify_member_invoice_ready.subject'), template_name: 'notify_member_invoice_ready') mail(to: @recipient.email, subject: t('notifications_mailer.notify_member_invoice_ready.subject'), template_name: 'notify_member_invoice_ready')
end end
def notify_user_when_avoir_ready def notify_user_when_avoir_ready
attachments['avoir.pdf'] = File.read(@attached_object.file) attachments[@attached_object.filename] = File.read(@attached_object.file)
mail(to: @recipient.email, subject: t('notifications_mailer.notify_member_avoir_ready.subject'), template_name: 'notify_member_avoir_ready') mail(to: @recipient.email, subject: t('notifications_mailer.notify_member_avoir_ready.subject'), template_name: 'notify_member_avoir_ready')
end end
end end

View File

@ -18,7 +18,11 @@ class Invoice < ActiveRecord::Base
# create directories if they doesn't exists (invoice & user_id) # create directories if they doesn't exists (invoice & user_id)
FileUtils::mkdir_p dir FileUtils::mkdir_p dir
"#{dir}/#{ENV['INVOICE_PREFIX']}-#{self.id}_#{self.created_at.strftime('%d%m%Y')}.pdf" "#{dir}/#{self.filename}"
end
def filename
"#{ENV['INVOICE_PREFIX']}-#{self.id}_#{self.created_at.strftime('%d%m%Y')}.pdf"
end end