Added vehicle groups and age calculations.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user