Fortellis cleanup.
This commit is contained in:
47252
VendorsBulk.json
47252
VendorsBulk.json
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
|||||||
Fortellis Feedback
|
|
||||||
|
|
||||||
Create Customer
|
|
||||||
https://apidocs.fortellis.io/apis/c5cfb5b3-2013-4870-8645-0379c01ae56b
|
|
||||||
Request Body compoennts do not show on website. Unable to determine which components are required.
|
|
||||||
@@ -69,7 +69,6 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleFinish = (values) => {
|
const handleFinish = (values) => {
|
||||||
//TODO: Add this as a split instead.
|
|
||||||
if (Fortellis.treatment === "on") {
|
if (Fortellis.treatment === "on") {
|
||||||
wsssocket.emit("fortellis-export-job", {
|
wsssocket.emit("fortellis-export-job", {
|
||||||
jobid: job.id,
|
jobid: job.id,
|
||||||
@@ -84,9 +83,8 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
txEnvelope: values
|
txEnvelope: values
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(logsRef);
|
|
||||||
if (logsRef) {
|
if (logsRef) {
|
||||||
console.log("executing", logsRef);
|
|
||||||
logsRef.curent &&
|
logsRef.curent &&
|
||||||
logsRef.current.scrollIntoView({
|
logsRef.current.scrollIntoView({
|
||||||
behavior: "smooth"
|
behavior: "smooth"
|
||||||
|
|||||||
@@ -14,12 +14,10 @@ const { DiscountNotAlreadyCounted } = InstanceManager({
|
|||||||
|
|
||||||
exports.defaultRoute = async function (req, res) {
|
exports.defaultRoute = async function (req, res) {
|
||||||
try {
|
try {
|
||||||
//Fortellis TODO: determine when this is called and whether refactor is required.
|
|
||||||
WsLogger.createLogEvent(req, "DEBUG", `Received request to calculate allocations for ${req.body.jobid}`);
|
WsLogger.createLogEvent(req, "DEBUG", `Received request to calculate allocations for ${req.body.jobid}`);
|
||||||
const jobData = await QueryJobData(req, req.BearerToken, req.body.jobid);
|
const jobData = await QueryJobData(req, req.BearerToken, req.body.jobid);
|
||||||
return res.status(200).json({ data: calculateAllocations(req, jobData) });
|
return res.status(200).json({ data: calculateAllocations(req, jobData) });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
////console.log(error);
|
|
||||||
WsLogger.createLogEvent(req, "ERROR", `Error encountered in CdkCalculateAllocations. ${error}`);
|
WsLogger.createLogEvent(req, "ERROR", `Error encountered in CdkCalculateAllocations. ${error}`);
|
||||||
WsLogger.createLogEvent(req, "ERROR", `Error encountered in CdkCalculateAllocations. ${error.stack}`);
|
WsLogger.createLogEvent(req, "ERROR", `Error encountered in CdkCalculateAllocations. ${error.stack}`);
|
||||||
res.status(500).json({ error: `Error encountered in CdkCalculateAllocations. ${error}` });
|
res.status(500).json({ error: `Error encountered in CdkCalculateAllocations. ${error}` });
|
||||||
@@ -31,7 +29,6 @@ exports.default = async function (socket, jobid, isFortellis = false) {
|
|||||||
const jobData = await QueryJobData(socket, "Bearer " + socket.handshake.auth.token, jobid, isFortellis);
|
const jobData = await QueryJobData(socket, "Bearer " + socket.handshake.auth.token, jobid, isFortellis);
|
||||||
return calculateAllocations(socket, jobData, isFortellis);
|
return calculateAllocations(socket, jobData, isFortellis);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
////console.log(error);
|
|
||||||
const loggingFunction = isFortellis ? CreateFortellisLogEvent : WsLogger.createLogEvent;
|
const loggingFunction = isFortellis ? CreateFortellisLogEvent : WsLogger.createLogEvent;
|
||||||
loggingFunction(socket, "ERROR", `Error encountered in CdkCalculateAllocations. ${error}`);
|
loggingFunction(socket, "ERROR", `Error encountered in CdkCalculateAllocations. ${error}`);
|
||||||
loggingFunction(socket, "ERROR", `Error encountered in CdkCalculateAllocations. ${error.stack}`);
|
loggingFunction(socket, "ERROR", `Error encountered in CdkCalculateAllocations. ${error.stack}`);
|
||||||
|
|||||||
@@ -178,14 +178,14 @@ exports.fortellis = async function ReloadFortellisMakes(req, res) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.log("cdk-replace-makes-models-success", "DEBUG", req.user.email, null, {
|
logger.log("fortellis-replace-makes-models-success", "DEBUG", req.user.email, null, {
|
||||||
cdk_dealerid,
|
cdk_dealerid,
|
||||||
count: newList.length
|
count: newList.length
|
||||||
});
|
});
|
||||||
|
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("cdk-replace-makes-models-error", "ERROR", req.user.email, null, {
|
logger.log("fortellis-replace-makes-models-error", "ERROR", req.user.email, null, {
|
||||||
cdk_dealerid,
|
cdk_dealerid,
|
||||||
error: error.message,
|
error: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
|
|||||||
@@ -26,11 +26,8 @@ class FortellisApiError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
axiosCurlirize(axios, (result, err) => {
|
axiosCurlirize(axios, (_result, _err) => {
|
||||||
// if (err) {
|
//Left intentionally blank. We don't want to console.log. We handle logging the cURL in MakeFortellisCall once completed.
|
||||||
// use your logger here
|
|
||||||
// } else {
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const getTransactionType = (jobid) => `fortellis:${jobid}`;
|
const getTransactionType = (jobid) => `fortellis:${jobid}`;
|
||||||
@@ -84,7 +81,7 @@ async function FetchSubscriptions({ redisHelpers, socket, jobid, SubscriptionObj
|
|||||||
return SubscriptionMetaFromCache;
|
return SubscriptionMetaFromCache;
|
||||||
} else {
|
} else {
|
||||||
const access_token = await GetAuthToken();
|
const access_token = await GetAuthToken();
|
||||||
const subscriptions = await axios.get(`https://subscriptions.fortellis.io/v1/solution/subscriptions`, {
|
const subscriptions = await axios.get(FortellisActions.GetSubscription.url, {
|
||||||
headers: { Authorization: `Bearer ${access_token}` },
|
headers: { Authorization: `Bearer ${access_token}` },
|
||||||
logRequest: false
|
logRequest: false
|
||||||
});
|
});
|
||||||
@@ -116,15 +113,15 @@ async function GetDepartmentId({ apiName, debug = false, SubscriptionMeta, overr
|
|||||||
console.log(JSON.stringify(SubscriptionMeta.apiDmsInfo, null, 4));
|
console.log(JSON.stringify(SubscriptionMeta.apiDmsInfo, null, 4));
|
||||||
console.log("===========");
|
console.log("===========");
|
||||||
}
|
}
|
||||||
//TODO: Verify how to select the correct department.
|
|
||||||
const departmentIds2 = SubscriptionMeta.apiDmsInfo //Get the subscription object.
|
const departmentIds = SubscriptionMeta.apiDmsInfo //Get the subscription object.
|
||||||
.find((info) => info.name === apiName)?.departments; //Departments are categorized by API name and have an array of departments.
|
.find((info) => info.name === apiName)?.departments; //Departments are categorized by API name and have an array of departments.
|
||||||
|
|
||||||
if (overrideDepartmentId) {
|
if (overrideDepartmentId) {
|
||||||
return departmentIds2 && departmentIds2.find(d => d.id === overrideDepartmentId)?.id //TODO: This makes the assumption that there is only 1 department.
|
return departmentIds && departmentIds.find(d => d.id === overrideDepartmentId)?.id
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return departmentIds2 && departmentIds2[0] && departmentIds2[0].id; //TODO: This makes the assumption that there is only 1 department.
|
return departmentIds && departmentIds[0] && departmentIds[0].id; //TODO: This makes the assumption that there is only 1 department.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,11 +141,10 @@ async function MakeFortellisCall({
|
|||||||
SubscriptionObject, //This is used because of the get make models to bypass all of the redis calls.
|
SubscriptionObject, //This is used because of the get make models to bypass all of the redis calls.
|
||||||
overrideDepartmentId
|
overrideDepartmentId
|
||||||
}) {
|
}) {
|
||||||
const { setSessionTransactionData, getSessionTransactionData } = redisHelpers;
|
//const { setSessionTransactionData, getSessionTransactionData } = redisHelpers;
|
||||||
|
|
||||||
const fullUrl = constructFullUrl({ url, pathParams: requestPathParams, requestSearchParams });
|
const fullUrl = constructFullUrl({ url, pathParams: requestPathParams, requestSearchParams });
|
||||||
|
if (debug) console.log(`Executing ${type} to ${fullUrl}`);
|
||||||
if (debug) logger.log(`Executing ${type} to ${fullUrl}`);
|
|
||||||
const ReqId = uuid();
|
const ReqId = uuid();
|
||||||
const access_token = await GetAuthToken();
|
const access_token = await GetAuthToken();
|
||||||
const SubscriptionMeta = await FetchSubscriptions({ redisHelpers, socket, jobid, SubscriptionObject });
|
const SubscriptionMeta = await FetchSubscriptions({ redisHelpers, socket, jobid, SubscriptionObject });
|
||||||
@@ -207,7 +203,7 @@ async function MakeFortellisCall({
|
|||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
console.log(`ReqID: ${ReqId} Data`);
|
console.log(`ReqID: ${ReqId} Data`);
|
||||||
//console.log(JSON.stringify(result.data, null, 4));
|
console.log(JSON.stringify(result.data, null, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.data.checkStatusAfterSeconds) {
|
if (result.data.checkStatusAfterSeconds) {
|
||||||
@@ -236,9 +232,6 @@ async function MakeFortellisCall({
|
|||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`ReqID: ${ReqId} Error`, error.response?.data);
|
|
||||||
//console.log(`ReqID: ${ReqId} Full Error`, JSON.stringify(error, null, 4));
|
|
||||||
|
|
||||||
const errorDetails = {
|
const errorDetails = {
|
||||||
reqId: ReqId,
|
reqId: ReqId,
|
||||||
url: fullUrl,
|
url: fullUrl,
|
||||||
@@ -263,12 +256,6 @@ async function MakeFortellisCall({
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// CreateFortellisLogEvent(socket, "ERROR", `Error in MakeFortellisCall for ${apiName}: ${error.message}`, {
|
|
||||||
// ...errorDetails,
|
|
||||||
// errorStack: error.stack
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Throw custom error with all the details
|
|
||||||
throw new FortellisApiError(`Fortellis API call failed for ${apiName}: ${error.message}`, errorDetails);
|
throw new FortellisApiError(`Fortellis API call failed for ${apiName}: ${error.message}`, errorDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +299,15 @@ function sleep(ms) {
|
|||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === "production";
|
const isProduction = process.env.NODE_ENV === "production";
|
||||||
|
|
||||||
|
//Get requests should have the trailing slash as they are used that way in the calls.
|
||||||
const FortellisActions = {
|
const FortellisActions = {
|
||||||
|
GetSubscription: {
|
||||||
|
url: isProduction
|
||||||
|
? "https://subscriptions.fortellis.io/v1/solution/subscriptions"
|
||||||
|
: "https://subscriptions.fortellis.io/v1/solution/subscriptions",
|
||||||
|
type: "get",
|
||||||
|
apiName: "Fortellis Get Subscriptions"
|
||||||
|
},
|
||||||
QueryVehicles: {
|
QueryVehicles: {
|
||||||
url: isProduction
|
url: isProduction
|
||||||
? "https://api.fortellis.io/cdkdrive/service/v1/vehicles/"
|
? "https://api.fortellis.io/cdkdrive/service/v1/vehicles/"
|
||||||
@@ -412,7 +407,7 @@ const FortellisActions = {
|
|||||||
},
|
},
|
||||||
QueryErrorWip: {
|
QueryErrorWip: {
|
||||||
url: isProduction
|
url: isProduction
|
||||||
? "https://api.fortellis.io/cdk/drive/glpost/errWIP/" //Get requests should have the trailing slash/
|
? "https://api.fortellis.io/cdk/drive/glpost/errWIP/"
|
||||||
: "https://api.fortellis.io/cdk-test/drive/glpost/errWIP/",
|
: "https://api.fortellis.io/cdk-test/drive/glpost/errWIP/",
|
||||||
type: "get",
|
type: "get",
|
||||||
apiName: "CDK Drive Post Accounts GL"
|
apiName: "CDK Drive Post Accounts GL"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const logger = require("../utils/logger");
|
const logger = require("../utils/logger");
|
||||||
|
|
||||||
const CreateFortellisLogEvent = (socket, level, message, txnDetails) => {
|
const CreateFortellisLogEvent = (socket, level, message, txnDetails) => {
|
||||||
//TODO: Add detaisl to track the whole transaction between Fortellis and the server.
|
|
||||||
logger.log("fortellis-log-event", level, socket?.user?.email, null, { wsmessage: message, txnDetails });
|
logger.log("fortellis-log-event", level, socket?.user?.email, null, { wsmessage: message, txnDetails });
|
||||||
socket.emit("fortellis-log-event", { level, message, txnDetails });
|
socket.emit("fortellis-log-event", { level, message, txnDetails });
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ async function FortellisJobExport({ socket, redisHelpers, txEnvelope, jobid }) {
|
|||||||
defaultFortellisTTL
|
defaultFortellisTTL
|
||||||
);
|
);
|
||||||
|
|
||||||
//TODO: Need to remove unnecessary stuff here to reduce the payload.
|
|
||||||
const JobData = await QueryJobData({ socket, jobid });
|
const JobData = await QueryJobData({ socket, jobid });
|
||||||
|
|
||||||
await setSessionTransactionData(
|
await setSessionTransactionData(
|
||||||
@@ -356,7 +355,7 @@ async function CalculateDmsVid({ socket, JobData, redisHelpers }) {
|
|||||||
vin: JobData.v_vin,
|
vin: JobData.v_vin,
|
||||||
jobId: JobData.id
|
jobId: JobData.id
|
||||||
});
|
});
|
||||||
throw error; // Re-throw to maintain existing error handling flow
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,9 +409,6 @@ async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
|||||||
["firstName", JobData.ownr_fn.replace(replaceSpecialRegex, "")],
|
["firstName", JobData.ownr_fn.replace(replaceSpecialRegex, "")],
|
||||||
["lastName", JobData.ownr_ln.replace(replaceSpecialRegex, "")]
|
["lastName", JobData.ownr_ln.replace(replaceSpecialRegex, "")]
|
||||||
];
|
];
|
||||||
|
|
||||||
CreateFortellisLogEvent(socket, "DEBUG", `Begin query DMS Customer by Name using ${JSON.stringify(ownerName)} `);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await MakeFortellisCall({
|
const result = await MakeFortellisCall({
|
||||||
...FortellisActions.QueryCustomerByName,
|
...FortellisActions.QueryCustomerByName,
|
||||||
@@ -903,7 +899,7 @@ async function UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust
|
|||||||
...DMSVehToSend,
|
...DMSVehToSend,
|
||||||
dealer: {
|
dealer: {
|
||||||
...DMSVehToSend.dealer, //TODO: Check why company is blank on a queried record.
|
...DMSVehToSend.dealer, //TODO: Check why company is blank on a queried record.
|
||||||
//company: "77",
|
|
||||||
...((txEnvelope.inservicedate || DMSVehToSend.dealer.inServiceDate) && {
|
...((txEnvelope.inservicedate || DMSVehToSend.dealer.inServiceDate) && {
|
||||||
inServiceDate:
|
inServiceDate:
|
||||||
txEnvelope.dms_unsold === true
|
txEnvelope.dms_unsold === true
|
||||||
@@ -1014,8 +1010,8 @@ async function InsertDmsStartWip({ socket, redisHelpers, JobData }) {
|
|||||||
srcCo: JobData.bodyshop.cdk_configuration.srcco,
|
srcCo: JobData.bodyshop.cdk_configuration.srcco,
|
||||||
srcJrnl: txEnvelope.journal,
|
srcJrnl: txEnvelope.journal,
|
||||||
transID: "",
|
transID: "",
|
||||||
userID: "partprgm" || JobData.bodyshop.cdk_configuration.cashierid,
|
userID: JobData.bodyshop.cdk_configuration.cashierid,
|
||||||
userName: "PROGRAM, PARTNER"
|
userName: "IMEX"
|
||||||
|
|
||||||
// acctgDate: "2025-07-07",
|
// acctgDate: "2025-07-07",
|
||||||
// desc: "DOCUMENT DESC. OPTIONAL REQUIREMENT",
|
// desc: "DOCUMENT DESC. OPTIONAL REQUIREMENT",
|
||||||
@@ -1043,26 +1039,6 @@ async function InsertDmsStartWip({ socket, redisHelpers, JobData }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function InsertDmsBatchWip({ socket, redisHelpers, JobData }) {
|
|
||||||
try {
|
|
||||||
const result = await MakeFortellisCall({
|
|
||||||
...FortellisActions.TranBatchWip,
|
|
||||||
headers: {},
|
|
||||||
redisHelpers,
|
|
||||||
socket,
|
|
||||||
jobid: JobData.id,
|
|
||||||
body: await GenerateTransWips({ socket, redisHelpers, JobData })
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
} catch (error) {
|
|
||||||
handleFortellisApiError(socket, error, "InsertDmsBatchWip", {
|
|
||||||
jobId: JobData.id,
|
|
||||||
errorStack: error.stack
|
|
||||||
});
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function GenerateTransWips({ socket, redisHelpers, JobData }) {
|
async function GenerateTransWips({ socket, redisHelpers, JobData }) {
|
||||||
//3rd prop sets fortellis to true to maintain logging.
|
//3rd prop sets fortellis to true to maintain logging.
|
||||||
const allocations = await CalculateAllocations(socket, JobData.id, true);
|
const allocations = await CalculateAllocations(socket, JobData.id, true);
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ const redisSocketEvents = ({
|
|||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
FortellisLogger(socket, "error", `Error during Fortellis export : ${error.message}`);
|
FortellisLogger(socket, "error", `Error during Fortellis export : ${error.message}`);
|
||||||
logger.log("fortellis-job-export-error", "error", null, null, {
|
logger.log("fortellis-job-export-error", "error", socket.user?.email, jobid, {
|
||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
@@ -289,7 +289,7 @@ const redisSocketEvents = ({
|
|||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
FortellisLogger(socket, "error", `Error during Fortellis export : ${error.message}`);
|
FortellisLogger(socket, "error", `Error during Fortellis export : ${error.message}`);
|
||||||
logger.log("fortellis-selectd-customer-error", "error", null, null, {
|
logger.log("fortellis-selectd-customer-error", "error", socket.user?.email, jobid, {
|
||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
@@ -301,7 +301,7 @@ const redisSocketEvents = ({
|
|||||||
callback(allocations);
|
callback(allocations);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
FortellisLogger(socket, "error", `Error during Fortellis export : ${error.message}`);
|
FortellisLogger(socket, "error", `Error during Fortellis export : ${error.message}`);
|
||||||
logger.log("fortellis-selectd-customer-error", "error", null, null, {
|
logger.log("fortellis-selectd-customer-error", "error", socket.user?.email, jobid, {
|
||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user