Compare commits
18 Commits
feature/IO
...
feature/IO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0c0b5dc45 | ||
|
|
a6a621e73f | ||
|
|
ee0f2c3293 | ||
|
|
83a30f1fcd | ||
|
|
ba3e831503 | ||
|
|
6b87b15e97 | ||
|
|
425cdac26e | ||
|
|
ade8461851 | ||
|
|
f6c5f85a87 | ||
|
|
532fa3fb18 | ||
|
|
c7875c7be3 | ||
|
|
78b9b8d260 | ||
|
|
38fc3285b4 | ||
|
|
9d14ad3167 | ||
|
|
2e53fe8606 | ||
|
|
6317606ce1 | ||
|
|
e599c2b2d6 | ||
|
|
2b35090359 |
@@ -264,29 +264,30 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
}${job.est_ct_fn ? job.est_ct_fn : ""}`
|
||||
},
|
||||
Dates: {
|
||||
DateEstimated: (job.date_estimated && moment(job.date_estimated).format(DateFormat)) || "",
|
||||
DateOpened: (job.date_opened && moment(job.date_opened).format(DateFormat)) || "",
|
||||
DateScheduled:
|
||||
(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)) || "",
|
||||
DateEstimated: job.date_estimated ? moment(job.date_estimated).format(DateFormat) : "",
|
||||
DateOpened: job.date_open ? moment(job.date_open).tz(job.bodyshop.timezone).format(DateFormat) : "",
|
||||
DateScheduled: 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) : "",
|
||||
DateStart: job.date_repairstarted
|
||||
? (job.date_repairstarted && moment(job.date_repairstarted).tz(job.bodyshop.timezone).format(DateFormat)) ||
|
||||
""
|
||||
: (job.actual_in && moment(job.actual_in).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)) || "",
|
||||
DateScheduledDelivery:
|
||||
(job.scheduled_delivery && moment(job.scheduled_delivery).tz(job.bodyshop.timezone).format(DateFormat)) || "",
|
||||
DateDelivered:
|
||||
(job.actual_delivery && moment(job.actual_delivery).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)) || ""
|
||||
? moment(job.date_repairstarted).tz(job.bodyshop.timezone).format(DateFormat)
|
||||
: job.actual_in
|
||||
? moment(job.actual_in).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)
|
||||
: "",
|
||||
DateScheduledDelivery: job.scheduled_delivery
|
||||
? moment(job.scheduled_delivery).tz(job.bodyshop.timezone).format(DateFormat)
|
||||
: "",
|
||||
DateDelivered: job.actual_delivery
|
||||
? moment(job.actual_delivery).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 () {
|
||||
const joblineSource = Array.isArray(job.joblines) ? job.joblines : job.joblines ? [job.joblines] : [];
|
||||
|
||||
@@ -235,18 +235,6 @@ async function MakeFortellisCall({
|
||||
// jobid: socket?.recordid
|
||||
// });
|
||||
|
||||
if (result.data.checkStatusAfterSeconds) {
|
||||
return DelayedCallback({
|
||||
delayMeta: result.data,
|
||||
access_token,
|
||||
SubscriptionID: SubscriptionMeta.subscriptionId,
|
||||
ReqId,
|
||||
departmentIds: DepartmentId
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
logger.log(
|
||||
"fortellis-log-event-json",
|
||||
"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;
|
||||
} catch (error) {
|
||||
const errorDetails = {
|
||||
@@ -310,7 +310,7 @@ async function MakeFortellisCall({
|
||||
//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.
|
||||
//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++) {
|
||||
await sleep(delayMeta.checkStatusAfterSeconds * 1000);
|
||||
//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
|
||||
}
|
||||
});
|
||||
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({
|
||||
// timestamp: new Date().toISOString(),
|
||||
// reqId: ReqId,
|
||||
|
||||
@@ -198,7 +198,7 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
);
|
||||
const existingCustomerInDMSCustList = DMSCustList.find((c) => c.customerId === selectedCustomerId);
|
||||
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(
|
||||
socket.id,
|
||||
@@ -207,8 +207,6 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
DMSCust,
|
||||
defaultFortellisTTL
|
||||
);
|
||||
|
||||
|
||||
} else {
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{3.2} Creating new customer.`);
|
||||
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}`);
|
||||
DMSVeh = await InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMSVid, DMSCust });
|
||||
} else {
|
||||
DMSVeh = await getSessionTransactionData(
|
||||
socket.id,
|
||||
getTransactionType(jobid),
|
||||
FortellisCacheEnums.DMSVeh
|
||||
)
|
||||
DMSVeh = await getSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSVeh);
|
||||
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")) {
|
||||
DMSVeh = await UpdateDmsVehicle({
|
||||
socket,
|
||||
@@ -271,7 +265,11 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
|
||||
if (DMSTransHeader.rtnCode === "0") {
|
||||
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.
|
||||
await setSessionTransactionData(
|
||||
@@ -282,16 +280,14 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
defaultFortellisTTL
|
||||
);
|
||||
|
||||
|
||||
if (DmsBatchTxnPost.rtnCode === "0") {
|
||||
//TODO: Validate this is a string and not #
|
||||
//something
|
||||
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 {
|
||||
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{7} Updating Service Vehicle History.`);
|
||||
const DMSVehHistory = await InsertServiceVehicleHistory({ socket, redisHelpers, JobData });
|
||||
await setSessionTransactionData(
|
||||
@@ -302,24 +298,19 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
defaultFortellisTTL
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
CreateFortellisLogEvent(socket, "ERROR", `{7.1} Error posting vehicle service history. ${error.message}`);
|
||||
}
|
||||
|
||||
socket.emit("export-success", JobData.id);
|
||||
} 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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
//Clean up the transaction and insert a faild error code
|
||||
// //Get the error code
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`);
|
||||
|
||||
|
||||
const DmsError = await QueryDmsErrWip({ socket, redisHelpers, JobData });
|
||||
// //Delete the transaction
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${DMSTransHeader.transID}`);
|
||||
@@ -345,7 +336,11 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
stack: error.stack,
|
||||
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 {
|
||||
//Ensure we always insert logEvents
|
||||
//GQL to insert logevents.
|
||||
@@ -374,7 +369,7 @@ async function CalculateDmsVid({ socket, JobData, redisHelpers }) {
|
||||
jobid: JobData.id,
|
||||
body: {}
|
||||
});
|
||||
return result;
|
||||
return Array.isArray(result) ? result.filter((v) => v.vehiclesVehId !== null && v.vehiclesVehId !== "") : [];
|
||||
} catch (error) {
|
||||
handleFortellisApiError(socket, error, "CalculateDmsVid", {
|
||||
vin: JobData.v_vin,
|
||||
@@ -429,12 +424,12 @@ async function QueryDmsCustomerById({ socket, redisHelpers, JobData, CustomerId
|
||||
async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
||||
const ownerName =
|
||||
JobData.ownr_co_nm && JobData.ownr_co_nm.trim() !== ""
|
||||
//? [["firstName", JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase()]] // Commented out until we receive direction.
|
||||
? [["phone", JobData.ownr_ph1?.replace(replaceSpecialRegex, "")]]
|
||||
? //? [["firstName", JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase()]] // Commented out until we receive direction.
|
||||
[["phone", JobData.ownr_ph1?.replace(/[^0-9]/g, "")]]
|
||||
: [
|
||||
["firstName", JobData.ownr_fn?.replace(/[^a-zA-Z-]/g, "").toUpperCase()],
|
||||
["lastName", JobData.ownr_ln?.replace(/[^a-zA-Z-]/g, "").toUpperCase()]
|
||||
];
|
||||
["firstName", JobData.ownr_fn?.replace(/[^a-zA-Z0-9]/g, "").toUpperCase()],
|
||||
["lastName", JobData.ownr_ln?.replace(/[^a-zA-Z0-9]/g, "").toUpperCase()]
|
||||
];
|
||||
try {
|
||||
const result = await MakeFortellisCall({
|
||||
...FortellisActions.QueryCustomerByName,
|
||||
@@ -457,7 +452,7 @@ async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
||||
|
||||
async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
|
||||
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({
|
||||
...FortellisActions.CreateCustomer,
|
||||
headers: {},
|
||||
@@ -466,21 +461,23 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
|
||||
jobid: JobData.id,
|
||||
body: {
|
||||
customerType: isBusiness ? "BUSINESS" : "INDIVIDUAL",
|
||||
...isBusiness ? {
|
||||
companyName: 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(),
|
||||
//"middleName": "",
|
||||
lastName: JobData.ownr_ln && JobData.ownr_ln.replace(/[^a-zA-Z-]/g, "").toUpperCase()
|
||||
//"title": "",
|
||||
//"nickName": ""
|
||||
}
|
||||
},
|
||||
...(isBusiness
|
||||
? {
|
||||
companyName: 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-Z0-9]/g, "").toUpperCase(),
|
||||
//"middleName": "",
|
||||
lastName: JobData.ownr_ln && JobData.ownr_ln.replace(/[^a-zA-Z0-9]/g, "").toUpperCase()
|
||||
//"title": "",
|
||||
//"nickName": ""
|
||||
}
|
||||
}),
|
||||
postalAddress: {
|
||||
addressLine1: JobData.ownr_addr1?.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
|
||||
}),
|
||||
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": ""
|
||||
},
|
||||
// "birthDate": {
|
||||
@@ -504,7 +501,7 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
|
||||
phones: [
|
||||
{
|
||||
//"uuid": "",
|
||||
number: JobData.ownr_ph1?.replace(replaceSpecialRegex, ""),
|
||||
number: JobData.ownr_ph1?.replace(/[^0-9]/g, ""),
|
||||
type: "HOME"
|
||||
// "doNotCallIndicator": true,
|
||||
// "doNotCallIndicatorDate": `null,
|
||||
@@ -540,18 +537,18 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
|
||||
emailAddresses: [
|
||||
...(!_.isEmpty(JobData.ownr_ea)
|
||||
? [
|
||||
{
|
||||
//"uuid": "",
|
||||
address: JobData.ownr_ea.toUpperCase(),
|
||||
type: "PERSONAL"
|
||||
// "doNotEmailSource": "",
|
||||
// "doNotEmail": false,
|
||||
// "isPreferred": true,
|
||||
// "transactionEmailNotificationOptIn": false,
|
||||
// "optInRequestDate": null,
|
||||
// "optInDate": null
|
||||
}
|
||||
]
|
||||
{
|
||||
//"uuid": "",
|
||||
address: JobData.ownr_ea.toUpperCase(),
|
||||
type: "PERSONAL"
|
||||
// "doNotEmailSource": "",
|
||||
// "doNotEmail": false,
|
||||
// "isPreferred": true,
|
||||
// "transactionEmailNotificationOptIn": false,
|
||||
// "optInRequestDate": null,
|
||||
// "optInDate": null
|
||||
}
|
||||
]
|
||||
: [])
|
||||
// {
|
||||
// "uuid": "",
|
||||
@@ -691,9 +688,9 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS
|
||||
txEnvelope.dms_unsold === true
|
||||
? ""
|
||||
: moment(txEnvelope.inservicedate)
|
||||
//.tz(JobData.bodyshop.timezone)
|
||||
.startOf("day")
|
||||
.toISOString()
|
||||
//.tz(JobData.bodyshop.timezone)
|
||||
.startOf("day")
|
||||
.toISOString()
|
||||
}),
|
||||
//"lastServiceDate": "2011-11-23",
|
||||
vehicleId: DMSVid.vehiclesVehId
|
||||
@@ -735,8 +732,8 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS
|
||||
txEnvelope.dms_unsold === true
|
||||
? ""
|
||||
: moment()
|
||||
// .tz(JobData.bodyshop.timezone)
|
||||
.format("YYYY-MM-DD"),
|
||||
// .tz(JobData.bodyshop.timezone)
|
||||
.format("YYYY-MM-DD"),
|
||||
// "deliveryMileage": 4,
|
||||
// "doorsQuantity": 4,
|
||||
// "engineNumber": "",
|
||||
@@ -753,8 +750,8 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS
|
||||
: String(JobData.plate_no).replace(/([^\w]|_)/g, "").length === 0
|
||||
? null
|
||||
: String(JobData.plate_no)
|
||||
.replace(/([^\w]|_)/g, "")
|
||||
.toUpperCase(),
|
||||
.replace(/([^\w]|_)/g, "")
|
||||
.toUpperCase(),
|
||||
make: txEnvelope.dms_make,
|
||||
// "model": "CC10753",
|
||||
modelAbrev: txEnvelope.dms_model,
|
||||
@@ -900,13 +897,13 @@ async function UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust
|
||||
},
|
||||
...(oldOwner
|
||||
? [
|
||||
{
|
||||
id: {
|
||||
assigningPartyId: "PREVIOUS",
|
||||
value: oldOwner.id.value
|
||||
{
|
||||
id: {
|
||||
assigningPartyId: "PREVIOUS",
|
||||
value: oldOwner.id.value
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
: [])
|
||||
];
|
||||
}
|
||||
@@ -936,24 +933,24 @@ async function UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust
|
||||
txEnvelope.dms_unsold === true
|
||||
? ""
|
||||
: moment(DMSVehToSend.dealer.inServiceDate || txEnvelope.inservicedate)
|
||||
// .tz(JobData.bodyshop.timezone)
|
||||
.toISOString()
|
||||
// .tz(JobData.bodyshop.timezone)
|
||||
.toISOString()
|
||||
})
|
||||
},
|
||||
vehicle: {
|
||||
...DMSVehToSend.vehicle,
|
||||
...(txEnvelope.dms_model_override
|
||||
? {
|
||||
make: txEnvelope.dms_make,
|
||||
modelAbrev: txEnvelope.dms_model
|
||||
}
|
||||
make: txEnvelope.dms_make,
|
||||
modelAbrev: txEnvelope.dms_model
|
||||
}
|
||||
: {}),
|
||||
deliveryDate:
|
||||
txEnvelope.dms_unsold === true
|
||||
? ""
|
||||
: moment(DMSVehToSend.vehicle.deliveryDate)
|
||||
//.tz(JobData.bodyshop.timezone)
|
||||
.toISOString()
|
||||
//.tz(JobData.bodyshop.timezone)
|
||||
.toISOString()
|
||||
},
|
||||
owners: ids
|
||||
}
|
||||
@@ -1061,7 +1058,7 @@ async function InsertDmsStartWip({ socket, redisHelpers, JobData }) {
|
||||
// transID: "",
|
||||
// userID: "partprgm",
|
||||
// userName: "PROGRAM, PARTNER"
|
||||
},
|
||||
}
|
||||
});
|
||||
return result;
|
||||
} catch (error) {
|
||||
@@ -1091,9 +1088,9 @@ async function GenerateTransWips({ socket, redisHelpers, JobData }) {
|
||||
acct: alloc.profitCenter.dms_acctnumber,
|
||||
cntl:
|
||||
alloc.profitCenter.dms_control_override &&
|
||||
alloc.profitCenter.dms_control_override !== null &&
|
||||
alloc.profitCenter.dms_control_override !== undefined &&
|
||||
alloc.profitCenter.dms_control_override?.trim() !== ""
|
||||
alloc.profitCenter.dms_control_override !== null &&
|
||||
alloc.profitCenter.dms_control_override !== undefined &&
|
||||
alloc.profitCenter.dms_control_override?.trim() !== ""
|
||||
? alloc.profitCenter.dms_control_override
|
||||
: JobData.ro_number,
|
||||
cntl2: null,
|
||||
@@ -1114,9 +1111,9 @@ async function GenerateTransWips({ socket, redisHelpers, JobData }) {
|
||||
acct: alloc.costCenter.dms_acctnumber,
|
||||
cntl:
|
||||
alloc.costCenter.dms_control_override &&
|
||||
alloc.costCenter.dms_control_override !== null &&
|
||||
alloc.costCenter.dms_control_override !== undefined &&
|
||||
alloc.costCenter.dms_control_override?.trim() !== ""
|
||||
alloc.costCenter.dms_control_override !== null &&
|
||||
alloc.costCenter.dms_control_override !== undefined &&
|
||||
alloc.costCenter.dms_control_override?.trim() !== ""
|
||||
? alloc.costCenter.dms_control_override
|
||||
: JobData.ro_number,
|
||||
cntl2: null,
|
||||
@@ -1134,9 +1131,9 @@ async function GenerateTransWips({ socket, redisHelpers, JobData }) {
|
||||
acct: alloc.costCenter.dms_wip_acctnumber,
|
||||
cntl:
|
||||
alloc.costCenter.dms_control_override &&
|
||||
alloc.costCenter.dms_control_override !== null &&
|
||||
alloc.costCenter.dms_control_override !== undefined &&
|
||||
alloc.costCenter.dms_control_override?.trim() !== ""
|
||||
alloc.costCenter.dms_control_override !== null &&
|
||||
alloc.costCenter.dms_control_override !== undefined &&
|
||||
alloc.costCenter.dms_control_override?.trim() !== ""
|
||||
? alloc.costCenter.dms_control_override
|
||||
: JobData.ro_number,
|
||||
cntl2: null,
|
||||
@@ -1158,9 +1155,9 @@ async function GenerateTransWips({ socket, redisHelpers, JobData }) {
|
||||
acct: alloc.profitCenter.dms_acctnumber,
|
||||
cntl:
|
||||
alloc.profitCenter.dms_control_override &&
|
||||
alloc.profitCenter.dms_control_override !== null &&
|
||||
alloc.profitCenter.dms_control_override !== undefined &&
|
||||
alloc.profitCenter.dms_control_override?.trim() !== ""
|
||||
alloc.profitCenter.dms_control_override !== null &&
|
||||
alloc.profitCenter.dms_control_override !== undefined &&
|
||||
alloc.profitCenter.dms_control_override?.trim() !== ""
|
||||
? alloc.profitCenter.dms_control_override
|
||||
: JobData.ro_number,
|
||||
cntl2: null,
|
||||
@@ -1228,7 +1225,7 @@ async function PostDmsBatchWip({ socket, redisHelpers, JobData }) {
|
||||
opCode: "P",
|
||||
transID: DMSTransHeader.transID,
|
||||
transWipReqList: await GenerateTransWips({ socket, redisHelpers, JobData })
|
||||
},
|
||||
}
|
||||
});
|
||||
return result;
|
||||
} catch (error) {
|
||||
@@ -1256,7 +1253,7 @@ async function QueryDmsErrWip({ socket, redisHelpers, JobData }) {
|
||||
socket,
|
||||
jobid: JobData.id,
|
||||
requestPathParams: DMSTransHeader.transID,
|
||||
body: {},
|
||||
body: {}
|
||||
});
|
||||
return result;
|
||||
} catch (error) {
|
||||
@@ -1286,7 +1283,7 @@ async function DeleteDmsWip({ socket, redisHelpers, JobData }) {
|
||||
body: {
|
||||
opCode: "D",
|
||||
transID: DMSTransHeader.transID
|
||||
},
|
||||
}
|
||||
});
|
||||
return result;
|
||||
} 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}`);
|
||||
|
||||
const transwips = await redisHelpers.getSessionTransactionData(
|
||||
socket.id,
|
||||
getTransactionType(JobData.id),
|
||||
FortellisCacheEnums.transWips
|
||||
);
|
||||
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
|
||||
const currentToken =
|
||||
(socket?.data && socket.data.authToken) || (socket?.handshake?.auth && socket.handshake.auth.token);
|
||||
@@ -1318,7 +1321,7 @@ async function MarkJobExported({ socket, jobid, JobData }) {
|
||||
jobid: jobid,
|
||||
successful: true,
|
||||
useremail: socket.user.email,
|
||||
metadata: socket.transWips
|
||||
metadata: transwips
|
||||
},
|
||||
bill: {
|
||||
exported: true,
|
||||
@@ -1338,13 +1341,15 @@ async function InsertFailedExportLog({ socket, JobData, error }) {
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: `Bearer ${currentToken}` })
|
||||
.request(queries.INSERT_EXPORT_LOG, {
|
||||
logs: [{
|
||||
bodyshopid: JobData.bodyshop.id,
|
||||
jobid: JobData.id,
|
||||
successful: false,
|
||||
message: JSON.stringify(error),
|
||||
useremail: socket.user.email
|
||||
}]
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: JobData.bodyshop.id,
|
||||
jobid: JobData.id,
|
||||
successful: false,
|
||||
message: JSON.stringify(error),
|
||||
useremail: socket.user.email
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user