Compare commits

...

18 Commits

Author SHA1 Message Date
Allan Carr
f0c0b5dc45 IO-3576 Fortellis Refetch Make Model
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-02-23 15:28:07 -08:00
Allan Carr
a6a621e73f Merged in hotfix/2026-02-19 (pull request #3026)
IO-3570 Strip - from Owner Name in regex
2026-02-19 21:21:52 +00:00
Allan Carr
ee0f2c3293 Merged in feature/IO-3570-Fortellis-Multiple-Veh-Records (pull request #3024)
IO-3570 Strip - from Owner Name in regex
2026-02-19 21:16:13 +00:00
Allan Carr
83a30f1fcd IO-3570 Strip - from Owner Name in regex
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-02-19 13:17:15 -08:00
Allan Carr
ba3e831503 Merged in hotfix/2026-02-19 (pull request #3023)
IO-3570 Fortellis Owner Phone Search
2026-02-19 20:37:09 +00:00
Allan Carr
6b87b15e97 IO-3570 Fortellis Owner Phone Search
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-02-19 12:36:43 -08:00
Allan Carr
425cdac26e Merged in feature/IO-3570-Fortellis-Multiple-Veh-Records (pull request #3022)
IO-3570 Fortellis Owner Phone Search
2026-02-19 20:36:15 +00:00
Allan Carr
ade8461851 Merged in hotfix/2026-02-19 (pull request #3020)
Hotfix/2026 02 19
2026-02-19 20:07:21 +00:00
Allan Carr
f6c5f85a87 IO-3570 Transwip fix
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-02-19 12:04:44 -08:00
Allan Carr
532fa3fb18 Merged in feature/IO-3570-Fortellis-Multiple-Veh-Records (pull request #3018)
Feature/IO-3570 Fortellis Multiple Veh Records
2026-02-19 20:02:45 +00:00
Allan Carr
c7875c7be3 IO-3570 Fix Regex to include numbers
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-02-19 11:59:36 -08:00
Allan Carr
78b9b8d260 Merged in hotfix/2026-02-19 (pull request #3016)
Hotfix/2026 02 19
2026-02-19 18:52:41 +00:00
Allan Carr
38fc3285b4 IO-3570 Check if array and then filter
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-02-19 10:52:37 -08:00
Allan Carr
9d14ad3167 Merged in feature/IO-3570-Fortellis-Multiple-Veh-Records (pull request #3015)
Feature/IO-3570 Fortellis Multiple Veh Records
2026-02-19 18:50:28 +00:00
Allan Carr
2e53fe8606 IO-3570 Fortellis Multi Veh
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-02-19 10:46:50 -08:00
Allan Carr
6317606ce1 Merged in hotfix/2026-02-19 (pull request #3014)
IO-3570 Filter Vehicle Results from VIN Query to records that only have a vehicleVehID
2026-02-19 18:02:40 +00:00
Allan Carr
e599c2b2d6 Merged in feature/IO-3570-Fortellis-Multiple-Veh-Records (pull request #3013)
IO-3570 Filter Vehicle Results from VIN Query to records that only have a vehicleVehID
2026-02-19 17:58:30 +00:00
Allan Carr
2b35090359 IO-3570 Filter Vehicle Results from VIN Query to records that only have a vehicleVehID
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-02-19 09:55:37 -08:00
3 changed files with 155 additions and 136 deletions

View File

@@ -264,29 +264,30 @@ const CreateRepairOrderTag = (job, errorCallback) => {
}${job.est_ct_fn ? job.est_ct_fn : ""}` }${job.est_ct_fn ? job.est_ct_fn : ""}`
}, },
Dates: { Dates: {
DateEstimated: (job.date_estimated && moment(job.date_estimated).format(DateFormat)) || "", DateEstimated: job.date_estimated ? moment(job.date_estimated).format(DateFormat) : "",
DateOpened: (job.date_opened && moment(job.date_opened).format(DateFormat)) || "", DateOpened: job.date_open ? moment(job.date_open).tz(job.bodyshop.timezone).format(DateFormat) : "",
DateScheduled: DateScheduled: job.scheduled_in ? moment(job.scheduled_in).tz(job.bodyshop.timezone).format(DateFormat) : "",
(job.scheduled_in && moment(job.scheduled_in).tz(job.bodyshop.timezone).format(DateFormat)) || "", DateArrived: job.actual_in ? moment(job.actual_in).tz(job.bodyshop.timezone).format(DateFormat) : "",
DateArrived: (job.actual_in && moment(job.actual_in).tz(job.bodyshop.timezone).format(DateFormat)) || "",
DateStart: job.date_repairstarted DateStart: job.date_repairstarted
? (job.date_repairstarted && moment(job.date_repairstarted).tz(job.bodyshop.timezone).format(DateFormat)) || ? moment(job.date_repairstarted).tz(job.bodyshop.timezone).format(DateFormat)
"" : job.actual_in
: (job.actual_in && moment(job.actual_in).tz(job.bodyshop.timezone).format(DateFormat)) || "", ? moment(job.actual_in).tz(job.bodyshop.timezone).format(DateFormat)
DateScheduledCompletion: : "",
(job.scheduled_completion && moment(job.scheduled_completion).tz(job.bodyshop.timezone).format(DateFormat)) || DateScheduledCompletion: job.scheduled_completion
"", ? moment(job.scheduled_completion).tz(job.bodyshop.timezone).format(DateFormat)
DateCompleted: : "",
(job.actual_completion && moment(job.actual_completion).tz(job.bodyshop.timezone).format(DateFormat)) || "", DateCompleted: job.actual_completion
DateScheduledDelivery: ? moment(job.actual_completion).tz(job.bodyshop.timezone).format(DateFormat)
(job.scheduled_delivery && moment(job.scheduled_delivery).tz(job.bodyshop.timezone).format(DateFormat)) || "", : "",
DateDelivered: DateScheduledDelivery: job.scheduled_delivery
(job.actual_delivery && moment(job.actual_delivery).tz(job.bodyshop.timezone).format(DateFormat)) || "", ? moment(job.scheduled_delivery).tz(job.bodyshop.timezone).format(DateFormat)
DateInvoiced: : "",
(job.date_invoiced && moment(job.date_invoiced).tz(job.bodyshop.timezone).format(DateFormat)) || "", DateDelivered: job.actual_delivery
DateExported: ? moment(job.actual_delivery).tz(job.bodyshop.timezone).format(DateFormat)
(job.date_exported && moment(job.date_exported).tz(job.bodyshop.timezone).format(DateFormat)) || "", : "",
DateVoid: (job.date_void && moment(job.date_void).tz(job.bodyshop.timezone).format(DateFormat)) || "" DateInvoiced: job.date_invoiced ? moment(job.date_invoiced).tz(job.bodyshop.timezone).format(DateFormat) : "",
DateExported: job.date_exported ? moment(job.date_exported).tz(job.bodyshop.timezone).format(DateFormat) : "",
DateVoid: job.date_void ? moment(job.date_void).tz(job.bodyshop.timezone).format(DateFormat) : ""
}, },
JobLineDetails: (function () { JobLineDetails: (function () {
const joblineSource = Array.isArray(job.joblines) ? job.joblines : job.joblines ? [job.joblines] : []; const joblineSource = Array.isArray(job.joblines) ? job.joblines : job.joblines ? [job.joblines] : [];

View File

@@ -235,18 +235,6 @@ async function MakeFortellisCall({
// jobid: socket?.recordid // jobid: socket?.recordid
// }); // });
if (result.data.checkStatusAfterSeconds) {
return DelayedCallback({
delayMeta: result.data,
access_token,
SubscriptionID: SubscriptionMeta.subscriptionId,
ReqId,
departmentIds: DepartmentId
});
}
logger.log( logger.log(
"fortellis-log-event-json", "fortellis-log-event-json",
"DEBUG", "DEBUG",
@@ -261,6 +249,18 @@ async function MakeFortellisCall({
}, },
); );
if (result.data.checkStatusAfterSeconds) {
return DelayedCallback({
delayMeta: result.data,
access_token,
SubscriptionID: SubscriptionMeta.subscriptionId,
ReqId,
departmentIds: DepartmentId,
jobid,
socket
});
}
return result.data; return result.data;
} catch (error) { } catch (error) {
const errorDetails = { const errorDetails = {
@@ -310,7 +310,7 @@ async function MakeFortellisCall({
//Some Fortellis calls return a batch result that isn't ready immediately. //Some Fortellis calls return a batch result that isn't ready immediately.
//This function will check the status of the call and wait until it is ready. //This function will check the status of the call and wait until it is ready.
//It will try 5 times before giving up. //It will try 5 times before giving up.
async function DelayedCallback({ delayMeta, access_token, SubscriptionID, ReqId, departmentIds }) { async function DelayedCallback({ delayMeta, access_token, SubscriptionID, ReqId, departmentIds, jobid, socket }) {
for (let index = 0; index < 5; index++) { for (let index = 0; index < 5; index++) {
await sleep(delayMeta.checkStatusAfterSeconds * 1000); await sleep(delayMeta.checkStatusAfterSeconds * 1000);
//Check to see if the call is ready. //Check to see if the call is ready.
@@ -334,6 +334,19 @@ async function DelayedCallback({ delayMeta, access_token, SubscriptionID, ReqId,
//"Department-Id": departmentIds[0].id //"Department-Id": departmentIds[0].id
} }
}); });
logger.log(
"fortellis-log-event-json-DelayedCallback",
"DEBUG",
socket?.user?.email,
jobid,
{
requestcurl: batchResult.config.curlCommand,
reqid: batchResult.config.headers["Request-Id"] || null,
subscriptionId: batchResult.config.headers["Subscription-Id"] || null,
resultdata: batchResult.data,
resultStatus: batchResult.status
},
);
// await writeFortellisLogToFile({ // await writeFortellisLogToFile({
// timestamp: new Date().toISOString(), // timestamp: new Date().toISOString(),
// reqId: ReqId, // reqId: ReqId,

View File

@@ -198,7 +198,7 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
); );
const existingCustomerInDMSCustList = DMSCustList.find((c) => c.customerId === selectedCustomerId); const existingCustomerInDMSCustList = DMSCustList.find((c) => c.customerId === selectedCustomerId);
DMSCust = existingCustomerInDMSCustList || { DMSCust = existingCustomerInDMSCustList || {
customerId: selectedCustomerId //This is the fall back in case it is the generic customer. customerId: selectedCustomerId //This is the fall back in case it is the generic customer.
}; };
await setSessionTransactionData( await setSessionTransactionData(
socket.id, socket.id,
@@ -207,8 +207,6 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
DMSCust, DMSCust,
defaultFortellisTTL defaultFortellisTTL
); );
} else { } else {
CreateFortellisLogEvent(socket, "DEBUG", `{3.2} Creating new customer.`); CreateFortellisLogEvent(socket, "DEBUG", `{3.2} Creating new customer.`);
const DMSCustomerInsertResponse = await InsertDmsCustomer({ socket, redisHelpers, JobData }); const DMSCustomerInsertResponse = await InsertDmsCustomer({ socket, redisHelpers, JobData });
@@ -227,14 +225,10 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
CreateFortellisLogEvent(socket, "DEBUG", `{4.1} Inserting new vehicle with ID: ID ${DMSVid.vehiclesVehId}`); CreateFortellisLogEvent(socket, "DEBUG", `{4.1} Inserting new vehicle with ID: ID ${DMSVid.vehiclesVehId}`);
DMSVeh = await InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMSVid, DMSCust }); DMSVeh = await InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMSVid, DMSCust });
} else { } else {
DMSVeh = await getSessionTransactionData( DMSVeh = await getSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSVeh);
socket.id,
getTransactionType(jobid),
FortellisCacheEnums.DMSVeh
)
CreateFortellisLogEvent(socket, "DEBUG", `{4.3} Updating Existing Vehicle to associate to owner.`); CreateFortellisLogEvent(socket, "DEBUG", `{4.3} Updating Existing Vehicle to associate to owner.`);
//Check to see if the vehicle needs to be updated - i.e. the owner is not the selected customer. //Check to see if the vehicle needs to be updated - i.e. the owner is not the selected customer.
if (!DMSVeh?.owners.find((o) => o.id.value === DMSCust.customerId && o.id.assigningPartyId === "CURRENT")) { if (!DMSVeh?.owners.find((o) => o.id.value === DMSCust.customerId && o.id.assigningPartyId === "CURRENT")) {
DMSVeh = await UpdateDmsVehicle({ DMSVeh = await UpdateDmsVehicle({
socket, socket,
@@ -271,7 +265,11 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
if (DMSTransHeader.rtnCode === "0") { if (DMSTransHeader.rtnCode === "0") {
try { try {
CreateFortellisLogEvent(socket, "DEBUG", `{6} Attempting to post Transaction with ID ${DMSTransHeader.transID}`); CreateFortellisLogEvent(
socket,
"DEBUG",
`{6} Attempting to post Transaction with ID ${DMSTransHeader.transID}`
);
const DmsBatchTxnPost = await PostDmsBatchWip({ socket, redisHelpers, JobData }); // 2 in 1 call that includes a post and the transactions. const DmsBatchTxnPost = await PostDmsBatchWip({ socket, redisHelpers, JobData }); // 2 in 1 call that includes a post and the transactions.
await setSessionTransactionData( await setSessionTransactionData(
@@ -282,16 +280,14 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
defaultFortellisTTL defaultFortellisTTL
); );
if (DmsBatchTxnPost.rtnCode === "0") { if (DmsBatchTxnPost.rtnCode === "0") {
//TODO: Validate this is a string and not # //TODO: Validate this is a string and not #
//something //something
CreateFortellisLogEvent(socket, "DEBUG", `{6} Successfully posted transaction to DMS.`); CreateFortellisLogEvent(socket, "DEBUG", `{6} Successfully posted transaction to DMS.`);
await MarkJobExported({ socket, jobid: JobData.id, JobData }); await MarkJobExported({ socket, jobid: JobData.id, JobData, redisHelpers });
try { try {
CreateFortellisLogEvent(socket, "DEBUG", `{7} Updating Service Vehicle History.`); CreateFortellisLogEvent(socket, "DEBUG", `{7} Updating Service Vehicle History.`);
const DMSVehHistory = await InsertServiceVehicleHistory({ socket, redisHelpers, JobData }); const DMSVehHistory = await InsertServiceVehicleHistory({ socket, redisHelpers, JobData });
await setSessionTransactionData( await setSessionTransactionData(
@@ -302,24 +298,19 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
defaultFortellisTTL defaultFortellisTTL
); );
} catch (error) { } catch (error) {
CreateFortellisLogEvent(socket, "ERROR", `{7.1} Error posting vehicle service history. ${error.message}`); CreateFortellisLogEvent(socket, "ERROR", `{7.1} Error posting vehicle service history. ${error.message}`);
} }
socket.emit("export-success", JobData.id); socket.emit("export-success", JobData.id);
} else { } else {
//There was something wrong. Throw an error to trigger clean up. //There was something wrong. Throw an error to trigger clean up.
//throw new Error("Error posting DMS Batch Transaction"); //throw new Error("Error posting DMS Batch Transaction");
} }
} catch (error) { } catch (error) {
//Clean up the transaction and insert a faild error code //Clean up the transaction and insert a faild error code
// //Get the error code // //Get the error code
CreateFortellisLogEvent(socket, "DEBUG", `{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`); CreateFortellisLogEvent(socket, "DEBUG", `{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`);
const DmsError = await QueryDmsErrWip({ socket, redisHelpers, JobData }); const DmsError = await QueryDmsErrWip({ socket, redisHelpers, JobData });
// //Delete the transaction // //Delete the transaction
CreateFortellisLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${DMSTransHeader.transID}`); CreateFortellisLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${DMSTransHeader.transID}`);
@@ -345,7 +336,11 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
stack: error.stack, stack: error.stack,
data: error.errorData data: error.errorData
}); });
await InsertFailedExportLog({ socket, JobData, error: error.errorData?.issues || [JSON.stringify(error.errorData)] }); await InsertFailedExportLog({
socket,
JobData,
error: error.errorData?.issues || [JSON.stringify(error.errorData)]
});
} finally { } finally {
//Ensure we always insert logEvents //Ensure we always insert logEvents
//GQL to insert logevents. //GQL to insert logevents.
@@ -374,7 +369,7 @@ async function CalculateDmsVid({ socket, JobData, redisHelpers }) {
jobid: JobData.id, jobid: JobData.id,
body: {} body: {}
}); });
return result; return Array.isArray(result) ? result.filter((v) => v.vehiclesVehId !== null && v.vehiclesVehId !== "") : [];
} catch (error) { } catch (error) {
handleFortellisApiError(socket, error, "CalculateDmsVid", { handleFortellisApiError(socket, error, "CalculateDmsVid", {
vin: JobData.v_vin, vin: JobData.v_vin,
@@ -429,12 +424,12 @@ async function QueryDmsCustomerById({ socket, redisHelpers, JobData, CustomerId
async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) { async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
const ownerName = const ownerName =
JobData.ownr_co_nm && JobData.ownr_co_nm.trim() !== "" JobData.ownr_co_nm && JobData.ownr_co_nm.trim() !== ""
//? [["firstName", JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase()]] // Commented out until we receive direction. ? //? [["firstName", JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase()]] // Commented out until we receive direction.
? [["phone", JobData.ownr_ph1?.replace(replaceSpecialRegex, "")]] [["phone", JobData.ownr_ph1?.replace(/[^0-9]/g, "")]]
: [ : [
["firstName", JobData.ownr_fn?.replace(/[^a-zA-Z-]/g, "").toUpperCase()], ["firstName", JobData.ownr_fn?.replace(/[^a-zA-Z0-9]/g, "").toUpperCase()],
["lastName", JobData.ownr_ln?.replace(/[^a-zA-Z-]/g, "").toUpperCase()] ["lastName", JobData.ownr_ln?.replace(/[^a-zA-Z0-9]/g, "").toUpperCase()]
]; ];
try { try {
const result = await MakeFortellisCall({ const result = await MakeFortellisCall({
...FortellisActions.QueryCustomerByName, ...FortellisActions.QueryCustomerByName,
@@ -457,7 +452,7 @@ async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
async function InsertDmsCustomer({ socket, redisHelpers, JobData }) { async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
try { try {
const isBusiness = (JobData.ownr_co_nm && JobData.ownr_co_nm.replace(replaceSpecialRegex, "").trim() !== "") const isBusiness = JobData.ownr_co_nm && JobData.ownr_co_nm.replace(replaceSpecialRegex, "").trim() !== "";
const result = await MakeFortellisCall({ const result = await MakeFortellisCall({
...FortellisActions.CreateCustomer, ...FortellisActions.CreateCustomer,
headers: {}, headers: {},
@@ -466,21 +461,23 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
jobid: JobData.id, jobid: JobData.id,
body: { body: {
customerType: isBusiness ? "BUSINESS" : "INDIVIDUAL", customerType: isBusiness ? "BUSINESS" : "INDIVIDUAL",
...isBusiness ? { ...(isBusiness
companyName: JobData.ownr_co_nm && JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase(), ? {
secondaryCustomerName: { companyName: JobData.ownr_co_nm && JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase(),
//lastName: JobData.ownr_co_nm && JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase() secondaryCustomerName: {
} //lastName: JobData.ownr_co_nm && JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase()
} : { }
customerName: { }
//"suffix": "Mr.", : {
firstName: JobData.ownr_fn && JobData.ownr_fn.replace(/[^a-zA-Z-]/g, "").toUpperCase(), customerName: {
//"middleName": "", //"suffix": "Mr.",
lastName: JobData.ownr_ln && JobData.ownr_ln.replace(/[^a-zA-Z-]/g, "").toUpperCase() firstName: JobData.ownr_fn && JobData.ownr_fn.replace(/[^a-zA-Z0-9]/g, "").toUpperCase(),
//"title": "", //"middleName": "",
//"nickName": "" lastName: JobData.ownr_ln && JobData.ownr_ln.replace(/[^a-zA-Z0-9]/g, "").toUpperCase()
} //"title": "",
}, //"nickName": ""
}
}),
postalAddress: { postalAddress: {
addressLine1: JobData.ownr_addr1?.replace(replaceSpecialRegex, "").trim().toUpperCase(), addressLine1: JobData.ownr_addr1?.replace(replaceSpecialRegex, "").trim().toUpperCase(),
addressLine2: JobData.ownr_addr2?.replace(replaceSpecialRegex, "").trim().toUpperCase(), addressLine2: JobData.ownr_addr2?.replace(replaceSpecialRegex, "").trim().toUpperCase(),
@@ -490,7 +487,7 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
rome: JobData.ownr_zip rome: JobData.ownr_zip
}), }),
state: JobData.ownr_st?.replace(replaceSpecialRegex, "").trim().toUpperCase(), state: JobData.ownr_st?.replace(replaceSpecialRegex, "").trim().toUpperCase(),
country: JobData.ownr_ctry?.replace(replaceSpecialRegex, "").trim().toUpperCase(), country: JobData.ownr_ctry?.replace(replaceSpecialRegex, "").trim().toUpperCase()
//"territory": "" //"territory": ""
}, },
// "birthDate": { // "birthDate": {
@@ -504,7 +501,7 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
phones: [ phones: [
{ {
//"uuid": "", //"uuid": "",
number: JobData.ownr_ph1?.replace(replaceSpecialRegex, ""), number: JobData.ownr_ph1?.replace(/[^0-9]/g, ""),
type: "HOME" type: "HOME"
// "doNotCallIndicator": true, // "doNotCallIndicator": true,
// "doNotCallIndicatorDate": `null, // "doNotCallIndicatorDate": `null,
@@ -540,18 +537,18 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
emailAddresses: [ emailAddresses: [
...(!_.isEmpty(JobData.ownr_ea) ...(!_.isEmpty(JobData.ownr_ea)
? [ ? [
{ {
//"uuid": "", //"uuid": "",
address: JobData.ownr_ea.toUpperCase(), address: JobData.ownr_ea.toUpperCase(),
type: "PERSONAL" type: "PERSONAL"
// "doNotEmailSource": "", // "doNotEmailSource": "",
// "doNotEmail": false, // "doNotEmail": false,
// "isPreferred": true, // "isPreferred": true,
// "transactionEmailNotificationOptIn": false, // "transactionEmailNotificationOptIn": false,
// "optInRequestDate": null, // "optInRequestDate": null,
// "optInDate": null // "optInDate": null
} }
] ]
: []) : [])
// { // {
// "uuid": "", // "uuid": "",
@@ -691,9 +688,9 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS
txEnvelope.dms_unsold === true txEnvelope.dms_unsold === true
? "" ? ""
: moment(txEnvelope.inservicedate) : moment(txEnvelope.inservicedate)
//.tz(JobData.bodyshop.timezone) //.tz(JobData.bodyshop.timezone)
.startOf("day") .startOf("day")
.toISOString() .toISOString()
}), }),
//"lastServiceDate": "2011-11-23", //"lastServiceDate": "2011-11-23",
vehicleId: DMSVid.vehiclesVehId vehicleId: DMSVid.vehiclesVehId
@@ -735,8 +732,8 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS
txEnvelope.dms_unsold === true txEnvelope.dms_unsold === true
? "" ? ""
: moment() : moment()
// .tz(JobData.bodyshop.timezone) // .tz(JobData.bodyshop.timezone)
.format("YYYY-MM-DD"), .format("YYYY-MM-DD"),
// "deliveryMileage": 4, // "deliveryMileage": 4,
// "doorsQuantity": 4, // "doorsQuantity": 4,
// "engineNumber": "", // "engineNumber": "",
@@ -753,8 +750,8 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS
: String(JobData.plate_no).replace(/([^\w]|_)/g, "").length === 0 : String(JobData.plate_no).replace(/([^\w]|_)/g, "").length === 0
? null ? null
: String(JobData.plate_no) : String(JobData.plate_no)
.replace(/([^\w]|_)/g, "") .replace(/([^\w]|_)/g, "")
.toUpperCase(), .toUpperCase(),
make: txEnvelope.dms_make, make: txEnvelope.dms_make,
// "model": "CC10753", // "model": "CC10753",
modelAbrev: txEnvelope.dms_model, modelAbrev: txEnvelope.dms_model,
@@ -900,13 +897,13 @@ async function UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust
}, },
...(oldOwner ...(oldOwner
? [ ? [
{ {
id: { id: {
assigningPartyId: "PREVIOUS", assigningPartyId: "PREVIOUS",
value: oldOwner.id.value value: oldOwner.id.value
}
} }
} ]
]
: []) : [])
]; ];
} }
@@ -936,24 +933,24 @@ async function UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust
txEnvelope.dms_unsold === true txEnvelope.dms_unsold === true
? "" ? ""
: moment(DMSVehToSend.dealer.inServiceDate || txEnvelope.inservicedate) : moment(DMSVehToSend.dealer.inServiceDate || txEnvelope.inservicedate)
// .tz(JobData.bodyshop.timezone) // .tz(JobData.bodyshop.timezone)
.toISOString() .toISOString()
}) })
}, },
vehicle: { vehicle: {
...DMSVehToSend.vehicle, ...DMSVehToSend.vehicle,
...(txEnvelope.dms_model_override ...(txEnvelope.dms_model_override
? { ? {
make: txEnvelope.dms_make, make: txEnvelope.dms_make,
modelAbrev: txEnvelope.dms_model modelAbrev: txEnvelope.dms_model
} }
: {}), : {}),
deliveryDate: deliveryDate:
txEnvelope.dms_unsold === true txEnvelope.dms_unsold === true
? "" ? ""
: moment(DMSVehToSend.vehicle.deliveryDate) : moment(DMSVehToSend.vehicle.deliveryDate)
//.tz(JobData.bodyshop.timezone) //.tz(JobData.bodyshop.timezone)
.toISOString() .toISOString()
}, },
owners: ids owners: ids
} }
@@ -1061,7 +1058,7 @@ async function InsertDmsStartWip({ socket, redisHelpers, JobData }) {
// transID: "", // transID: "",
// userID: "partprgm", // userID: "partprgm",
// userName: "PROGRAM, PARTNER" // userName: "PROGRAM, PARTNER"
}, }
}); });
return result; return result;
} catch (error) { } catch (error) {
@@ -1091,9 +1088,9 @@ async function GenerateTransWips({ socket, redisHelpers, JobData }) {
acct: alloc.profitCenter.dms_acctnumber, acct: alloc.profitCenter.dms_acctnumber,
cntl: cntl:
alloc.profitCenter.dms_control_override && alloc.profitCenter.dms_control_override &&
alloc.profitCenter.dms_control_override !== null && alloc.profitCenter.dms_control_override !== null &&
alloc.profitCenter.dms_control_override !== undefined && alloc.profitCenter.dms_control_override !== undefined &&
alloc.profitCenter.dms_control_override?.trim() !== "" alloc.profitCenter.dms_control_override?.trim() !== ""
? alloc.profitCenter.dms_control_override ? alloc.profitCenter.dms_control_override
: JobData.ro_number, : JobData.ro_number,
cntl2: null, cntl2: null,
@@ -1114,9 +1111,9 @@ async function GenerateTransWips({ socket, redisHelpers, JobData }) {
acct: alloc.costCenter.dms_acctnumber, acct: alloc.costCenter.dms_acctnumber,
cntl: cntl:
alloc.costCenter.dms_control_override && alloc.costCenter.dms_control_override &&
alloc.costCenter.dms_control_override !== null && alloc.costCenter.dms_control_override !== null &&
alloc.costCenter.dms_control_override !== undefined && alloc.costCenter.dms_control_override !== undefined &&
alloc.costCenter.dms_control_override?.trim() !== "" alloc.costCenter.dms_control_override?.trim() !== ""
? alloc.costCenter.dms_control_override ? alloc.costCenter.dms_control_override
: JobData.ro_number, : JobData.ro_number,
cntl2: null, cntl2: null,
@@ -1134,9 +1131,9 @@ async function GenerateTransWips({ socket, redisHelpers, JobData }) {
acct: alloc.costCenter.dms_wip_acctnumber, acct: alloc.costCenter.dms_wip_acctnumber,
cntl: cntl:
alloc.costCenter.dms_control_override && alloc.costCenter.dms_control_override &&
alloc.costCenter.dms_control_override !== null && alloc.costCenter.dms_control_override !== null &&
alloc.costCenter.dms_control_override !== undefined && alloc.costCenter.dms_control_override !== undefined &&
alloc.costCenter.dms_control_override?.trim() !== "" alloc.costCenter.dms_control_override?.trim() !== ""
? alloc.costCenter.dms_control_override ? alloc.costCenter.dms_control_override
: JobData.ro_number, : JobData.ro_number,
cntl2: null, cntl2: null,
@@ -1158,9 +1155,9 @@ async function GenerateTransWips({ socket, redisHelpers, JobData }) {
acct: alloc.profitCenter.dms_acctnumber, acct: alloc.profitCenter.dms_acctnumber,
cntl: cntl:
alloc.profitCenter.dms_control_override && alloc.profitCenter.dms_control_override &&
alloc.profitCenter.dms_control_override !== null && alloc.profitCenter.dms_control_override !== null &&
alloc.profitCenter.dms_control_override !== undefined && alloc.profitCenter.dms_control_override !== undefined &&
alloc.profitCenter.dms_control_override?.trim() !== "" alloc.profitCenter.dms_control_override?.trim() !== ""
? alloc.profitCenter.dms_control_override ? alloc.profitCenter.dms_control_override
: JobData.ro_number, : JobData.ro_number,
cntl2: null, cntl2: null,
@@ -1228,7 +1225,7 @@ async function PostDmsBatchWip({ socket, redisHelpers, JobData }) {
opCode: "P", opCode: "P",
transID: DMSTransHeader.transID, transID: DMSTransHeader.transID,
transWipReqList: await GenerateTransWips({ socket, redisHelpers, JobData }) transWipReqList: await GenerateTransWips({ socket, redisHelpers, JobData })
}, }
}); });
return result; return result;
} catch (error) { } catch (error) {
@@ -1256,7 +1253,7 @@ async function QueryDmsErrWip({ socket, redisHelpers, JobData }) {
socket, socket,
jobid: JobData.id, jobid: JobData.id,
requestPathParams: DMSTransHeader.transID, requestPathParams: DMSTransHeader.transID,
body: {}, body: {}
}); });
return result; return result;
} catch (error) { } catch (error) {
@@ -1286,7 +1283,7 @@ async function DeleteDmsWip({ socket, redisHelpers, JobData }) {
body: { body: {
opCode: "D", opCode: "D",
transID: DMSTransHeader.transID transID: DMSTransHeader.transID
}, }
}); });
return result; return result;
} catch (error) { } catch (error) {
@@ -1298,9 +1295,15 @@ async function DeleteDmsWip({ socket, redisHelpers, JobData }) {
} }
} }
async function MarkJobExported({ socket, jobid, JobData }) { async function MarkJobExported({ socket, jobid, JobData, redisHelpers }) {
CreateFortellisLogEvent(socket, "DEBUG", `Marking job as exported for id ${jobid}`); CreateFortellisLogEvent(socket, "DEBUG", `Marking job as exported for id ${jobid}`);
const transwips = await redisHelpers.getSessionTransactionData(
socket.id,
getTransactionType(JobData.id),
FortellisCacheEnums.transWips
);
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {}); const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
const currentToken = const currentToken =
(socket?.data && socket.data.authToken) || (socket?.handshake?.auth && socket.handshake.auth.token); (socket?.data && socket.data.authToken) || (socket?.handshake?.auth && socket.handshake.auth.token);
@@ -1318,7 +1321,7 @@ async function MarkJobExported({ socket, jobid, JobData }) {
jobid: jobid, jobid: jobid,
successful: true, successful: true,
useremail: socket.user.email, useremail: socket.user.email,
metadata: socket.transWips metadata: transwips
}, },
bill: { bill: {
exported: true, exported: true,
@@ -1338,13 +1341,15 @@ async function InsertFailedExportLog({ socket, JobData, error }) {
const result = await client const result = await client
.setHeaders({ Authorization: `Bearer ${currentToken}` }) .setHeaders({ Authorization: `Bearer ${currentToken}` })
.request(queries.INSERT_EXPORT_LOG, { .request(queries.INSERT_EXPORT_LOG, {
logs: [{ logs: [
bodyshopid: JobData.bodyshop.id, {
jobid: JobData.id, bodyshopid: JobData.bodyshop.id,
successful: false, jobid: JobData.id,
message: JSON.stringify(error), successful: false,
useremail: socket.user.email message: JSON.stringify(error),
}] useremail: socket.user.email
}
]
}); });
return result; return result;