Add SGI rule set.

This commit is contained in:
Patrick Fic
2026-05-04 09:24:52 -07:00
parent 2ca05f1eb7
commit 51cff523f5
3 changed files with 104 additions and 2 deletions

View File

@@ -395,8 +395,10 @@ async function DecodeLinFile(extensionlessFilePath, close_date) {
joblines.map((jobline) => {
jobline.ignore = false;
switch (ins_rule_set) {
case "MPI":
case "SGI":
jobline = SGI_V1Ruleset(jobline, joblines);
break;
case "MPI":
const rulesetToApply = WhichRulesetToApply(close_date);
switch (rulesetToApply) {
@@ -593,6 +595,101 @@ function V3Ruleset(jobline, joblines) {
return jobline;
}
function SGI_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) {
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.db_price === 0
) {
jobline.ignore = true;
}
//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.
//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..`);
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}`)) {
console.log(jobline.line_desc, "NAGS Line ignored");
jobline.ignore = true;
}
//Logic Based Exclusions.
//Verified on 08/24/21
if (
!jobline.part_type ||
jobline.db_ref.startsWith("900") ||
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("label")) ||
jobline.line_desc.toLowerCase().startsWith("hazardous") ||
jobline.line_desc.toLowerCase().startsWith("detail") ||
jobline.line_desc.toLowerCase().startsWith("clean") ||
// jobline.part_type.toUpperCase() === "PAG" ||Removed for RPS-43.
jobline.part_type.toUpperCase() === "PAS" ||
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;
//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);
if (parentLine && parentLine.ignore) {
jobline.ignore = true;
}
}
//RPS-42 Dynamic Inclusion or Exclusion of Lines based on RPS-EXCLUDE or RPS.
if (jobline.oem_partno.toLowerCase().includes("/rps-exclude")) {
jobline.ignore = true;
} else if (jobline.oem_partno.toLowerCase().includes("/rps")) {
jobline.ignore = false;
}
//Copy of SGI V2 - duplicated to prevent impacts to MPI.
//Remove any glass related items.
if (jobline.mod_lbr_ty?.toUpperCase() === "LAG") {
jobline.ignore = true;
}
//ADAS Part Line
if (
AdasDescriptions.some((d) => {
const ret = jobline.line_desc.toLowerCase().includes(d);
return ret;
})
) {
jobline.ignore = true;
}
//Additional glass line exclusions
if (v2GlassLines.some((d) => jobline.line_desc.toLowerCase().includes(d))) {
jobline.ignore = true;
}
return jobline;
}
const AdasDescriptions = [
"seat belt",
"air bag bolt",