IO-2240 Resolve efficiency calculation issue.

This commit is contained in:
Patrick Fic
2023-04-14 12:29:11 -07:00
parent 0e06b449cb
commit 8602ccbb8a

View File

@@ -223,18 +223,31 @@ export default function ScoreboardTimeTickets() {
ret2.push(r); ret2.push(r);
}); });
console.log(
"🚀 ~ file: scoreboard-timetickets.component.jsx:238 ~ calculatedData ~ ret:",
ret
);
// Add total efficiency of employees // Add total efficiency of employees
ret.totalEffieciencyOverPeriod = Object.keys(ret.employees) const totalActualAndProductive = Object.keys(ret.employees)
.map((key) => { .map((key) => {
return { employee_number: key, ...ret.employees[key] }; return { employee_number: key, ...ret.employees[key] };
}) })
.map((e) => .reduce(
((e.totalOverPeriod / (e.actualTotalOverPeriod || 0.1)) * 100).toFixed( (acc, e) => {
1 return {
) totalOverPeriod: acc.totalOverPeriod + e.totalOverPeriod,
) actualTotalOverPeriod:
.reduce((acc, prev) => acc + Number(prev), 0); acc.actualTotalOverPeriod + e.actualTotalOverPeriod,
};
},
{ totalOverPeriod: 0, actualTotalOverPeriod: 0 }
);
ret.totalEffieciencyOverPeriod =
(totalActualAndProductive.totalOverPeriod /
totalActualAndProductive.actualTotalOverPeriod) *
100;
roundObject(ret); roundObject(ret);
roundObject(totals); roundObject(totals);