diff --git a/lib/model/company/exporter/summary.js b/lib/model/company/exporter/summary.js index b6569f2cc..6eeeb5ff3 100644 --- a/lib/model/company/exporter/summary.js +++ b/lib/model/company/exporter/summary.js @@ -46,7 +46,7 @@ class CompanySummary { // Put headers results.push([ - 'Ddepartment', 'Lastname', 'Name', 'Email address', + 'Department', 'Last name', 'Name', 'Email address', 'Type of absence', 'Started at', 'Date type', 'Ended at', 'Date type' ]); @@ -63,9 +63,17 @@ class CompanySummary { // Get a row per every leave .forEach(u => u.my_leaves.forEach(l => { - const - start_date = moment(l.date_start).format(date_format), - end_date = moment(l.date_end).format(date_format); + const start_date = moment(l.date_start).format(date_format); + const end_date = moment(l.date_end).format(date_format); + + const startDatePart = l.does_start_half_morning() ? 'Morning' + : l.does_start_half_afternoon() ? 'Afternoon' + : 'All Day'; + + const endDatePart = start_date === end_date ? startDatePart + : l.does_end_half_morning() ? 'Morning' + : l.does_end_half_afternoon() ? 'Afternoon' + : 'All Day'; results.push([ departmentsMap[ u.DepartmentId ].name, @@ -74,18 +82,9 @@ class CompanySummary { u.email, leaveTypesMap[ l.leaveTypeId ].name, start_date, - ( - l.does_start_half_morning() ? 'morning' - : l.does_start_half_afternoon() ? 'afternoon' - : 'whole day' - ), + startDatePart, end_date, - ( - start_date === end_date ? 'N/A' - : l.does_end_half_morning() ? 'morning' - : l.does_end_half_afternoon() ? 'afternoon' - : 'whole day' - ), + endDatePart, ]) }));