-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathPayrollElementsTableFactory.ts
More file actions
82 lines (76 loc) · 2.83 KB
/
Copy pathPayrollElementsTableFactory.ts
File metadata and controls
82 lines (76 loc) · 2.83 KB
1
2
3
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { Injectable } from '@nestjs/common';
import { UserElementsView } from 'src/Application/HumanResource/Payslip/View/UserElementsView';
import { Table } from 'src/Infrastructure/Tables';
import { RowFactory } from 'src/Infrastructure/Tables/RowFactory';
import { formatFullName } from 'src/Infrastructure/Common/Utils/formatUtils';
@Injectable()
export class PayrollElementsTableFactory {
constructor(private readonly cells: RowFactory) {}
public create(elements: UserElementsView[]): Table {
const columns = [
'payroll-elements-user',
'payroll-elements-contract',
'payroll-elements-joiningDate',
'payroll-elements-annualEarnings',
'payroll-elements-monthlyEarnings',
'payroll-elements-workingTime',
'payroll-elements-transportFee',
'payroll-elements-sustainableMobilityFee',
'payroll-elements-sportsPassFee',
'payroll-elements-mealTickets',
'payroll-elements-healthInsurance',
'payroll-elements-paidLeaves',
'payroll-elements-unpaidLeaves',
'payroll-elements-medicalLeaves',
'payroll-elements-specialLeaves',
'payroll-elements-postponedWorkedFreeDayLeaves',
'payroll-elements-relocationLeaves'
];
const rows = [];
for (const item of elements) {
const row = this.cells
.createBuilder()
.value(formatFullName(item))
.trans('payroll-elements-contract-value', {
contract: item.contract,
executivePosition: item.isExecutivePosition ? 'yes' : 'no'
})
.trans('common-date', { date: new Date(item.joiningDate) })
.trans('common-money', { value: item.annualEarnings })
.trans('common-money', { value: item.monthlyEarnings })
.trans('users-workingTime-value', {
workingTime: item.workingTime
})
.trans('common-money', { value: item.transportFee })
.trans('common-money', {
value: item.sustainableMobilityFee
})
.trans('common-money', {
value: item.sportsPassFee
})
.value(item.mealTickets)
.trans(item.healthInsurance ? 'common-yes' : 'common-no')
.template('pages/payroll_elements/_leaves.njk', {
leaves: item.paidLeaves
})
.template('pages/payroll_elements/_leaves.njk', {
leaves: item.unpaidLeaves
})
.template('pages/payroll_elements/_leaves.njk', {
leaves: item.sickLeaves
})
.template('pages/payroll_elements/_leaves.njk', {
leaves: item.exceptionalLeaves
})
.template('pages/payroll_elements/_leaves.njk', {
leaves: item.postponedWorkedFreeDayLeaves
})
.template('pages/payroll_elements/_leaves.njk', {
leaves: item.relocationLeaves
})
.build();
rows.push(row);
}
return new Table(columns, rows);
}
}