IO-1972 add table for converted parts to labor lines.

This commit is contained in:
Patrick Fic
2022-07-13 13:50:13 -07:00
parent 7a0d5d712a
commit 05a0ee30f4
6 changed files with 126 additions and 14 deletions

View File

@@ -26551,6 +26551,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>convertedtolabor</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node> <concept_node>
<name>cost</name> <name>cost</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -1,6 +1,6 @@
import { EditFilled } from "@ant-design/icons"; import { EditFilled } from "@ant-design/icons";
import { Card, Space, Table } from "antd"; import { Card, Space, Table, Row, Col } from "antd";
import React, { useEffect, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
@@ -11,6 +11,8 @@ import LaborAllocationsAdjustmentEdit from "../labor-allocations-adjustment-edit
import "./labor-allocations-table.styles.scss"; import "./labor-allocations-table.styles.scss";
import { CalculateAllocationsTotals } from "./labor-allocations-table.utility"; import { CalculateAllocationsTotals } from "./labor-allocations-table.utility";
import _ from "lodash"; import _ from "lodash";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
technician: selectTechnician, technician: selectTechnician,
@@ -43,6 +45,11 @@ export function LaborAllocationsTable({
if (!jobId) setTotals([]); if (!jobId) setTotals([]);
}, [joblines, timetickets, bodyshop, adjustments, jobId]); }, [joblines, timetickets, bodyshop, adjustments, jobId]);
const convertedLines = useMemo(
() => joblines && joblines.filter((j) => j.convertedtolbr),
[joblines]
);
const columns = [ const columns = [
{ {
title: t("timetickets.fields.cost_center"), title: t("timetickets.fields.cost_center"),
@@ -114,24 +121,104 @@ export function LaborAllocationsTable({
), ),
}, },
]; ];
const convertedTableCols = [
{
title: t("joblines.fields.line_desc"),
dataIndex: "line_desc",
key: "line_desc",
ellipsis: true,
},
{
title: t("joblines.fields.op_code_desc"),
dataIndex: "op_code_desc",
key: "op_code_desc",
ellipsis: true,
render: (text, record) =>
`${record.op_code_desc || ""}${
record.alt_partm ? ` ${record.alt_partm}` : ""
}`,
},
{
title: t("joblines.fields.act_price"),
dataIndex: "act_price",
key: "act_price",
ellipsis: true,
render: (text, record) => (
<>
<CurrencyFormatter>
{record.db_ref === "900510" || record.db_ref === "900511"
? record.prt_dsmk_m
: record.act_price}
</CurrencyFormatter>
{record.prt_dsmk_p && record.prt_dsmk_p !== 0 ? (
<span
style={{ marginLeft: ".2rem" }}
>{`(${record.prt_dsmk_p}%)`}</span>
) : (
<></>
)}
</>
),
},
{
title: t("joblines.fields.part_qty"),
dataIndex: "part_qty",
key: "part_qty",
},
{
title: t("joblines.fields.mod_lbr_ty"),
dataIndex: "mod_lbr_ty",
key: "mod_lbr_ty",
render: (text, record) =>
record.mod_lbr_ty
? t(`joblines.fields.lbr_types.${record.mod_lbr_ty}`)
: null,
},
{
title: t("joblines.fields.mod_lb_hrs"),
dataIndex: "mod_lb_hrs",
key: "mod_lb_hrs",
},
];
const handleTableChange = (pagination, filters, sorter) => { const handleTableChange = (pagination, filters, sorter) => {
setState({ ...state, filteredInfo: filters, sortedInfo: sorter }); setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
}; };
return ( return (
<Card title={t("jobs.labels.laborallocations")}> <Row gutter={[16, 16]}>
<Table <Col span={24}>
columns={columns} <Card title={t("jobs.labels.laborallocations")}>
rowKey="cost_center" <Table
pagination={false} columns={columns}
onChange={handleTableChange} rowKey="cost_center"
dataSource={totals} pagination={false}
scroll={{ onChange={handleTableChange}
x: true, dataSource={totals}
}} scroll={{
/> x: true,
</Card> }}
/>
</Card>
</Col>
{convertedLines && convertedLines.length > 0 && (
<Col span={24}>
<Card title={t("jobs.labels.convertedtolabor")}>
<Table
columns={convertedTableCols}
rowKey="id"
pagination={false}
dataSource={convertedLines}
scroll={{
x: true,
}}
/>
</Card>
</Col>
)}
</Row>
); );
} }
export default connect(mapStateToProps, null)(LaborAllocationsTable); export default connect(mapStateToProps, null)(LaborAllocationsTable);

View File

@@ -48,6 +48,7 @@ export const GET_LINE_TICKET_BY_PK = gql`
lbr_op lbr_op
lbr_amt lbr_amt
op_code_desc op_code_desc
convertedtolbr
} }
timetickets(where: { jobid: { _eq: $id } }) { timetickets(where: { jobid: { _eq: $id } }) {
actualhrs actualhrs

View File

@@ -1570,6 +1570,7 @@
"closeconfirm": "Are you sure you want to close this job? This cannot be easily undone.", "closeconfirm": "Are you sure you want to close this job? This cannot be easily undone.",
"closejob": "Close Job {{ro_number}}", "closejob": "Close Job {{ro_number}}",
"contracts": "CC Contracts", "contracts": "CC Contracts",
"convertedtolabor": "Lines Converted to Labor",
"cost": "Cost", "cost": "Cost",
"cost_Additional": "Cost - Additional", "cost_Additional": "Cost - Additional",
"cost_labor": "Cost - Labor", "cost_labor": "Cost - Labor",

View File

@@ -1570,6 +1570,7 @@
"closeconfirm": "", "closeconfirm": "",
"closejob": "", "closejob": "",
"contracts": "", "contracts": "",
"convertedtolabor": "",
"cost": "", "cost": "",
"cost_Additional": "", "cost_Additional": "",
"cost_labor": "", "cost_labor": "",

View File

@@ -1570,6 +1570,7 @@
"closeconfirm": "", "closeconfirm": "",
"closejob": "", "closejob": "",
"contracts": "", "contracts": "",
"convertedtolabor": "",
"cost": "", "cost": "",
"cost_Additional": "", "cost_Additional": "",
"cost_labor": "", "cost_labor": "",