From 0f800c5a4caa8d6d25c7613fe792a935f4f60bb4 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 27 May 2026 12:40:41 -0700 Subject: [PATCH 1/4] IO-3722 Add additional await. --- server/fortellis/fortellis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/fortellis/fortellis.js b/server/fortellis/fortellis.js index 6db9ce498..d639cf516 100644 --- a/server/fortellis/fortellis.js +++ b/server/fortellis/fortellis.js @@ -137,7 +137,7 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) { CreateFortellisLogEvent(socket, "DEBUG", `{2.3} Querying the Customer using the name.`); if (!JobData.bodyshop.cdk_configuration.disablecontact) { //Just go straight to posting. - FortellisSelectedCustomer({ socket, redisHelpers, selectedCustomerId: bypassCustomerId, jobid }); + await FortellisSelectedCustomer({ socket, redisHelpers, selectedCustomerId: bypassCustomerId, jobid }); } else { const DMSCustList = await QueryDmsCustomerByName({ socket, redisHelpers, JobData }); await setSessionTransactionData( From 322ebd3bc711078cc120ef39d0b912a4572d44c0 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 27 May 2026 12:46:09 -0700 Subject: [PATCH 2/4] Resolve inversed if statement. --- server/fortellis/fortellis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/fortellis/fortellis.js b/server/fortellis/fortellis.js index d639cf516..c69531518 100644 --- a/server/fortellis/fortellis.js +++ b/server/fortellis/fortellis.js @@ -135,7 +135,7 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) { } } 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. await FortellisSelectedCustomer({ socket, redisHelpers, selectedCustomerId: bypassCustomerId, jobid }); } else { From 468ed23f73fa0c7b7ba7cf5271cc109549e52fa6 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 27 May 2026 14:18:31 -0700 Subject: [PATCH 3/4] IO-3722 Fix undefined customer ref. --- server/fortellis/fortellis.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/fortellis/fortellis.js b/server/fortellis/fortellis.js index c69531518..75e419824 100644 --- a/server/fortellis/fortellis.js +++ b/server/fortellis/fortellis.js @@ -226,8 +226,8 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome return; } //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) { - let DMSCust; if (selectedCustomerId) { CreateFortellisLogEvent(socket, "DEBUG", `{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`); @@ -257,6 +257,8 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome defaultFortellisTTL ); } + }else{ + DMSCust = { customerId: bypassCustomerId }; } let DMSVeh; @@ -916,7 +918,7 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS // "wheelbase": "" }, // Owners is not required. Exclude it if we are bypassing. - ...(selectedCustomerId !== bypassCustomerId && { + ...(DMSCust?.customerId !== bypassCustomerId && { owners: [ { id: { From aa3b303fe9cfc4fd09794ebfab7ba844242060f9 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 28 May 2026 09:53:40 -0700 Subject: [PATCH 4/4] IO-3722 Remove customer lookup by Vehicle Owner. --- server/fortellis/fortellis.js | 74 +++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/server/fortellis/fortellis.js b/server/fortellis/fortellis.js index 75e419824..709461eaf 100644 --- a/server/fortellis/fortellis.js +++ b/server/fortellis/fortellis.js @@ -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} `, {