Further work on totals testing. Almost accurate now.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<babeledit_project version="1.2" be_version="2.6.1">
|
<babeledit_project be_version="2.6.1" version="1.2">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
BabelEdit project file
|
BabelEdit project file
|
||||||
@@ -4807,6 +4807,27 @@
|
|||||||
<folder_node>
|
<folder_node>
|
||||||
<name>actions</name>
|
<name>actions</name>
|
||||||
<children>
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>edit</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>receive</name>
|
<name>receive</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
@@ -5122,7 +5143,7 @@
|
|||||||
<name>successes</name>
|
<name>successes</name>
|
||||||
<children>
|
<children>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>creating</name>
|
<name>created</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
<description></description>
|
<description></description>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useLazyQuery, useMutation, useQuery } from "@apollo/react-hooks";
|
import { useLazyQuery, useMutation, useQuery } from "@apollo/react-hooks";
|
||||||
import { Form, Modal, notification } from "antd";
|
import { Form, Modal, notification } from "antd";
|
||||||
import React, { useState } from "react";
|
import React 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";
|
||||||
@@ -28,7 +28,6 @@ function InvoiceEnterModalContainer({
|
|||||||
}) {
|
}) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const linesState = useState([]);
|
|
||||||
|
|
||||||
const [insertInvoice] = useMutation(INSERT_NEW_INVOICE);
|
const [insertInvoice] = useMutation(INSERT_NEW_INVOICE);
|
||||||
|
|
||||||
@@ -67,6 +66,9 @@ function InvoiceEnterModalContainer({
|
|||||||
notification["success"]({
|
notification["success"]({
|
||||||
message: t("invoices.successes.created"),
|
message: t("invoices.successes.created"),
|
||||||
});
|
});
|
||||||
|
if (invoiceEnterModal.actions.refetch)
|
||||||
|
invoiceEnterModal.actions.refetch();
|
||||||
|
|
||||||
toggleModalVisible();
|
toggleModalVisible();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@@ -82,8 +84,6 @@ function InvoiceEnterModalContainer({
|
|||||||
toggleModalVisible();
|
toggleModalVisible();
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("invoiceEnterModal", invoiceEnterModal);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={
|
title={
|
||||||
@@ -116,7 +116,6 @@ function InvoiceEnterModalContainer({
|
|||||||
VendorAutoCompleteData && VendorAutoCompleteData.vendors
|
VendorAutoCompleteData && VendorAutoCompleteData.vendors
|
||||||
}
|
}
|
||||||
loadLines={loadLines}
|
loadLines={loadLines}
|
||||||
linesState={linesState}
|
|
||||||
lineData={lineData ? lineData.joblines : null}
|
lineData={lineData ? lineData.joblines : null}
|
||||||
responsibilityCenters={bodyshop.md_responsibility_centers || null}
|
responsibilityCenters={bodyshop.md_responsibility_centers || null}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,60 +1,146 @@
|
|||||||
import { Table } from "antd";
|
import { Button, Descriptions, Table } from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { alphaSort } from "../../utils/sorters";
|
import { Link } from "react-router-dom";
|
||||||
|
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||||
import { DateFormatter } from "../../utils/DateFormatter";
|
import { DateFormatter } from "../../utils/DateFormatter";
|
||||||
export default function InvoicesListTableComponent({ loading, invoices }) {
|
import { alphaSort } from "../../utils/sorters";
|
||||||
const [state, setState] = useState({
|
|
||||||
sortedInfo: {}
|
export default function InvoicesListTableComponent({
|
||||||
});
|
loading,
|
||||||
|
invoices,
|
||||||
|
selectedInvoice,
|
||||||
|
handleOnRowClick,
|
||||||
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [state, setState] = useState({
|
||||||
|
sortedInfo: {},
|
||||||
|
});
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: t("invoices.fields.vendorname"),
|
title: t("invoices.fields.vendorname"),
|
||||||
dataIndex: "vendorname",
|
dataIndex: "vendorname",
|
||||||
key: "vendorname",
|
key: "vendorname",
|
||||||
// onFilter: (value, record) => record.ro_number.includes(value),
|
|
||||||
// filteredValue: state.filteredInfo.text || null,
|
|
||||||
sorter: (a, b) => alphaSort(a.vendor.name, b.vendor.name),
|
sorter: (a, b) => alphaSort(a.vendor.name, b.vendor.name),
|
||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === "vendorname" && state.sortedInfo.order,
|
state.sortedInfo.columnKey === "vendorname" && state.sortedInfo.order,
|
||||||
//ellipsis: true,
|
render: (text, record) => <span>{record.vendor.name}</span>,
|
||||||
render: (text, record) => <span>{record.vendor.name}</span>
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("invoices.fields.invoice_number"),
|
title: t("invoices.fields.invoice_number"),
|
||||||
dataIndex: "invoice_number",
|
dataIndex: "invoice_number",
|
||||||
key: "invoice_number",
|
key: "invoice_number",
|
||||||
// onFilter: (value, record) => record.ro_number.includes(value),
|
|
||||||
// filteredValue: state.filteredInfo.text || null,
|
|
||||||
sorter: (a, b) => alphaSort(a.invoice_number, b.invoice_number),
|
sorter: (a, b) => alphaSort(a.invoice_number, b.invoice_number),
|
||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === "invoice_number" &&
|
state.sortedInfo.columnKey === "invoice_number" &&
|
||||||
state.sortedInfo.order
|
state.sortedInfo.order,
|
||||||
//ellipsis: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("invoices.fields.date"),
|
title: t("invoices.fields.date"),
|
||||||
dataIndex: "date",
|
dataIndex: "date",
|
||||||
key: "date",
|
key: "date",
|
||||||
// onFilter: (value, record) => record.ro_number.includes(value),
|
|
||||||
// filteredValue: state.filteredInfo.text || null,
|
|
||||||
sorter: (a, b) => a.date - b.date,
|
sorter: (a, b) => a.date - b.date,
|
||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === "date" && state.sortedInfo.order,
|
state.sortedInfo.columnKey === "date" && state.sortedInfo.order,
|
||||||
//ellipsis: true,
|
render: (text, record) => <DateFormatter>{record.date}</DateFormatter>,
|
||||||
render: (text, record) => <DateFormatter>{record.date}</DateFormatter>
|
},
|
||||||
}
|
{
|
||||||
|
title: t("invoices.fields.total"),
|
||||||
|
dataIndex: "total",
|
||||||
|
key: "total",
|
||||||
|
|
||||||
|
sorter: (a, b) => a.total - b.total,
|
||||||
|
sortOrder:
|
||||||
|
state.sortedInfo.columnKey === "total" && state.sortedInfo.order,
|
||||||
|
render: (text, record) => (
|
||||||
|
<CurrencyFormatter>{record.total}</CurrencyFormatter>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("general.labels.actions"),
|
||||||
|
dataIndex: "actions",
|
||||||
|
key: "actions",
|
||||||
|
render: (text, record) => (
|
||||||
|
<Link to={`/manage/invoices/${record.id}`}>
|
||||||
|
<Button>{t("invoices.actions.edit")}</Button>
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const handleTableChange = (pagination, filters, sorter) => {
|
const handleTableChange = (pagination, filters, sorter) => {
|
||||||
setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
|
setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
|
||||||
};
|
};
|
||||||
|
|
||||||
const rowExpander = record => (
|
const rowExpander = (record) => {
|
||||||
<div style={{ margin: 0 }}>Invoice details</div>
|
const columns = [
|
||||||
);
|
{
|
||||||
|
title: t("invoicelines.fields.line_desc"),
|
||||||
|
dataIndex: "line_desc",
|
||||||
|
key: "line_desc",
|
||||||
|
sorter: (a, b) => alphaSort(a.line_desc, b.line_desc),
|
||||||
|
sortOrder:
|
||||||
|
state.sortedInfo.columnKey === "line_desc" && state.sortedInfo.order,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("invoicelines.fields.retail"),
|
||||||
|
dataIndex: "actual_price",
|
||||||
|
key: "actual_price",
|
||||||
|
sorter: (a, b) => a.actual_price - b.actual_price,
|
||||||
|
sortOrder:
|
||||||
|
state.sortedInfo.columnKey === "actual_price" &&
|
||||||
|
state.sortedInfo.order,
|
||||||
|
render: (text, record) => (
|
||||||
|
<CurrencyFormatter>{record.actual_price}</CurrencyFormatter>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("invoicelines.fields.actual_cost"),
|
||||||
|
dataIndex: "actual_cost",
|
||||||
|
key: "actual_cost",
|
||||||
|
sorter: (a, b) => a.actual_cost - b.actual_cost,
|
||||||
|
sortOrder:
|
||||||
|
state.sortedInfo.columnKey === "actual_cost" &&
|
||||||
|
state.sortedInfo.order,
|
||||||
|
render: (text, record) => (
|
||||||
|
<CurrencyFormatter>{record.actual_cost}</CurrencyFormatter>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("invoicelines.fields.cost_center"),
|
||||||
|
dataIndex: "cost_center",
|
||||||
|
key: "cost_center",
|
||||||
|
sorter: (a, b) => alphaSort(a.cost_center, b.cost_center),
|
||||||
|
sortOrder:
|
||||||
|
state.sortedInfo.columnKey === "cost_center" &&
|
||||||
|
state.sortedInfo.order,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Descriptions title="User Info">
|
||||||
|
<Descriptions.Item label="UserName">Zhou Maomao</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="Telephone">1810000000</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="Live">Hangzhou, Zhejiang</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="Remark">empty</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="Address">
|
||||||
|
No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
pagination={{ position: "top", defaultPageSize: 25 }}
|
||||||
|
columns={columns.map((item) => ({ ...item }))}
|
||||||
|
rowKey="id"
|
||||||
|
dataSource={record.invoicelines}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
@@ -62,10 +148,34 @@ export default function InvoicesListTableComponent({ loading, invoices }) {
|
|||||||
size="small"
|
size="small"
|
||||||
expandedRowRender={rowExpander}
|
expandedRowRender={rowExpander}
|
||||||
pagination={{ position: "top", defaultPageSize: 25 }}
|
pagination={{ position: "top", defaultPageSize: 25 }}
|
||||||
columns={columns.map(item => ({ ...item }))}
|
columns={columns.map((item) => ({ ...item }))}
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
dataSource={invoices}
|
dataSource={invoices}
|
||||||
onChange={handleTableChange}
|
onChange={handleTableChange}
|
||||||
|
expandable={{
|
||||||
|
expandedRowKeys: [selectedInvoice],
|
||||||
|
onExpand: (expanded, record) => {
|
||||||
|
handleOnRowClick(expanded ? record : null);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
rowSelection={{
|
||||||
|
onSelect: (record) => {
|
||||||
|
handleOnRowClick(record);
|
||||||
|
},
|
||||||
|
selectedRowKeys: [selectedInvoice],
|
||||||
|
type: "radio",
|
||||||
|
}}
|
||||||
|
onRow={(record, rowIndex) => {
|
||||||
|
return {
|
||||||
|
onClick: (event) => {
|
||||||
|
handleOnRowClick(record);
|
||||||
|
}, // click row
|
||||||
|
onDoubleClick: (event) => {}, // double click row
|
||||||
|
onContextMenu: (event) => {}, // right button click row
|
||||||
|
onMouseEnter: (event) => {}, // mouse enter row
|
||||||
|
onMouseLeave: (event) => {}, // mouse leave row
|
||||||
|
};
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
console.log("otherTotals", otherTotals);
|
console.log("otherTotals", otherTotals);
|
||||||
|
|
||||||
console.log("job", job);
|
console.log("job", job);
|
||||||
console.log("parts pst", statePartsTax);
|
console.log("parts pst", statePartsTax);
|
||||||
console.log(
|
console.log(
|
||||||
@@ -158,19 +157,23 @@ function CalculateRatesTotals(ratesList, shoprates) {
|
|||||||
},
|
},
|
||||||
rate_atp: {
|
rate_atp: {
|
||||||
rate: shoprates.rate_atp || 0,
|
rate: shoprates.rate_atp || 0,
|
||||||
hours: jobLines
|
hours:
|
||||||
.filter(
|
jobLines.filter((item) => item.line_desc.includes("ATS Amount"))
|
||||||
(item) =>
|
.length > 0
|
||||||
item.mod_lbr_ty !== "LA1" &&
|
? jobLines
|
||||||
item.mod_lbr_ty !== "LA2" &&
|
.filter(
|
||||||
item.mod_lbr_ty !== "LA3" &&
|
(item) =>
|
||||||
item.mod_lbr_ty !== "LA4" &&
|
item.mod_lbr_ty !== "LA1" &&
|
||||||
item.mod_lbr_ty !== "LAU" &&
|
item.mod_lbr_ty !== "LA2" &&
|
||||||
item.mod_lbr_ty !== "LAG" &&
|
item.mod_lbr_ty !== "LA3" &&
|
||||||
item.mod_lbr_ty !== "LAS" &&
|
item.mod_lbr_ty !== "LA4" &&
|
||||||
item.mod_lbr_ty !== "LAA"
|
item.mod_lbr_ty !== "LAU" &&
|
||||||
)
|
item.mod_lbr_ty !== "LAG" &&
|
||||||
.reduce((acc, value) => acc + value.mod_lb_hrs, 0),
|
item.mod_lbr_ty !== "LAS" &&
|
||||||
|
item.mod_lbr_ty !== "LAA"
|
||||||
|
)
|
||||||
|
.reduce((acc, value) => acc + value.mod_lb_hrs, 0)
|
||||||
|
: 0,
|
||||||
},
|
},
|
||||||
paint_mat: {
|
paint_mat: {
|
||||||
rate: ratesList.rate_mapa,
|
rate: ratesList.rate_mapa,
|
||||||
@@ -193,8 +196,8 @@ function CalculateRatesTotals(ratesList, shoprates) {
|
|||||||
subtotal = subtotal + ret[property].hours * ret[property].rate;
|
subtotal = subtotal + ret[property].hours * ret[property].rate;
|
||||||
if (
|
if (
|
||||||
property !== "paint_mat" &&
|
property !== "paint_mat" &&
|
||||||
property !== "shop_mat" &&
|
property !== "shop_mat"
|
||||||
property !== "rate_atp"
|
//&& property !== "rate_atp"
|
||||||
)
|
)
|
||||||
rates_subtotal =
|
rates_subtotal =
|
||||||
rates_subtotal + ret[property].hours * ret[property].rate;
|
rates_subtotal + ret[property].hours * ret[property].rate;
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
import { Button } from "antd";
|
import { Button } from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
import InvoicesListTableComponent from "../invoices-list-table/invoices-list-table.component";
|
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
|
import InvoicesListTableComponent from "../invoices-list-table/invoices-list-table.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
|
||||||
//currentUser: selectCurrentUser
|
|
||||||
});
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setInvoiceEnterContext: (context) =>
|
setInvoiceEnterContext: (context) =>
|
||||||
dispatch(setModalContext({ context: context, modal: "invoiceEnter" })),
|
dispatch(setModalContext({ context: context, modal: "invoiceEnter" })),
|
||||||
});
|
});
|
||||||
export default connect(
|
|
||||||
mapStateToProps,
|
export function JobsDetailPliComponent({
|
||||||
mapDispatchToProps
|
|
||||||
)(function JobsDetailPliComponent({
|
|
||||||
setInvoiceEnterContext,
|
setInvoiceEnterContext,
|
||||||
job,
|
job,
|
||||||
invoicesQuery,
|
invoicesQuery,
|
||||||
|
handleOnRowClick,
|
||||||
|
selectedInvoice,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -40,8 +36,13 @@ export default connect(
|
|||||||
) : null}
|
) : null}
|
||||||
<InvoicesListTableComponent
|
<InvoicesListTableComponent
|
||||||
loading={invoicesQuery.loading}
|
loading={invoicesQuery.loading}
|
||||||
|
handleOnRowClick={handleOnRowClick}
|
||||||
|
selectedInvoice={selectedInvoice}
|
||||||
invoices={invoicesQuery.data ? invoicesQuery.data.invoices : null}
|
invoices={invoicesQuery.data ? invoicesQuery.data.invoices : null}
|
||||||
|
refetch={invoicesQuery.refetch}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps)(JobsDetailPliComponent);
|
||||||
|
|||||||
@@ -2,11 +2,35 @@ import React from "react";
|
|||||||
import { useQuery } from "@apollo/react-hooks";
|
import { useQuery } from "@apollo/react-hooks";
|
||||||
import JobsDetailPliComponent from "./jobs-detail-pli.component";
|
import JobsDetailPliComponent from "./jobs-detail-pli.component";
|
||||||
import { QUERY_INVOICES_BY_JOBID } from "../../graphql/invoices.queries";
|
import { QUERY_INVOICES_BY_JOBID } from "../../graphql/invoices.queries";
|
||||||
|
import { useHistory, useLocation } from "react-router-dom";
|
||||||
|
import queryString from "query-string";
|
||||||
|
|
||||||
export default function JobsDetailPliContainer({ job }) {
|
export default function JobsDetailPliContainer({ job }) {
|
||||||
const invoicesQuery = useQuery(QUERY_INVOICES_BY_JOBID, {
|
const invoicesQuery = useQuery(QUERY_INVOICES_BY_JOBID, {
|
||||||
variables: { jobid: job.id },
|
variables: { jobid: job.id },
|
||||||
fetchPolicy: "network-only"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return <JobsDetailPliComponent job={job} invoicesQuery={invoicesQuery} />;
|
const search = queryString.parse(useLocation().search);
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
const handleOnRowClick = (record) => {
|
||||||
|
if (record) {
|
||||||
|
if (record.id) {
|
||||||
|
search.invoiceid = record.id;
|
||||||
|
history.push({ search: queryString.stringify(search) });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delete search.invoiceid;
|
||||||
|
history.push({ search: queryString.stringify(search) });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<JobsDetailPliComponent
|
||||||
|
job={job}
|
||||||
|
invoicesQuery={invoicesQuery}
|
||||||
|
handleOnRowClick={handleOnRowClick}
|
||||||
|
selectedInvoice={search.invoiceid}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,17 +8,20 @@ import PhoneFormatter from "../../utils/PhoneFormatter";
|
|||||||
import { alphaSort } from "../../utils/sorters";
|
import { alphaSort } from "../../utils/sorters";
|
||||||
import StartChatButton from "../chat-open-button/chat-open-button.component";
|
import StartChatButton from "../chat-open-button/chat-open-button.component";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
import queryString from "query-string";
|
||||||
|
|
||||||
export default withRouter(function JobsList({
|
export default withRouter(function JobsList({
|
||||||
searchTextState,
|
searchTextState,
|
||||||
refetch,
|
refetch,
|
||||||
loading,
|
loading,
|
||||||
jobs,
|
jobs,
|
||||||
selectedJob
|
searchParams,
|
||||||
}) {
|
}) {
|
||||||
|
const { selected } = searchParams;
|
||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
sortedInfo: {},
|
sortedInfo: {},
|
||||||
filteredInfo: { text: "" }
|
filteredInfo: { text: "" },
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -42,7 +45,7 @@ export default withRouter(function JobsList({
|
|||||||
<Link to={"/manage/jobs/" + record.id}>
|
<Link to={"/manage/jobs/" + record.id}>
|
||||||
{record.ro_number ? record.ro_number : record.est_number}
|
{record.ro_number ? record.ro_number : record.est_number}
|
||||||
</Link>
|
</Link>
|
||||||
)
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("jobs.fields.owner"),
|
title: t("jobs.fields.owner"),
|
||||||
@@ -61,7 +64,7 @@ export default withRouter(function JobsList({
|
|||||||
) : (
|
) : (
|
||||||
<span>{`${record.ownr_fn} ${record.ownr_ln}`}</span>
|
<span>{`${record.ownr_fn} ${record.ownr_ln}`}</span>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("jobs.fields.ownr_ph1"),
|
title: t("jobs.fields.ownr_ph1"),
|
||||||
@@ -76,7 +79,7 @@ export default withRouter(function JobsList({
|
|||||||
<StartChatButton phone={record.ownr_ph1} />
|
<StartChatButton phone={record.ownr_ph1} />
|
||||||
</span>
|
</span>
|
||||||
) : null;
|
) : null;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("jobs.fields.status"),
|
title: t("jobs.fields.status"),
|
||||||
@@ -89,7 +92,7 @@ export default withRouter(function JobsList({
|
|||||||
state.sortedInfo.columnKey === "status" && state.sortedInfo.order,
|
state.sortedInfo.columnKey === "status" && state.sortedInfo.order,
|
||||||
render: (text, record) => {
|
render: (text, record) => {
|
||||||
return record.status || t("general.labels.na");
|
return record.status || t("general.labels.na");
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -101,14 +104,16 @@ export default withRouter(function JobsList({
|
|||||||
render: (text, record) => {
|
render: (text, record) => {
|
||||||
return record.vehicleid ? (
|
return record.vehicleid ? (
|
||||||
<Link to={"/manage/vehicles/" + record.vehicleid}>
|
<Link to={"/manage/vehicles/" + record.vehicleid}>
|
||||||
{`${record.v_model_yr || ""} ${record.v_make_desc ||
|
{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${
|
||||||
""} ${record.v_model_desc || ""}`}
|
record.v_model_desc || ""
|
||||||
|
}`}
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<span>{`${record.v_model_yr || ""} ${record.v_make_desc ||
|
<span>{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${
|
||||||
""} ${record.v_model_desc || ""}`}</span>
|
record.v_model_desc || ""
|
||||||
|
}`}</span>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("vehicles.fields.plate_no"),
|
title: t("vehicles.fields.plate_no"),
|
||||||
@@ -121,7 +126,7 @@ export default withRouter(function JobsList({
|
|||||||
state.sortedInfo.columnKey === "plate_no" && state.sortedInfo.order,
|
state.sortedInfo.columnKey === "plate_no" && state.sortedInfo.order,
|
||||||
render: (text, record) => {
|
render: (text, record) => {
|
||||||
return record.plate_no ? record.plate_no : "";
|
return record.plate_no ? record.plate_no : "";
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("jobs.fields.clm_no"),
|
title: t("jobs.fields.clm_no"),
|
||||||
@@ -138,7 +143,7 @@ export default withRouter(function JobsList({
|
|||||||
) : (
|
) : (
|
||||||
t("general.labels.unknown")
|
t("general.labels.unknown")
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("jobs.fields.clm_total"),
|
title: t("jobs.fields.clm_total"),
|
||||||
@@ -154,7 +159,7 @@ export default withRouter(function JobsList({
|
|||||||
) : (
|
) : (
|
||||||
t("general.labels.unknown")
|
t("general.labels.unknown")
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("jobs.fields.owner_owing"),
|
title: t("jobs.fields.owner_owing"),
|
||||||
@@ -167,18 +172,24 @@ export default withRouter(function JobsList({
|
|||||||
) : (
|
) : (
|
||||||
t("general.labels.unknown")
|
t("general.labels.unknown")
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const handleTableChange = (pagination, filters, sorter) => {
|
const handleTableChange = (pagination, filters, sorter) => {
|
||||||
setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
|
setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnRowClick = record => {
|
const handleOnRowClick = (record) => {
|
||||||
if (record) {
|
if (record) {
|
||||||
if (record.id) {
|
if (record.id) {
|
||||||
history.push({ search: `selected=${record.id}` });
|
console.log("searchParams", searchParams);
|
||||||
|
history.push({
|
||||||
|
search: queryString.stringify({
|
||||||
|
...searchParams,
|
||||||
|
selected: record.id,
|
||||||
|
}),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -195,7 +206,7 @@ export default withRouter(function JobsList({
|
|||||||
</Button>
|
</Button>
|
||||||
<Input.Search
|
<Input.Search
|
||||||
placeholder={t("general.labels.search")}
|
placeholder={t("general.labels.search")}
|
||||||
onChange={e => {
|
onChange={(e) => {
|
||||||
setSearchText(e.target.value);
|
setSearchText(e.target.value);
|
||||||
}}
|
}}
|
||||||
enterButton
|
enterButton
|
||||||
@@ -205,26 +216,26 @@ export default withRouter(function JobsList({
|
|||||||
}}
|
}}
|
||||||
size="small"
|
size="small"
|
||||||
pagination={{ position: "top" }}
|
pagination={{ position: "top" }}
|
||||||
columns={columns.map(item => ({ ...item }))}
|
columns={columns.map((item) => ({ ...item }))}
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
dataSource={jobs}
|
dataSource={jobs}
|
||||||
rowSelection={{
|
rowSelection={{
|
||||||
onSelect: record => {
|
onSelect: (record) => {
|
||||||
handleOnRowClick(record);
|
handleOnRowClick(record);
|
||||||
},
|
},
|
||||||
selectedRowKeys: [selectedJob],
|
selectedRowKeys: [selected],
|
||||||
type: "radio"
|
type: "radio",
|
||||||
}}
|
}}
|
||||||
onChange={handleTableChange}
|
onChange={handleTableChange}
|
||||||
onRow={(record, rowIndex) => {
|
onRow={(record, rowIndex) => {
|
||||||
return {
|
return {
|
||||||
onClick: event => {
|
onClick: (event) => {
|
||||||
handleOnRowClick(record);
|
handleOnRowClick(record);
|
||||||
}, // click row
|
}, // click row
|
||||||
onDoubleClick: event => {}, // double click row
|
onDoubleClick: (event) => {}, // double click row
|
||||||
onContextMenu: event => {}, // right button click row
|
onContextMenu: (event) => {}, // right button click row
|
||||||
onMouseEnter: event => {}, // mouse enter row
|
onMouseEnter: (event) => {}, // mouse enter row
|
||||||
onMouseLeave: event => {} // mouse leave row
|
onMouseLeave: (event) => {}, // mouse leave row
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -31,3 +31,31 @@ export const QUERY_INVOICES_BY_JOBID = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const QUERY_INVOICE_BY_PK = gql`
|
||||||
|
query QUERY_INVOICE_BY_PK($invoiceid: uuid!) {
|
||||||
|
invoices_by_pk(id: $invoiceid) {
|
||||||
|
due_date
|
||||||
|
exported
|
||||||
|
exported_at
|
||||||
|
id
|
||||||
|
invoice_number
|
||||||
|
date
|
||||||
|
is_credit_memo
|
||||||
|
jobid
|
||||||
|
total
|
||||||
|
updated_at
|
||||||
|
vendor {
|
||||||
|
name
|
||||||
|
discount
|
||||||
|
}
|
||||||
|
invoicelines {
|
||||||
|
id
|
||||||
|
line_desc
|
||||||
|
actual_price
|
||||||
|
actual_cost
|
||||||
|
cost_center
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -435,6 +435,7 @@ export const QUERY_JOB_FINANCIALS = gql`
|
|||||||
rate_matd
|
rate_matd
|
||||||
joblines {
|
joblines {
|
||||||
id
|
id
|
||||||
|
line_desc
|
||||||
tax_part
|
tax_part
|
||||||
prt_dsmk_p
|
prt_dsmk_p
|
||||||
prt_dsmk_m
|
prt_dsmk_m
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import { QUERY_ALL_ACTIVE_JOBS } from "../../graphql/jobs.queries";
|
|||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop
|
bodyshop: selectBodyshop,
|
||||||
});
|
});
|
||||||
|
|
||||||
export function JobsPage({ location, bodyshop }) {
|
export function JobsPage({ location, bodyshop }) {
|
||||||
const { loading, error, data, refetch } = useQuery(QUERY_ALL_ACTIVE_JOBS, {
|
const { loading, error, data, refetch } = useQuery(QUERY_ALL_ACTIVE_JOBS, {
|
||||||
variables: {
|
variables: {
|
||||||
statuses: bodyshop.md_ro_statuses.open_statuses || ["Open"]
|
statuses: bodyshop.md_ro_statuses.open_statuses || ["Open"],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -39,14 +39,14 @@ export function JobsPage({ location, bodyshop }) {
|
|||||||
searchTextState={searchTextState}
|
searchTextState={searchTextState}
|
||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
selectedJob={search.selected}
|
searchParams={search}
|
||||||
//setSelectedJob={setSelectedJob}
|
//setSelectedJob={setSelectedJob}
|
||||||
jobs={
|
jobs={
|
||||||
data
|
data
|
||||||
? searchText === ""
|
? searchText === ""
|
||||||
? data.jobs
|
? data.jobs
|
||||||
: data.jobs.filter(
|
: data.jobs.filter(
|
||||||
j =>
|
(j) =>
|
||||||
(j.ro_number || "")
|
(j.ro_number || "")
|
||||||
.toString()
|
.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
|
|||||||
@@ -339,6 +339,7 @@
|
|||||||
},
|
},
|
||||||
"invoices": {
|
"invoices": {
|
||||||
"actions": {
|
"actions": {
|
||||||
|
"edit": "Edit",
|
||||||
"receive": "Receive Part"
|
"receive": "Receive Part"
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
@@ -361,7 +362,7 @@
|
|||||||
"new": "New Invoice"
|
"new": "New Invoice"
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"creating": "Invoice added successfully."
|
"created": "Invoice added successfully."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"joblines": {
|
"joblines": {
|
||||||
|
|||||||
@@ -339,6 +339,7 @@
|
|||||||
},
|
},
|
||||||
"invoices": {
|
"invoices": {
|
||||||
"actions": {
|
"actions": {
|
||||||
|
"edit": "",
|
||||||
"receive": ""
|
"receive": ""
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
@@ -361,7 +362,7 @@
|
|||||||
"new": ""
|
"new": ""
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"creating": ""
|
"created": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"joblines": {
|
"joblines": {
|
||||||
|
|||||||
@@ -339,6 +339,7 @@
|
|||||||
},
|
},
|
||||||
"invoices": {
|
"invoices": {
|
||||||
"actions": {
|
"actions": {
|
||||||
|
"edit": "",
|
||||||
"receive": ""
|
"receive": ""
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
@@ -361,7 +362,7 @@
|
|||||||
"new": ""
|
"new": ""
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"creating": ""
|
"created": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"joblines": {
|
"joblines": {
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ES6",
|
|
||||||
"module": "commonjs",
|
|
||||||
"allowSyntheticDefaultImports": true
|
|
||||||
},
|
|
||||||
"exclude": [
|
|
||||||
"dist",
|
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user