4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/mailers/employee_payroll_disbursement_mailer.rb', line 4
def notification(
transaction_header:,
employee:
)
@employee = employee
payslip_pdf_binary = FrontendApiService.new(
current_user_id: ErpUser.admin.erp_user_id,
company_id: employee.company_id,
tenant_id: employee.company.tenant_id
).pdf_from_component(
component: 'FetchingPayslipReport',
props: {
employeeIds: [employee.employee_id],
payrollTransactionHeaderId: .id,
noContainer: true
},
return_file: false
)
@company_name = employee.company.name
@period_description = .payroll_period.formatted
subject = "#{@company_name} #{I18n.t('payroll.report.payslip')} - #{@period_description}"
subject_without_spaces = subject.gsub(/\s+/, '_')
attachments["#{subject_without_spaces}.pdf"] = {
mime_type: 'application/pdf',
content: payslip_pdf_binary
}
I18n.with_locale(employee.locale) do
mail(
to: employee.personal_email,
subject: subject,
from: Rails.application.config.from_email_address
)
end
end
|