From 4d5bcae39050882f74807b3f42a07f791c8a0d14 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 2 Apr 2026 14:24:57 -0700 Subject: [PATCH] Rename R4P date, adjust group molecule. --- package.json | 2 +- .../requires-reimport.atom.jsx | 2 +- .../close-date-display.molecule.jsx | 4 +- .../job-group/job-group.molecule.jsx | 24 ++++--- .../jobs-detail-description.molecule.jsx | 12 ++-- .../jobs-group-modal.molecule.jsx | 6 +- .../jobs-targets-stats.molecule.jsx | 6 +- .../reporting-jobs-list.molecule.jsx | 2 +- .../audit-results/audit-results.organism.jsx | 6 +- src/ipc/ipc-estimate-utils.js | 72 ++++++++++--------- src/util/GetJobTarget.js | 4 +- src/util/constants.js | 2 +- 12 files changed, 78 insertions(+), 64 deletions(-) diff --git a/package.json b/package.json index 434091c..33928d1 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "productName": "ImEX RPS", "author": "ImEX Systems Inc. ", "description": "ImEX RPS", - "version": "1.6.0-alpha.4", + "version": "1.6.0-alpha.5", "main": "electron/main.js", "homepage": "./", "dependencies": { diff --git a/src/components/atoms/requires-reimport/requires-reimport.atom.jsx b/src/components/atoms/requires-reimport/requires-reimport.atom.jsx index e3177f7..e922320 100644 --- a/src/components/atoms/requires-reimport/requires-reimport.atom.jsx +++ b/src/components/atoms/requires-reimport/requires-reimport.atom.jsx @@ -5,7 +5,7 @@ export default function RequiresReimportDisplay({ job }) { return ( job.requires_reimport && ( diff --git a/src/components/molecules/close-date-display/close-date-display.molecule.jsx b/src/components/molecules/close-date-display/close-date-display.molecule.jsx index deca1af..bad239c 100644 --- a/src/components/molecules/close-date-display/close-date-display.molecule.jsx +++ b/src/components/molecules/close-date-display/close-date-display.molecule.jsx @@ -28,7 +28,7 @@ export default function CloseDateDisplayMolecule({ job, jobId, close_date }) { notification.open({ type: "warning", message: - "Changing the R4P date has changed the applicable ruleset. Please re-import the job for accurate scoring." + "Changing the close date has changed the applicable ruleset. Please re-import the job for accurate scoring." }); } @@ -44,7 +44,7 @@ export default function CloseDateDisplayMolecule({ job, jobId, close_date }) { }); if (!result.errors) { - message.success("R4P date updated."); + message.success("Close date updated."); } else { message.error("Error updating job."); } diff --git a/src/components/molecules/job-group/job-group.molecule.jsx b/src/components/molecules/job-group/job-group.molecule.jsx index 2d3a94d..4e1fecb 100644 --- a/src/components/molecules/job-group/job-group.molecule.jsx +++ b/src/components/molecules/job-group/job-group.molecule.jsx @@ -9,7 +9,7 @@ import ipcTypes from "../../../ipc.types"; import { selectBodyshop } from "../../../redux/user/user.selectors"; import GroupVerifySwitch from "../group-verify-switch/group-verify-switch.component"; import JobsGroupModalMolecule from "../jobs-group-modal/jobs-group-modal.molecule"; -import { WhichRulesetToApply } from "../../../util/constants"; +import { WhichMPIRulesetToApply } from "../../../util/constants"; const { ipcRenderer } = window; const mapStateToProps = createStructuredSelector({ @@ -45,9 +45,9 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) { setLoading(false); }; - const RulesetToApply = WhichRulesetToApply(job.close_date); - const menu = - RulesetToApply === "V3" ? ( + const MPIRulesetToApply = WhichMPIRulesetToApply(job.close_date); + const MPImenu = + MPIRulesetToApply === "V3" ? ( ({ key: g, title: g, label: g }))}> ); + const SGImenu = ( + + ); + const menuToUse = bodyshop.ins_rule_set === "MPI" ? MPImenu : SGImenu; return ( - + e.preventDefault()}> {group} @@ -93,7 +98,8 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) { )} - + {bodyshop.ins_rule_set === "MPI" && } + {loading && } ); diff --git a/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx b/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx index a985d55..8e76528 100644 --- a/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx +++ b/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx @@ -4,7 +4,7 @@ import { Alert, Button, Descriptions, Skeleton, Space, Tooltip } from "antd"; import moment from "moment"; import { useMemo, useRef } from "react"; import { useReactToPrint } from "react-to-print"; -import { DateFormat, WhichRulesetToApply } from "../../../util/constants"; +import { DateFormat, WhichMPIRulesetToApply } from "../../../util/constants"; import dayjs from "../../../util/day.js"; import CurrencyFormatterAtom from "../../atoms/currency-formatter/currency-formatter.atom"; import DeleteJobAtom from "../../atoms/delete-job/delete-job.atom"; @@ -78,7 +78,7 @@ export function JobsDetailDescriptionMolecule({ bodyshop, loading, job, jobDetai return ( ); - const ruleSetToApply = WhichRulesetToApply(job.close_date); + const MPIRulesetToApply = WhichMPIRulesetToApply(job.close_date); return ( {job.v_age} - R4P Date + + Close Date } > @@ -139,7 +139,7 @@ export function JobsDetailDescriptionMolecule({ bodyshop, loading, job, jobDetai {job.v_mileage} - {ruleSetToApply === "V3" && job.v_mileage < 20000 && ( + {bodyshop.ins_rule_set === "MPI" && MPIRulesetToApply === "V3" && job.v_mileage < 20000 && ( diff --git a/src/components/molecules/jobs-group-modal/jobs-group-modal.molecule.jsx b/src/components/molecules/jobs-group-modal/jobs-group-modal.molecule.jsx index f992a40..b7001c4 100644 --- a/src/components/molecules/jobs-group-modal/jobs-group-modal.molecule.jsx +++ b/src/components/molecules/jobs-group-modal/jobs-group-modal.molecule.jsx @@ -3,7 +3,7 @@ import _ from "lodash"; import React, { useState } from "react"; import { InfoCircleFilled } from "@ant-design/icons"; import { FakedGroupsForV3WithMake } from "../../../ipc/ipc-estimate-utils"; -import { WhichRulesetToApply } from "../../../util/constants"; +import { WhichMPIRulesetToApply } from "../../../util/constants"; import { alphaSort } from "../../../util/sorters"; const data = [ @@ -285,8 +285,8 @@ const data = [ ]; export default function JobsGroupModalMolecule({ job }) { - const RulesetToApply = WhichRulesetToApply(job.close_date); - return RulesetToApply === "V3" ? : ; + const MPIRulesetToApply = WhichMPIRulesetToApply(job.close_date); + return MPIRulesetToApply === "V3" ? : ; } export function JobsGroupPreV3ModalMolecule() { diff --git a/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx b/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx index 43a282a..a49175b 100644 --- a/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx +++ b/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx @@ -7,7 +7,7 @@ import { createStructuredSelector } from "reselect"; import { selectSelectedJobTargetPc } from "../../../redux/application/application.selectors"; import { CalculateJobRpsDollars, CalculateJobRpsPc } from "../../../util/CalculateJobRps"; import ErrorResultAtom from "../../atoms/error-result/error-result.atom"; -import { WhichRulesetToApply } from "../../../util/constants"; +import { WhichMPIRulesetToApply } from "../../../util/constants"; import { selectBodyshop } from "../../../redux/user/user.selectors"; const mapStateToProps = createStructuredSelector({ @@ -38,7 +38,7 @@ export function JobsTargetsStatsMolecule({ loading, job, selectedJobTargetPc, bo const targetRpsDollars = dbPriceSum.percentage(selectedJobTargetPc * 100); const dollarDiff = jobRpsDollars.subtract(targetRpsDollars); - const ruleSetToApply = WhichRulesetToApply(job.close_date); + const MPIRulesetToApply = WhichMPIRulesetToApply(job.close_date); return (
% - {ruleSetToApply === "V3" && job.v_mileage < 20000 && ( + {MPIRulesetToApply === "V3" && job.v_mileage < 20000 && ( diff --git a/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx b/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx index 56f088c..966d08f 100644 --- a/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx +++ b/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx @@ -213,7 +213,7 @@ export function ReportingJobsListMolecule({ {ErroredRecords > 0 && ( )} diff --git a/src/components/organisms/audit-results/audit-results.organism.jsx b/src/components/organisms/audit-results/audit-results.organism.jsx index 493af47..e0392bd 100644 --- a/src/components/organisms/audit-results/audit-results.organism.jsx +++ b/src/components/organisms/audit-results/audit-results.organism.jsx @@ -41,7 +41,7 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud { key: "close_date", width: "12%", - title: "[ImEX RPS] R4P", + title: "[ImEX RPS] Close", dataIndex: "close_date", defaultSortOrder: "ascend", sorter: (a, b) => dateSort(a.close_date, b.close_date), @@ -93,7 +93,7 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud }, { key: "close_date", - title: "[ImEX RPS] R4P", + title: "[ImEX RPS] Close", dataIndex: "close_date", defaultSortOrder: "ascend", sorter: (a, b) => dateSort(a.rps.close_date, b.rps.close_date), @@ -102,7 +102,7 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud { key: "close_date_audit", width: "12%", - title: "[MPI Audit] R4P", + title: "[MPI Audit] Close", dataIndex: "close_date_audit", sorter: (a, b) => dateSort(a.audit.close_date, b.audit.close_date), diff --git a/src/ipc/ipc-estimate-utils.js b/src/ipc/ipc-estimate-utils.js index f0080da..e8c85cd 100644 --- a/src/ipc/ipc-estimate-utils.js +++ b/src/ipc/ipc-estimate-utils.js @@ -7,7 +7,7 @@ import { QUERY_GROUPS_BY_MAKE_TYPE } from "../graphql/veh_group.queries"; import ipcTypes from "../ipc.types"; import { clearEsResults } from "../redux/application/application.actions.js"; import { store } from "../redux/store"; -import { WhichRulesetToApply } from "../util/constants.js"; +import { WhichMPIRulesetToApply } from "../util/constants.js"; import dayjs from "../util/day.js"; import CargoVanList from "./cargovans.json"; import PassengerVanList from "./passengervans.json"; @@ -304,41 +304,49 @@ const DetermineVehicleGroup = async (job) => { job.v_type ? job.v_type.toUpperCase() : null ); //Need to add a ruleset check here. If using V3, then we need to check against a different table. + const ins_rule_set = store.getState().user.bodyshop.ins_rule_set; - const RulesetToApply = WhichRulesetToApply(job.close_date); + switch (ins_rule_set) { + case "SGI": + logger.info("SGI doesn't use vehicle groups, returning null."); + return "Default"; + case "MPI": + default: + const MPIRulesetToApply = WhichMPIRulesetToApply(job.close_date); - if (RulesetToApply === "V3") { - const target = V3GroupFinder(job); + if (MPIRulesetToApply === "V3") { + const target = V3GroupFinder(job); - return target?.group || "Default"; - } else { - const vehicleGroups = await client.query({ - query: QUERY_GROUPS_BY_MAKE_TYPE, - variables: { - make: job.v_makedesc.toUpperCase(), - type: job.v_type, - date: dayjs().format("YYYY-MM-DD") + return target?.group || "Default"; + } else { + const vehicleGroups = await client.query({ + query: QUERY_GROUPS_BY_MAKE_TYPE, + variables: { + make: job.v_makedesc.toUpperCase(), + type: job.v_type, + date: dayjs().format("YYYY-MM-DD") + } + }); + + if (vehicleGroups.data.groupings.length === 1) { + logger.info("Found 1 vehicle group.!", vehicleGroups.data.groupings[0]); + return vehicleGroups.data.groupings[0].group; + } else if (vehicleGroups.data.groupings.length === 0) { + //Uh-oh, should only be 1. + logger.info("No vehicle groups found."); + return null; + } else { + //Should never be here. + alert("Fatal error. Multiple vehicle groups found for this claim."); + logger.error( + "Found multiple vehicle groups!", + job.v_makedesc.toUpperCase(), + job.v_type ? job.v_type.toUpperCase() : null + ); + } + + return ""; } - }); - - if (vehicleGroups.data.groupings.length === 1) { - logger.info("Found 1 vehicle group.!", vehicleGroups.data.groupings[0]); - return vehicleGroups.data.groupings[0].group; - } else if (vehicleGroups.data.groupings.length === 0) { - //Uh-oh, should only be 1. - logger.info("No vehicle groups found."); - return null; - } else { - //Should never be here. - alert("Fatal error. Multiple vehicle groups found for this claim."); - logger.error( - "Found multiple vehicle groups!", - job.v_makedesc.toUpperCase(), - job.v_type ? job.v_type.toUpperCase() : null - ); - } - - return ""; } }; diff --git a/src/util/GetJobTarget.js b/src/util/GetJobTarget.js index 416d2c0..34ad168 100644 --- a/src/util/GetJobTarget.js +++ b/src/util/GetJobTarget.js @@ -1,6 +1,6 @@ import { V3TargetFinder } from "../ipc/ipc-estimate-utils"; import { store } from "../redux/store"; -import { WhichRulesetToApply } from "./constants"; +import { WhichMPIRulesetToApply } from "./constants"; export default function GetJobTarget({ group, v_age, targets, close_date, v_mileage, job }) { const ins_rule_set = store.getState().user.bodyshop.ins_rule_set; @@ -13,7 +13,7 @@ export default function GetJobTarget({ group, v_age, targets, close_date, v_mile default: const newTargets = store.getState().user.targets; - const rulesToApply = WhichRulesetToApply(close_date); + const rulesToApply = WhichMPIRulesetToApply(close_date); if (rulesToApply === "V3") { //V3 Check - If vehicle is less than 20,000KM, there is NO TARGET. if (v_mileage && v_mileage <= 20000) { diff --git a/src/util/constants.js b/src/util/constants.js index a021847..d36ba9e 100644 --- a/src/util/constants.js +++ b/src/util/constants.js @@ -28,7 +28,7 @@ export function ChangeOfRuleSet({ prevDateMoment = dayjs(), newDateMoment = dayj return prevRuleSet?.title !== newRuleSet?.title; } -export function WhichRulesetToApply(close_date) { +export function WhichMPIRulesetToApply(close_date) { const DateMoment = close_date ? dayjs(close_date) : dayjs(); const newRuleSet = RuleSets.find((r) => DateMoment.isSameOrAfter(r.range[0]) && DateMoment.isBefore(r.range[1])); //console.log("Using ruleset:", newRuleSet);