|
|
|
|
@@ -14,9 +14,8 @@ const {
|
|
|
|
|
defaultFortellisTTL,
|
|
|
|
|
FortellisCacheEnums
|
|
|
|
|
} = require("./fortellis-helpers");
|
|
|
|
|
const { last } = require("lodash");
|
|
|
|
|
|
|
|
|
|
// const moment = require("moment-timezone");
|
|
|
|
|
const _ = require("lodash");
|
|
|
|
|
const moment = require("moment-timezone");
|
|
|
|
|
|
|
|
|
|
const replaceSpecialRegex = /[^a-zA-Z0-9 .,\n #]+/g;
|
|
|
|
|
|
|
|
|
|
@@ -28,15 +27,15 @@ async function FortellisJobExport({
|
|
|
|
|
jobid
|
|
|
|
|
}) {
|
|
|
|
|
const {
|
|
|
|
|
setSessionData,
|
|
|
|
|
getSessionData,
|
|
|
|
|
addUserSocketMapping,
|
|
|
|
|
removeUserSocketMapping,
|
|
|
|
|
refreshUserSocketTTL,
|
|
|
|
|
getUserSocketMappingByBodyshop,
|
|
|
|
|
// setSessionData,
|
|
|
|
|
// getSessionData,
|
|
|
|
|
// addUserSocketMapping,
|
|
|
|
|
// removeUserSocketMapping,
|
|
|
|
|
// refreshUserSocketTTL,
|
|
|
|
|
// getUserSocketMappingByBodyshop,
|
|
|
|
|
setSessionTransactionData,
|
|
|
|
|
getSessionTransactionData,
|
|
|
|
|
clearSessionTransactionData
|
|
|
|
|
// getSessionTransactionData,
|
|
|
|
|
// clearSessionTransactionData
|
|
|
|
|
} = redisHelpers;
|
|
|
|
|
try {
|
|
|
|
|
CreateFortellisLogEvent(socket, "debug", `Received Job export request for id ${jobid}`);
|
|
|
|
|
@@ -49,21 +48,21 @@ 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);
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.JobData, JobData, defaultFortellisTTL);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSVid, DMSVid, defaultFortellisTTL);
|
|
|
|
|
|
|
|
|
|
let DMSVehCustomer;
|
|
|
|
|
if (DMSVid.newId === "N") {
|
|
|
|
|
if (!DMSVid.newId) {
|
|
|
|
|
CreateFortellisLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{2.1} Querying the Vehicle using the DMSVid: ${socket.DMSVid.vehiclesVehId}`
|
|
|
|
|
`{2.1} Querying the Vehicle using the DMSVid: ${DMSVid.vehiclesVehId}`
|
|
|
|
|
);
|
|
|
|
|
const DMSVeh = await QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid });
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSVeh`, DMSVeh, defaultFortellisTTL);
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSVeh, DMSVeh, defaultFortellisTTL);
|
|
|
|
|
|
|
|
|
|
const DMSVehCustomerFromVehicle =
|
|
|
|
|
DMSVeh && DMSVeh.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
|
|
|
|
@@ -75,13 +74,13 @@ async function FortellisJobExport({
|
|
|
|
|
`{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);
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSVehCustomer, DMSVehCustomer, defaultFortellisTTL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CreateFortellisLogEvent(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);
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSCustList, DMSCustList, defaultFortellisTTL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit("fortellis-select-customer", [
|
|
|
|
|
@@ -99,33 +98,73 @@ async function FortellisJobExport({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
// }
|
|
|
|
|
async function FortellisSelectedCustomer({ socket, redisHelpers, ioHelpers, selectedCustomerId, jobid }) {
|
|
|
|
|
try {
|
|
|
|
|
const {
|
|
|
|
|
// setSessionData,
|
|
|
|
|
// getSessionData,
|
|
|
|
|
// addUserSocketMapping,
|
|
|
|
|
// removeUserSocketMapping,
|
|
|
|
|
// refreshUserSocketTTL,
|
|
|
|
|
// getUserSocketMappingByBodyshop,
|
|
|
|
|
setSessionTransactionData,
|
|
|
|
|
getSessionTransactionData,
|
|
|
|
|
//clearSessionTransactionData
|
|
|
|
|
} = redisHelpers;
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
// }
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.selectedCustomerId, selectedCustomerId, defaultFortellisTTL);
|
|
|
|
|
const JobData = await getSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.JobData);
|
|
|
|
|
const txEnvelope = await getSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.txEnvelope);
|
|
|
|
|
const DMSVid = await redisHelpers.getSessionTransactionData(socket.id, getTransactionType(JobData.id), FortellisCacheEnums.DMSVid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let DMSCust;
|
|
|
|
|
if (selectedCustomerId) {
|
|
|
|
|
CreateFortellisLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`
|
|
|
|
|
);
|
|
|
|
|
DMSCust = await QueryDmsCustomerById({ socket, redisHelpers, JobData, CustomerId: selectedCustomerId });
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSCust, DMSCust, defaultFortellisTTL);
|
|
|
|
|
} else {
|
|
|
|
|
CreateFortellisLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{3.2} Creating new customer.`
|
|
|
|
|
);
|
|
|
|
|
DMSCust = await InsertDmsCustomer({ socket, redisHelpers, JobData });
|
|
|
|
|
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSCust, DMSCust, defaultFortellisTTL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let DMSVeh;
|
|
|
|
|
if (DMSVid.newId) {
|
|
|
|
|
CreateFortellisLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{4.1} Inserting new vehicle with ID: ID ${DMSVid.vehiclesVehId}`
|
|
|
|
|
);
|
|
|
|
|
DMSVeh = await InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMSVid, DMSCust });
|
|
|
|
|
} else {
|
|
|
|
|
CreateFortellisLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{4.2} Querying Existing Vehicle using ID ${DMSVid.vehiclesVehId}`
|
|
|
|
|
);
|
|
|
|
|
DMSVeh = await QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid });
|
|
|
|
|
|
|
|
|
|
CreateFortellisLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{4.3} Updating Existing Vehicle to associate to owner.`
|
|
|
|
|
);
|
|
|
|
|
DMSVeh = await UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust, selectedCustomerId, txEnvelope });
|
|
|
|
|
}
|
|
|
|
|
////New code above.
|
|
|
|
|
/// Old code below.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(DMSVeh)
|
|
|
|
|
// 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}`);
|
|
|
|
|
@@ -167,18 +206,18 @@ async function FortellisJobExport({
|
|
|
|
|
// CdkBase.createLogEvent(socket, "ERROR", `Error(s) encountered in posting transaction. ${e}`)
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
} 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.
|
|
|
|
|
} finally {
|
|
|
|
|
//Ensure we always insert logEvents
|
|
|
|
|
//GQL to insert logevents.
|
|
|
|
|
|
|
|
|
|
//CdkBase.createLogEvent(socket, "DEBUG", `Capturing log events to database.`);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// exports.CdkSelectedCustomer = CdkSelectedCustomer;
|
|
|
|
|
exports.FortellisSelectedCustomer = FortellisSelectedCustomer;
|
|
|
|
|
|
|
|
|
|
async function QueryJobData({ socket, jobid }) {
|
|
|
|
|
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
|
|
|
|
|
@@ -217,8 +256,7 @@ async function QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid }) {
|
|
|
|
|
jobid: JobData.id,
|
|
|
|
|
body: {},
|
|
|
|
|
});
|
|
|
|
|
const VehicleFromDMS = result && result.return && result.return.vehicle;
|
|
|
|
|
return VehicleFromDMS;
|
|
|
|
|
return result;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CreateFortellisLogEvent(socket, "ERROR", `Error in QueryDmsVehicleById - ${error}`, { request: error.request });
|
|
|
|
|
}
|
|
|
|
|
@@ -226,41 +264,19 @@ async function QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid }) {
|
|
|
|
|
|
|
|
|
|
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 = await MakeFortellisCall({
|
|
|
|
|
...FortellisActions.ReadCustomer,
|
|
|
|
|
requestPathParams: CustomerId,
|
|
|
|
|
headers: {},
|
|
|
|
|
redisHelpers,
|
|
|
|
|
socket,
|
|
|
|
|
jobid: JobData.id,
|
|
|
|
|
body: {},
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const [result, rawResponse, , rawRequest] = soapResponseCustomerInsertUpdate;
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(socket, rawRequest, `soapClientCustomerInsertUpdate.readAsync request.`);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
return result.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CdkBase.createXmlEvent(socket, error.request, `soapClientCustomerInsertUpdate.readAsync request.`, true);
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
error.response && error.response.data,
|
|
|
|
|
`soapClientCustomerInsertUpdate.readAsync response.`,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsCustomerById - ${error}`);
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
CreateFortellisLogEvent(socket, "ERROR", `Error in QueryDmsCustomerById - ${error}`, { request: error.request });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -293,53 +309,205 @@ async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// async function GenerateDmsCustomerNumber(socket) {
|
|
|
|
|
// try {
|
|
|
|
|
// const soapClientCustomerInsertUpdate = await soap.createClientAsync(CdkWsdl.CustomerInsertUpdate);
|
|
|
|
|
// const soapResponseCustomerInsertUpdate = await soapClientCustomerInsertUpdate.getCustomerNumberAsync(
|
|
|
|
|
// {
|
|
|
|
|
// arg0: CDK_CREDENTIALS,
|
|
|
|
|
// arg1: { dealerId: socket.JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
|
|
|
|
// arg2: { userId: null }
|
|
|
|
|
async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const result = await MakeFortellisCall({
|
|
|
|
|
...FortellisActions.CreateCustomer,
|
|
|
|
|
headers: {},
|
|
|
|
|
redisHelpers,
|
|
|
|
|
socket,
|
|
|
|
|
jobid: JobData.id,
|
|
|
|
|
body: {
|
|
|
|
|
"customerType": "INDIVIDUAL",
|
|
|
|
|
"customerName": {
|
|
|
|
|
//"suffix": "Mr.",
|
|
|
|
|
"firstName": JobData.ownr_fn && JobData.ownr_fn.replace(replaceSpecialRegex, "").toUpperCase(),
|
|
|
|
|
//"middleName": "",
|
|
|
|
|
"lastName": JobData.ownr_ln && JobData.ownr_ln.replace(replaceSpecialRegex, "").toUpperCase(),
|
|
|
|
|
//"title": "",
|
|
|
|
|
//"nickName": ""
|
|
|
|
|
},
|
|
|
|
|
"companyName": JobData.ownr_co_nm && JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase(),
|
|
|
|
|
"postalAddress": {
|
|
|
|
|
"addressLine1": JobData.ownr_addr1?.replace(replaceSpecialRegex, "").trim(),
|
|
|
|
|
"addressLine2": JobData.ownr_addr2?.replace(replaceSpecialRegex, "").trim(),
|
|
|
|
|
"city": JobData.ownr_city?.replace(replaceSpecialRegex, "").trim(),
|
|
|
|
|
"state": JobData.ownr_state?.replace(replaceSpecialRegex, "").trim(),
|
|
|
|
|
"postalCode": InstanceMgr({
|
|
|
|
|
imex:
|
|
|
|
|
JobData.ownr_zip &&
|
|
|
|
|
JobData.ownr_zip
|
|
|
|
|
.toUpperCase()
|
|
|
|
|
.replace(/\W/g, "")
|
|
|
|
|
.replace(/(...)/, "$1 "),
|
|
|
|
|
rome: JobData.ownr_zip
|
|
|
|
|
}),
|
|
|
|
|
//"county": JobData.ownr_county?.trim(),
|
|
|
|
|
"country": JobData.ownr_ctry?.replace(replaceSpecialRegex, "").trim(),
|
|
|
|
|
"province": JobData.ownr_st?.replace(replaceSpecialRegex, "").trim(),
|
|
|
|
|
//"territory": ""
|
|
|
|
|
},
|
|
|
|
|
// "birthDate": {
|
|
|
|
|
// "day": "15",
|
|
|
|
|
// "month": "07",
|
|
|
|
|
// "year": "1979"
|
|
|
|
|
// },
|
|
|
|
|
//"gender": "M",
|
|
|
|
|
//"language": "English",
|
|
|
|
|
"contactMethods": {
|
|
|
|
|
"phones": [
|
|
|
|
|
{
|
|
|
|
|
//"uuid": "",
|
|
|
|
|
"number": JobData.ownr_ph1?.replace(replaceSpecialRegex, ""),
|
|
|
|
|
// "type": "MOBILE",
|
|
|
|
|
// "doNotCallIndicator": true,
|
|
|
|
|
// "doNotCallIndicatorDate": `null,
|
|
|
|
|
// "doNotCallRegistrySource": "",
|
|
|
|
|
// "isOnDoNotCallRegistry": false,
|
|
|
|
|
// "isPrimary": false,
|
|
|
|
|
// "isPreferred": false,
|
|
|
|
|
// "isTextMessageAllowed": false,
|
|
|
|
|
// "textMessageCarrier": "",
|
|
|
|
|
// "optInDate": null,
|
|
|
|
|
// "optInRequestedDate": null,
|
|
|
|
|
// "preferredDay": "",
|
|
|
|
|
// "preferredTime": ""
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// "uuid": "",
|
|
|
|
|
// "number": "6666666666",
|
|
|
|
|
// "type": "MOBILE",
|
|
|
|
|
// "doNotCallIndicator": true,
|
|
|
|
|
// "doNotCallIndicatorDate": null,
|
|
|
|
|
// "doNotCallRegistrySource": "",
|
|
|
|
|
// "isOnDoNotCallRegistry": false,
|
|
|
|
|
// "isPrimary": true,
|
|
|
|
|
// "isPreferred": true,
|
|
|
|
|
// "isTextMessageAllowed": false,
|
|
|
|
|
// "textMessageCarrier": "",
|
|
|
|
|
// "optInDate": null,
|
|
|
|
|
// "optInRequestedDate": null,
|
|
|
|
|
// "preferredDay": "",
|
|
|
|
|
// "preferredTime": ""
|
|
|
|
|
// }
|
|
|
|
|
],
|
|
|
|
|
"emailAddresses": [
|
|
|
|
|
|
|
|
|
|
// {}
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
// const [result, rawResponse, , rawRequest] = soapResponseCustomerInsertUpdate;
|
|
|
|
|
|
|
|
|
|
// CdkBase.createXmlEvent(socket, rawRequest, `soapClientCustomerInsertUpdate.getCustomerNumberAsync request.`);
|
|
|
|
|
|
|
|
|
|
// CdkBase.createXmlEvent(socket, rawResponse, `soapClientCustomerInsertUpdate.getCustomerNumberAsync response.`);
|
|
|
|
|
|
|
|
|
|
// CdkBase.createLogEvent(
|
|
|
|
|
// socket,
|
|
|
|
|
// "SILLY",
|
|
|
|
|
// `soapClientCustomerInsertUpdate.getCustomerNumberAsync Result ${JSON.stringify(result, null, 2)}`
|
|
|
|
|
// );
|
|
|
|
|
// CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
|
|
|
|
// const customerNumber = result && result.return && result.return.customerNumber;
|
|
|
|
|
// return customerNumber;
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
// CdkBase.createXmlEvent(
|
|
|
|
|
// socket,
|
|
|
|
|
// error.request,
|
|
|
|
|
// `soapClientCustomerInsertUpdate.getCustomerNumberAsync request.`,
|
|
|
|
|
// true
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
// CdkBase.createXmlEvent(
|
|
|
|
|
// socket,
|
|
|
|
|
// error.response && error.response.data,
|
|
|
|
|
// `soapClientCustomerInsertUpdate.getCustomerNumberAsync response.`,
|
|
|
|
|
// true
|
|
|
|
|
// );
|
|
|
|
|
// CdkBase.createLogEvent(socket, "ERROR", `Error in GenerateDmsCustomerNumber - ${error}`);
|
|
|
|
|
// throw new Error(error);
|
|
|
|
|
!_.isEmpty(socket.JobData.ownr_ea) ?
|
|
|
|
|
[{
|
|
|
|
|
//"uuid": "",
|
|
|
|
|
"address": socket.JobData.ownr_ea,
|
|
|
|
|
// "type": "PERSONAL",
|
|
|
|
|
// "doNotEmailSource": "",
|
|
|
|
|
// "doNotEmail": false,
|
|
|
|
|
// "isPreferred": true,
|
|
|
|
|
// "transactionEmailNotificationOptIn": false,
|
|
|
|
|
// "optInRequestDate": null,
|
|
|
|
|
// "optInDate": null
|
|
|
|
|
}] : [],
|
|
|
|
|
// {
|
|
|
|
|
// "uuid": "",
|
|
|
|
|
// "address": "jilldoe@test.com",
|
|
|
|
|
// "type": "WORK",
|
|
|
|
|
// "doNotEmailSource": "",
|
|
|
|
|
// "doNotEmail": false,
|
|
|
|
|
// "isPreferred": false,
|
|
|
|
|
// "transactionEmailNotificationOptIn": false,
|
|
|
|
|
// "optInRequestDate": null,
|
|
|
|
|
// "optInDate": null
|
|
|
|
|
// }
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
// // "doNotContact": false,
|
|
|
|
|
// // "optOutDate": "",
|
|
|
|
|
// // "optOutTime": "",
|
|
|
|
|
// // "optOutFlag": false,
|
|
|
|
|
// // "isDeleteDataFlag": false,
|
|
|
|
|
// // "deleteDataDate": "",
|
|
|
|
|
// // "deleteDataTime": "",
|
|
|
|
|
// // "blockMailFlag": true,
|
|
|
|
|
// // "dateAdded": "",
|
|
|
|
|
// // "employer": "employer",
|
|
|
|
|
// "insurance": {
|
|
|
|
|
// "policy": {
|
|
|
|
|
// "effectiveDate": "2022-01-01",
|
|
|
|
|
// "expirationDate": "2023-01-01",
|
|
|
|
|
// "number": "12345",
|
|
|
|
|
// "verifiedBy": "Agent",
|
|
|
|
|
// "verifiedDate": "2023-01-01",
|
|
|
|
|
// "insPolicyCollisionDed": "",
|
|
|
|
|
// "insPolicyComprehensiveDed": "",
|
|
|
|
|
// "insPolicyFireTheftDed": ""
|
|
|
|
|
// },
|
|
|
|
|
// "insuranceAgency": {
|
|
|
|
|
// "agencyName": "InsAgency",
|
|
|
|
|
// "agentName": "agent",
|
|
|
|
|
// "phoneNumber": "9999999999",
|
|
|
|
|
// "postalAddress": {
|
|
|
|
|
// "addressLine1": "999 Main St",
|
|
|
|
|
// "addressLine2": "Suite 999",
|
|
|
|
|
// "city": "Austin",
|
|
|
|
|
// "state": "TX",
|
|
|
|
|
// "postalCode": "78750",
|
|
|
|
|
// "county": "Travis",
|
|
|
|
|
// "country": "USA"
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// "insuranceCompany": {
|
|
|
|
|
// "name": "InsCompany",
|
|
|
|
|
// "phoneNumber": "8888888888",
|
|
|
|
|
// "postalAddress": {
|
|
|
|
|
// "addressLine1": "888 Main St",
|
|
|
|
|
// "addressLine2": "Suite 888",
|
|
|
|
|
// "city": "Austin",
|
|
|
|
|
// "state": "TX",
|
|
|
|
|
// "postalCode": "78750",
|
|
|
|
|
// "county": "Travis",
|
|
|
|
|
// "country": "USA"
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// "specialInstructions": [
|
|
|
|
|
// {
|
|
|
|
|
// "lineNuber": "1",
|
|
|
|
|
// "specialInstruction": "specialInstruction1"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "lineNuber": "2",
|
|
|
|
|
// "specialInstruction": "specialInstruction2"
|
|
|
|
|
// }
|
|
|
|
|
// ],
|
|
|
|
|
// "groupCode": "PT",
|
|
|
|
|
// "priceCode": "5",
|
|
|
|
|
// "roPriceCode": "5",
|
|
|
|
|
// "taxCode": "3145",
|
|
|
|
|
// "dealerLoyaltyIndicator": "PN612345",
|
|
|
|
|
// "delCdeServiceNames": "99",
|
|
|
|
|
// "deleteCode": "9999",
|
|
|
|
|
// "fleetFlag": "1",
|
|
|
|
|
// "dealerFields": [
|
|
|
|
|
// {
|
|
|
|
|
// "lineNumber": null,
|
|
|
|
|
// "dealerField": "Custom dealer field value 1"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "lineNumber": null,
|
|
|
|
|
// "dealerField": "Custom dealer field value 2"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "lineNumber": null,
|
|
|
|
|
// "dealerField": "Custom dealer field value 3"
|
|
|
|
|
// }
|
|
|
|
|
// ]
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CreateFortellisLogEvent(socket, "ERROR", `Error in InsertDmsCustomer - ${error}`, { request: error.request });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// async function InsertDmsCustomer(socket, newCustomerNumber) {
|
|
|
|
|
// try {
|
|
|
|
|
// const soapClientCustomerInsertUpdate = await soap.createClientAsync(CdkWsdl.CustomerInsertUpdate);
|
|
|
|
|
// const soapResponseCustomerInsertUpdate = await soapClientCustomerInsertUpdate.insertAsync(
|
|
|
|
|
@@ -420,82 +588,307 @@ async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
|
|
|
|
// CdkBase.createLogEvent(socket, "ERROR", `Error in InsertDmsCustomer - ${error}`);
|
|
|
|
|
// throw new Error(error);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// async function InsertDmsVehicle(socket) {
|
|
|
|
|
// try {
|
|
|
|
|
// const soapClientVehicleInsertUpdate = await soap.createClientAsync(CdkWsdl.VehicleInsertUpdate);
|
|
|
|
|
async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMSVid, DMSCust }) {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
// const soapResponseVehicleInsertUpdate = await soapClientVehicleInsertUpdate.insertAsync({
|
|
|
|
|
// arg0: CDK_CREDENTIALS,
|
|
|
|
|
// arg1: { id: socket.JobData.bodyshop.cdk_dealerid },
|
|
|
|
|
// arg2: {
|
|
|
|
|
// dealer: {
|
|
|
|
|
// dealerNumber: socket.JobData.bodyshop.cdk_dealerid,
|
|
|
|
|
// ...(socket.txEnvelope.inservicedate && {
|
|
|
|
|
// inServiceDate:
|
|
|
|
|
// socket.txEnvelope.dms_unsold === true
|
|
|
|
|
// ? ""
|
|
|
|
|
// : moment(socket.txEnvelope.inservicedate)
|
|
|
|
|
// //.tz(socket.JobData.bodyshop.timezone)
|
|
|
|
|
// .startOf("day")
|
|
|
|
|
// .toISOString()
|
|
|
|
|
// }),
|
|
|
|
|
// vehicleId: socket.DMSVid.vehiclesVehId
|
|
|
|
|
const result = await MakeFortellisCall({
|
|
|
|
|
...FortellisActions.InsertVehicle,
|
|
|
|
|
requestSearchParams: {},
|
|
|
|
|
headers: {},
|
|
|
|
|
redisHelpers,
|
|
|
|
|
socket,
|
|
|
|
|
jobid: JobData.id,
|
|
|
|
|
body: {
|
|
|
|
|
"dealer": {
|
|
|
|
|
"company": JobData.bodyshop.cdk_configuration.srcco || "77",
|
|
|
|
|
// "dealNumber": "",
|
|
|
|
|
// "dealerAssignedNumber": "82268",
|
|
|
|
|
// "dealerDefined1": "2WDSP",
|
|
|
|
|
// "dealerDefined2": "33732.71",
|
|
|
|
|
// "dealerDefined3": "",
|
|
|
|
|
// "dealerDefined4": "G0901",
|
|
|
|
|
// "dealerDefined5": "",
|
|
|
|
|
// "dealerDefined6": "",
|
|
|
|
|
// "dealerDefined7": "",
|
|
|
|
|
// "dealerDefined8": "",
|
|
|
|
|
// "dealerNumber": "",
|
|
|
|
|
...(txEnvelope.inservicedate && {
|
|
|
|
|
inServiceDate:
|
|
|
|
|
txEnvelope.dms_unsold === true
|
|
|
|
|
? ""
|
|
|
|
|
: moment(txEnvelope.inservicedate)
|
|
|
|
|
//.tz(JobData.bodyshop.timezone)
|
|
|
|
|
.startOf("day")
|
|
|
|
|
.toISOString()
|
|
|
|
|
}),
|
|
|
|
|
//"lastServiceDate": "2011-11-23",
|
|
|
|
|
"vehicleId": DMSVid.vehiclesVehId,
|
|
|
|
|
// "vehicleLocation": "",
|
|
|
|
|
// "vehicleSoldDate": "2021-04-06",
|
|
|
|
|
// "wholesaleVehicleInd": false
|
|
|
|
|
},
|
|
|
|
|
// "manufacturer": {
|
|
|
|
|
// "name": "",
|
|
|
|
|
// "plant": "",
|
|
|
|
|
// "productionNumber": "PZPKM6",
|
|
|
|
|
// "vehicleProductionDate": "2020-04-06"
|
|
|
|
|
// },
|
|
|
|
|
// manufacturer: {},
|
|
|
|
|
// vehicle: {
|
|
|
|
|
// deliveryDate:
|
|
|
|
|
// socket.txEnvelope.dms_unsold === true
|
|
|
|
|
// ? ""
|
|
|
|
|
// : moment()
|
|
|
|
|
// // .tz(socket.JobData.bodyshop.timezone)
|
|
|
|
|
// .format("YYYYMMDD"),
|
|
|
|
|
// licensePlateNo:
|
|
|
|
|
// socket.JobData.plate_no === null
|
|
|
|
|
// ? null
|
|
|
|
|
// : String(socket.JobData.plate_no).replace(/([^\w]|_)/g, "").length === 0
|
|
|
|
|
// ? null
|
|
|
|
|
// : String(socket.JobData.plate_no)
|
|
|
|
|
// .replace(/([^\w]|_)/g, "")
|
|
|
|
|
// .toUpperCase(),
|
|
|
|
|
// make: socket.txEnvelope.dms_make,
|
|
|
|
|
// modelAbrev: socket.txEnvelope.dms_model,
|
|
|
|
|
// modelYear: socket.JobData.v_model_yr,
|
|
|
|
|
// odometerStatus: socket.txEnvelope.kmout,
|
|
|
|
|
// saleClassValue: "MISC",
|
|
|
|
|
// VIN: socket.JobData.v_vin
|
|
|
|
|
// "invoice": {
|
|
|
|
|
// "entryDate": "2012-01-19",
|
|
|
|
|
// "freight": {
|
|
|
|
|
// "freightInCharge": 995.95,
|
|
|
|
|
// "freightOutCharge": 95.95,
|
|
|
|
|
// "freightTaxCharge": 5.95
|
|
|
|
|
// },
|
|
|
|
|
// owners: {
|
|
|
|
|
// id: {
|
|
|
|
|
// assigningPartyId: "CURRENT",
|
|
|
|
|
// value: socket.DMSCust.id.value
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// "vehicleAcquisitionDate": "2012-01-18",
|
|
|
|
|
// "vehicleOrderDate": "2012-01-12",
|
|
|
|
|
// "vehicleOrderNumber": "",
|
|
|
|
|
// "vehicleOrderPriority": "",
|
|
|
|
|
// "vehicleOrderType": "TRE RETAIL - STOCK"
|
|
|
|
|
// },
|
|
|
|
|
// arg3: "VEHICLES"
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
|
|
|
|
|
|
|
|
|
|
// CdkBase.createXmlEvent(socket, rawRequest, `soapClientVehicleInsertUpdate.insertAsync request.`);
|
|
|
|
|
|
|
|
|
|
// CdkBase.createLogEvent(
|
|
|
|
|
// socket,
|
|
|
|
|
// "SILLY",
|
|
|
|
|
// `soapClientVehicleInsertUpdate.insertAsync Result ${JSON.stringify(result, null, 2)}`
|
|
|
|
|
// );
|
|
|
|
|
// CdkBase.createXmlEvent(socket, rawResponse, `soapClientVehicleInsertUpdate.insertAsync response.`);
|
|
|
|
|
// CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
|
|
|
|
// const VehicleFromDMS = result && result.return && result.return.vehicle;
|
|
|
|
|
// return VehicleFromDMS;
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
// CdkBase.createLogEvent(socket, "ERROR", `Error in InsertDmsVehicle - ${error}`);
|
|
|
|
|
// throw new Error(error);
|
|
|
|
|
"vehicle": {
|
|
|
|
|
// "axleCode": "GU6/3.42 REAR AXLE RATIO",
|
|
|
|
|
// "axleCount": 2,
|
|
|
|
|
// "bodyStyle": "PU",
|
|
|
|
|
// "brakeSystem": "",
|
|
|
|
|
// "cabType": "",
|
|
|
|
|
// "certifiedPreownedInd": false,
|
|
|
|
|
// "certifiedPreownedNumber": "",
|
|
|
|
|
// "chassis": "",
|
|
|
|
|
// "color": "",
|
|
|
|
|
// "dealerBodyStyle": "",
|
|
|
|
|
deliveryDate:
|
|
|
|
|
txEnvelope.dms_unsold === true
|
|
|
|
|
? ""
|
|
|
|
|
: moment()
|
|
|
|
|
// .tz(JobData.bodyshop.timezone)
|
|
|
|
|
.format("YYYY-MM-DD"),
|
|
|
|
|
// "deliveryMileage": 4,
|
|
|
|
|
// "doorsQuantity": 4,
|
|
|
|
|
// "engineNumber": "",
|
|
|
|
|
// "engineType": "LMG/VORTEC 5.3L VVT V8 SFI FLEXFUEL",
|
|
|
|
|
// "exteriorColor": "",
|
|
|
|
|
// "fleetVehicleId": "",
|
|
|
|
|
// "frontTireCode": "",
|
|
|
|
|
// "gmRPOCode": "",
|
|
|
|
|
// "ignitionKeyNumber": "",
|
|
|
|
|
// "interiorColor": "EBONY",
|
|
|
|
|
licensePlateNo:
|
|
|
|
|
JobData.plate_no === null
|
|
|
|
|
? null
|
|
|
|
|
: String(JobData.plate_no).replace(/([^\w]|_)/g, "").length === 0
|
|
|
|
|
? null
|
|
|
|
|
: String(JobData.plate_no)
|
|
|
|
|
.replace(/([^\w]|_)/g, "")
|
|
|
|
|
.toUpperCase(),
|
|
|
|
|
make: txEnvelope.dms_make,
|
|
|
|
|
// "model": "CC10753",
|
|
|
|
|
modelAbrev: txEnvelope.dms_model,
|
|
|
|
|
// "modelDescription": "SILVERADO 1500 2WD EXT CAB LT",
|
|
|
|
|
// "modelType": "T",
|
|
|
|
|
modelYear: JobData.v_model_yr,
|
|
|
|
|
// "numberOfEngineCylinders": 4,
|
|
|
|
|
odometerStatus: txEnvelope.kmout,
|
|
|
|
|
// "options": [
|
|
|
|
|
// {
|
|
|
|
|
// "optionCategory": "SS",
|
|
|
|
|
// "optionCode": "A95",
|
|
|
|
|
// "optionCost": 875.6,
|
|
|
|
|
// "optionDescription": "FRONT BUCKET SEATS INCLUDING: PWR SEAT ADJUST DRIVER 6-WAY",
|
|
|
|
|
// "optionPrices": [
|
|
|
|
|
// {
|
|
|
|
|
// "optionPricingType": "RETAIL",
|
|
|
|
|
// "price": 995
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "optionPricingType": "INVOICE",
|
|
|
|
|
// "price": 875.6
|
|
|
|
|
// }
|
|
|
|
|
// ]
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "optionCategory": "E",
|
|
|
|
|
// "optionCode": "LMG",
|
|
|
|
|
// "optionCost": 0,
|
|
|
|
|
// "optionDescription": "VORTEC 5.3L V8 SFI ENGINE W/ACTIVE FUEL MANAGEMENT",
|
|
|
|
|
// "optionPrices": [
|
|
|
|
|
// {
|
|
|
|
|
// "optionPricingType": "RETAIL",
|
|
|
|
|
// "price": 0
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "optionPricingType": "INVOICE",
|
|
|
|
|
// "price": 0
|
|
|
|
|
// }
|
|
|
|
|
// ]
|
|
|
|
|
// }
|
|
|
|
|
// ],
|
|
|
|
|
// "rearTireCode": "",
|
|
|
|
|
// "restraintSystem": "",
|
|
|
|
|
saleClassValue: "MISC",
|
|
|
|
|
// "sourceCodeValue": "",
|
|
|
|
|
// "sourceDescription": "",
|
|
|
|
|
// "standardEquipment": "",
|
|
|
|
|
// "stickerNumber": "",
|
|
|
|
|
// "transmissionType": "A",
|
|
|
|
|
// "transmissionNo": "MYC/ELECTRONIC 6-SPEED AUTOMATIC W/OD",
|
|
|
|
|
// "trimCode": "",
|
|
|
|
|
// "vehicleNote": "",
|
|
|
|
|
// "vehiclePrices": [
|
|
|
|
|
// {
|
|
|
|
|
// "price": 35894,
|
|
|
|
|
// "vehiclePricingType": "SELLINGPRICE"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "price": 33749.87,
|
|
|
|
|
// "vehiclePricingType": "INVOICE"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "price": 36472,
|
|
|
|
|
// "vehiclePricingType": "RETAIL"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "price": 28276.66,
|
|
|
|
|
// "vehiclePricingType": "BASEINVOICE"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "price": 30405,
|
|
|
|
|
// "vehiclePricingType": "BASERETAIL"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "price": 33749.87,
|
|
|
|
|
// "vehiclePricingType": "COMMISSIONPRICE"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "price": 32702.9,
|
|
|
|
|
// "vehiclePricingType": "DRAFTAMOUNT"
|
|
|
|
|
// }
|
|
|
|
|
// ],
|
|
|
|
|
// "vehicleStatus": "G",
|
|
|
|
|
// "vehicleStock": "82268",
|
|
|
|
|
// "vehicleWeight": "6800",
|
|
|
|
|
vin: JobData.v_vin
|
|
|
|
|
// "warrantyExpDate": "2015-01-12",
|
|
|
|
|
// "wheelbase": ""
|
|
|
|
|
},
|
|
|
|
|
"owners": [
|
|
|
|
|
{
|
|
|
|
|
"id": {
|
|
|
|
|
assigningPartyId: "CURRENT",
|
|
|
|
|
value: DMSCust.customerId
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
//"inventoryAccount": "237"
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
return result.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CreateFortellisLogEvent(socket, "ERROR", `Error in InsertDmsVehicle - ${error}`, { request: error.request });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust, selectedCustomerId, txEnvelope }) {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
let ids = [];
|
|
|
|
|
|
|
|
|
|
//if it's a generic customer, don't update the vehicle owners.
|
|
|
|
|
|
|
|
|
|
if (selectedCustomerId === JobData.bodyshop.cdk_configuration.generic_customer_number) {
|
|
|
|
|
ids = DMSVeh && DMSVeh.owners && DMSVeh.owners;
|
|
|
|
|
} else {
|
|
|
|
|
const existingOwnerinVeh =
|
|
|
|
|
DMSVeh &&
|
|
|
|
|
DMSVeh.owners &&
|
|
|
|
|
DMSVeh.owners.find((o) => o.id.value === DMSCust.customerId);
|
|
|
|
|
|
|
|
|
|
if (existingOwnerinVeh) {
|
|
|
|
|
ids = DMSVeh.owners.map((o) => {
|
|
|
|
|
return {
|
|
|
|
|
id: {
|
|
|
|
|
assigningPartyId: o.id.value === DMSCust.customerId ? "CURRENT" : "PREVIOUS",
|
|
|
|
|
value: o.id.value
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
const oldOwner =
|
|
|
|
|
DMSVeh &&
|
|
|
|
|
DMSVeh.owners &&
|
|
|
|
|
DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
|
|
|
|
|
|
|
|
|
ids = [
|
|
|
|
|
{
|
|
|
|
|
id: {
|
|
|
|
|
assigningPartyId: "CURRENT",
|
|
|
|
|
value: DMSCust.customerId
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
...(oldOwner
|
|
|
|
|
? [
|
|
|
|
|
{
|
|
|
|
|
id: {
|
|
|
|
|
assigningPartyId: "PREVIOUS",
|
|
|
|
|
value: oldOwner.id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
: [])
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const result = await MakeFortellisCall({
|
|
|
|
|
...FortellisActions.UpdateVehicle,
|
|
|
|
|
requestSearchParams: {},
|
|
|
|
|
headers: {},
|
|
|
|
|
redisHelpers,
|
|
|
|
|
socket,
|
|
|
|
|
jobid: JobData.id,
|
|
|
|
|
body: {
|
|
|
|
|
...DMSVeh,
|
|
|
|
|
dealer: {
|
|
|
|
|
...DMSVeh.dealer,
|
|
|
|
|
...((txEnvelope.inservicedate || DMSVeh.dealer.inServiceDate) && {
|
|
|
|
|
inServiceDate:
|
|
|
|
|
txEnvelope.dms_unsold === true
|
|
|
|
|
? ""
|
|
|
|
|
: moment(DMSVeh.dealer.inServiceDate || txEnvelope.inservicedate)
|
|
|
|
|
// .tz(JobData.bodyshop.timezone)
|
|
|
|
|
.toISOString()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
vehicle: {
|
|
|
|
|
...DMSVeh.vehicle,
|
|
|
|
|
...(txEnvelope.dms_model_override
|
|
|
|
|
? {
|
|
|
|
|
make: txEnvelope.dms_make,
|
|
|
|
|
modelAbrev: txEnvelope.dms_model
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
deliveryDate:
|
|
|
|
|
txEnvelope.dms_unsold === true
|
|
|
|
|
? ""
|
|
|
|
|
: moment(DMSVeh.vehicle.deliveryDate)
|
|
|
|
|
//.tz(JobData.bodyshop.timezone)
|
|
|
|
|
.toISOString()
|
|
|
|
|
},
|
|
|
|
|
owners: ids
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CreateFortellisLogEvent(socket, "ERROR", `Error in UpdateDmsVehicle - ${error}`, { request: error.request });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// async function UpdateDmsVehicle(socket) {
|
|
|
|
|
// try {
|
|
|
|
|
// const soapClientVehicleInsertUpdate = await soap.createClientAsync(CdkWsdl.VehicleInsertUpdate);
|
|
|
|
|
|
|
|
|
|
@@ -599,7 +992,7 @@ async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
|
|
|
|
// CdkBase.createLogEvent(socket, "ERROR", `Error in UpdateDmsVehicle - ${error}`);
|
|
|
|
|
// throw new Error(error);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// async function InsertServiceVehicleHistory(socket) {
|
|
|
|
|
// try {
|
|
|
|
|
@@ -984,4 +1377,4 @@ async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
exports.getTransactionType = getTransactionType;
|
|
|
|
|
exports.default = FortellisJobExport;
|
|
|
|
|
exports.FortellisJobExport = FortellisJobExport;
|
|
|
|
|
|