Add line discounting & remove NA ignores & reset ignore values on reimport.

This commit is contained in:
Patrick Fic
2021-05-20 14:07:18 -07:00
parent 0a330b66b6
commit 7d529c3155
4 changed files with 50 additions and 74 deletions

View File

@@ -279,61 +279,6 @@ async function DecodeLinFile(extensionlessFilePath) {
let records = await dbf.readRecords();
let joblines = records
.map((record) => {
try {
console.log(
"Trying pick",
_.pick(record, [
"LINE_NO",
"LINE_IND",
// "LINE_REF",
// "TRAN_CODE",
"DB_REF",
"UNQ_SEQ",
// "WHO_PAYS",
"LINE_DESC",
"PART_TYPE",
// "PART_DESCJ",
"PRT_DSMK_M",
"OEM_PARTNO",
// "PRICE_INC",
// "ALT_PART_I",
// "TAX_PART",
"DB_PRICE",
"ACT_PRICE",
"PART_QTY",
"PRICE_J",
"GLASS_FLAG",
// "CERT_PART",
// "ALT_CO_ID",
// "ALT_PARTNO",
// "ALT_OVERRD",
// "ALT_PARTM",
// "PRT_DSMK_P",
// "MOD_LBR_TY",
// "DB_HRS",
// "MOD_LB_HRS",
// "LBR_INC",
// "LBR_OP",
// "LBR_HRS_J",
// "LBR_TYP_J",
// "LBR_OP_J",
// "PAINT_STG",
// "PAINT_TONE",
// "LBR_TAX",
// "LBR_AMT",
// "MISC_AMT",
// "MISC_SUBLT",
// "MISC_TAX",
// "BETT_TYPE",
// "BETT_PCTG",
// "BETT_AMT",
// "BETT_TAX",
])
);
} catch (error) {
console.log(error);
}
return _.transform(
_.pick(record, [
"LINE_NO",
@@ -361,7 +306,7 @@ async function DecodeLinFile(extensionlessFilePath) {
// "ALT_PARTNO",
// "ALT_OVERRD",
// "ALT_PARTM",
// "PRT_DSMK_P",
"PRT_DSMK_P",
// "MOD_LBR_TY",
// "DB_HRS",
@@ -385,7 +330,7 @@ async function DecodeLinFile(extensionlessFilePath) {
]),
function (result, val, key) {
//Required because unq_seq gets pulled as a numeric instaed of a string.
console.log(result, val, key);
if (key === "UNQ_SEQ") {
result[key.toLowerCase()] = val.toString();
return;
@@ -442,6 +387,8 @@ async function DecodeLinFile(extensionlessFilePath) {
// jobline.ignore = true;
// }
jobline.ignore = false;
//Wheel Repair Pricing PRS-82
if (
jobline.part_type === "PAN" &&
@@ -452,14 +399,16 @@ async function DecodeLinFile(extensionlessFilePath) {
log.info(`Jobline '${jobline.line_desc}' ignored due to wheel repair.`);
jobline.ignore = true;
}
//RPS-46 Ignore NA Line Items.
if (
jobline.part_type === "PAN" &&
jobline.price_j === true &&
jobline.db_price === 0
) {
jobline.ignore = true;
}
//Removed on 05/20. We are seeing more $0DB lines than NA lines and they are getting incorrectly ignored.
// if (
// jobline.part_type === "PAN" &&
// jobline.price_j === true &&
// jobline.db_price === 0
// ) {
// jobline.ignore = true;
// }
//RPS-39 - OEM ON OEM SAVINGS
if (
@@ -479,6 +428,20 @@ async function DecodeLinFile(extensionlessFilePath) {
jobline.db_price = jobline.act_price;
}
//05/20
//Well have to apply a rule that will not count any A/M, Reman or new part price that is manually changed to $0.00. 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.
// 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;
// }
// if (
// !!jobline.db_price &&
// jobline.db_price > 0 &&
@@ -509,8 +472,16 @@ async function DecodeLinFile(extensionlessFilePath) {
jobline.part_type.toUpperCase() === "PASL" ||
jobline.part_type.toUpperCase() === "PAE"
//jobline.glass_flag === true //Removed for RPS-43.
)
) {
jobline.ignore = true;
}
//Check to see if this is a discount line i.e. a 900511
if (jobline.db_ref === "900511" && jobline.prt_dsmk_p !== 50) {
jobline.ignore = false;
console.log("dsmk_d", jobline.prt_dsmk_p);
//Calculate the discount to be added as a negative.
jobline.act_price = jobline.prt_dsmk_m;
}
//RPS-42 Dynamic Inclusion or Exclusion of Lines based on RPS-EXCLUDE or RPS.
if (jobline.oem_partno.toLowerCase().includes("/rps-exclude")) {
@@ -520,6 +491,7 @@ async function DecodeLinFile(extensionlessFilePath) {
}
delete jobline.prt_dsmk_m; //Delete price markup for wheel repair
delete jobline.prt_dsmk_p;
delete jobline.glass_flag;
delete jobline.price_j;
return jobline;