Added labor adjustments to allocations table. IO-570
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Typography, Row, Col } from "antd";
|
||||
import { EditFilled } from "@ant-design/icons";
|
||||
import { Typography } from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CalculateAllocationsTotals } from "./labor-allocations-table.utility";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import LaborAllocationsAdjustmentEdit from "../labor-allocations-adjustment-edit/labor-allocations-adjustment-edit.component";
|
||||
import "./labor-allocations-table.styles.scss";
|
||||
import { CalculateAllocationsTotals } from "./labor-allocations-table.utility";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
|
||||
export function LaborAllocationsTable({ joblines, timetickets, bodyshop }) {
|
||||
export function LaborAllocationsTable({
|
||||
jobId,
|
||||
joblines,
|
||||
timetickets,
|
||||
bodyshop,
|
||||
adjustments,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [totals, setTotals] = useState([]);
|
||||
@@ -19,47 +29,70 @@ export function LaborAllocationsTable({ joblines, timetickets, bodyshop }) {
|
||||
CalculateAllocationsTotals(
|
||||
bodyshop.md_responsibility_centers,
|
||||
joblines,
|
||||
timetickets
|
||||
timetickets,
|
||||
adjustments
|
||||
)
|
||||
);
|
||||
}, [joblines, timetickets, bodyshop]);
|
||||
}, [joblines, timetickets, bodyshop, adjustments]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Typography.Title level={3}>
|
||||
{t("jobs.labels.laborallocations")}
|
||||
</Typography.Title>
|
||||
|
||||
<Row>
|
||||
<Col span={6}>
|
||||
<strong>{t("timetickets.fields.cost_center")}</strong>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<strong>{t("jobs.labels.hrs_total")}</strong>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<strong>{t("jobs.labels.hrs_claimed")}</strong>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<strong>{t("jobs.labels.difference")}</strong>
|
||||
</Col>
|
||||
</Row>
|
||||
{totals.map((t, idx) => (
|
||||
<Row key={idx}>
|
||||
<Col span={6}>{t.cost_center}</Col>
|
||||
<Col span={6}>{t.total.toFixed(2)}</Col>
|
||||
<Col span={6}>{t.claimed.toFixed(2)}</Col>
|
||||
<Col span={6}>
|
||||
<strong
|
||||
style={{
|
||||
color: t.total - t.claimed > 0 ? "green" : "red",
|
||||
}}
|
||||
>
|
||||
{(t.total - t.claimed).toFixed(2)}
|
||||
</strong>
|
||||
</Col>
|
||||
</Row>
|
||||
))}
|
||||
<div className="imex-flex-row" style={{ margin: ".5rem" }}>
|
||||
<Typography.Title level={3}>
|
||||
{t("jobs.labels.laborallocations")}
|
||||
</Typography.Title>
|
||||
<div className="labor-allocations-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<strong>{t("timetickets.fields.cost_center")}</strong>
|
||||
</th>
|
||||
<th>
|
||||
<strong>{t("jobs.labels.hrs_total")}</strong>
|
||||
</th>
|
||||
<th>
|
||||
<strong>{t("jobs.labels.hrs_claimed")}</strong>
|
||||
</th>
|
||||
<th>
|
||||
<strong>{t("jobs.labels.adjustments")}</strong>
|
||||
</th>
|
||||
<th>
|
||||
<strong>{t("jobs.labels.difference")}</strong>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{totals.map((t, idx) => (
|
||||
<tr key={idx}>
|
||||
<td>{t.cost_center}</td>
|
||||
<td>{t.total.toFixed(1)}</td>
|
||||
<td>{t.claimed.toFixed(1)}</td>
|
||||
<td>
|
||||
{t.adjustments.toFixed(1)}
|
||||
<LaborAllocationsAdjustmentEdit
|
||||
jobId={jobId}
|
||||
adjustments={adjustments}
|
||||
mod_lbr_ty={t.opcode}
|
||||
>
|
||||
<EditFilled style={{ marginLeft: ".2rem" }} />
|
||||
</LaborAllocationsAdjustmentEdit>
|
||||
</td>
|
||||
<td>
|
||||
<strong
|
||||
style={{
|
||||
color: t.difference > 0 ? "green" : "red",
|
||||
}}
|
||||
>
|
||||
{t.difference}
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user