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);
});
console.log(
"🚀 ~ file: scoreboard-timetickets.component.jsx:238 ~ calculatedData ~ ret:",
ret
);
// Add total efficiency of employees
ret.totalEffieciencyOverPeriod = Object.keys(ret.employees)
const totalActualAndProductive = Object.keys(ret.employees)
.map((key) => {
return { employee_number: key, ...ret.employees[key] };
})
.map((e) =>
((e.totalOverPeriod / (e.actualTotalOverPeriod || 0.1)) * 100).toFixed(
1
)
)
.reduce((acc, prev) => acc + Number(prev), 0);
.reduce(
(acc, e) => {
return {
totalOverPeriod: acc.totalOverPeriod + e.totalOverPeriod,
actualTotalOverPeriod:
acc.actualTotalOverPeriod + e.actualTotalOverPeriod,
};
},
{ totalOverPeriod: 0, actualTotalOverPeriod: 0 }
);
ret.totalEffieciencyOverPeriod =
(totalActualAndProductive.totalOverPeriod /
totalActualAndProductive.actualTotalOverPeriod) *
100;
roundObject(ret);
roundObject(totals);