Merged in feature/IO-3722-disable-contact-fortellis (pull request #3284)
IO-3722 Remove customer lookup by Vehicle Owner.
This commit is contained in:
@@ -95,7 +95,8 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) {
|
||||
defaultFortellisTTL
|
||||
);
|
||||
|
||||
let DMSVehCustomer;
|
||||
let DMSVehCustomerFromVehicle;
|
||||
//let DMSVehCustomer;
|
||||
if (!DMSVid.newId) {
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{2.1} Querying the Vehicle using the DMSVid: ${DMSVid.vehiclesVehId}`);
|
||||
const DMSVeh = await QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid });
|
||||
@@ -106,33 +107,34 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) {
|
||||
DMSVeh,
|
||||
defaultFortellisTTL
|
||||
);
|
||||
DMSVehCustomerFromVehicle = DMSVeh?.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
||||
|
||||
//Add in contact bypass for Fortellis.
|
||||
if (!JobData.bodyshop.cdk_configuration.disablecontact) {
|
||||
const DMSVehCustomerFromVehicle =
|
||||
DMSVeh?.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
||||
// //Add in contact bypass for Fortellis.
|
||||
// if (!JobData.bodyshop.cdk_configuration.disablecontact) {
|
||||
// const DMSVehCustomerFromVehicle =
|
||||
// DMSVeh?.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
||||
|
||||
if (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),
|
||||
FortellisCacheEnums.DMSVehCustomer,
|
||||
DMSVehCustomer,
|
||||
defaultFortellisTTL
|
||||
);
|
||||
}
|
||||
}
|
||||
// if (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),
|
||||
// FortellisCacheEnums.DMSVehCustomer,
|
||||
// DMSVehCustomer,
|
||||
// defaultFortellisTTL
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{2.3} Querying the Customer using the name.`);
|
||||
if (JobData.bodyshop.cdk_configuration.disablecontact) {
|
||||
@@ -148,10 +150,22 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) {
|
||||
defaultFortellisTTL
|
||||
);
|
||||
|
||||
socket.emit("fortellis-select-customer", [
|
||||
...(DMSVehCustomer ? [{ ...DMSVehCustomer, vinOwner: true }] : []),
|
||||
...DMSCustList
|
||||
]);
|
||||
socket.emit("fortellis-select-customer",
|
||||
//Removed to save one one API call while disputing with fortellis.
|
||||
// [
|
||||
// // ...(DMSVehCustomer ? [{ ...DMSVehCustomer, vinOwner: true }] : []),
|
||||
// ...DMSCustList
|
||||
// ]
|
||||
DMSVehCustomerFromVehicle ?
|
||||
DMSCustList.map(c => {
|
||||
//if customer id is the same as the current assigned owner on the vehicle id, set it as vinowner true. )
|
||||
if (DMSVehCustomerFromVehicle?.id?.value === c.customerId) {
|
||||
return { ...c, vinOwner: true }
|
||||
} else {
|
||||
return c
|
||||
}
|
||||
}) : DMSCustList
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
CreateFortellisLogEvent(socket, "ERROR", `Error in FortellisJobExport - ${error} `, {
|
||||
|
||||
Reference in New Issue
Block a user