Added vehicle groups and age calculations.

This commit is contained in:
Patrick Fic
2020-10-16 11:51:53 -07:00
parent 827243e11f
commit 4582bd0f4d
70 changed files with 1793 additions and 213 deletions

View File

@@ -4,14 +4,20 @@ const _ = require("lodash");
async function DecodeEstimate(filePath) {
const parsedFilePath = path.parse(filePath);
let extensionlessFilePath = `${parsedFilePath.dir}\\${parsedFilePath.name}`;
let extensionlessFilePath = path.join(
parsedFilePath.dir,
parsedFilePath.name
);
console.log("DecodeEstimate -> extensionlessFilePath", extensionlessFilePath);
const ret = {
...(await DecodeAd1File(extensionlessFilePath)),
...(await DecodeVehFile(extensionlessFilePath)),
...(await DecodeTtlFile(extensionlessFilePath)),
...(await DecodeLinFile(extensionlessFilePath)),
};
return ret;
if (ret.V_MILEAGE > 20000) return ret;
return null;
}
async function DecodeAd1File(extensionlessFilePath) {
@@ -32,7 +38,7 @@ async function DecodeAd1File(extensionlessFilePath) {
// "DED_AMT",
// "DED_STATUS",
// "ASGN_NO",
// "ASGN_DATE",
//"ASGN_DATE",
// "ASGN_TYPE",
"CLM_NO",
// "CLM_OFC_ID",
@@ -80,7 +86,7 @@ async function DecodeAd1File(extensionlessFilePath) {
// "AGT_CT_PHX",
// "AGT_EA",
// "AGT_LIC_NO",
// "LOSS_DATE",
"LOSS_DATE",
// "LOSS_TYPE",
// "LOSS_DESC",
// "THEFT_IND",
@@ -152,6 +158,7 @@ async function DecodeVehFile(extensionlessFilePath) {
"V_MAKEDESC",
"V_MODEL",
"V_TYPE",
"V_MILEAGE",
// "V_BSTYLE",
// "V_TRIMCODE",
// "TRIM_COLOR",
@@ -178,17 +185,17 @@ async function DecodeLinFile(extensionlessFilePath) {
let joblines = records.map((record) =>
_.transform(
_.pick(record, [
// "LINE_NO",
"LINE_NO",
"LINE_IND",
// "LINE_REF",
// "TRAN_CODE",
// "DB_REF",
"DB_REF",
"UNQ_SEQ",
// "WHO_PAYS",
"LINE_DESC",
"PART_TYPE",
// "PART_DESCJ",
// "GLASS_FLAG",
"GLASS_FLAG",
"OEM_PARTNO",
// "PRICE_INC",
// "ALT_PART_I",
@@ -225,6 +232,7 @@ async function DecodeLinFile(extensionlessFilePath) {
// "BETT_TAX",
]),
function (result, val, key) {
//Required because unq_seq gets pulled as a numeric instaed of a string.
if (key === "UNQ_SEQ") {
return (result[key.toLowerCase()] = val.toString());
}
@@ -232,7 +240,39 @@ async function DecodeLinFile(extensionlessFilePath) {
}
)
);
return { joblines: { data: joblines } };
//Perform required RPS Validations.
//Update DB Prices.
const massagedJobLines = joblines
.filter(
(jobline) =>
!jobline.db_ref.startsWith("900") &&
(jobline.part_type && jobline.part_type.toUpperCase()) !== "PAG" &&
jobline.glass_flag === false
)
.map((jobline) => {
//
if (
(jobline.db_price === null || jobline.db_price === 0) &&
!!jobline.act_price &&
jobline.act_price > 0
) {
jobline.db_price = jobline.act_price;
}
if (
jobline.db_price &&
jobline.act_price &&
jobline.act_price > jobline.db_price
) {
jobline.db_price = jobline.act_price;
}
delete jobline.glass_flag;
return jobline;
});
return { joblines: { data: massagedJobLines } };
}
exports.DecodeEstimate = DecodeEstimate;

View File

@@ -11,7 +11,7 @@ const {
var watcher;
function StartWatcher() {
async function StartWatcher() {
const filePaths =
store.get("filePaths").map((fp) => path.join(fp, "**.[eE][nN][vV]")) || [];
console.log("StartWatcher -> filePaths", filePaths);
@@ -26,8 +26,10 @@ function StartWatcher() {
if (watcher) {
try {
console.log("Trying to close watcher - it already existed.");
watcher.close().then();
console.log("Trying to close watcher - it already existed.111");
await watcher.close();
console.log("Watcher closed successfully!");
} catch (error) {
console.log("Error trying to close Watcher.", error);
}
@@ -71,6 +73,7 @@ function StartWatcher() {
// This event should be triggered everytime something happens.
// console.log("Raw event info:", event, path, details);
});
return filePaths;
}
@@ -107,13 +110,21 @@ async function HandleNewFile(path) {
result[key.toLowerCase()] = val;
});
b.webContents.send(
ipcTypes.default.estimate.toRenderer.estimateDecodeSuccess,
newJobLow
);
if (newJobLow && newJob) {
b.webContents.send(
ipcTypes.default.estimate.toRenderer.estimateDecodeSuccess,
newJobLow
);
NewNotification({
title: "Job Uploaded",
body: "A new job has been uploaded.",
}).show();
NewNotification({
title: "Job Uploaded",
body: "A new job has been uploaded.",
}).show();
} else {
NewNotification({
title: "Job Ignored",
body:
"The job was not uploaded because it does not meet RPS requirements.",
}).show();
}
}

View File

@@ -86,6 +86,7 @@ app.whenReady().then(() => {
if (isDev) {
console.log(`Path to Settings File: ${store.path}`);
console.log(`Path to Log File: ${log.log}`);
installExtension(REACT_DEVELOPER_TOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((error) => console.log(`An error occurred: , ${error}`));

View File

@@ -1,7 +1,26 @@
console.log("Running preloader!");
const { contextBridge, ipcRenderer } = require("electron");
const log = require("electron-log");
//ipcRenderer.removeAllListeners();
contextBridge.exposeInMainWorld("logger", {
info: (...msg) => {
log.info(...msg);
},
debug: (...msg) => {
log.debug(...msg);
},
warn: (...msg) => {
log.warn(...msg);
},
error: (...msg) => {
log.error(...msg);
},
silly: (...msg) => {
log.silly(...msg);
},
});
ipcRenderer.removeAllListeners();
contextBridge.exposeInMainWorld("ipcRenderer", {
send: (channel, data) => {
// whitelist channels