UNPKG

harvest-overtime

Version:
26 lines (25 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const R = require("ramda"); const calculator_1 = require("./calculator"); function report(regularDayHours) { return (employees) => { const onlyEmployees = R.filter((n) => n.employee, employees); const employeeNames = R.uniq(R.map((n) => n.name, onlyEmployees)); return R.map((n) => getInformationByEmployee(n, onlyEmployees, regularDayHours), employeeNames); }; } exports.default = report; function getInformationByEmployee(firstName, employees, regularDayHours) { const employee = R.filter((n) => n.name === firstName, employees); const dates = R.uniq(R.map((n) => n.date, employee)); const timesheet = getTimesheets(employee, dates); return { employee: firstName, report: calculator_1.getOvertime(timesheet, regularDayHours), timesheet, }; } function getTimesheets(employee, dates) { return R.map((n) => calculator_1.getTimesheet(n, employee), dates); }