@@ -46,7 +46,7 @@ class CompanySummary {
46
46
47
47
// Put headers
48
48
results . push ( [
49
- 'Ddepartment ' , 'Lastname ' , 'Name' , 'Email address' ,
49
+ 'Department ' , 'Last name ' , 'Name' , 'Email address' ,
50
50
'Type of absence' , 'Started at' , 'Date type' , 'Ended at' , 'Date type'
51
51
] ) ;
52
52
@@ -63,9 +63,17 @@ class CompanySummary {
63
63
// Get a row per every leave
64
64
. forEach ( u => u . my_leaves . forEach ( l => {
65
65
66
- const
67
- start_date = moment ( l . date_start ) . format ( date_format ) ,
68
- end_date = moment ( l . date_end ) . format ( date_format ) ;
66
+ const start_date = moment ( l . date_start ) . format ( date_format ) ;
67
+ const end_date = moment ( l . date_end ) . format ( date_format ) ;
68
+
69
+ const startDatePart = l . does_start_half_morning ( ) ? 'Morning'
70
+ : l . does_start_half_afternoon ( ) ? 'Afternoon'
71
+ : 'All Day' ;
72
+
73
+ const endDatePart = start_date === end_date ? startDatePart
74
+ : l . does_end_half_morning ( ) ? 'Morning'
75
+ : l . does_end_half_afternoon ( ) ? 'Afternoon'
76
+ : 'All Day' ;
69
77
70
78
results . push ( [
71
79
departmentsMap [ u . DepartmentId ] . name ,
@@ -74,18 +82,9 @@ class CompanySummary {
74
82
u . email ,
75
83
leaveTypesMap [ l . leaveTypeId ] . name ,
76
84
start_date ,
77
- (
78
- l . does_start_half_morning ( ) ? 'morning'
79
- : l . does_start_half_afternoon ( ) ? 'afternoon'
80
- : 'whole day'
81
- ) ,
85
+ startDatePart ,
82
86
end_date ,
83
- (
84
- start_date === end_date ? 'N/A'
85
- : l . does_end_half_morning ( ) ? 'morning'
86
- : l . does_end_half_afternoon ( ) ? 'afternoon'
87
- : 'whole day'
88
- ) ,
87
+ endDatePart ,
89
88
] )
90
89
} ) ) ;
91
90
0 commit comments