@@ -95,7 +95,8 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) {
|
|||||||
defaultFortellisTTL
|
defaultFortellisTTL
|
||||||
);
|
);
|
||||||
|
|
||||||
let DMSVehCustomer;
|
let DMSVehCustomerFromVehicle;
|
||||||
|
//let DMSVehCustomer;
|
||||||
if (!DMSVid.newId) {
|
if (!DMSVid.newId) {
|
||||||
CreateFortellisLogEvent(socket, "DEBUG", `{2.1} Querying the Vehicle using the DMSVid: ${DMSVid.vehiclesVehId}`);
|
CreateFortellisLogEvent(socket, "DEBUG", `{2.1} Querying the Vehicle using the DMSVid: ${DMSVid.vehiclesVehId}`);
|
||||||
const DMSVeh = await QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid });
|
const DMSVeh = await QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid });
|
||||||
@@ -106,38 +107,39 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) {
|
|||||||
DMSVeh,
|
DMSVeh,
|
||||||
defaultFortellisTTL
|
defaultFortellisTTL
|
||||||
);
|
);
|
||||||
|
DMSVehCustomerFromVehicle = DMSVeh?.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
||||||
|
|
||||||
//Add in contact bypass for Fortellis.
|
// //Add in contact bypass for Fortellis.
|
||||||
if (!JobData.bodyshop.cdk_configuration.disablecontact) {
|
// if (!JobData.bodyshop.cdk_configuration.disablecontact) {
|
||||||
const DMSVehCustomerFromVehicle =
|
// const DMSVehCustomerFromVehicle =
|
||||||
DMSVeh?.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
// DMSVeh?.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
||||||
|
|
||||||
if (DMSVehCustomerFromVehicle?.id && DMSVehCustomerFromVehicle.id.value) {
|
// if (DMSVehCustomerFromVehicle?.id && DMSVehCustomerFromVehicle.id.value) {
|
||||||
CreateFortellisLogEvent(
|
// CreateFortellisLogEvent(
|
||||||
socket,
|
// socket,
|
||||||
"DEBUG",
|
// "DEBUG",
|
||||||
`{2.2} Querying the Customer using the ID from DMSVeh: ${DMSVehCustomerFromVehicle.id.value}`
|
// `{2.2} Querying the Customer using the ID from DMSVeh: ${DMSVehCustomerFromVehicle.id.value}`
|
||||||
);
|
// );
|
||||||
DMSVehCustomer = await QueryDmsCustomerById({
|
// DMSVehCustomer = await QueryDmsCustomerById({
|
||||||
socket,
|
// socket,
|
||||||
redisHelpers,
|
// redisHelpers,
|
||||||
JobData,
|
// JobData,
|
||||||
CustomerId: DMSVehCustomerFromVehicle.id.value
|
// CustomerId: DMSVehCustomerFromVehicle.id.value
|
||||||
});
|
// });
|
||||||
await setSessionTransactionData(
|
// await setSessionTransactionData(
|
||||||
socket.id,
|
// socket.id,
|
||||||
getTransactionType(jobid),
|
// getTransactionType(jobid),
|
||||||
FortellisCacheEnums.DMSVehCustomer,
|
// FortellisCacheEnums.DMSVehCustomer,
|
||||||
DMSVehCustomer,
|
// DMSVehCustomer,
|
||||||
defaultFortellisTTL
|
// defaultFortellisTTL
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
CreateFortellisLogEvent(socket, "DEBUG", `{2.3} Querying the Customer using the name.`);
|
CreateFortellisLogEvent(socket, "DEBUG", `{2.3} Querying the Customer using the name.`);
|
||||||
if (!JobData.bodyshop.cdk_configuration.disablecontact) {
|
if (JobData.bodyshop.cdk_configuration.disablecontact) {
|
||||||
//Just go straight to posting.
|
//Just go straight to posting.
|
||||||
FortellisSelectedCustomer({ socket, redisHelpers, selectedCustomerId: bypassCustomerId, jobid });
|
await FortellisSelectedCustomer({ socket, redisHelpers, selectedCustomerId: bypassCustomerId, jobid });
|
||||||
} else {
|
} else {
|
||||||
const DMSCustList = await QueryDmsCustomerByName({ socket, redisHelpers, JobData });
|
const DMSCustList = await QueryDmsCustomerByName({ socket, redisHelpers, JobData });
|
||||||
await setSessionTransactionData(
|
await setSessionTransactionData(
|
||||||
@@ -148,10 +150,22 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) {
|
|||||||
defaultFortellisTTL
|
defaultFortellisTTL
|
||||||
);
|
);
|
||||||
|
|
||||||
socket.emit("fortellis-select-customer", [
|
socket.emit("fortellis-select-customer",
|
||||||
...(DMSVehCustomer ? [{ ...DMSVehCustomer, vinOwner: true }] : []),
|
//Removed to save one one API call while disputing with fortellis.
|
||||||
...DMSCustList
|
// [
|
||||||
]);
|
// // ...(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) {
|
} catch (error) {
|
||||||
CreateFortellisLogEvent(socket, "ERROR", `Error in FortellisJobExport - ${error} `, {
|
CreateFortellisLogEvent(socket, "ERROR", `Error in FortellisJobExport - ${error} `, {
|
||||||
@@ -226,8 +240,8 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Bypass only the customer creation. We still need to create the vehicle and update it to post the service history later on.
|
//Bypass only the customer creation. We still need to create the vehicle and update it to post the service history later on.
|
||||||
|
let DMSCust;
|
||||||
if (!JobData.bodyshop.cdk_configuration.disablecontact) {
|
if (!JobData.bodyshop.cdk_configuration.disablecontact) {
|
||||||
let DMSCust;
|
|
||||||
if (selectedCustomerId) {
|
if (selectedCustomerId) {
|
||||||
CreateFortellisLogEvent(socket, "DEBUG", `{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`);
|
CreateFortellisLogEvent(socket, "DEBUG", `{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`);
|
||||||
|
|
||||||
@@ -257,6 +271,8 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
|||||||
defaultFortellisTTL
|
defaultFortellisTTL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
DMSCust = { customerId: bypassCustomerId };
|
||||||
}
|
}
|
||||||
|
|
||||||
let DMSVeh;
|
let DMSVeh;
|
||||||
@@ -916,7 +932,7 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS
|
|||||||
// "wheelbase": ""
|
// "wheelbase": ""
|
||||||
},
|
},
|
||||||
// Owners is not required. Exclude it if we are bypassing.
|
// Owners is not required. Exclude it if we are bypassing.
|
||||||
...(selectedCustomerId !== bypassCustomerId && {
|
...(DMSCust?.customerId !== bypassCustomerId && {
|
||||||
owners: [
|
owners: [
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
|
|||||||
Reference in New Issue
Block a user