Final updates for Fortellis to pass certification and remove logging.

This commit is contained in:
Patrick Fic
2026-01-09 10:16:33 -08:00
parent 3cf1d9a59d
commit f4b45c693a
4 changed files with 114 additions and 54 deletions

View File

@@ -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",