Remove all but -01 and -99 estimates.

This commit is contained in:
Patrick Fic
2024-05-10 09:44:59 -07:00
parent a8805d68e4
commit 036aa04658

View File

@@ -5,24 +5,19 @@ const log = require("electron-log");
const { store } = require("../electron-store");
const { BrowserWindow } = require("electron");
const ipcTypes = require("../../src/ipc.types.commonjs");
const {
NewNotification,
} = require("../notification-wrapper/notification-wrapper");
const { NewNotification } = require("../notification-wrapper/notification-wrapper");
const { WhichRulesetToApply } = require("./constants");
//const Nucleus = require("nucleus-nodejs");
async function ImportJob(filepath) {
const parsedFilePath = path.parse(filepath);
let extensionlessFilePath = path.join(
parsedFilePath.dir,
parsedFilePath.name
);
let extensionlessFilePath = path.join(parsedFilePath.dir, parsedFilePath.name);
const decodedJob = await DecodeAd1File(extensionlessFilePath);
const b = BrowserWindow.getAllWindows()[0];
b.webContents.send(ipcTypes.default.estimate.toRenderer.getCloseDate, {
filepath,
clm_no: decodedJob.CLM_NO,
clm_no: decodedJob.CLM_NO
});
}
@@ -30,43 +25,33 @@ async function ImportJobWithCloseDate(filepath, close_date) {
const newJob = await DecodeEstimate(filepath, false, close_date);
const b = BrowserWindow.getAllWindows()[0];
if (newJob && !newJob.ERROR) {
b.webContents.send(
ipcTypes.default.estimate.toRenderer.estimateDecodeSuccess,
newJob
);
b.webContents.send(ipcTypes.default.estimate.toRenderer.estimateDecodeSuccess, newJob);
log.info(`Sent job for upload. ${newJob.clm_no}`);
NewNotification({
title: "Job Uploaded",
body: "A new job has been uploaded.",
body: "A new job has been uploaded."
});
} else {
log.info(`Ignored job. ${newJob.ERROR}`);
// Nucleus.track("IGNORE_JOB", { reason: newJob.ERROR });
NewNotification({
title: "Job Ignored",
body: newJob.ERROR,
body: newJob.ERROR
});
}
}
exports.ImportJobWithCloseDate = ImportJobWithCloseDate;
async function DecodeEstimate(
filePath,
includeFilePathInReturnJob = false,
close_date = null
) {
async function DecodeEstimate(filePath, includeFilePathInReturnJob = false, close_date = null) {
const parsedFilePath = path.parse(filePath);
let extensionlessFilePath = path.join(
parsedFilePath.dir,
parsedFilePath.name
);
let extensionlessFilePath = path.join(parsedFilePath.dir, parsedFilePath.name);
const job = {
...(await DecodeAd1File(extensionlessFilePath)),
...(await DecodeVehFile(extensionlessFilePath)),
...(await DecodeTtlFile(extensionlessFilePath)),
...(await DecodeLinFile(extensionlessFilePath, close_date)),
...(includeFilePathInReturnJob ? { filePath } : {}),
...(includeFilePathInReturnJob ? { filePath } : {})
};
const ad2 = await DecodeAd2File(extensionlessFilePath);
@@ -85,19 +70,18 @@ async function DecodeEstimate(
if (!accepted_ins_co.includes(job.INS_CO_NM)) {
returnValue = {
ERROR: `Insurance Company Name is not valid for RPS. (${
job.INS_CO_NM || "No name set"
})`,
ERROR: `Insurance Company Name is not valid for RPS. (${job.INS_CO_NM || "No name set"})`
};
} else if (!job.CLM_NO) {
log.info("Job ignored. No claim #. ");
returnValue = {
ERROR: `An unique claim number must be set for all jobs sent to RPS.`,
ERROR: `An unique claim number must be set for all jobs sent to RPS.`
};
} else if (job.CLM_NO.match("02$")) {
log.info("Job ignored. This is an -02 claim. Claim #. " + job.CLM_NO);
} else if (!(job.CLM_NO.match("-01$") || job.CLM_NO.match("-99$"))) {
// 2024-05-10 Only -01 and -99 apply. Refactor logic.
log.info("Job ignored. This is not a -01 or -99 claim. Claim #. " + job.CLM_NO);
returnValue = {
ERROR: "Job ignored. This is an -02 claim. Claim #. " + job.CLM_NO,
ERROR: "Job ignored. This is not a -01 or -99 claim. Claim #. " + job.CLM_NO
};
}
// else if (job.LOSS_TYPE.toLowerCase() === "h") {
@@ -217,7 +201,7 @@ async function DecodeAd1File(extensionlessFilePath) {
"OWNR_LN",
"OWNR_FN",
// "OWNR_TITLE",
"OWNR_CO_NM",
"OWNR_CO_NM"
// "OWNR_ADDR1",
// "OWNR_ADDR2",
// "OWNR_CITY",
@@ -287,7 +271,7 @@ async function DecodeVehFile(extensionlessFilePath) {
"V_MAKEDESC",
"V_MODEL",
"V_TYPE",
"V_MILEAGE",
"V_MILEAGE"
// "V_BSTYLE",
// "V_TRIMCODE",
// "TRIM_COLOR",
@@ -352,8 +336,8 @@ async function DecodeLinFile(extensionlessFilePath, close_date) {
// "PAINT_STG",
// "PAINT_TONE",
// "LBR_TAX",
"LBR_AMT",
"MISC_AMT",
"LBR_AMT",
"MISC_AMT"
// "MISC_SUBLT",
// "MISC_TAX",
// "BETT_TYPE",
@@ -417,8 +401,7 @@ function V1Ruleset(jobline, joblines) {
if (
jobline.part_type === "PAN" &&
jobline.line_desc.toLowerCase().includes("wheel") &&
Math.abs(jobline.prt_dsmk_m) ===
Math.round((jobline.act_price / 2) * 100) / 100
Math.abs(jobline.prt_dsmk_m) === Math.round((jobline.act_price / 2) * 100) / 100
) {
log.info(`Jobline '${jobline.line_desc}' ignored due to wheel repair.`);
jobline.ignore = true;
@@ -426,19 +409,13 @@ function V1Ruleset(jobline, joblines) {
//RPS-39 - OEM ON OEM SAVINGS
//Verified on 08/24/21
if (
jobline.part_type === "PAN" &&
jobline.db_price !== jobline.act_price &&
jobline.db_price !== 0
) {
if (jobline.part_type === "PAN" && jobline.db_price !== jobline.act_price && jobline.db_price !== 0) {
jobline.db_price = jobline.act_price;
}
//Remove all $0DB line items 02/17/2022.
if (
(jobline.part_type === "PAA" ||
jobline.part_type === "PAL" ||
jobline.part_type === "PAN") &&
(jobline.part_type === "PAA" || jobline.part_type === "PAL" || jobline.part_type === "PAN") &&
jobline.db_price === 0
) {
jobline.ignore = true;
@@ -449,22 +426,13 @@ function V1Ruleset(jobline, joblines) {
//Only recycled parts that are changed to $0.00 can be counted towards RPS.
// This is separate from $0.00 DB prices that need to be updated to the manually entered price.
//Verified on 08/24/21
if (
jobline.part_type !== "PAL" &&
jobline.act_price === 0 &&
jobline.price_j
) {
log.info(
`Jobline '${jobline.line_desc}' ignored because it was manually changed to 0..`
);
if (jobline.part_type !== "PAL" && jobline.act_price === 0 && jobline.price_j) {
log.info(`Jobline '${jobline.line_desc}' ignored because it was manually changed to 0..`);
jobline.ignore = true;
}
//09/2021 Detect NAGS lines using RegEx for the Part Number
if (
jobline.line_desc.toLowerCase().includes("glass") &&
jobline.oem_partno.match(`[A-Z]{2}[0-9]{5,6}[A-Z]{3}`)
) {
if (jobline.line_desc.toLowerCase().includes("glass") && jobline.oem_partno.match(`[A-Z]{2}[0-9]{5,6}[A-Z]{3}`)) {
console.log(jobline.line_desc, "NAGS Line ignored");
jobline.ignore = true;
}
@@ -477,8 +445,7 @@ function V1Ruleset(jobline, joblines) {
jobline.line_desc.toLowerCase().startsWith("urethane") ||
jobline.line_desc.toLowerCase().startsWith("w/shield adhesive") ||
//jobline.line_desc.toLowerCase().includes("wheel") || Removed as a part of RPS-41
(jobline.line_desc.toLowerCase().includes("tire") &&
!jobline.line_desc.toLowerCase().includes("sensor")) ||
(jobline.line_desc.toLowerCase().includes("tire") && !jobline.line_desc.toLowerCase().includes("sensor")) ||
jobline.line_desc.toLowerCase().startsWith("hazardous") ||
jobline.line_desc.toLowerCase().startsWith("detail") ||
jobline.line_desc.toLowerCase().startsWith("clean") ||
@@ -497,9 +464,7 @@ function V1Ruleset(jobline, joblines) {
//Calculate the discount to be added as a negative.
jobline.act_price = jobline.prt_dsmk_m;
//Check to see if the parent line has a discount.
const parentLine = joblines.find(
(r) => parseInt(r.unq_seq) === jobline.line_ref
);
const parentLine = joblines.find((r) => parseInt(r.unq_seq) === jobline.line_ref);
if (parentLine && parentLine.ignore) {
jobline.ignore = true;
}
@@ -619,7 +584,7 @@ const AdasDescriptions = [
"air bag gas",
"air bag bracket",
"suspension air bag",
"passenger air bag",
"passenger air bag"
];
const v2GlassLines = [
@@ -633,5 +598,5 @@ const v2GlassLines = [
"sunroof assembly",
"sunroof glass assembly",
"sunroof glass panel",
"sunroof sliding panel",
"sunroof sliding panel"
];