Final updates for Fortellis to pass certification and remove logging.
This commit is contained in:
@@ -133,16 +133,23 @@ export function ExportLogsPageComponent() {
|
||||
title: t("general.labels.message"),
|
||||
dataIndex: "message",
|
||||
key: "message",
|
||||
render: (text, record) =>
|
||||
record.message && (
|
||||
<div>
|
||||
<ul>
|
||||
{JSON.parse(record.message).map((m, idx) => (
|
||||
<li key={idx}>{m}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
render: (text, record) => {
|
||||
if (!record.message) return null;
|
||||
const message = JSON.parse(record.message);
|
||||
if (Array.isArray(message)) {
|
||||
return (
|
||||
<div>
|
||||
<ul>
|
||||
{message.map((m, idx) => (
|
||||
<li key={idx}>{m}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return <div>{record.message}</div>;
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const vehicletype = async (req, res) => {
|
||||
if (!model || model.trim() === "") {
|
||||
res.status(400).json({ success: false, error: "Please provide a model" });
|
||||
} else {
|
||||
|
||||
vehicle
|
||||
const type = getVehicleType(model.trim())
|
||||
res.status(200).json({ success: true, ...type });
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ const defaultFortellisTTL = 60 * 60;
|
||||
async function GetAuthToken() {
|
||||
//Done with Authorization Code Flow
|
||||
//https://docs.fortellis.io/docs/tutorials/solution-integration/authorization-code-flow/
|
||||
|
||||
//TODO: This should get stored in the redis cache and only be refreshed when it expires.
|
||||
const {
|
||||
data: { access_token, expires_in, token_type }
|
||||
} = await axios.post(
|
||||
@@ -221,6 +219,22 @@ async function MakeFortellisCall({
|
||||
console.log(JSON.stringify(result.data, null, 4));
|
||||
}
|
||||
|
||||
// await writeFortellisLogToFile({
|
||||
// timestamp: new Date().toISOString(),
|
||||
// reqId: ReqId,
|
||||
// url: fullUrl,
|
||||
// request:
|
||||
// {
|
||||
// requestcurl: result.config.curlCommand,
|
||||
// reqid: result.config.headers["Request-Id"] || null,
|
||||
// subscriptionId: result.config.headers["Subscription-Id"] || null,
|
||||
// resultdata: result.data,
|
||||
// resultStatus: result.status
|
||||
// },
|
||||
// user: socket?.user?.email,
|
||||
// jobid: socket?.recordid
|
||||
// });
|
||||
|
||||
if (result.data.checkStatusAfterSeconds) {
|
||||
return DelayedCallback({
|
||||
delayMeta: result.data,
|
||||
@@ -231,6 +245,8 @@ async function MakeFortellisCall({
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
logger.log(
|
||||
"fortellis-log-event-json",
|
||||
"DEBUG",
|
||||
@@ -256,6 +272,21 @@ async function MakeFortellisCall({
|
||||
errorStatusText: error.response?.statusText,
|
||||
originalError: error
|
||||
};
|
||||
// await writeFortellisLogToFile({
|
||||
// timestamp: new Date().toISOString(),
|
||||
// reqId: ReqId,
|
||||
// url: fullUrl,
|
||||
// request:
|
||||
// {
|
||||
// requestcurl: error.config.curlCommand,
|
||||
// reqid: error.config.headers["Request-Id"] || null,
|
||||
// subscriptionId: error.config.headers["Subscription-Id"] || null,
|
||||
// resultdata: error.message,
|
||||
// resultStatus: error.status
|
||||
// },
|
||||
// user: socket?.user?.email,
|
||||
// jobid: socket?.recordid
|
||||
// });
|
||||
|
||||
logger.log(
|
||||
"fortellis-log-event-error",
|
||||
@@ -263,10 +294,11 @@ async function MakeFortellisCall({
|
||||
socket?.user?.email,
|
||||
socket?.recordid,
|
||||
{
|
||||
wsmessage: "",//message,
|
||||
curl: error?.config.curlCommand,
|
||||
reqid: error.config?.headers["Request-Id"] || null,
|
||||
subscriptionId: error.config?.headers["Subscription-Id"] || null,
|
||||
requestcurl: error.config.curlCommand,
|
||||
reqid: error.config.headers["Request-Id"] || null,
|
||||
subscriptionId: error.config.headers["Subscription-Id"] || null,
|
||||
resultdata: error.message,
|
||||
resultStatus: error.status
|
||||
},
|
||||
true
|
||||
);
|
||||
@@ -302,6 +334,19 @@ async function DelayedCallback({ delayMeta, access_token, SubscriptionID, ReqId,
|
||||
//"Department-Id": departmentIds[0].id
|
||||
}
|
||||
});
|
||||
// await writeFortellisLogToFile({
|
||||
// timestamp: new Date().toISOString(),
|
||||
// reqId: ReqId,
|
||||
// url: statusResult.data._links.result.href,
|
||||
// request:
|
||||
// {
|
||||
// requestcurl: batchResult.config.curlCommand,
|
||||
// reqid: batchResult.config.headers["Request-Id"] || null,
|
||||
// subscriptionId: batchResult.config.headers["Subscription-Id"] || null,
|
||||
// resultdata: batchResult.data,
|
||||
// resultStatus: batchResult.status
|
||||
// },
|
||||
// });
|
||||
return batchResult;
|
||||
} else {
|
||||
return "Error!!! Still need to implement batch waiting.";
|
||||
@@ -313,6 +358,7 @@ function sleep(ms) {
|
||||
}
|
||||
|
||||
async function writeFortellisLogToFile(logObject) {
|
||||
//The was only used for the certification. Commented out in case of future need.
|
||||
try {
|
||||
const logsDir = path.join(process.cwd(), 'logs');
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
@@ -336,9 +382,6 @@ async function writeFortellisLogToFile(logObject) {
|
||||
|
||||
async function WriteToIOEventLog({ apiName, type, fullUrl, bodyshopid, useremail, logger, socket }) {
|
||||
try {
|
||||
|
||||
|
||||
|
||||
await client.request(INSERT_IOEVENT, {
|
||||
event: {
|
||||
operationname: `fortellis-${apiName}-${type}`,
|
||||
|
||||
@@ -242,7 +242,7 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
JobData,
|
||||
DMSVeh,
|
||||
DMSCust,
|
||||
selectedCustomerId,
|
||||
selectedCustomerId: selectedCustomerId || DMSCust.customerId,
|
||||
txEnvelope
|
||||
});
|
||||
await setSessionTransactionData(
|
||||
@@ -293,14 +293,14 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
try {
|
||||
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{7} Updating Service Vehicle History.`);
|
||||
const DMSVehHistory = await InsertServiceVehicleHistory({ socket, redisHelpers, JobData });
|
||||
await setSessionTransactionData(
|
||||
socket.id,
|
||||
getTransactionType(jobid),
|
||||
FortellisCacheEnums.DMSVehHistory,
|
||||
DMSVehHistory,
|
||||
defaultFortellisTTL
|
||||
);
|
||||
const DMSVehHistory = await InsertServiceVehicleHistory({ socket, redisHelpers, JobData });
|
||||
await setSessionTransactionData(
|
||||
socket.id,
|
||||
getTransactionType(jobid),
|
||||
FortellisCacheEnums.DMSVehHistory,
|
||||
DMSVehHistory,
|
||||
defaultFortellisTTL
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
CreateFortellisLogEvent(socket, "ERROR", `{7.1} Error posting vehicle service history. ${error.message}`);
|
||||
@@ -346,7 +346,7 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
stack: error.stack,
|
||||
data: error.errorData
|
||||
});
|
||||
await InsertFailedExportLog({ socket, JobData, error });
|
||||
await InsertFailedExportLog({ socket, JobData, error: error.errorData?.issues || [JSON.stringify(error.errorData)] });
|
||||
} finally {
|
||||
//Ensure we always insert logEvents
|
||||
//GQL to insert logevents.
|
||||
@@ -430,10 +430,11 @@ async function QueryDmsCustomerById({ socket, redisHelpers, JobData, CustomerId
|
||||
async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
|
||||
const ownerName =
|
||||
JobData.ownr_co_nm && JobData.ownr_co_nm.trim() !== ""
|
||||
? [["lastName", JobData.ownr_co_nm.replace(replaceSpecialRegex, "")]]
|
||||
//? [["firstName", JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase()]] // Commented out until we receive direction.
|
||||
? [["email", JobData.ownr_ea.toUpperCase()]]
|
||||
: [
|
||||
["firstName", JobData.ownr_fn.replace(replaceSpecialRegex, "")],
|
||||
["lastName", JobData.ownr_ln.replace(replaceSpecialRegex, "")]
|
||||
["firstName", JobData.ownr_fn.replace(replaceSpecialRegex, "").toUpperCase()],
|
||||
["lastName", JobData.ownr_ln.replace(replaceSpecialRegex, "").toUpperCase()]
|
||||
];
|
||||
try {
|
||||
const result = await MakeFortellisCall({
|
||||
@@ -457,6 +458,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 result = await MakeFortellisCall({
|
||||
...FortellisActions.CreateCustomer,
|
||||
headers: {},
|
||||
@@ -464,28 +466,32 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
|
||||
socket,
|
||||
jobid: JobData.id,
|
||||
body: {
|
||||
customerType: "INDIVIDUAL",
|
||||
customerName: {
|
||||
//"suffix": "Mr.",
|
||||
firstName: JobData.ownr_fn && JobData.ownr_fn.replace(replaceSpecialRegex, "").toUpperCase(),
|
||||
//"middleName": "",
|
||||
lastName: JobData.ownr_ln && JobData.ownr_ln.replace(replaceSpecialRegex, "").toUpperCase()
|
||||
//"title": "",
|
||||
//"nickName": ""
|
||||
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(replaceSpecialRegex, "").toUpperCase(),
|
||||
//"middleName": "",
|
||||
lastName: JobData.ownr_ln && JobData.ownr_ln.replace(replaceSpecialRegex, "").toUpperCase()
|
||||
//"title": "",
|
||||
//"nickName": ""
|
||||
}
|
||||
},
|
||||
companyName: JobData.ownr_co_nm && JobData.ownr_co_nm.replace(replaceSpecialRegex, "").toUpperCase(),
|
||||
postalAddress: {
|
||||
addressLine1: JobData.ownr_addr1?.replace(replaceSpecialRegex, "").trim(),
|
||||
addressLine2: JobData.ownr_addr2?.replace(replaceSpecialRegex, "").trim(),
|
||||
city: JobData.ownr_city?.replace(replaceSpecialRegex, "").trim(),
|
||||
state: JobData.ownr_state?.replace(replaceSpecialRegex, "").trim(),
|
||||
addressLine1: JobData.ownr_addr1?.replace(replaceSpecialRegex, "").trim().toUpperCase(),
|
||||
addressLine2: JobData.ownr_addr2?.replace(replaceSpecialRegex, "").trim().toUpperCase(),
|
||||
city: JobData.ownr_city?.replace(replaceSpecialRegex, "").trim().toUpperCase(),
|
||||
postalCode: InstanceMgr({
|
||||
imex: JobData.ownr_zip && JobData.ownr_zip.toUpperCase().replace(/\W/g, "").replace(/(...)/, "$1 "),
|
||||
rome: JobData.ownr_zip
|
||||
}),
|
||||
//"county": JobData.ownr_county?.trim(),
|
||||
country: JobData.ownr_ctry?.replace(replaceSpecialRegex, "").trim(),
|
||||
province: JobData.ownr_st?.replace(replaceSpecialRegex, "").trim()
|
||||
state: JobData.ownr_st?.replace(replaceSpecialRegex, "").trim().toUpperCase(),
|
||||
country: JobData.ownr_ctry?.replace(replaceSpecialRegex, "").trim().toUpperCase(),
|
||||
//"territory": ""
|
||||
},
|
||||
// "birthDate": {
|
||||
@@ -537,7 +543,7 @@ async function InsertDmsCustomer({ socket, redisHelpers, JobData }) {
|
||||
? [
|
||||
{
|
||||
//"uuid": "",
|
||||
address: JobData.ownr_ea,
|
||||
address: JobData.ownr_ea.toUpperCase(),
|
||||
type: "PERSONAL"
|
||||
// "doNotEmailSource": "",
|
||||
// "doNotEmail": false,
|
||||
@@ -836,7 +842,7 @@ async function InsertDmsVehicle({ socket, redisHelpers, JobData, txEnvelope, DMS
|
||||
// "vehicleStatus": "G",
|
||||
// "vehicleStock": "82268",
|
||||
// "vehicleWeight": "6800",
|
||||
vin: JobData.v_vin
|
||||
vin: JobData.v_vin.toUpperCase()
|
||||
// "warrantyExpDate": "2015-01-12",
|
||||
// "wheelbase": ""
|
||||
},
|
||||
@@ -898,7 +904,7 @@ async function UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust
|
||||
{
|
||||
id: {
|
||||
assigningPartyId: "PREVIOUS",
|
||||
value: oldOwner.id
|
||||
value: oldOwner.id.value
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -994,7 +1000,7 @@ async function InsertServiceVehicleHistory({ socket, redisHelpers, JobData }) {
|
||||
openTime: moment(JobData.actual_in).tz(JobData.bodyshop.timezone).format("HH:mm:ss"),
|
||||
closeDate: moment(JobData.invoice_date).tz(JobData.bodyshop.timezone).format("YYYY-MM-DD"),
|
||||
closeTime: moment(JobData.invoice_date).tz(JobData.bodyshop.timezone).format("HH:mm:ss"),
|
||||
comments: txEnvelope.story?.slice(0, 40), // has to be between 0 and 40.
|
||||
comments: txEnvelope.story?.slice(0, 40).toUpperCase(), // has to be between 0 and 40.
|
||||
cashierId: JobData.bodyshop.cdk_configuration.cashierid,
|
||||
referenceNumber: JobData.ro_number.match(/\d+/g)[0]
|
||||
}
|
||||
@@ -1026,7 +1032,7 @@ async function InsertDmsStartWip({ socket, redisHelpers, JobData }) {
|
||||
jobid: JobData.id,
|
||||
body: {
|
||||
acctgDate: moment().tz(JobData.bodyshop.timezone).format("YYYY-MM-DD"),
|
||||
desc: txEnvelope.story && txEnvelope.story.replace(replaceSpecialRegex, ""),
|
||||
desc: txEnvelope.story && txEnvelope.story.replace(replaceSpecialRegex, "").toUpperCase(),
|
||||
docType: "10",
|
||||
m13Flag: "0",
|
||||
refer: JobData.ro_number,
|
||||
@@ -1039,6 +1045,10 @@ async function InsertDmsStartWip({ socket, redisHelpers, JobData }) {
|
||||
userID: JobData.bodyshop.cdk_configuration.cashierid,
|
||||
userName: "IMEX"
|
||||
|
||||
//Cert Values Below
|
||||
// userID: "partprgm",
|
||||
// userName: "PROGRAM, PARTNER"
|
||||
|
||||
// acctgDate: "2025-07-07",
|
||||
// desc: "DOCUMENT DESC. OPTIONAL REQUIREMENT",
|
||||
// docType: "3",
|
||||
|
||||
Reference in New Issue
Block a user