Basic posting up to fortellis-select-customer.
This commit is contained in:
@@ -17,7 +17,7 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
});
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DmsCdkVehicles);
|
||||
|
||||
export function DmsCdkVehicles({ bodyshop, form, socket, job }) {
|
||||
export function DmsCdkVehicles({ bodyshop, form, job }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [selectedModel, setSelectedModel] = useState(null);
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Button, Checkbox, Col, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket";
|
||||
import { socket } from "../../pages/dms/dms.container";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
@@ -22,17 +24,47 @@ export function DmsCustomerSelector({ bodyshop }) {
|
||||
const [selectedCustomer, setSelectedCustomer] = useState(null);
|
||||
const [dmsType, setDmsType] = useState("cdk");
|
||||
|
||||
socket.on("cdk-select-customer", (customerList, callback) => {
|
||||
setOpen(true);
|
||||
setDmsType("cdk");
|
||||
setcustomerList(customerList);
|
||||
});
|
||||
socket.on("pbs-select-customer", (customerList, callback) => {
|
||||
setOpen(true);
|
||||
setDmsType("pbs");
|
||||
setcustomerList(customerList);
|
||||
const {
|
||||
treatments: { Fortellis }
|
||||
} = useSplitTreatments({
|
||||
attributes: {},
|
||||
names: ["Fortellis"],
|
||||
splitKey: bodyshop.imexshopid
|
||||
});
|
||||
|
||||
const { socket: wsssocket } = useSocket();
|
||||
|
||||
useEffect(() => {
|
||||
if (Fortellis.treatment === "on") {
|
||||
const handleFortellisSelectCustomer = (customerList, callback) => {
|
||||
setOpen(true);
|
||||
setDmsType("fortellis");
|
||||
setcustomerList(customerList);
|
||||
};
|
||||
wsssocket.on("fortellis-select-customer", handleFortellisSelectCustomer);
|
||||
return () => {
|
||||
wsssocket.off("fortellis-select-customer", handleFortellisSelectCustomer);
|
||||
};
|
||||
} else {
|
||||
const handleCdkSelectCustomer = (customerList, callback) => {
|
||||
setOpen(true);
|
||||
setDmsType("cdk");
|
||||
setcustomerList(customerList);
|
||||
};
|
||||
const handlePbsSelectCustomer = (customerList, callback) => {
|
||||
setOpen(true);
|
||||
setDmsType("pbs");
|
||||
setcustomerList(customerList);
|
||||
};
|
||||
socket.on("cdk-select-customer", handleCdkSelectCustomer);
|
||||
socket.on("pbs-select-customer", handlePbsSelectCustomer);
|
||||
return () => {
|
||||
socket.off("cdk-select-customer", handleCdkSelectCustomer);
|
||||
socket.off("pbs-select-customer", handlePbsSelectCustomer);
|
||||
};
|
||||
}
|
||||
}, []);
|
||||
|
||||
const onUseSelected = () => {
|
||||
setOpen(false);
|
||||
socket.emit(`${dmsType}-selected-customer`, selectedCustomer);
|
||||
@@ -51,6 +83,42 @@ export function DmsCustomerSelector({ bodyshop }) {
|
||||
setSelectedCustomer(null);
|
||||
};
|
||||
|
||||
const fortellisColumns = [
|
||||
{
|
||||
title: t("jobs.fields.dms.id"),
|
||||
dataIndex: "customerId",
|
||||
key: "id"
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.dms.vinowner"),
|
||||
dataIndex: "vinOwner",
|
||||
key: "vinOwner",
|
||||
render: (text, record) => <Checkbox disabled checked={record.vinOwner} />
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.dms.name1"),
|
||||
dataIndex: ["customerName", "firstName"],
|
||||
key: "firstName",
|
||||
sorter: (a, b) => alphaSort(a.customerName?.firstName, b.customerName?.firstName)
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.dms.name1"),
|
||||
dataIndex: ["customerName", "lastName"],
|
||||
key: "lastName",
|
||||
sorter: (a, b) => alphaSort(a.customerName?.lastName, b.customerName?.lastName)
|
||||
},
|
||||
{
|
||||
title: t("jobs.fields.dms.address"),
|
||||
|
||||
key: "address",
|
||||
render: (record, value) =>
|
||||
`${record.postalAddress?.addressLine1} ${record.postalAddress?.addressLine2 ? `, ${record.postalAddress?.addressLine2}` : ""},
|
||||
${record.postalAddress?.city} ${record.postalAddress?.state} ${record.postalAddress?.postalCode} ${
|
||||
record.postalAddress?.country
|
||||
}`
|
||||
}
|
||||
];
|
||||
|
||||
const cdkColumns = [
|
||||
{
|
||||
title: t("jobs.fields.dms.id"),
|
||||
@@ -122,13 +190,13 @@ export function DmsCustomerSelector({ bodyshop }) {
|
||||
</div>
|
||||
)}
|
||||
pagination={{ position: "top" }}
|
||||
columns={dmsType === "cdk" ? cdkColumns : pbsColumns}
|
||||
rowKey={(record) => (dmsType === "cdk" ? record.id.value : record.ContactId)}
|
||||
columns={dmsType === "cdk" ? (Fortellis.treatment === "on" ? fortellisColumns : cdkColumns) : pbsColumns}
|
||||
rowKey={(record) => (dmsType === "cdk" ? record.id?.value || record.customerId : record.ContactId)}
|
||||
dataSource={customerList}
|
||||
//onChange={handleTableChange}
|
||||
rowSelection={{
|
||||
onSelect: (record) => {
|
||||
setSelectedCustomer(dmsType === "cdk" ? record.id.value : record.ContactId);
|
||||
setSelectedCustomer(dmsType === "cdk" ? record.id?.value || record.customerId : record.ContactId);
|
||||
},
|
||||
type: "radio",
|
||||
selectedRowKeys: [selectedCustomer]
|
||||
|
||||
@@ -28,6 +28,7 @@ import CurrencyInput from "../form-items-formatted/currency-form-item.component"
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component.jsx";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket";
|
||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
@@ -38,6 +39,14 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(DmsPostForm);
|
||||
|
||||
export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
||||
const {
|
||||
treatments: { Fortellis }
|
||||
} = useSplitTreatments({
|
||||
attributes: {},
|
||||
names: ["Fortellis"],
|
||||
splitKey: bodyshop.imexshopid
|
||||
});
|
||||
|
||||
const [form] = Form.useForm();
|
||||
const { t } = useTranslation();
|
||||
const { socket: wsssocket } = useSocket();
|
||||
@@ -62,21 +71,21 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
||||
|
||||
const handleFinish = (values) => {
|
||||
//TODO: Add this as a split instead.
|
||||
if (true) {
|
||||
if (Fortellis.treatment === "on") {
|
||||
wsssocket.emit("fortellis-export-job", { jobid: job.id, txEnvelope: values });
|
||||
} else {
|
||||
socket.emit(`${determineDmsType(bodyshop)}-export-job`, {
|
||||
jobid: job.id,
|
||||
txEnvelope: values
|
||||
});
|
||||
console.log(logsRef);
|
||||
if (logsRef) {
|
||||
console.log("executing", logsRef);
|
||||
logsRef.curent &&
|
||||
logsRef.current.scrollIntoView({
|
||||
behavior: "smooth"
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log(logsRef);
|
||||
if (logsRef) {
|
||||
console.log("executing", logsRef);
|
||||
logsRef.curent &&
|
||||
logsRef.current.scrollIntoView({
|
||||
behavior: "smooth"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -185,7 +194,7 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<Space>
|
||||
<DmsCdkMakes form={form} socket={socket} job={job} />
|
||||
<DmsCdkMakes form={form} job={job} />
|
||||
<DmsCdkMakesRefetch />
|
||||
<Form.Item name="dms_unsold" label={t("jobs.fields.dms.dms_unsold")} initialValue={false}>
|
||||
<Switch />
|
||||
|
||||
@@ -21,6 +21,8 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket.js";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
@@ -54,6 +56,14 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const { jobId } = search;
|
||||
const notification = useNotification();
|
||||
const {
|
||||
treatments: { Fortellis }
|
||||
} = useSplitTreatments({
|
||||
attributes: {},
|
||||
names: ["Fortellis"],
|
||||
splitKey: bodyshop.imexshopid
|
||||
});
|
||||
const { socket: wsssocket } = useSocket();
|
||||
|
||||
const { loading, error, data } = useQuery(QUERY_JOB_EXPORT_DMS, {
|
||||
variables: { id: jobId },
|
||||
@@ -84,45 +94,75 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
}, [t, setBreadcrumbs, setSelectedHeader]);
|
||||
|
||||
useEffect(() => {
|
||||
socket.on("connect", () => socket.emit("set-log-level", logLevel));
|
||||
socket.on("reconnect", () => {
|
||||
setLogs((logs) => {
|
||||
return [
|
||||
...logs,
|
||||
{
|
||||
timestamp: new Date(),
|
||||
level: "warn",
|
||||
message: "Reconnected to CDK Export Service"
|
||||
}
|
||||
];
|
||||
});
|
||||
});
|
||||
socket.on("connect_error", (err) => {
|
||||
console.log(`connect_error due to ${err}`, err);
|
||||
notification.error({ message: err.message });
|
||||
});
|
||||
socket.on("log-event", (payload) => {
|
||||
setLogs((logs) => {
|
||||
return [...logs, payload];
|
||||
});
|
||||
});
|
||||
socket.on("export-success", (payload) => {
|
||||
notification.success({
|
||||
message: t("jobs.successes.exported")
|
||||
});
|
||||
insertAuditTrail({
|
||||
jobid: payload,
|
||||
operation: AuditTrailMapping.jobexported(),
|
||||
type: "jobexported"
|
||||
});
|
||||
history("/manage/accounting/receivables");
|
||||
});
|
||||
if (Fortellis.treatment === "on") {
|
||||
wsssocket.emit("set-log-level", logLevel);
|
||||
|
||||
if (socket.disconnected) socket.connect();
|
||||
return () => {
|
||||
socket.removeAllListeners();
|
||||
socket.disconnect();
|
||||
};
|
||||
const handleLogEvent = (payload) => {
|
||||
setLogs((logs) => {
|
||||
return [...logs, payload];
|
||||
});
|
||||
};
|
||||
|
||||
const handleExportSuccess = (payload) => {
|
||||
notification.success({
|
||||
message: t("jobs.successes.exported")
|
||||
});
|
||||
insertAuditTrail({
|
||||
jobid: payload,
|
||||
operation: AuditTrailMapping.jobexported(),
|
||||
type: "jobexported"
|
||||
});
|
||||
history("/manage/accounting/receivables");
|
||||
};
|
||||
|
||||
wsssocket.on("fortellis-log-event", handleLogEvent);
|
||||
wsssocket.on("export-success", handleExportSuccess);
|
||||
|
||||
return () => {
|
||||
wsssocket.off("fortellis-log-event", handleLogEvent);
|
||||
wsssocket.off("export-success", handleExportSuccess);
|
||||
};
|
||||
} else {
|
||||
socket.on("connect", () => socket.emit("set-log-level", logLevel));
|
||||
socket.on("reconnect", () => {
|
||||
setLogs((logs) => {
|
||||
return [
|
||||
...logs,
|
||||
{
|
||||
timestamp: new Date(),
|
||||
level: "warn",
|
||||
message: "Reconnected to CDK Export Service"
|
||||
}
|
||||
];
|
||||
});
|
||||
});
|
||||
socket.on("connect_error", (err) => {
|
||||
console.log(`connect_error due to ${err}`, err);
|
||||
notification.error({ message: err.message });
|
||||
});
|
||||
socket.on("log-event", (payload) => {
|
||||
setLogs((logs) => {
|
||||
return [...logs, payload];
|
||||
});
|
||||
});
|
||||
socket.on("export-success", (payload) => {
|
||||
notification.success({
|
||||
message: t("jobs.successes.exported")
|
||||
});
|
||||
insertAuditTrail({
|
||||
jobid: payload,
|
||||
operation: AuditTrailMapping.jobexported(),
|
||||
type: "jobexported"
|
||||
});
|
||||
history("/manage/accounting/receivables");
|
||||
});
|
||||
|
||||
if (socket.disconnected) socket.connect();
|
||||
return () => {
|
||||
socket.removeAllListeners();
|
||||
socket.disconnect();
|
||||
};
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
@@ -137,6 +177,9 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
|
||||
return (
|
||||
<div>
|
||||
{Fortellis.treatment === "on" && (
|
||||
<AlertComponent message="Posting to Fortellis" type="warning" showIcon closable />
|
||||
)}
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col md={24} lg={10}>
|
||||
<DmsAllocationsSummary
|
||||
|
||||
7
package-lock.json
generated
7
package-lock.json
generated
@@ -23,6 +23,7 @@
|
||||
"archiver": "^7.0.1",
|
||||
"aws4": "^1.13.2",
|
||||
"axios": "^1.8.4",
|
||||
"axios-curlirize": "^2.0.0",
|
||||
"bee-queue": "^1.7.1",
|
||||
"better-queue": "^3.8.12",
|
||||
"bluebird": "^3.7.2",
|
||||
@@ -4848,6 +4849,12 @@
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/axios-curlirize": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/axios-curlirize/-/axios-curlirize-2.0.0.tgz",
|
||||
"integrity": "sha512-TrQBa8MfIwaYsrCoYhfCr7NDRXLuGm+Rqh/PtAuO64b8PCCOJWn37BWQvpN4/mzzig3uHb4qXzvpxJmALHaiwA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/axios-ntlm": {
|
||||
"version": "1.4.4",
|
||||
"resolved": "https://registry.npmjs.org/axios-ntlm/-/axios-ntlm-1.4.4.tgz",
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"archiver": "^7.0.1",
|
||||
"aws4": "^1.13.2",
|
||||
"axios": "^1.8.4",
|
||||
"axios-curlirize": "^2.0.0",
|
||||
"bee-queue": "^1.7.1",
|
||||
"better-queue": "^3.8.12",
|
||||
"bluebird": "^3.7.2",
|
||||
|
||||
@@ -12,6 +12,17 @@ const logger = require("../utils/logger");
|
||||
const uuid = require("uuid").v4;
|
||||
const AxiosLib = require("axios").default;
|
||||
const axios = AxiosLib.create();
|
||||
const axiosCurlirize = require('axios-curlirize').default;
|
||||
|
||||
axiosCurlirize(axios, (result, err) => {
|
||||
const { command } = result;
|
||||
console.log("*** ~ axiosCurlirize ~ command:", command);
|
||||
|
||||
// if (err) {
|
||||
// use your logger here
|
||||
// } else {
|
||||
// }
|
||||
});
|
||||
|
||||
const getTransactionType = (jobid) => `fortellis:${jobid}`;
|
||||
const defaultFortellisTTL = 60 * 60;
|
||||
@@ -100,10 +111,11 @@ async function GetDepartmentId({ apiName, debug = false, SubscriptionMeta }) {
|
||||
);
|
||||
console.log("===========");
|
||||
}
|
||||
//TODO: Verify how to select the correct department.
|
||||
const departmentIds2 = SubscriptionMeta.apiDmsInfo //Get the subscription object.
|
||||
.find((info) => info.name === apiName)?.departments; //Departments are categorized by API name and have an array of departments.
|
||||
|
||||
return departmentIds2[0].id; //TODO: This makes the assumption that there is only 1 department.
|
||||
return departmentIds2 && departmentIds2[0] && departmentIds2[0].id; //TODO: This makes the assumption that there is only 1 department.
|
||||
}
|
||||
|
||||
//Highest level function call to make a call to fortellis. This should be the only call required, and it will handle all the logic for making the call.
|
||||
@@ -114,13 +126,17 @@ async function MakeFortellisCall({
|
||||
body = {},
|
||||
type = "post",
|
||||
debug = true,
|
||||
requestPathParams,
|
||||
requestSearchParams = [], //Array of key/value strings like [["key", "value"]]
|
||||
jobid,
|
||||
redisHelpers,
|
||||
socket
|
||||
socket,
|
||||
}) {
|
||||
const { setSessionTransactionData, getSessionTransactionData } = redisHelpers;
|
||||
|
||||
if (debug) logger.log(`Executing ${type} to ${url}`);
|
||||
const fullUrl = constructFullUrl({ url, pathParams: requestPathParams, requestSearchParams });
|
||||
|
||||
if (debug) logger.log(`Executing ${type} to ${fullUrl}`);
|
||||
const ReqId = uuid();
|
||||
const access_token = await GetAuthToken();
|
||||
const SubscriptionMeta = await FetchSubscriptions({ redisHelpers, socket, jobid });
|
||||
@@ -138,18 +154,18 @@ async function MakeFortellisCall({
|
||||
switch (type) {
|
||||
case "post":
|
||||
default:
|
||||
result = await axios.post(url, body, {
|
||||
result = await axios.post(fullUrl, body, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${access_token}`,
|
||||
"Subscription-Id": SubscriptionMeta.subscriptionId,
|
||||
"Request-Id": ReqId,
|
||||
"Department-Id": DepartmentId,
|
||||
...DepartmentId && { "Department-Id": DepartmentId },
|
||||
...headers
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "get":
|
||||
result = await axios.get(url, {
|
||||
result = await axios.get(fullUrl, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${access_token}`,
|
||||
"Subscription-Id": SubscriptionMeta.subscriptionId,
|
||||
@@ -229,10 +245,31 @@ const FortellisActions = {
|
||||
type: "get",
|
||||
apiName: "Service Vehicle - Query Vehicles"
|
||||
},
|
||||
GetVehicleId: {
|
||||
url: isProduction
|
||||
? "https://api.fortellis.io/cdk/drive/service-vehicle-mgmt/v2/vehicle-ids/" //Request path params of vins
|
||||
: "https://api.fortellis.io/cdk-test/drive/service-vehicle-mgmt/v2/vehicle-ids/",
|
||||
type: "get",
|
||||
apiName: "CDK Drive Post Service Vehicle",
|
||||
},
|
||||
GetVehicleById: {
|
||||
url: isProduction
|
||||
? "https://api.fortellis.io/cdk/drive/service-vehicle-mgmt/v2/" //Request path params of vehicleId
|
||||
: "https://api.fortellis.io/cdk-test/drive/service-vehicle-mgmt/v2/",
|
||||
type: "get",
|
||||
apiName: "CDK Drive Post Service Vehicle",
|
||||
},
|
||||
QueryCustomerByName: {
|
||||
url: isProduction
|
||||
? "https://api.fortellis.io/cdk/drive/customerpost/v1/search"
|
||||
: "https://api.fortellis.io/cdk-test/drive/customerpost/v1/search",
|
||||
type: "get",
|
||||
apiName: "CDK Drive Post Customer",
|
||||
},
|
||||
GetCOA: {
|
||||
type: "get",
|
||||
apiName: "CDK Drive Post Accounts GL WIP",
|
||||
url: `https://api.fortellis.io/cdk-test/drive/chartofaccounts/v2/bulk`,
|
||||
url: `https://api.fortellis.io/cdk-test/drive/chartofaccounts/v2/bulk/`,
|
||||
waitForResult: true
|
||||
}
|
||||
};
|
||||
@@ -243,6 +280,17 @@ const FortellisCacheEnums = {
|
||||
DepartmentId: "DepartmentId"
|
||||
};
|
||||
|
||||
function constructFullUrl({ url, pathParams = "", requestSearchParams = [] }) {
|
||||
// Ensure the base URL ends with a single "/"
|
||||
url = url.replace(/\/+$/, "/");
|
||||
const fullPath = pathParams ? `${url}${pathParams}` : url;
|
||||
const searchParams = new URLSearchParams(requestSearchParams).toString();
|
||||
const fullUrl = searchParams ? `${fullPath}?${searchParams}` : fullPath;
|
||||
return fullUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
GetAuthToken,
|
||||
FortellisCacheEnums,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const logger = require("../utils/logger");
|
||||
|
||||
const CreateFortellisLogEvent = (socket, level, message, txnDetails) => {
|
||||
//TODO: Add detaisl to track the whole transaction between Fortellis and the server.
|
||||
//TODO: Add detaisl to track the whole transaction between Fortellis and the server.
|
||||
logger.log("fortellis-log-event", level, socket?.user?.email, null, { wsmessage: message, txnDetails });
|
||||
socket.emit("fortellis-log-event", { level, message, txnDetails });
|
||||
};
|
||||
|
||||
@@ -14,10 +14,11 @@ const {
|
||||
defaultFortellisTTL,
|
||||
FortellisCacheEnums
|
||||
} = require("./fortellis-helpers");
|
||||
const { last } = require("lodash");
|
||||
|
||||
// const moment = require("moment-timezone");
|
||||
|
||||
// const replaceSpecialRegex = /[^a-zA-Z0-9 .,\n #]+/g;
|
||||
const replaceSpecialRegex = /[^a-zA-Z0-9 .,\n #]+/g;
|
||||
|
||||
async function FortellisJobExport({
|
||||
socket,
|
||||
@@ -37,10 +38,6 @@ async function FortellisJobExport({
|
||||
getSessionTransactionData,
|
||||
clearSessionTransactionData
|
||||
} = redisHelpers;
|
||||
// ////Store the following information into the redis store for this transaction.
|
||||
// socket.logEvents = [];
|
||||
// socket.recordid = jobid;
|
||||
// socket.txEnvelope = txEnvelope;
|
||||
try {
|
||||
CreateFortellisLogEvent(socket, "debug", `Received Job export request for id ${jobid}`);
|
||||
await setSessionTransactionData(
|
||||
@@ -54,127 +51,133 @@ async function FortellisJobExport({
|
||||
const JobData = await QueryJobData({ socket, jobid }); //TODO: Need to remove unnecessary stuff here to reduce the payload.
|
||||
await setSessionTransactionData(socket.id, getTransactionType(jobid), `JobData`, JobData, defaultFortellisTTL);
|
||||
|
||||
// const DealerId = JobData.bodyshop.cdk_dealerid;
|
||||
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{1} Begin Calculate DMS Vehicle ID using VIN: ${JobData.v_vin}`);
|
||||
const DMSVid = await CalculateDmsVid({ socket, JobData, redisHelpers });
|
||||
await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSVid`, DMSVid, defaultFortellisTTL);
|
||||
|
||||
if (socket.DMSVid.newId === "N") {
|
||||
let DMSVehCustomer;
|
||||
if (DMSVid.newId === "N") {
|
||||
CreateFortellisLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{2.1} Querying the Vehicle using the DMSVid: ${socket.DMSVid.vehiclesVehId}`
|
||||
);
|
||||
// socket.DMSVeh = await QueryDmsVehicleById(socket, JobData, socket.DMSVid);
|
||||
const DMSVeh = await QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid });
|
||||
await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSVeh`, DMSVeh, defaultFortellisTTL);
|
||||
|
||||
// const DMSVehCustomer =
|
||||
// socket.DMSVeh && socket.DMSVeh.owners && socket.DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
||||
const DMSVehCustomerFromVehicle =
|
||||
DMSVeh && DMSVeh.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
||||
|
||||
// if (DMSVehCustomer && DMSVehCustomer.id && DMSVehCustomer.id.value) {
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "DEBUG",
|
||||
// `{2.2} Querying the Customer using the ID from DMSVeh: ${DMSVehCustomer.id.value}`
|
||||
// );
|
||||
// socket.DMSVehCustomer = await QueryDmsCustomerById(socket, JobData, DMSVehCustomer.id.value);
|
||||
if (DMSVehCustomerFromVehicle && DMSVehCustomerFromVehicle.id && DMSVehCustomerFromVehicle.id.value) {
|
||||
CreateFortellisLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{2.2} Querying the Customer using the ID from DMSVeh: ${DMSVehCustomerFromVehicle.id.value}`
|
||||
);
|
||||
DMSVehCustomer = await QueryDmsCustomerById({ socket, redisHelpers, JobData, CustomerId: DMSVehCustomerFromVehicle.id.value });
|
||||
await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSVehCustomer`, DMSVehCustomer, defaultFortellisTTL);
|
||||
}
|
||||
}
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{2.3} Querying the Customer using the name.`);
|
||||
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{2.3} Querying the Customer using the name.`);
|
||||
const DMSCustList = await QueryDmsCustomerByName({ socket, redisHelpers, JobData });
|
||||
await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSCustList`, DMSCustList, defaultFortellisTTL);
|
||||
|
||||
// socket.DMSCustList = await QueryDmsCustomerByName(socket, JobData);
|
||||
|
||||
// socket.emit("cdk-select-customer", [
|
||||
// ...(socket.DMSVehCustomer ? [{ ...socket.DMSVehCustomer, vinOwner: true }] : []),
|
||||
// ...socket.DMSCustList
|
||||
// ]);
|
||||
socket.emit("fortellis-select-customer", [
|
||||
...(DMSVehCustomer ? [{ ...DMSVehCustomer, vinOwner: true }] : []),
|
||||
...DMSCustList
|
||||
]);
|
||||
|
||||
} catch (error) {
|
||||
CreateFortellisLogEvent(socket, "ERROR", `Error in FortellisJobExport - ${error}`, {
|
||||
error: error.message,
|
||||
stack: error.stack
|
||||
});
|
||||
//CdkBase.createLogEvent(socket, "ERROR", `Error encountered in CdkJobExport. ${error}`);
|
||||
}
|
||||
|
||||
// async function CdkSelectedCustomer(socket, selectedCustomerId) {
|
||||
// try {
|
||||
// socket.selectedCustomerId = selectedCustomerId;
|
||||
// if (selectedCustomerId) {
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`);
|
||||
// socket.DMSCust = await QueryDmsCustomerById(socket, socket.JobData, selectedCustomerId);
|
||||
// } else {
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{3.2} Generating a new customer ID.`);
|
||||
// const newCustomerId = await GenerateDmsCustomerNumber(socket);
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{3.3} Inserting new customer with ID: ${newCustomerId}`);
|
||||
// socket.DMSCust = await InsertDmsCustomer(socket, newCustomerId);
|
||||
// }
|
||||
|
||||
// if (socket.DMSVid.newId === "Y") {
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{4.1} Inserting new vehicle with ID: ID ${socket.DMSVid.vehiclesVehId}`);
|
||||
// socket.DMSVeh = await InsertDmsVehicle(socket);
|
||||
// } else {
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "DEBUG",
|
||||
// `{4.2} Querying Existing Vehicle using ID ${socket.DMSVid.vehiclesVehId}`
|
||||
// );
|
||||
// socket.DMSVeh = await QueryDmsVehicleById(socket, socket.JobData, socket.DMSVid);
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{4.3} Updating Existing Vehicle to associate to owner.`);
|
||||
// socket.DMSVeh = await UpdateDmsVehicle(socket);
|
||||
// }
|
||||
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{5} Creating Transaction header with Dms Start WIP`);
|
||||
// socket.DMSTransHeader = await InsertDmsStartWip(socket);
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{5.1} Creating Transaction with ID ${socket.DMSTransHeader.transID}`);
|
||||
|
||||
// socket.DMSBatchTxn = await InsertDmsBatchWip(socket);
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "DEBUG",
|
||||
// `{6} Attempting to post Transaction with ID ${socket.DMSTransHeader.transID}`
|
||||
// );
|
||||
// socket.DmsBatchTxnPost = await PostDmsBatchWip(socket);
|
||||
// if (socket.DmsBatchTxnPost.code === "success") {
|
||||
// //something
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{6} Successfully posted sransaction to DMS.`);
|
||||
|
||||
// await MarkJobExported(socket, socket.JobData.id);
|
||||
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{5} Updating Service Vehicle History.`);
|
||||
// socket.DMSVehHistory = await InsertServiceVehicleHistory(socket);
|
||||
// socket.emit("export-success", socket.JobData.id);
|
||||
// } else {
|
||||
// //Get the error code
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "DEBUG",
|
||||
// `{6.1} Getting errors for Transaction ID ${socket.DMSTransHeader.transID}`
|
||||
// );
|
||||
// socket.DmsError = await QueryDmsErrWip(socket);
|
||||
// //Delete the transaction
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${socket.DMSTransHeader.transID}`);
|
||||
// socket.DmsBatchTxnPost = await DeleteDmsWip(socket);
|
||||
|
||||
// socket.DmsError.errMsg
|
||||
// .split("|")
|
||||
// .map(
|
||||
// (e) =>
|
||||
// e !== null &&
|
||||
// e !== "" &&
|
||||
// CdkBase.createLogEvent(socket, "ERROR", `Error(s) encountered in posting transaction. ${e}`)
|
||||
// );
|
||||
// }
|
||||
// } catch (error) {
|
||||
// CdkBase.createLogEvent(socket, "ERROR", `Error encountered in CdkSelectedCustomer. ${error}`);
|
||||
// await InsertFailedExportLog(socket, error);
|
||||
// } finally {
|
||||
// //Ensure we always insert logEvents
|
||||
// //GQL to insert logevents.
|
||||
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `Capturing log events to database.`);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
// async function CdkSelectedCustomer(socket, selectedCustomerId) {
|
||||
// try {
|
||||
// socket.selectedCustomerId = selectedCustomerId;
|
||||
// if (selectedCustomerId) {
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`);
|
||||
// socket.DMSCust = await QueryDmsCustomerById(socket, socket.JobData, selectedCustomerId);
|
||||
// } else {
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{3.2} Generating a new customer ID.`);
|
||||
// const newCustomerId = await GenerateDmsCustomerNumber(socket);
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{3.3} Inserting new customer with ID: ${newCustomerId}`);
|
||||
// socket.DMSCust = await InsertDmsCustomer(socket, newCustomerId);
|
||||
// }
|
||||
|
||||
// if (socket.DMSVid.newId === "Y") {
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{4.1} Inserting new vehicle with ID: ID ${socket.DMSVid.vehiclesVehId}`);
|
||||
// socket.DMSVeh = await InsertDmsVehicle(socket);
|
||||
// } else {
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "DEBUG",
|
||||
// `{4.2} Querying Existing Vehicle using ID ${socket.DMSVid.vehiclesVehId}`
|
||||
// );
|
||||
// socket.DMSVeh = await QueryDmsVehicleById(socket, socket.JobData, socket.DMSVid);
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{4.3} Updating Existing Vehicle to associate to owner.`);
|
||||
// socket.DMSVeh = await UpdateDmsVehicle(socket);
|
||||
// }
|
||||
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{5} Creating Transaction header with Dms Start WIP`);
|
||||
// socket.DMSTransHeader = await InsertDmsStartWip(socket);
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{5.1} Creating Transaction with ID ${socket.DMSTransHeader.transID}`);
|
||||
|
||||
// socket.DMSBatchTxn = await InsertDmsBatchWip(socket);
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "DEBUG",
|
||||
// `{6} Attempting to post Transaction with ID ${socket.DMSTransHeader.transID}`
|
||||
// );
|
||||
// socket.DmsBatchTxnPost = await PostDmsBatchWip(socket);
|
||||
// if (socket.DmsBatchTxnPost.code === "success") {
|
||||
// //something
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{6} Successfully posted sransaction to DMS.`);
|
||||
|
||||
// await MarkJobExported(socket, socket.JobData.id);
|
||||
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{5} Updating Service Vehicle History.`);
|
||||
// socket.DMSVehHistory = await InsertServiceVehicleHistory(socket);
|
||||
// socket.emit("export-success", socket.JobData.id);
|
||||
// } else {
|
||||
// //Get the error code
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "DEBUG",
|
||||
// `{6.1} Getting errors for Transaction ID ${socket.DMSTransHeader.transID}`
|
||||
// );
|
||||
// socket.DmsError = await QueryDmsErrWip(socket);
|
||||
// //Delete the transaction
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${socket.DMSTransHeader.transID}`);
|
||||
// socket.DmsBatchTxnPost = await DeleteDmsWip(socket);
|
||||
|
||||
// socket.DmsError.errMsg
|
||||
// .split("|")
|
||||
// .map(
|
||||
// (e) =>
|
||||
// e !== null &&
|
||||
// e !== "" &&
|
||||
// CdkBase.createLogEvent(socket, "ERROR", `Error(s) encountered in posting transaction. ${e}`)
|
||||
// );
|
||||
// }
|
||||
// } catch (error) {
|
||||
// CdkBase.createLogEvent(socket, "ERROR", `Error encountered in CdkSelectedCustomer. ${error}`);
|
||||
// await InsertFailedExportLog(socket, error);
|
||||
// } finally {
|
||||
// //Ensure we always insert logEvents
|
||||
// //GQL to insert logevents.
|
||||
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `Capturing log events to database.`);
|
||||
// }
|
||||
//}
|
||||
|
||||
// exports.CdkSelectedCustomer = CdkSelectedCustomer;
|
||||
|
||||
async function QueryJobData({ socket, jobid }) {
|
||||
@@ -188,170 +191,107 @@ async function QueryJobData({ socket, jobid }) {
|
||||
async function CalculateDmsVid({ socket, JobData, redisHelpers }) {
|
||||
try {
|
||||
const result = await MakeFortellisCall({
|
||||
...FortellisActions.QueryVehicles,
|
||||
...FortellisActions.GetVehicleId,
|
||||
requestPathParams: JobData.v_vin,
|
||||
headers: {},
|
||||
redisHelpers,
|
||||
socket,
|
||||
jobid: JobData.id,
|
||||
body: {
|
||||
vin: JobData.v_vin
|
||||
//Include the contents of the call here.
|
||||
}
|
||||
body: {},
|
||||
|
||||
});
|
||||
// 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 }
|
||||
// });
|
||||
// const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
|
||||
// CdkBase.createXmlEvent(socket, rawRequest, `soapClientVehicleInsertUpdate.getVehIdsAsync request.`);
|
||||
// CdkBase.createXmlEvent(socket, rawResponse, `soapClientVehicleInsertUpdate.getVehIdsAsync response.`);
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "SILLY",
|
||||
// `soapClientVehicleInsertUpdate.getVehIdsAsync Result ${JSON.stringify(result, null, 2)}`
|
||||
// );
|
||||
// CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
||||
// //if (result && result.return && result.return.length > 1) {
|
||||
// return result.return.find((r) => r.vehiclesVehId);
|
||||
// //}
|
||||
//return result && result.return && result.return[0];
|
||||
return result;
|
||||
} catch (error) {
|
||||
CreateFortellisLogEvent(socket, "ERROR", `Error in CalculateDmsVid - ${error}`, { request: error.request });
|
||||
// CdkBase.createXmlEvent(socket, error.request, `soapClientVehicleInsertUpdate.getVehIdsAsync request.`, true);
|
||||
|
||||
// CdkBase.createXmlEvent(
|
||||
// socket,
|
||||
// error.response && error.response.data,
|
||||
// `soapClientVehicleInsertUpdate.getVehIdsAsync response.`,
|
||||
// true
|
||||
// );
|
||||
// CdkBase.createLogEvent(socket, "ERROR", `{1} Error in CalculateDmsVid - ${error}`);
|
||||
// throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
// async function QueryDmsVehicleById(socket, JobData, DMSVid) {
|
||||
// try {
|
||||
// const soapClientVehicleInsertUpdate = await soap.createClientAsync(CdkWsdl.VehicleInsertUpdate);
|
||||
async function QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid }) {
|
||||
try {
|
||||
const result = await MakeFortellisCall({
|
||||
...FortellisActions.GetVehicleById,
|
||||
requestPathParams: DMSVid.vehiclesVehId,
|
||||
headers: {},
|
||||
redisHelpers,
|
||||
socket,
|
||||
jobid: JobData.id,
|
||||
body: {},
|
||||
});
|
||||
const VehicleFromDMS = result && result.return && result.return.vehicle;
|
||||
return VehicleFromDMS;
|
||||
} catch (error) {
|
||||
CreateFortellisLogEvent(socket, "ERROR", `Error in QueryDmsVehicleById - ${error}`, { request: error.request });
|
||||
}
|
||||
}
|
||||
|
||||
// const soapResponseVehicleInsertUpdate = await soapClientVehicleInsertUpdate.readAsync({
|
||||
// arg0: CDK_CREDENTIALS,
|
||||
// arg1: { id: JobData.bodyshop.cdk_dealerid },
|
||||
// arg2: {
|
||||
// fileType: "VEHICLES",
|
||||
// vehiclesVehicleId: DMSVid.vehiclesVehId
|
||||
// }
|
||||
// });
|
||||
async function QueryDmsCustomerById({ socket, redisHelpers, JobData, CustomerId }) {
|
||||
try {
|
||||
const soapClientCustomerInsertUpdate = await soap.createClientAsync(CdkWsdl.CustomerInsertUpdate);
|
||||
const soapResponseCustomerInsertUpdate = await soapClientCustomerInsertUpdate.readAsync({
|
||||
arg0: CDK_CREDENTIALS,
|
||||
arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
||||
arg2: {
|
||||
// userId: CustomerId,
|
||||
},
|
||||
arg3: CustomerId
|
||||
});
|
||||
|
||||
// const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
|
||||
const [result, rawResponse, , rawRequest] = soapResponseCustomerInsertUpdate;
|
||||
|
||||
// CdkBase.createXmlEvent(socket, rawRequest, `soapClientVehicleInsertUpdate.readAsync request.`);
|
||||
CdkBase.createXmlEvent(socket, rawRequest, `soapClientCustomerInsertUpdate.readAsync request.`);
|
||||
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "SILLY",
|
||||
// `soapClientVehicleInsertUpdate.readAsync Result ${JSON.stringify(result, null, 2)}`
|
||||
// );
|
||||
// CdkBase.createXmlEvent(socket, rawResponse, `soapClientVehicleInsertUpdate.readAsync response.`);
|
||||
// CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
||||
// const VehicleFromDMS = result && result.return && result.return.vehicle;
|
||||
// return VehicleFromDMS;
|
||||
// } catch (error) {
|
||||
// CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsVehicleById - ${error}`);
|
||||
// throw new Error(error);
|
||||
// }
|
||||
// }
|
||||
CdkBase.createXmlEvent(socket, rawResponse, `soapClientCustomerInsertUpdate.readAsync response.`);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"SILLY",
|
||||
`soapClientCustomerInsertUpdate.readAsync Result ${JSON.stringify(result, null, 2)}`
|
||||
);
|
||||
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
||||
const CustomersFromDms = result && result.return && result.return.customerParty;
|
||||
return CustomersFromDms;
|
||||
} catch (error) {
|
||||
CdkBase.createXmlEvent(socket, error.request, `soapClientCustomerInsertUpdate.readAsync request.`, true);
|
||||
|
||||
// async function QueryDmsCustomerById(socket, JobData, CustomerId) {
|
||||
// try {
|
||||
// const soapClientCustomerInsertUpdate = await soap.createClientAsync(CdkWsdl.CustomerInsertUpdate);
|
||||
// const soapResponseCustomerInsertUpdate = await soapClientCustomerInsertUpdate.readAsync({
|
||||
// arg0: CDK_CREDENTIALS,
|
||||
// arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
||||
// arg2: {
|
||||
// // userId: CustomerId,
|
||||
// },
|
||||
// arg3: CustomerId
|
||||
// });
|
||||
CdkBase.createXmlEvent(
|
||||
socket,
|
||||
error.response && error.response.data,
|
||||
`soapClientCustomerInsertUpdate.readAsync response.`,
|
||||
true
|
||||
);
|
||||
|
||||
// const [result, rawResponse, , rawRequest] = soapResponseCustomerInsertUpdate;
|
||||
CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsCustomerById - ${error}`);
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
// CdkBase.createXmlEvent(socket, rawRequest, `soapClientCustomerInsertUpdate.readAsync request.`);
|
||||
async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
||||
const ownerName =
|
||||
JobData.ownr_co_nm && JobData.ownr_co_nm.trim() !== ""
|
||||
? [["lastName", JobData.ownr_co_nm.replace(replaceSpecialRegex, "")]]
|
||||
: [["firstName", JobData.ownr_fn.replace(replaceSpecialRegex, "")], ["lastName", JobData.ownr_ln.replace(replaceSpecialRegex, "")]];
|
||||
|
||||
// CdkBase.createXmlEvent(socket, rawResponse, `soapClientCustomerInsertUpdate.readAsync response.`);
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "SILLY",
|
||||
// `soapClientCustomerInsertUpdate.readAsync Result ${JSON.stringify(result, null, 2)}`
|
||||
// );
|
||||
// CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
||||
// const CustomersFromDms = result && result.return && result.return.customerParty;
|
||||
// return CustomersFromDms;
|
||||
// } catch (error) {
|
||||
// CdkBase.createXmlEvent(socket, error.request, `soapClientCustomerInsertUpdate.readAsync request.`, true);
|
||||
CreateFortellisLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`Begin query DMS Customer by Name using ${JSON.stringify(ownerName)}`
|
||||
);
|
||||
|
||||
// CdkBase.createXmlEvent(
|
||||
// socket,
|
||||
// error.response && error.response.data,
|
||||
// `soapClientCustomerInsertUpdate.readAsync response.`,
|
||||
// true
|
||||
// );
|
||||
try {
|
||||
const result = await MakeFortellisCall({
|
||||
...FortellisActions.QueryCustomerByName,
|
||||
requestSearchParams: ownerName,
|
||||
headers: {},
|
||||
redisHelpers,
|
||||
socket,
|
||||
jobid: JobData.id,
|
||||
body: {},
|
||||
|
||||
// CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsCustomerById - ${error}`);
|
||||
// throw new Error(error);
|
||||
// }
|
||||
// }
|
||||
|
||||
// async function QueryDmsCustomerByName(socket, JobData) {
|
||||
// const ownerName = (
|
||||
// JobData.ownr_co_nm && JobData.ownr_co_nm.trim() !== ""
|
||||
// ? JobData.ownr_co_nm
|
||||
// : `${JobData.ownr_ln},${JobData.ownr_fn}`
|
||||
// ).replace(replaceSpecialRegex, "");
|
||||
|
||||
// CdkBase.createLogEvent(socket, "DEBUG", `Begin Query DMS Customer by Name using: ${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
|
||||
// }
|
||||
// });
|
||||
|
||||
// const [result, rawResponse, , rawRequest] = soapResponseCustomerSearch;
|
||||
|
||||
// CdkBase.createXmlEvent(socket, rawRequest, `soapClientCustomerSearch.executeSearchBulkAsync request.`);
|
||||
|
||||
// CdkBase.createXmlEvent(socket, rawResponse, `soapClientCustomerSearch.executeSearchBulkAsync response.`);
|
||||
|
||||
// CdkBase.createLogEvent(
|
||||
// socket,
|
||||
// "SILLY",
|
||||
// `soapClientCustomerSearch.executeSearchBulkAsync Result ${JSON.stringify(result, null, 2)}`
|
||||
// );
|
||||
// CheckCdkResponseForError(socket, soapResponseCustomerSearch);
|
||||
// const CustomersFromDms = (result && result.return) || [];
|
||||
// return CustomersFromDms;
|
||||
// } catch (error) {
|
||||
// CdkBase.createXmlEvent(socket, error.request, `soapClientCustomerSearch.executeSearchBulkAsync request.`, true);
|
||||
|
||||
// CdkBase.createXmlEvent(
|
||||
// socket,
|
||||
// error.response && error.response.data,
|
||||
// `soapClientCustomerSearch.executeSearchBulkAsync response.`,
|
||||
// true
|
||||
// );
|
||||
|
||||
// CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsCustomerByName - ${error}`);
|
||||
// throw new Error(error);
|
||||
// }
|
||||
// }
|
||||
});
|
||||
return result.data;
|
||||
} catch (error) {
|
||||
CreateFortellisLogEvent(socket, "ERROR", `Error in QueryDmsCustomerByName - ${error}`, { request: error.request });
|
||||
}
|
||||
}
|
||||
|
||||
// async function GenerateDmsCustomerNumber(socket) {
|
||||
// try {
|
||||
|
||||
Reference in New Issue
Block a user