Added graphs, fixed rps total calculation
This commit is contained in:
@@ -2,6 +2,7 @@ const { DBFFile } = require("dbffile");
|
||||
const path = require("path");
|
||||
const _ = require("lodash");
|
||||
const log = require("electron-log");
|
||||
const { store } = require("../electron-store");
|
||||
|
||||
async function DecodeEstimate(filePath) {
|
||||
const parsedFilePath = path.parse(filePath);
|
||||
@@ -9,18 +10,34 @@ async function DecodeEstimate(filePath) {
|
||||
parsedFilePath.dir,
|
||||
parsedFilePath.name
|
||||
);
|
||||
const ret = {
|
||||
const job = {
|
||||
...(await DecodeAd1File(extensionlessFilePath)),
|
||||
...(await DecodeVehFile(extensionlessFilePath)),
|
||||
...(await DecodeTtlFile(extensionlessFilePath)),
|
||||
...(await DecodeLinFile(extensionlessFilePath)),
|
||||
};
|
||||
|
||||
if (ret.V_MILEAGE > 20000)
|
||||
return _.transform(ret, function (result, val, key) {
|
||||
const ad2 = await DecodeAd2File(extensionlessFilePath);
|
||||
|
||||
if (job.OWNR_FN === "") job.OWNR_FN = ad2.CLMT_FN;
|
||||
if (job.OWNR_LN === "") job.OWNR_LN = ad2.CLMT_LN;
|
||||
|
||||
const accepted_ins_co = store.get("accepted_ins_co");
|
||||
|
||||
let returnValue;
|
||||
if (job.V_MILEAGE <= 20000) {
|
||||
returnValue = { ERROR: "Vehicle mileage is less than 20,000kms." };
|
||||
} else if (!accepted_ins_co.includes(job.INS_CO_NM)) {
|
||||
returnValue = {
|
||||
ERROR: `Insurance Company Name is not valid for RPS. (${job.INS_CO_NM})`,
|
||||
};
|
||||
} else {
|
||||
returnValue = _.transform(job, function (result, val, key) {
|
||||
result[key.toLowerCase()] = val;
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
async function DecodeAd1File(extensionlessFilePath) {
|
||||
@@ -144,6 +161,13 @@ async function DecodeAd1File(extensionlessFilePath) {
|
||||
// "LOSS_CAT",
|
||||
]);
|
||||
}
|
||||
|
||||
async function DecodeAd2File(extensionlessFilePath) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}B.AD2`);
|
||||
let records = await dbf.readRecords(1);
|
||||
return _.pick(records[0], ["CLMT_LN", "CLMT_FN"]);
|
||||
}
|
||||
|
||||
async function DecodeVehFile(extensionlessFilePath) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}V.VEH`);
|
||||
let records = await dbf.readRecords(1);
|
||||
@@ -299,6 +323,11 @@ async function DecodeLinFile(extensionlessFilePath) {
|
||||
(jobline) =>
|
||||
jobline.part_type &&
|
||||
!jobline.db_ref.startsWith("900") &&
|
||||
!jobline.db_ref.toLowerCase().startsWith("urethane") &&
|
||||
!jobline.db_ref.toLowerCase().startsWith("wheel") &&
|
||||
!jobline.db_ref.toLowerCase().startsWith("hazardous") &&
|
||||
!jobline.db_ref.toLowerCase().startsWith("detail") &&
|
||||
!jobline.db_ref.toLowerCase().startsWith("clean") &&
|
||||
jobline.part_type.toUpperCase() !== "PAG" &&
|
||||
jobline.part_type.toUpperCase() !== "PAS" &&
|
||||
jobline.part_type.toUpperCase() !== "PASL" &&
|
||||
|
||||
Reference in New Issue
Block a user