Compare commits
4 Commits
feature/20
...
feature/cd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0d6c5e1b1 | ||
|
|
84b39f3d2b | ||
|
|
4ab0947cc8 | ||
|
|
105ecd4221 |
6
_reference/Responsibility Center Setup.md
Normal file
6
_reference/Responsibility Center Setup.md
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,77 @@
|
||||
import { Button, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { socket } from "../../pages/dms/dms.container";
|
||||
import PhoneFormatter from "../../utils/PhoneFormatter";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
export default function DmsCustomerSelector() {
|
||||
const { t } = useTranslation();
|
||||
const [customerList, setcustomerList] = useState([]);
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [selectedCustomer, setSelectedCustomer] = useState(null);
|
||||
|
||||
socket.on("cdk-select-customer", (customerList, callback) => {
|
||||
setVisible(true);
|
||||
setcustomerList(customerList);
|
||||
});
|
||||
|
||||
const onOk = () => {
|
||||
setVisible(false);
|
||||
socket.emit("cdk-selected-customer", selectedCustomer);
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t("dms.fields.name1"),
|
||||
dataIndex: ["name1", "fullName"],
|
||||
key: "name1",
|
||||
sorter: (a, b) => alphaSort(a.name1?.fullName, b.name1?.fullName),
|
||||
},
|
||||
{
|
||||
title: t("dms.fields.name2"),
|
||||
dataIndex: ["name2", "fullName"],
|
||||
key: "name2",
|
||||
sorter: (a, b) => alphaSort(a.name2?.fullName, b.name2?.fullName),
|
||||
},
|
||||
{
|
||||
title: t("dms.fields.phone"),
|
||||
dataIndex: ["contactInfo", "mainTelephoneNumber", "value"],
|
||||
key: "phone",
|
||||
render: (record, value) => (
|
||||
<PhoneFormatter>
|
||||
{record.contactInfo?.mainTelephoneNumber?.value}
|
||||
</PhoneFormatter>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("dms.fields.address"),
|
||||
//dataIndex: ["name2", "fullName"],
|
||||
key: "address",
|
||||
render: (record, value) =>
|
||||
`${record.address?.addressLine[0]}, ${record.address?.city} ${record.address?.stateOrProvince} ${record.address?.postalCode}`,
|
||||
},
|
||||
];
|
||||
|
||||
if (!visible) return <></>;
|
||||
return (
|
||||
<Table
|
||||
title={() => (
|
||||
<div>
|
||||
<Button onClick={onOk}>Select</Button>
|
||||
</div>
|
||||
)}
|
||||
pagination={{ position: "top" }}
|
||||
columns={columns}
|
||||
rowKey={(record) => record.id.value}
|
||||
dataSource={customerList}
|
||||
//onChange={handleTableChange}
|
||||
rowSelection={{
|
||||
onSelect: (props) => {
|
||||
setSelectedCustomer(props.id.value);
|
||||
},
|
||||
type: "radio",
|
||||
selectedRowKeys: [selectedCustomer],
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ export default function GlobalSearch() {
|
||||
<span>{`${job.v_model_yr || ""} ${job.v_make_desc || ""} ${
|
||||
job.v_model_desc || ""
|
||||
}`}</span>
|
||||
<span>{`${job.clm_no || ""}`}</span>
|
||||
<span>{`${job.clm_no}`}</span>
|
||||
</Space>
|
||||
</Link>
|
||||
),
|
||||
@@ -91,8 +91,8 @@ export default function GlobalSearch() {
|
||||
vehicle.v_make_desc || ""
|
||||
} ${vehicle.v_model_desc || ""}`}
|
||||
</span>
|
||||
<span>{vehicle.plate_no || ""}</span>
|
||||
<span> {vehicle.v_vin || ""}</span>
|
||||
<span>{vehicle.plate_no}</span>
|
||||
<span> {vehicle.v_vin}</span>
|
||||
</Space>
|
||||
</Link>
|
||||
),
|
||||
@@ -108,11 +108,10 @@ export default function GlobalSearch() {
|
||||
label: (
|
||||
<Link to={`/manage/jobs/${payment.job.id}`}>
|
||||
<Space size="small" split={<Divider type="vertical" />}>
|
||||
<span>{payment.paymentnum}</span>
|
||||
<span>{payment.job.ro_number}</span>
|
||||
<span>{payment.memo || ""}</span>
|
||||
<span>{payment.amount || ""}</span>
|
||||
<span>{payment.transactionid || ""}</span>
|
||||
<span>{payment.job.memo}</span>
|
||||
<span>{payment.job.amount}</span>
|
||||
<span>{payment.job.transactionid}</span>
|
||||
</Space>
|
||||
</Link>
|
||||
),
|
||||
|
||||
@@ -295,18 +295,18 @@ export function JobLinesComponent({
|
||||
onClick={async () => {
|
||||
await deleteJobLine({
|
||||
variables: { joblineId: record.id },
|
||||
// update(cache) {
|
||||
// cache.modify({
|
||||
// id: cache.identify(job),
|
||||
// fields: {
|
||||
// joblines(existingJobLines, { readField }) {
|
||||
// return existingJobLines.filter(
|
||||
// (jlRef) => record.id !== readField("id", jlRef)
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// },
|
||||
update(cache) {
|
||||
cache.modify({
|
||||
id: cache.identify(job),
|
||||
fields: {
|
||||
joblines(existingJobLines, { readField }) {
|
||||
return existingJobLines.filter(
|
||||
(jlRef) => record.id !== readField("id", jlRef)
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
await axios.post("/job/totalsssu", {
|
||||
id: job.id,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Checkbox, Table, Typography } from "antd";
|
||||
import { Checkbox, PageHeader, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
@@ -21,7 +21,6 @@ export default function JobReconciliationBillsTable({
|
||||
title: t("billlines.fields.line_desc"),
|
||||
dataIndex: "line_desc",
|
||||
key: "line_desc",
|
||||
width: "35%",
|
||||
sorter: (a, b) => alphaSort(a.line_desc, b.line_desc),
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "line_desc" && state.sortedInfo.order,
|
||||
@@ -30,8 +29,6 @@ export default function JobReconciliationBillsTable({
|
||||
title: t("billlines.labels.from"),
|
||||
dataIndex: "from",
|
||||
key: "from",
|
||||
width: "20%",
|
||||
ellipsis: true,
|
||||
render: (text, record) =>
|
||||
`${record.bill.vendor && record.bill.vendor.name} / ${
|
||||
record.bill.invoice_number
|
||||
@@ -60,7 +57,7 @@ export default function JobReconciliationBillsTable({
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("joblines.fields.part_qty"),
|
||||
title: t("billlines.fields.quantity"),
|
||||
dataIndex: "quantity",
|
||||
key: "quantity",
|
||||
sorter: (a, b) => a.quantity - b.quantity,
|
||||
@@ -89,12 +86,10 @@ export default function JobReconciliationBillsTable({
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Typography.Title level={4}>{t("bills.labels.bills")}</Typography.Title>
|
||||
<PageHeader title={t("bills.labels.bills")}>
|
||||
<Table
|
||||
pagination={false}
|
||||
size="small"
|
||||
scroll={{ y: "80vh", x: true }}
|
||||
scroll={{ y: "40vh", x: true }}
|
||||
columns={columns}
|
||||
rowKey="id"
|
||||
dataSource={invoiceLineData}
|
||||
@@ -104,6 +99,6 @@ export default function JobReconciliationBillsTable({
|
||||
selectedRowKeys: selectedLines,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</PageHeader>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,23 +22,21 @@ export default function JobReconciliationModalComponent({ job, bills }) {
|
||||
);
|
||||
|
||||
return (
|
||||
<div style={{ flex: 1, display: "flex", flexDirection: "column" }}>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Row gutter={8}>
|
||||
<Col span={12}>
|
||||
<JobReconciliationPartsTable
|
||||
jobLineData={jobLineData}
|
||||
jobLineState={jobLineState}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<JobReconciliationBillsTable
|
||||
invoiceLineData={invoiceLineData}
|
||||
billLineState={billLineState}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
<div>
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col span={12}>
|
||||
<JobReconciliationPartsTable
|
||||
jobLineData={jobLineData}
|
||||
jobLineState={jobLineState}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<JobReconciliationBillsTable
|
||||
invoiceLineData={invoiceLineData}
|
||||
billLineState={billLineState}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<JobReconciliationTotals
|
||||
jobLines={jobLineData}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
.imex-reconciliation-modal {
|
||||
top: 20px;
|
||||
.ant-modal-content {
|
||||
height: 95vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.ant-modal-body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import { selectReconciliation } from "../../redux/modals/modals.selectors";
|
||||
import JobReconciliationModalComponent from "./job-reconciliation-modal.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import "./job-reconciliation-modal.styles.scss";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
reconciliationModal: selectReconciliation,
|
||||
@@ -39,23 +38,23 @@ function JobReconciliationModalContainer({
|
||||
return (
|
||||
<Modal
|
||||
title={t("jobs.labels.reconciliationheader")}
|
||||
width={"95%"}
|
||||
width={"90%"}
|
||||
visible={visible}
|
||||
okText={t("general.actions.close")}
|
||||
onOk={handleCancel}
|
||||
onCancel={handleCancel}
|
||||
cancelButtonProps={{ display: "none" }}
|
||||
destroyOnClose
|
||||
className="imex-reconciliation-modal"
|
||||
>
|
||||
{loading && <LoadingSpinner loading={loading} />}
|
||||
{error && <AlertComponent message={error.message} type="error" />}
|
||||
{data && (
|
||||
<JobReconciliationModalComponent
|
||||
job={data && data.jobs_by_pk}
|
||||
bills={data && data.bills}
|
||||
/>
|
||||
)}
|
||||
<LoadingSpinner loading={loading}>
|
||||
{error && <AlertComponent message={error.message} type="error" />}
|
||||
{data && (
|
||||
<JobReconciliationModalComponent
|
||||
job={data && data.jobs_by_pk}
|
||||
bills={data && data.bills}
|
||||
/>
|
||||
)}
|
||||
</LoadingSpinner>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Table, Typography } from "antd";
|
||||
import { PageHeader, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
@@ -102,13 +102,11 @@ export default function JobReconcilitionPartsTable({
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Typography.Title level={4}>{t("jobs.labels.lines")}</Typography.Title>
|
||||
<PageHeader title={t("jobs.labels.lines")}>
|
||||
<Table
|
||||
pagination={false}
|
||||
columns={columns}
|
||||
size="small"
|
||||
scroll={{ y: "80vh", x: true }}
|
||||
scroll={{ y: "40vh", x: true }}
|
||||
rowKey="id"
|
||||
dataSource={jobLineData}
|
||||
onChange={handleTableChange}
|
||||
@@ -124,6 +122,6 @@ export default function JobReconcilitionPartsTable({
|
||||
<div style={{ fontStyle: "italic", margin: "4px" }}>
|
||||
{t("jobs.labels.reconciliation.removedpartsstrikethrough")}
|
||||
</div>
|
||||
</div>
|
||||
</PageHeader>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
import { DownCircleFilled } from "@ant-design/icons";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Button, Dropdown, Menu, notification } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { UPDATE_JOB_STATUS } from "../../graphql/jobs.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(JobsAdminStatus);
|
||||
|
||||
export function JobsAdminStatus({ bodyshop, job }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [mutationUpdateJobstatus] = useMutation(UPDATE_JOB_STATUS);
|
||||
const updateJobStatus = (status) => {
|
||||
mutationUpdateJobstatus({
|
||||
variables: { jobId: job.id, status: status },
|
||||
})
|
||||
.then((r) => {
|
||||
notification["success"]({ message: t("jobs.successes.save") });
|
||||
// refetch();
|
||||
})
|
||||
.catch((error) => {
|
||||
notification["error"]({ message: t("jobs.errors.saving") });
|
||||
});
|
||||
};
|
||||
|
||||
const statusmenu = (
|
||||
<Menu
|
||||
onClick={(e) => {
|
||||
updateJobStatus(e.key);
|
||||
}}
|
||||
>
|
||||
{bodyshop.md_ro_statuses.statuses.map((item) => (
|
||||
<Menu.Item key={item}>{item}</Menu.Item>
|
||||
))}
|
||||
</Menu>
|
||||
);
|
||||
|
||||
return (
|
||||
<Dropdown overlay={statusmenu} trigger={["click"]} key="changestatus">
|
||||
<Button shape="round">
|
||||
<span>{job.status}</span>
|
||||
|
||||
<DownCircleFilled />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,6 @@ export const GetSupplementDelta = async (client, jobId, newLines) => {
|
||||
query: GET_ALL_JOBLINES_BY_PK,
|
||||
variables: { id: jobId },
|
||||
});
|
||||
|
||||
const existingLines = _.cloneDeep(existingLinesFromDb);
|
||||
const linesToInsert = [];
|
||||
const linesToUpdate = [];
|
||||
@@ -20,14 +19,11 @@ export const GetSupplementDelta = async (client, jobId, newLines) => {
|
||||
const matchingIndex = existingLines.findIndex(
|
||||
(eL) => eL.unq_seq === newLine.unq_seq
|
||||
);
|
||||
|
||||
//Should do a check to make sure there is only 1 matching unq sequence number.
|
||||
|
||||
if (matchingIndex >= 0) {
|
||||
//Found a relevant matching line. Add it to lines to update.
|
||||
linesToUpdate.push({
|
||||
id: existingLines[matchingIndex].id,
|
||||
newData: { ...newLine, removed: false },
|
||||
newData: newLine,
|
||||
});
|
||||
|
||||
//Splice out item we found for performance.
|
||||
|
||||
@@ -31,14 +31,11 @@ function OwnerDetailJobsComponent({ bodyshop, owner }) {
|
||||
title: t("jobs.fields.vehicle"),
|
||||
dataIndex: "vehicleid",
|
||||
key: "vehicleid",
|
||||
render: (text, record) =>
|
||||
record.vehicleid ? (
|
||||
<Link to={`/manage/vehicles/${record.vehicleid}`}>
|
||||
{`${record.v_model_yr} ${record.v_make_desc} ${record.v_model_desc}`}
|
||||
</Link>
|
||||
) : (
|
||||
t("jobs.errors.novehicle")
|
||||
),
|
||||
render: (text, record) => (
|
||||
<Link to={`/manage/vehicles/${record.vehicleid}`}>
|
||||
{`${record.v_model_yr} ${record.v_make_desc} ${record.v_model_desc}`}
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.clm_no"),
|
||||
|
||||
@@ -23,6 +23,19 @@ export const GET_ALL_JOBLINES_BY_PK = gql`
|
||||
notes
|
||||
location
|
||||
tax_part
|
||||
parts_order_lines {
|
||||
id
|
||||
parts_order {
|
||||
id
|
||||
order_number
|
||||
order_date
|
||||
user_email
|
||||
vendor {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -215,11 +228,7 @@ export const generateJobLinesUpdatesForInvoicing = (joblines) => {
|
||||
|
||||
export const DELETE_JOB_LINE_BY_PK = gql`
|
||||
mutation DELETE_JOB_LINE_BY_PK($joblineId: uuid!) {
|
||||
update_joblines_by_pk(
|
||||
pk_columns: { id: $joblineId }
|
||||
_set: { removed: true }
|
||||
) {
|
||||
removed
|
||||
delete_joblines_by_pk(id: $joblineId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ export const GLOBAL_SEARCH_QUERY = gql`
|
||||
search_payments(args: { search: $search }) {
|
||||
id
|
||||
amount
|
||||
paymentnum
|
||||
job {
|
||||
ro_number
|
||||
id
|
||||
|
||||
@@ -81,52 +81,48 @@ export default class Home extends React.Component {
|
||||
dataSource={Banner00DataSource}
|
||||
isMobile={this.state.isMobile}
|
||||
/>,
|
||||
...(process.env.NODE_ENV !== "production"
|
||||
? [
|
||||
// <Content4
|
||||
// id="Content4_0"
|
||||
// key="Content4_0"
|
||||
// dataSource={Content40DataSource}
|
||||
// isMobile={this.state.isMobile}
|
||||
// />,
|
||||
<Content1
|
||||
id="Content1_0"
|
||||
key="Content1_0"
|
||||
dataSource={Content10DataSource}
|
||||
isMobile={this.state.isMobile}
|
||||
/>,
|
||||
<Content0
|
||||
id="Content0_0"
|
||||
key="Content0_0"
|
||||
dataSource={Content00DataSource}
|
||||
isMobile={this.state.isMobile}
|
||||
/>,
|
||||
<Pricing2
|
||||
id="Pricing2_0"
|
||||
key="Pricing2_0"
|
||||
dataSource={Pricing20DataSource}
|
||||
isMobile={this.state.isMobile}
|
||||
/>,
|
||||
// <Pricing1
|
||||
// id="Pricing1_1"
|
||||
// key="Pricing1_1"
|
||||
// dataSource={Pricing11DataSource}
|
||||
// isMobile={this.state.isMobile}
|
||||
// />,
|
||||
// <Content3
|
||||
// id="Content3_0"
|
||||
// key="Content3_0"
|
||||
// dataSource={Content30DataSource}
|
||||
// isMobile={this.state.isMobile}
|
||||
// />,
|
||||
// <Content12
|
||||
// id="Content12_0"
|
||||
// key="Content12_0"
|
||||
// dataSource={Content120DataSource}
|
||||
// isMobile={this.state.isMobile}
|
||||
// />,
|
||||
]
|
||||
: []),
|
||||
// <Content4
|
||||
// id="Content4_0"
|
||||
// key="Content4_0"
|
||||
// dataSource={Content40DataSource}
|
||||
// isMobile={this.state.isMobile}
|
||||
// />,
|
||||
<Content1
|
||||
id="Content1_0"
|
||||
key="Content1_0"
|
||||
dataSource={Content10DataSource}
|
||||
isMobile={this.state.isMobile}
|
||||
/>,
|
||||
<Content0
|
||||
id="Content0_0"
|
||||
key="Content0_0"
|
||||
dataSource={Content00DataSource}
|
||||
isMobile={this.state.isMobile}
|
||||
/>,
|
||||
<Pricing2
|
||||
id="Pricing2_0"
|
||||
key="Pricing2_0"
|
||||
dataSource={Pricing20DataSource}
|
||||
isMobile={this.state.isMobile}
|
||||
/>,
|
||||
// <Pricing1
|
||||
// id="Pricing1_1"
|
||||
// key="Pricing1_1"
|
||||
// dataSource={Pricing11DataSource}
|
||||
// isMobile={this.state.isMobile}
|
||||
// />,
|
||||
// <Content3
|
||||
// id="Content3_0"
|
||||
// key="Content3_0"
|
||||
// dataSource={Content30DataSource}
|
||||
// isMobile={this.state.isMobile}
|
||||
// />,
|
||||
// <Content12
|
||||
// id="Content12_0"
|
||||
// key="Content12_0"
|
||||
// dataSource={Content120DataSource}
|
||||
// isMobile={this.state.isMobile}
|
||||
// />,
|
||||
<Footer1
|
||||
id="Footer1_0"
|
||||
key="Footer1_0"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Result, Timeline, Space, Tag, Divider, Button } from "antd";
|
||||
import { Result, Timeline, Space, Tag, Divider, Button, Select } from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -11,6 +11,7 @@ import { useTranslation } from "react-i18next";
|
||||
import SocketIO from "socket.io-client";
|
||||
import { auth } from "../../firebase/firebase.utils";
|
||||
import moment from "moment";
|
||||
import DmsCustomerSelector from "../../components/dms-customer-selector/dms-customer-selector.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -38,6 +39,7 @@ export const socket = SocketIO(
|
||||
|
||||
export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
const { t } = useTranslation();
|
||||
const [logLevel, setLogLevel] = useState("DEBUG");
|
||||
const [logs, setLogs] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -55,6 +57,19 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
socket.on("connected", () => {
|
||||
console.log("Connected again.");
|
||||
});
|
||||
socket.on("reconnect", () => {
|
||||
console.log("Connected again.");
|
||||
setLogs((logs) => {
|
||||
return [
|
||||
...logs,
|
||||
{
|
||||
timestamp: new Date(),
|
||||
level: "WARNING",
|
||||
message: "Reconnected to CDK Export Service",
|
||||
},
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
socket.on("log-event", (payload) => {
|
||||
setLogs((logs) => {
|
||||
@@ -63,12 +78,13 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
});
|
||||
|
||||
socket.connect();
|
||||
socket.emit("set-log-level", "TRACE");
|
||||
socket.emit("set-log-level", logLevel);
|
||||
|
||||
return () => {
|
||||
socket.removeAllListeners();
|
||||
socket.disconnect();
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
if (!bodyshop.cdk_dealerid) return <Result status="404" />;
|
||||
@@ -77,27 +93,43 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
onClick={() => {
|
||||
socket.emit(
|
||||
`${dmsType}-export-job`,
|
||||
"752a4f5f-22ab-414b-b182-98d4e62227ef"
|
||||
);
|
||||
}}
|
||||
>
|
||||
Export
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => {
|
||||
setLogs([]);
|
||||
socket.disconnect();
|
||||
socket.connect();
|
||||
}}
|
||||
>
|
||||
reconnect
|
||||
</Button>
|
||||
|
||||
<Space>
|
||||
<Select
|
||||
placeholder="Log Level"
|
||||
value={logLevel}
|
||||
onChange={(value) => {
|
||||
setLogLevel(value);
|
||||
socket.emit("set-log-level", value);
|
||||
}}
|
||||
>
|
||||
<Select.Option>TRACE</Select.Option>
|
||||
<Select.Option>DEBUG</Select.Option>
|
||||
<Select.Option>INFO</Select.Option>
|
||||
<Select.Option>WARNING</Select.Option>
|
||||
<Select.Option>ERROR</Select.Option>
|
||||
</Select>
|
||||
<Button
|
||||
onClick={() => {
|
||||
socket.emit(
|
||||
`${dmsType}-export-job`,
|
||||
"752a4f5f-22ab-414b-b182-98d4e62227ef"
|
||||
);
|
||||
}}
|
||||
>
|
||||
Export
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setLogs([]);
|
||||
socket.disconnect();
|
||||
socket.connect();
|
||||
}}
|
||||
>
|
||||
Reconnect
|
||||
</Button>
|
||||
<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
||||
</Space>
|
||||
<DmsCustomerSelector />
|
||||
<Timeline pending={socket.connected && "Processing..."} reverse={true}>
|
||||
{logs.map((log, idx) => (
|
||||
<Timeline.Item key={idx} color={LogLevelHierarchy(log.level)}>
|
||||
@@ -105,7 +137,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
<Tag color={LogLevelHierarchy(log.level)}>{log.level}</Tag>
|
||||
<span>{moment(log.timestamp).format("MM/DD/YYYY HH:MM:ss")}</span>
|
||||
<Divider type="vertical" />
|
||||
<span>{log.message}</span>
|
||||
<span style={{ whiteSpace: "pre-line" }}>{log.message}</span>
|
||||
</Space>
|
||||
</Timeline.Item>
|
||||
))}
|
||||
@@ -119,11 +151,11 @@ function LogLevelHierarchy(level) {
|
||||
case "TRACE":
|
||||
return "pink";
|
||||
case "DEBUG":
|
||||
return "orange";
|
||||
return "green";
|
||||
case "INFO":
|
||||
return "blue";
|
||||
case "WARNING":
|
||||
return "yellow";
|
||||
return "orange";
|
||||
case "ERROR":
|
||||
return "red";
|
||||
default:
|
||||
|
||||
@@ -12,6 +12,7 @@ import AlertComponent from "../../components/alert/alert.component";
|
||||
import { QUERY_EXPORT_LOG_PAGINATED } from "../../graphql/accounting.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -78,10 +79,12 @@ export function ExportLogsPageComponent({ bodyshop }) {
|
||||
title: t("jobs.fields.ro_number"),
|
||||
dataIndex: "ro_number",
|
||||
key: "ro_number",
|
||||
sorter: (a, b) => alphaSort(a.ro_number, b.ro_number),
|
||||
sortOrder: sortcolumn === "ro_number" && sortorder,
|
||||
|
||||
render: (text, record) =>
|
||||
record.job && (
|
||||
<Link to={`/manage/jobs/${record.job.id}`}>
|
||||
<Link to={"/manage/jobs/" + record.job && record.job.id}>
|
||||
{(record.job && record.job.ro_number) || t("general.labels.na")}
|
||||
</Link>
|
||||
),
|
||||
|
||||
@@ -15,8 +15,6 @@ import JobAdminOwnerReassociate from "../../components/jobs-admin-owner-reassoci
|
||||
import JobsAdminUnvoid from "../../components/jobs-admin-unvoid/jobs-admin-unvoid.component";
|
||||
import JobAdminVehicleReassociate from "../../components/jobs-admin-vehicle-reassociate/jobs-admin-vehicle-reassociate.component";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import JobsAdminStatus from "../../components/jobs-admin-change-status/jobs-admin-change.status.component";
|
||||
|
||||
import NotFound from "../../components/not-found/not-found.component";
|
||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||
import { GET_JOB_BY_PK } from "../../graphql/jobs.queries";
|
||||
@@ -98,7 +96,6 @@ export function JobsCloseContainer({ setBreadcrumbs, setSelectedHeader }) {
|
||||
<JobsAdminDeleteIntake job={data ? data.jobs_by_pk : {}} />
|
||||
<JobsAdminMarkReexport job={data ? data.jobs_by_pk : {}} />
|
||||
<JobsAdminUnvoid job={data ? data.jobs_by_pk : {}} />
|
||||
<JobsAdminStatus job={data ? data.jobs_by_pk : {}} />
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
@@ -42,26 +42,9 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
|
||||
setLoading(true);
|
||||
const result = await client.mutate({
|
||||
mutation: generateJobLinesUpdatesForInvoicing(values.joblines),
|
||||
});
|
||||
if (result.errors) {
|
||||
return; // Abandon the rest of the close.
|
||||
}
|
||||
|
||||
const closeResult = await closeJob({
|
||||
variables: {
|
||||
jobId: job.id,
|
||||
job: {
|
||||
status: bodyshop.md_ro_statuses.default_invoiced || "",
|
||||
date_invoiced: new Date(),
|
||||
actual_in: values.actual_in,
|
||||
actual_completion: values.actual_completion,
|
||||
actual_delivery: values.actual_delivery,
|
||||
},
|
||||
},
|
||||
refetchQueries: ["QUERY_JOB_CLOSE_DETAILS"],
|
||||
awaitRefetchQueries: true,
|
||||
});
|
||||
|
||||
if (!result.errors) {
|
||||
notification["success"]({ message: t("jobs.successes.save") });
|
||||
// form.resetFields();
|
||||
@@ -73,6 +56,18 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
|
||||
});
|
||||
return; // Abandon the rest of the close.
|
||||
}
|
||||
form.resetFields();
|
||||
form.resetFields();
|
||||
|
||||
const closeResult = await closeJob({
|
||||
variables: {
|
||||
jobId: job.id,
|
||||
job: {
|
||||
status: bodyshop.md_ro_statuses.default_invoiced || "",
|
||||
date_invoiced: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!closeResult.errors) {
|
||||
setLoading(false);
|
||||
@@ -89,8 +84,6 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
|
||||
}),
|
||||
});
|
||||
}
|
||||
form.resetFields();
|
||||
form.resetFields();
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
@@ -1441,11 +1441,11 @@
|
||||
"name": "ImEX Online",
|
||||
"status": "System Status"
|
||||
},
|
||||
"slogan": "A whole new kind of shop management system."
|
||||
"slogan": "The future of shop management systems. "
|
||||
},
|
||||
"hero": {
|
||||
"button": "Coming Soon",
|
||||
"title": "A whole new kind of shop management system."
|
||||
"button": "Learn More",
|
||||
"title": "Bringing the future to the collision repair process."
|
||||
},
|
||||
"labels": {
|
||||
"features": "Features",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
[]
|
||||
@@ -1,11 +0,0 @@
|
||||
- args:
|
||||
cascade: false
|
||||
read_only: false
|
||||
sql: "CREATE OR REPLACE FUNCTION public.search_payments(search text)\n RETURNS
|
||||
SETOF payments\n LANGUAGE plpgsql\n STABLE\nAS $function$\n\nBEGIN\n if search
|
||||
= '' then\n return query select * from payments ;\n else \n return query
|
||||
SELECT\n p.*\nFROM\n payments p, jobs j\nWHERE\np.jobid = j.id AND\n(\nsearch
|
||||
<% p.paymentnum OR\nsearch <% j.ownr_fn OR\nsearch <% j.ownr_ln OR\nsearch <%
|
||||
j.ownr_co_nm OR\nsearch <% j.ro_number OR\n search <% (p.payer) OR\n search
|
||||
<% (p.transactionid) OR\n search <% (p.memo));\n end if;\n\n\tEND\n$function$;"
|
||||
type: run_sql
|
||||
@@ -288,7 +288,7 @@ const generateInvoiceQbxml = (
|
||||
});
|
||||
// console.log("Done creating hash", JSON.stringify(invoiceLineHash));
|
||||
|
||||
if (!hasMapaLine && jobs_by_pk.job_totals.rates.mapa.total.amount > 0) {
|
||||
if (!hasMapaLine) {
|
||||
console.log("Adding MAPA Line Manually.");
|
||||
const mapaAccountName = responsibilityCenters.defaults.profits.MAPA;
|
||||
|
||||
@@ -313,7 +313,7 @@ const generateInvoiceQbxml = (
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasMashLine && jobs_by_pk.job_totals.rates.mash.total.amount > 0) {
|
||||
if (!hasMashLine) {
|
||||
console.log("Adding MASH Line Manually.");
|
||||
|
||||
const mashAccountName = responsibilityCenters.defaults.profits.MASH;
|
||||
@@ -424,11 +424,9 @@ const generateInvoiceQbxml = (
|
||||
TxnDate: moment(jobs_by_pk.date_invoiced).format("YYYY-MM-DD"),
|
||||
RefNumber: jobs_by_pk.ro_number,
|
||||
ShipAddress: {
|
||||
Addr1: jobs_by_pk.ownr_co_nm
|
||||
? jobs_by_pk.ownr_co_nm.substring(0, 30)
|
||||
: `${`${jobs_by_pk.ownr_ln || ""} ${
|
||||
jobs_by_pk.ownr_fn || ""
|
||||
}`.substring(0, 30)}`,
|
||||
Addr1: `${jobs_by_pk.ownr_fn || ""} ${jobs_by_pk.ownr_ln || ""} ${
|
||||
jobs_by_pk.ownr_co_nm || ""
|
||||
}`,
|
||||
Addr2: jobs_by_pk.ownr_addr1,
|
||||
Addr3: jobs_by_pk.ownr_addr2,
|
||||
City: jobs_by_pk.ownr_city,
|
||||
|
||||
@@ -17,13 +17,12 @@ exports.generateOwnerTier = (jobs_by_pk, isThreeTier, twotierpref) => {
|
||||
if (isThreeTier) {
|
||||
//It's always gonna be the owner now. Same as 2 tier by name
|
||||
return jobs_by_pk.ownr_co_nm
|
||||
? `${jobs_by_pk.ownr_co_nm.substring(0, 30)} #${
|
||||
? `${jobs_by_pk.ownr_co_nm} - ${jobs_by_pk.ownr_ln || ""} ${
|
||||
jobs_by_pk.ownr_fn || ""
|
||||
} #${jobs_by_pk.owner.accountingid || ""}`
|
||||
: `${jobs_by_pk.ownr_ln || ""} ${jobs_by_pk.ownr_fn || ""} #${
|
||||
jobs_by_pk.owner.accountingid || ""
|
||||
}`
|
||||
: `${`${jobs_by_pk.ownr_ln || ""} ${jobs_by_pk.ownr_fn || ""}`.substring(
|
||||
0,
|
||||
30
|
||||
)} #${jobs_by_pk.owner.accountingid || ""}`;
|
||||
}`;
|
||||
} else {
|
||||
//What's the 2 tier pref?
|
||||
if (twotierpref === "source") {
|
||||
@@ -32,12 +31,12 @@ exports.generateOwnerTier = (jobs_by_pk, isThreeTier, twotierpref) => {
|
||||
} else {
|
||||
//Same as 3 tier
|
||||
return jobs_by_pk.ownr_co_nm
|
||||
? `${jobs_by_pk.ownr_co_nm.substring(0, 30)} #${
|
||||
jobs_by_pk.owner.accountingid || ""
|
||||
}`
|
||||
: `${`${jobs_by_pk.ownr_ln || ""} ${
|
||||
? `${jobs_by_pk.ownr_co_nm} - ${jobs_by_pk.ownr_ln || ""} ${
|
||||
jobs_by_pk.ownr_fn || ""
|
||||
}`.substring(0, 30)} #${jobs_by_pk.owner.accountingid || ""}`;
|
||||
} #${jobs_by_pk.owner.accountingid || ""}`
|
||||
: `${jobs_by_pk.ownr_ln || ""} ${jobs_by_pk.ownr_fn || ""} #${
|
||||
jobs_by_pk.owner.accountingid || ""
|
||||
}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,6 +13,10 @@ const CdkWsdl = require("./cdk-wsdl").default;
|
||||
|
||||
const IMEX_CDK_USER = process.env.IMEX_CDK_USER,
|
||||
IMEX_CDK_PASSWORD = process.env.IMEX_CDK_PASSWORD;
|
||||
const CDK_CREDENTIALS = {
|
||||
password: IMEX_CDK_PASSWORD,
|
||||
username: IMEX_CDK_USER,
|
||||
};
|
||||
|
||||
exports.default = async function (socket, jobid) {
|
||||
socket.logEvents = [];
|
||||
@@ -22,28 +26,156 @@ exports.default = async function (socket, jobid) {
|
||||
"DEBUG",
|
||||
`Received Job export request for id ${jobid}`
|
||||
);
|
||||
|
||||
//The following values will be stored on the socket to allow callbacks.
|
||||
//let clVFV, clADPV, clADPC;
|
||||
const JobData = await QueryJobData(socket, jobid);
|
||||
console.log(JSON.stringify(JobData, null, 2));
|
||||
const DealerId = JobData.bodyshop.cdk_dealerid;
|
||||
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`Dealer ID detected: ${JSON.stringify(DealerId)}`
|
||||
);
|
||||
|
||||
// Begin Calculate VID from DMS {1}
|
||||
await DetermineDMSVid(socket, JobData);
|
||||
//{1} Begin Calculate DMS Vehicle Id
|
||||
socket.clVFV = await CalculateDmsVid(socket, JobData);
|
||||
if (socket.clVFV.newId === "Y") {
|
||||
//{1.2} This is a new Vehicle ID
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{1.2} clVFV DMSVid does *not* exist.`
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.2} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
);
|
||||
//Check if DMSCustId is Empty - which it should always be?
|
||||
//{6.6} Should check to see if a customer exists so that we can marry it to the new vehicle.
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{6.6} Trying to find customer ID in DMS.`
|
||||
);
|
||||
|
||||
//Array
|
||||
const strIDS = await FindCustomerIdFromDms(socket, JobData);
|
||||
if (strIDS && strIDS.length > 0) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{8.2} ${strIDS.length} Customer ID(s) found.`
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{8.2} strIDS: ${JSON.stringify(strIDS, null, 2)}`
|
||||
);
|
||||
if (strIDS.length > 1) {
|
||||
//We have multiple IDs
|
||||
//TODO: Do we need to let the person select it?
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"WARNING",
|
||||
`{F} Mutliple customer ids have been found (${strIDS.length})`
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`Asking for user intervention to select customer.`
|
||||
);
|
||||
socket.emit("cdk-select-customer", strIDS);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{8.5} Customer ID(s) *not* found.`
|
||||
);
|
||||
|
||||
//Create a customer number, then use that to insert the customer record.
|
||||
const newCustomerNumber = await GenerateCustomerNumberFromDms(
|
||||
socket,
|
||||
JobData
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{10.1} New Customer number generated. newCustomerNumber: ${newCustomerNumber}`
|
||||
);
|
||||
|
||||
//Use the new customer number to insert the customer record.
|
||||
socket.clADPC = await CreateCustomerInDms(
|
||||
socket,
|
||||
JobData,
|
||||
newCustomerNumber
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{11.1} New Customer inserted.`
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{11.1} clADPC: ${JSON.stringify(socket.clADPC, null, 2)}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
CdkBase.createLogEvent(socket, "DEBUG", `{1.1} clVFV DMSVid does exist.`);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.1} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
);
|
||||
|
||||
//{2} Begin Find Vehicle in DMS
|
||||
socket.clADPV = await FindVehicleInDms(socket, JobData, socket.clVFV); //TODO: Verify that this should always return a result. If an ID was found previously, it should be correct?
|
||||
|
||||
//{2.2} Check if the vehicle was found in the DMS.
|
||||
if (socket.clADPV.AppErrorNo === "0") {
|
||||
//Vehicle was found.
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{1.4} Vehicle was found in the DMS.`
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.4} clADPV: ${JSON.stringify(socket.clADPV, null, 2)}`
|
||||
);
|
||||
} else {
|
||||
//Vehicle was not found.
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{6.4} Vehicle does not exist in DMS. Will have to create one.`
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{6.4} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error encountered in JobExport. ${error}`
|
||||
`Error encountered in CdkJobExport. ${error}`
|
||||
);
|
||||
} finally {
|
||||
//Ensure we always insert logEvents
|
||||
//GQL to insert logevents.
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`Capturing log events to database.`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,27 +193,319 @@ async function QueryJobData(socket, jobid) {
|
||||
return result.jobs_by_pk;
|
||||
}
|
||||
|
||||
async function DetermineDMSVid(socket, JobData) {
|
||||
CdkBase.createLogEvent(socket, "TRACE", "{1} Begin Determine DMS VehicleID");
|
||||
async function CreateCustomerInDms(socket, JobData, newCustomerNumber) {
|
||||
CdkBase.createLogEvent(socket, "DEBUG", `{11} Begin Create Customer in DMS`);
|
||||
|
||||
try {
|
||||
//Create SOAP Request for <getVehIds/>
|
||||
const soapClient = await soap.createClientAsync(CdkWsdl.VehicleSearch);
|
||||
const result = await soapClient.searchIDsByVINAsync(
|
||||
{
|
||||
arg0: { password: IMEX_CDK_PASSWORD, username: IMEX_CDK_USER },
|
||||
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
||||
arg2: { VIN: JobData.v_vin },
|
||||
},
|
||||
|
||||
{}
|
||||
const soapClientCustomerInsertUpdate = await soap.createClientAsync(
|
||||
CdkWsdl.CustomerInsertUpdate
|
||||
);
|
||||
console.log(result);
|
||||
const soapResponseCustomerInsertUpdate =
|
||||
await soapClientCustomerInsertUpdate.insertAsync(
|
||||
{
|
||||
arg0: CDK_CREDENTIALS,
|
||||
arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
||||
arg2: { userId: null },
|
||||
arg3: {
|
||||
//Copied the required fields from the other integration.
|
||||
//TODO: Verify whether we need to bring more information in.
|
||||
id: { value: newCustomerNumber },
|
||||
address: {
|
||||
city: JobData.ownr_city,
|
||||
country: null,
|
||||
postalcode: JobData.ownr_zip,
|
||||
stateOrProvince: JobData.ownr_st,
|
||||
},
|
||||
contactInfo: {
|
||||
mainTelephoneNumber: { main: true, value: JobData.ownr_ph1 },
|
||||
},
|
||||
demographics: null,
|
||||
name1: {
|
||||
companyname: null,
|
||||
firstName: JobData.ownr_fn,
|
||||
fullname: null,
|
||||
lastName: JobData.ownr_ln,
|
||||
middleName: null,
|
||||
nameType: "Person",
|
||||
suffix: null,
|
||||
title: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{}
|
||||
);
|
||||
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
||||
const [
|
||||
result, //rawResponse, soapheader, rawRequest
|
||||
] = soapResponseCustomerInsertUpdate;
|
||||
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`soapClientCustomerInsertUpdate.insertAsync Result ${JSON.stringify(
|
||||
result,
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
);
|
||||
const customer = result && result.return;
|
||||
return customer;
|
||||
} catch (error) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error in DetermineDMSVid - ${JSON.stringify(error, null, 2)}`
|
||||
`Error in CreateCustomerInDms - ${JSON.stringify(error, null, 2)}`
|
||||
);
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function GenerateCustomerNumberFromDms(socket, JobData) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{10} Begin Generate Customer Number from DMS`
|
||||
);
|
||||
|
||||
try {
|
||||
const soapClientCustomerInsertUpdate = await soap.createClientAsync(
|
||||
CdkWsdl.CustomerInsertUpdate
|
||||
);
|
||||
const soapResponseCustomerInsertUpdate =
|
||||
await soapClientCustomerInsertUpdate.getCustomerNumberAsync(
|
||||
{
|
||||
arg0: CDK_CREDENTIALS,
|
||||
arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
||||
arg2: { userId: null },
|
||||
},
|
||||
|
||||
{}
|
||||
);
|
||||
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
||||
const [
|
||||
result, //rawResponse, soapheader, rawRequest
|
||||
] = soapResponseCustomerInsertUpdate;
|
||||
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`soapClientCustomerInsertUpdate.getCustomerNumberAsync Result ${JSON.stringify(
|
||||
result,
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
);
|
||||
const customerNumber =
|
||||
result && result.return && result.return.customerNumber;
|
||||
return customerNumber;
|
||||
} catch (error) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error in GenerateCustomerNumberFromDms - ${JSON.stringify(
|
||||
error,
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
);
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function FindCustomerIdFromDms(socket, JobData) {
|
||||
const ownerName = `${JobData.ownr_ln},${JobData.ownr_fn}`;
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{8} Begin Read Customer from DMS using OWNER NAME: ${ownerName}`
|
||||
);
|
||||
|
||||
try {
|
||||
const soapClientCustomerSearch = await soap.createClientAsync(
|
||||
CdkWsdl.CustomerSearch
|
||||
);
|
||||
const soapResponseCustomerSearch =
|
||||
await soapClientCustomerSearch.executeSearchAsync(
|
||||
{
|
||||
arg0: CDK_CREDENTIALS,
|
||||
arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
||||
arg2: {
|
||||
verb: "EXACT",
|
||||
key: ownerName,
|
||||
},
|
||||
},
|
||||
|
||||
{}
|
||||
);
|
||||
CheckCdkResponseForError(socket, soapResponseCustomerSearch);
|
||||
const [
|
||||
result, // rawResponse, soapheader, rawRequest
|
||||
] = soapResponseCustomerSearch;
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`soapClientCustomerSearch.executeSearchBulkAsync Result ${JSON.stringify(
|
||||
result,
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
);
|
||||
const CustomersFromDms = result && result.return;
|
||||
return CustomersFromDms;
|
||||
} catch (error) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error in FindCustomerIdFromDms - ${JSON.stringify(error, null, 2)}`
|
||||
);
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function FindVehicleInDms(socket, JobData, clVFV) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{2}/{6} Begin Find Vehicle In DMS using clVFV: ${clVFV}`
|
||||
);
|
||||
|
||||
try {
|
||||
const soapClientVehicleInsertUpdate = await soap.createClientAsync(
|
||||
CdkWsdl.VehicleInsertUpdate
|
||||
);
|
||||
const soapResponseVehicleInsertUpdate =
|
||||
await soapClientVehicleInsertUpdate.readBulkAsync(
|
||||
{
|
||||
arg0: CDK_CREDENTIALS,
|
||||
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
||||
arg2: {
|
||||
fileType: "VEHICLES",
|
||||
vehiclesVehicleId: clVFV.vehiclesVehId,
|
||||
},
|
||||
},
|
||||
|
||||
{}
|
||||
);
|
||||
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
||||
const [
|
||||
result, //rawResponse, soapheader, rawRequest
|
||||
] = soapResponseVehicleInsertUpdate;
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`soapClientVehicleInsertUpdate.readBulkAsync Result ${JSON.stringify(
|
||||
result,
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
);
|
||||
const VehicleFromDMS = result && result.return && result.return[0];
|
||||
return VehicleFromDMS;
|
||||
} catch (error) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error in FindVehicleInDms - ${JSON.stringify(error, null, 2)}`
|
||||
);
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function CalculateDmsVid(socket, JobData) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1} Begin Calculate DMS Vehicle ID using VIN: ${JobData.v_vin}`
|
||||
);
|
||||
|
||||
try {
|
||||
const soapClientVehicleInsertUpdate = await soap.createClientAsync(
|
||||
CdkWsdl.VehicleInsertUpdate
|
||||
);
|
||||
const soapResponseVehicleInsertUpdate =
|
||||
await soapClientVehicleInsertUpdate.getVehIdsAsync(
|
||||
{
|
||||
arg0: CDK_CREDENTIALS,
|
||||
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
||||
arg2: { VIN: JobData.v_vin },
|
||||
},
|
||||
|
||||
{}
|
||||
);
|
||||
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
||||
const [
|
||||
result, //rawResponse, soapheader, rawRequest
|
||||
] = soapResponseVehicleInsertUpdate;
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`soapClientVehicleInsertUpdate.searchIDsByVINAsync Result ${JSON.stringify(
|
||||
result,
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
);
|
||||
const DmsVehicle = result && result.return && result.return[0];
|
||||
return DmsVehicle;
|
||||
} catch (error) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error in CalculateDmsVid - ${JSON.stringify(error, null, 2)}`
|
||||
);
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
function CheckCdkResponseForError(socket, soapResponse) {
|
||||
if (!soapResponse[0]) {
|
||||
//The response was null, this might be ok, it might not.
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"WARNING",
|
||||
`Warning detected in CDK Response - it appears to be null. Stack: ${
|
||||
new Error().stack
|
||||
}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const ResultToCheck = soapResponse[0].return;
|
||||
|
||||
if (Array.isArray(ResultToCheck)) {
|
||||
ResultToCheck.forEach((result) => checkIndividualResult(socket, result));
|
||||
} else {
|
||||
checkIndividualResult(socket, ResultToCheck);
|
||||
}
|
||||
}
|
||||
|
||||
function checkIndividualResult(socket, ResultToCheck) {
|
||||
if (
|
||||
ResultToCheck.errorLevel === 0 ||
|
||||
ResultToCheck.errorLevel === "0" ||
|
||||
ResultToCheck.code === "success" ||
|
||||
(!ResultToCheck.code && !ResultToCheck.errorLevel)
|
||||
)
|
||||
//TODO: Verify that this is the best way to detect errors.
|
||||
return;
|
||||
else {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error detected in CDK Response - ${JSON.stringify(
|
||||
ResultToCheck,
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
);
|
||||
|
||||
throw new Error(
|
||||
`Error found while validating CDK response for ${JSON.stringify(
|
||||
ResultToCheck,
|
||||
null,
|
||||
2
|
||||
)}:`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,33 @@
|
||||
const path = require("path");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
// const cdkDomain =
|
||||
// process.env.NODE_ENV === "production"
|
||||
// ? "https://3pa.dmotorworks.com"
|
||||
// : "https://uat-3pa.dmotorworks.com";
|
||||
|
||||
const cdkDomain = "https://uat-3pa.dmotorworks.com";
|
||||
exports.default = {
|
||||
VehicleSearch:
|
||||
"https://uat-3pa.dmotorworks.com/pip-vehicle/services/VehicleSearch?wsdl",
|
||||
// VehicleSearch: `${cdkDomain}/pip-vehicle/services/VehicleSearch?wsdl`,
|
||||
VehicleInsertUpdate: `${cdkDomain}/pip-vehicle/services/VehicleInsertUpdate?wsdl`,
|
||||
CustomerInsertUpdate: `${cdkDomain}/pip-customer/services/CustomerInsertUpdate?wsdl`,
|
||||
CustomerSearch: `${cdkDomain}/pip-customer/services/CustomerSearch?wsdl`,
|
||||
};
|
||||
|
||||
// The following login credentials will be used for all PIPs and all environments (User Acceptance Testing and Production).
|
||||
// Only the URLs will change from https://uat-3pa.dmoto... to https://3pa.dmoto... or https://api-dit.connect... to https://api.connect...
|
||||
// Accounting GL/Accounting GL WIP Update - https://uat-3pa.dmotorworks.com/pip-accounting-gl/services/AccountingGLInsertUpdate?wsdl
|
||||
// Customer Insert Update - https://uat-3pa.dmotorworks.com/pip-customer/services/CustomerInsertUpdate?wsdl
|
||||
// Help Database Location - https://uat-3pa.dmotorworks.com/pip-help-database-location/services/HelpDatabaseLocation?wsdl
|
||||
// Parts Inventory Insert Update - https://uat-3pa.dmotorworks.com/pip-parts-inventory/services/PartsInventoryInsertUpdate?wsdl
|
||||
// Purchase Order Insert - https://uat-3pa.dmotorworks.com/pip-purchase-order/services/PurchaseOrderInsert?wsdl
|
||||
// Repair Order MLS Insert Update - https://uat-3pa.dmotorworks.com/pip-repair-order-mls/services/RepairOrderMLSInsertUpdate?wsdl
|
||||
// Repair Order Parts Insert Update - https://uat-3pa.dmotorworks.com/pip-repair-order-parts/services/RepairOrderPartsInsertUpdate?wsdl
|
||||
// Service History Insert - https://uat-3pa.dmotorworks.com/pip-service-history-insert/services/ServiceHistoryInsert?wsdl
|
||||
// Service Repair Order Update - https://uat-3pa.dmotorworks.com/pip-service-repair-order/services/ServiceRepairOrderUpdate?wsdl
|
||||
// Service Vehicle Insert Update - https://uat-3pa.dmotorworks.com/pip-vehicle/services/VehicleInsertUpdate?wsdl
|
||||
|
||||
@@ -57,7 +57,6 @@ query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($ids: [uuid!]!) {
|
||||
ownerid
|
||||
ownr_ln
|
||||
ownr_fn
|
||||
ownr_co_nm
|
||||
ownr_addr1
|
||||
ownr_addr2
|
||||
ownr_zip
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const path = require("path");
|
||||
const _ = require("lodash");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
@@ -46,6 +45,15 @@ io.on("connection", (socket) => {
|
||||
socket.on("cdk-export-job", (jobid) => {
|
||||
CdkJobExport(socket, jobid);
|
||||
});
|
||||
socket.on("cdk-selected-customer", (selectedCustomerId) => {
|
||||
createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`User selected customer ID ${selectedCustomerId}`
|
||||
);
|
||||
socket.selectedCustomerId = selectedCustomerId;
|
||||
//CdkJobExport(socket, jobid);
|
||||
});
|
||||
|
||||
socket.on("disconnect", () => {
|
||||
createLogEvent(socket, "DEBUG", `User disconnected.`);
|
||||
@@ -72,6 +80,9 @@ function createLogEvent(socket, level, message) {
|
||||
message,
|
||||
});
|
||||
}
|
||||
// if (level === "ERROR") {
|
||||
// throw new Error(message);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user