Rename R4P date, adjust group molecule.

This commit is contained in:
Patrick Fic
2026-04-02 14:24:57 -07:00
parent 152e4cb23a
commit 4d5bcae390
12 changed files with 78 additions and 64 deletions

View File

@@ -3,7 +3,7 @@
"productName": "ImEX RPS",
"author": "ImEX Systems Inc. <support@thinkimex.com>",
"description": "ImEX RPS",
"version": "1.6.0-alpha.4",
"version": "1.6.0-alpha.5",
"main": "electron/main.js",
"homepage": "./",
"dependencies": {

View File

@@ -5,7 +5,7 @@ export default function RequiresReimportDisplay({ job }) {
return (
job.requires_reimport && (
<CloudUploadOutlined
title="A change in R4P date changed the applicable rules. Import this job again for accurate scoring."
title="A change in close date changed the applicable rules. Import this job again for accurate scoring."
style={{ marginLeft: ".5rem", color: "tomato" }}
className="blink_me"
/>

View File

@@ -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.");
}

View File

@@ -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" ? (
<Menu
onClick={handleMenuClick}
//disabled
@@ -70,13 +70,18 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) {
) : (
<Menu onClick={handleMenuClick} items={bodyshop.groups.map((g, idx) => ({ key: g, title: g, label: g }))}></Menu>
);
const SGImenu = (
<Menu
onClick={handleMenuClick}
//disabled
items={[{ label: "Default", key: "Default", value: "Default" }]}
></Menu>
);
const menuToUse = bodyshop.ins_rule_set === "MPI" ? MPImenu : SGImenu;
return (
<Space align="top">
<Dropdown
overlay={menu} //disabled={RulesetToApply === "V3"}
trigger={["click"]}
>
<Dropdown overlay={menuToUse} trigger={["click"]}>
<a href=" #" onClick={(e) => e.preventDefault()}>
{group}
<DownOutlined style={{ marginLeft: ".2rem" }} />
@@ -93,7 +98,8 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) {
<GroupVerifySwitch job={job} loading={loading} loadingCallback={setLoading} />
</div>
)}
<JobsGroupModalMolecule job={job} />
{bodyshop.ins_rule_set === "MPI" && <JobsGroupModalMolecule job={job} />}
{loading && <LoadingOutlined />}
</Space>
);

View File

@@ -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 (
<ErrorResultAtom title="Error displaying job header data." errorMessage="It looks like this job doesn't exist." />
);
const ruleSetToApply = WhichRulesetToApply(job.close_date);
const MPIRulesetToApply = WhichMPIRulesetToApply(job.close_date);
return (
<PageHeader
@@ -88,7 +88,7 @@ export function JobsDetailDescriptionMolecule({ bodyshop, loading, job, jobDetai
job.requires_reimport && (
<Tooltip
key="reimport"
title="There are different rules that apply for claims submitted in different periods. In order to ensure accurate calculation, you must import this job again to determine which parts are eligible for parts autonomy. This happened because the R4P date was changed between these periods."
title="There are different rules that apply for claims submitted in different periods. In order to ensure accurate calculation, you must import this job again to determine which parts are eligible for parts autonomy. This happened because the close date was changed between these periods."
>
<Alert
type="warning"
@@ -118,8 +118,8 @@ export function JobsDetailDescriptionMolecule({ bodyshop, loading, job, jobDetai
<Descriptions.Item label="Age">{job.v_age}</Descriptions.Item>
<Descriptions.Item
label={
<Tooltip title="This is the date you will submit for payment from MPI. This should always be the latest date in the case of supplements.">
R4P Date
<Tooltip title="This is the date you will submit for payment. This should always be the latest date in the case of supplements.">
Close Date
</Tooltip>
}
>
@@ -139,7 +139,7 @@ export function JobsDetailDescriptionMolecule({ bodyshop, loading, job, jobDetai
<Descriptions.Item label="Mileage">
<Space size="small">
{job.v_mileage}
{ruleSetToApply === "V3" && job.v_mileage < 20000 && (
{bodyshop.ins_rule_set === "MPI" && MPIRulesetToApply === "V3" && job.v_mileage < 20000 && (
<Tooltip title="Vehicle is under 20,000 KMs. No expected savings.">
<WarningOutlined style={{ color: "seagreen" }} />
</Tooltip>

View File

@@ -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" ? <JobsGroupV3ModalMolecule /> : <JobsGroupPreV3ModalMolecule />;
const MPIRulesetToApply = WhichMPIRulesetToApply(job.close_date);
return MPIRulesetToApply === "V3" ? <JobsGroupV3ModalMolecule /> : <JobsGroupPreV3ModalMolecule />;
}
export function JobsGroupPreV3ModalMolecule() {

View File

@@ -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 (
<div
@@ -57,7 +57,7 @@ export function JobsTargetsStatsMolecule({ loading, job, selectedJobTargetPc, bo
suffix={
<Space size="small">
%
{ruleSetToApply === "V3" && job.v_mileage < 20000 && (
{MPIRulesetToApply === "V3" && job.v_mileage < 20000 && (
<Tooltip title="Vehicle is under 20,000 KMs. No expected savings.">
<WarningOutlined style={{ color: "seagreen" }} />
</Tooltip>

View File

@@ -213,7 +213,7 @@ export function ReportingJobsListMolecule({
{ErroredRecords > 0 && (
<Alert
showIcon
message={`${ErroredRecords} job(s) may have innacurate data due to R4P and applicable rule changes. Please import them again.`}
message={`${ErroredRecords} job(s) may have innacurate data due to close date and applicable rule changes. Please import them again.`}
type="warning"
/>
)}

View File

@@ -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),

View File

@@ -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 "";
}
};

View File

@@ -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) {

View File

@@ -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);