Added time tickets by cost center BOD-239
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
React App:
|
||||
|
||||
Yarn Dependency Management:
|
||||
To force upgrades for some packages: yarn upgrade-interactive --latest
|
||||
To force upgrades for some packages:
|
||||
yarn upgrade-interactive --latest
|
||||
|
||||
GraphQL API:
|
||||
Hasura is hosted on another dyno. Several environmental variables are required, including disabling the console.
|
||||
|
||||
@@ -78,6 +78,8 @@ export function TimeTicketsSummaryEmployees({
|
||||
displayTemplateInWindow(html);
|
||||
};
|
||||
|
||||
console.log("jobTickets", jobTickets);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<List
|
||||
@@ -90,73 +92,79 @@ export function TimeTicketsSummaryEmployees({
|
||||
//dataSource={jobTickets}
|
||||
>
|
||||
{jobTickets.map((item, idx) => {
|
||||
const costCenters = item.tickets
|
||||
const employeeCostCenters = item.tickets
|
||||
.map((i) => i.cost_center)
|
||||
.filter(onlyUnique);
|
||||
|
||||
console.log("costCenters", costCenters);
|
||||
console.log("employeeCostCenters", employeeCostCenters);
|
||||
|
||||
const actHrs = item.tickets.reduce(
|
||||
(acc, val) => acc + val.actualhrs,
|
||||
0
|
||||
);
|
||||
return employeeCostCenters.map((costCenter) => {
|
||||
const actHrs = item.tickets
|
||||
.filter((ticket) => ticket.cost_center === costCenter)
|
||||
.reduce((acc, val) => acc + val.actualhrs, 0);
|
||||
|
||||
const prodHrs = item.tickets.reduce(
|
||||
(acc, val) => acc + val.productivehrs,
|
||||
0
|
||||
);
|
||||
const prodHrs = item.tickets
|
||||
.filter((ticket) => ticket.cost_center === costCenter)
|
||||
.reduce((acc, val) => acc + val.productivehrs, 0);
|
||||
|
||||
const clockHrs = item.tickets.reduce((acc, val) => {
|
||||
if (!!val.clockoff && !!val.clockon)
|
||||
return (
|
||||
acc +
|
||||
moment(val.clockoff).diff(moment(val.clockon), "hours", true)
|
||||
);
|
||||
return acc;
|
||||
}, 0);
|
||||
const clockHrs = item.tickets
|
||||
.filter((ticket) => ticket.cost_center === costCenter)
|
||||
.reduce((acc, val) => {
|
||||
if (!!val.clockoff && !!val.clockon)
|
||||
return (
|
||||
acc +
|
||||
moment(val.clockoff).diff(
|
||||
moment(val.clockon),
|
||||
"hours",
|
||||
true
|
||||
)
|
||||
);
|
||||
return acc;
|
||||
}, 0);
|
||||
|
||||
return (
|
||||
<List.Item
|
||||
key={idx}
|
||||
actions={[
|
||||
<Button
|
||||
onClick={() => handlePrintEmployeeTicket(item.employee.id)}
|
||||
>
|
||||
{t("timetickets.actions.printemployee")}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<LoadingSkeleton loading={loading}>
|
||||
<List.Item.Meta
|
||||
title={`${item.employee.first_name} ${item.employee.last_name}`}
|
||||
description="cost center?"
|
||||
/>
|
||||
<Space>
|
||||
<Statistic
|
||||
title={t("timetickets.fields.actualhrs")}
|
||||
precision={1}
|
||||
value={actHrs}
|
||||
return (
|
||||
<List.Item
|
||||
key={`${idx}${costCenter}`}
|
||||
actions={[
|
||||
<Button
|
||||
onClick={() => handlePrintEmployeeTicket(item.employee.id)}
|
||||
>
|
||||
{t("timetickets.actions.printemployee")}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<LoadingSkeleton loading={loading}>
|
||||
<List.Item.Meta
|
||||
title={`${item.employee.first_name} ${item.employee.last_name}`}
|
||||
description={costCenter}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("timetickets.fields.productivehrs")}
|
||||
precision={1}
|
||||
value={prodHrs}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("timetickets.fields.efficiency")}
|
||||
precision={1}
|
||||
value={(prodHrs / actHrs) * 100}
|
||||
suffix={"%"}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("timetickets.fields.clockhours")}
|
||||
precision={1}
|
||||
value={clockHrs}
|
||||
/>
|
||||
</Space>
|
||||
</LoadingSkeleton>
|
||||
</List.Item>
|
||||
);
|
||||
<Space>
|
||||
<Statistic
|
||||
title={t("timetickets.fields.actualhrs")}
|
||||
precision={1}
|
||||
value={actHrs}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("timetickets.fields.productivehrs")}
|
||||
precision={1}
|
||||
value={prodHrs}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("timetickets.fields.efficiency")}
|
||||
precision={1}
|
||||
value={(prodHrs / actHrs) * 100}
|
||||
suffix={"%"}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("timetickets.fields.clockhours")}
|
||||
precision={1}
|
||||
value={clockHrs}
|
||||
/>
|
||||
</Space>
|
||||
</LoadingSkeleton>
|
||||
</List.Item>
|
||||
);
|
||||
});
|
||||
})}
|
||||
</List>
|
||||
<List
|
||||
|
||||
Reference in New Issue
Block a user