IO-2240 Moved the calculation within the function
This commit is contained in:
@@ -81,6 +81,7 @@ export default function ScoreboardTimeTickets() {
|
||||
totalLastMonth: 0,
|
||||
totalOverPeriod: 0,
|
||||
actualTotalOverPeriod: 0,
|
||||
totalEffieciencyOverPeriod: 0,
|
||||
employees: {},
|
||||
};
|
||||
data.fixedperiod.forEach((ticket) => {
|
||||
@@ -94,6 +95,7 @@ export default function ScoreboardTimeTickets() {
|
||||
totalLastMonth: 0,
|
||||
totalOverPeriod: 0,
|
||||
actualTotalOverPeriod: 0,
|
||||
totalEffieciencyOverPeriod: 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -217,6 +219,19 @@ export default function ScoreboardTimeTickets() {
|
||||
r.employees[ticket.employee.employee_number].actual +
|
||||
ticket.actualhrs;
|
||||
});
|
||||
|
||||
// Add total efficiency of employees
|
||||
ret.totalEffieciencyOverPeriod = 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);
|
||||
}
|
||||
|
||||
ret2.push(r);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Card, Col, Row, Statistic, Table, Typography } from "antd";
|
||||
import React, { useMemo } from "react";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -74,23 +74,6 @@ export function ScoreboardTicketsStats({ data, bodyshop }) {
|
||||
})
|
||||
: [];
|
||||
|
||||
const totalEffieciencyOverPeriod = useMemo(
|
||||
() =>
|
||||
Object.keys(data?.employees ?? [])
|
||||
.map((key) => {
|
||||
return { employee_number: key, ...data.employees[key] };
|
||||
})
|
||||
.map((e) =>
|
||||
(
|
||||
(e.totalOverPeriod / (e.actualTotalOverPeriod || 0.1)) *
|
||||
100
|
||||
).toFixed(1)
|
||||
)
|
||||
.reduce((acc, prev) => acc + Number(prev), 0)
|
||||
.toFixed(1),
|
||||
[data]
|
||||
);
|
||||
|
||||
return (
|
||||
<Card title={t("scoreboard.labels.productivestatistics")}>
|
||||
<Row gutter={[16, 16]}>
|
||||
@@ -133,7 +116,7 @@ export function ScoreboardTicketsStats({ data, bodyshop }) {
|
||||
<Col span={12}>
|
||||
<Statistic
|
||||
title={t("scoreboard.labels.efficiencyoverperiod")}
|
||||
value={`${totalEffieciencyOverPeriod}%`}
|
||||
value={`${data.totalEffieciencyOverPeriod}%`}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
Reference in New Issue
Block a user