From 946fd03fa61e7453dddb24f43725bd781f4cab4b Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 5 May 2026 12:02:20 -0700 Subject: [PATCH] Add in RCC toggle & use parts threshold inclusion. --- electron/changelog.json | 5 + electron/decoder/decoder.js | 5 + electron/main-src.js | 4 +- .../databases/default/tables/public_jobs.yaml | 141 +++++++++--------- .../down.sql | 4 + .../up.sql | 2 + package.json | 2 +- .../job-group/job-group.molecule.jsx | 13 +- .../jobs-targets-stats.molecule.jsx | 5 + .../sgi-rcc-switch.component.jsx | 46 ++++++ src/graphql/jobs.queries.js | 3 + src/graphql/reporting.queries.js | 1 + src/redux/reporting/reporting.actions.js | 4 + src/redux/reporting/reporting.reducer.js | 11 ++ src/redux/reporting/reporting.types.js | 3 +- src/util/GetJobTarget.js | 4 + 16 files changed, 177 insertions(+), 76 deletions(-) create mode 100644 hasura/migrations/default/1778000277781_alter_table_public_jobs_add_column_sgi_rcc/down.sql create mode 100644 hasura/migrations/default/1778000277781_alter_table_public_jobs_add_column_sgi_rcc/up.sql create mode 100644 src/components/molecules/sgi-rcc-switch/sgi-rcc-switch.component.jsx diff --git a/electron/changelog.json b/electron/changelog.json index fda911f..0f056a8 100644 --- a/electron/changelog.json +++ b/electron/changelog.json @@ -213,5 +213,10 @@ "title": "Release Notes for 1.6.0-beta.2", "date": "05/04/2026", "notes": "New Features:\r\n* Added projected targets for SGI claims.\r\n" + }, + "1.6.0-beta.3": { + "title": "Release Notes for 1.6.0-beta.3", + "date": "05/05/2026", + "notes": "New Features:\r\n* Added a toggle for SGI RCC Claims to set targets to $0.\r\n* Added handling for used parts thresholds for SGI claims. Please re-import previous jobs for accurate scoring." } } diff --git a/electron/decoder/decoder.js b/electron/decoder/decoder.js index 88b19f4..8bb29da 100644 --- a/electron/decoder/decoder.js +++ b/electron/decoder/decoder.js @@ -687,6 +687,11 @@ function SGI_V1Ruleset(jobline, joblines) { jobline.ignore = true; } + //Is it the use parts line threshold? Added at the end to undo the 900500 lines. + if (jobline.line_desc.toUpperCase().includes("USED PARTS THRESHOLD")) { + jobline.ignore = false; + } + return jobline; } diff --git a/electron/main-src.js b/electron/main-src.js index 444d445..766830f 100644 --- a/electron/main-src.js +++ b/electron/main-src.js @@ -8,7 +8,7 @@ const log = require("electron-log"); const contextMenu = require("electron-context-menu"); const Sentry = require("@sentry/electron/main"); -const enableDevTools = true; // Always enable dev tools (was: isDev || process.env.ELECTRON_ENABLE_DEVTOOLS === "1") +const enableDevTools = isDev || process.env.ELECTRON_ENABLE_DEVTOOLS === "1"; // Always enable dev tools (was: isDev || process.env.ELECTRON_ENABLE_DEVTOOLS === "1") //const Nucleus = require("nucleus-nodejs"); require("./ipc-main-handler"); @@ -204,7 +204,7 @@ function createWindow() { // Open the DevTools when explicitly enabled. if (enableDevTools) { mainWindow.webContents.openDevTools({ - mode: "detach" + // mode: "detach" }); } diff --git a/hasura/metadata/databases/default/tables/public_jobs.yaml b/hasura/metadata/databases/default/tables/public_jobs.yaml index 6acece6..8cb02e2 100644 --- a/hasura/metadata/databases/default/tables/public_jobs.yaml +++ b/hasura/metadata/databases/default/tables/public_jobs.yaml @@ -23,88 +23,90 @@ insert_permissions: authid: _eq: X-Hasura-User-Id columns: - - id - bodyshopid - - created_at - - updated_at - - ro_number - - ins_co_nm - clm_no - clm_total - - ownr_ln - - ownr_fn - - v_vin - - v_makedesc - - v_model - - v_model_yr - - v_type - - group - - v_mileage - - v_age - - loss_date - close_date - - group_verified - - requires_reimport + - created_at - ded_amt - - loss_desc - - ownr_addr1 - - ownr_city - - ownr_ph1 - - v_stage - - rates - - totals - - supp_amt + - est_system - g_bett_amt + - group + - group_verified + - id - id_pro_nam - impact_1 - impact_2 - - est_system - - tlos_ind - - theft_ind + - ins_co_nm - insp_date + - loss_date + - loss_desc + - ownr_addr1 + - ownr_city + - ownr_fn + - ownr_ln + - ownr_ph1 + - rates + - requires_reimport + - ro_number + - sgi_rcc + - supp_amt + - theft_ind + - tlos_ind + - totals + - updated_at + - v_age + - v_makedesc + - v_mileage + - v_model + - v_model_yr + - v_stage + - v_type + - v_vin select_permissions: - role: user permission: columns: - - group_verified - - requires_reimport - - theft_ind - - tlos_ind - - close_date - - insp_date - - loss_date - - rates - - totals - - clm_total - - ded_amt - - g_bett_amt - - supp_amt - - v_age - - v_mileage - - v_stage + - bodyshopid - clm_no + - clm_total + - close_date + - created_at + - ded_amt - est_system + - g_bett_amt - group + - group_verified + - id - id_pro_nam - impact_1 - impact_2 - ins_co_nm + - insp_date + - loss_date - loss_desc - ownr_addr1 - ownr_city - ownr_fn - ownr_ln - ownr_ph1 + - rates + - requires_reimport - ro_number + - sgi_rcc + - supp_amt + - theft_ind + - tlos_ind + - totals + - updated_at + - v_age - v_makedesc + - v_mileage - v_model - v_model_yr + - v_stage - v_type - v_vin - - created_at - - updated_at - - bodyshopid - - id filter: bodyshop: associations: @@ -116,45 +118,46 @@ update_permissions: - role: user permission: columns: - - group_verified - - requires_reimport - - theft_ind - - tlos_ind - - close_date - - insp_date - - loss_date - - rates - - totals - - clm_total - - ded_amt - - g_bett_amt - - supp_amt - - v_age - - v_mileage - - v_stage + - bodyshopid - clm_no + - clm_total + - close_date + - created_at + - ded_amt - est_system + - g_bett_amt - group + - group_verified + - id - id_pro_nam - impact_1 - impact_2 - ins_co_nm + - insp_date + - loss_date - loss_desc - ownr_addr1 - ownr_city - ownr_fn - ownr_ln - ownr_ph1 + - rates + - requires_reimport - ro_number + - sgi_rcc + - supp_amt + - theft_ind + - tlos_ind + - totals + - updated_at + - v_age - v_makedesc + - v_mileage - v_model - v_model_yr + - v_stage - v_type - v_vin - - created_at - - updated_at - - bodyshopid - - id filter: bodyshop: associations: diff --git a/hasura/migrations/default/1778000277781_alter_table_public_jobs_add_column_sgi_rcc/down.sql b/hasura/migrations/default/1778000277781_alter_table_public_jobs_add_column_sgi_rcc/down.sql new file mode 100644 index 0000000..ceb6476 --- /dev/null +++ b/hasura/migrations/default/1778000277781_alter_table_public_jobs_add_column_sgi_rcc/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."jobs" add column "sgi_rcc" boolean +-- null; diff --git a/hasura/migrations/default/1778000277781_alter_table_public_jobs_add_column_sgi_rcc/up.sql b/hasura/migrations/default/1778000277781_alter_table_public_jobs_add_column_sgi_rcc/up.sql new file mode 100644 index 0000000..cc92e1e --- /dev/null +++ b/hasura/migrations/default/1778000277781_alter_table_public_jobs_add_column_sgi_rcc/up.sql @@ -0,0 +1,2 @@ +alter table "public"."jobs" add column "sgi_rcc" boolean + null; diff --git a/package.json b/package.json index cbc2d45..148432b 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-beta.2", + "version": "1.6.0-beta.3", "main": "electron/main.js", "homepage": "./", "dependencies": { diff --git a/src/components/molecules/job-group/job-group.molecule.jsx b/src/components/molecules/job-group/job-group.molecule.jsx index 9ecf37d..7ca78b1 100644 --- a/src/components/molecules/job-group/job-group.molecule.jsx +++ b/src/components/molecules/job-group/job-group.molecule.jsx @@ -1,6 +1,6 @@ import { AlertFilled, DownOutlined, LoadingOutlined } from "@ant-design/icons"; import { useMutation } from "@apollo/client"; -import { Dropdown, Menu, message, Space } from "antd"; +import { Dropdown, Menu, message, Space, Tooltip } from "antd"; import React, { useState } from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -10,6 +10,7 @@ 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 { WhichMPIRulesetToApply } from "../../../util/constants"; +import SGIRccSwitch from "../sgi-rcc-switch/sgi-rcc-switch.component"; const { ipcRenderer } = window; const mapStateToProps = createStructuredSelector({ @@ -80,7 +81,7 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) { const menuToUse = bodyshop.ins_rule_set === "MPI" ? MPImenu : SGImenu; return ( - + e.preventDefault()}> {group} @@ -93,11 +94,17 @@ export function JobGroupMolecule({ bodyshop, jobId, group, job }) { No group set. )} - {group && ( + {bodyshop.ins_rule_set === "MPI" && group && (
)} + + {bodyshop.ins_rule_set === "SGI" && ( + + + + )} {loading && } 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 4928b99..3137977 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 @@ -63,6 +63,11 @@ export function JobsTargetsStatsMolecule({ loading, job, selectedJobTargetPc, bo )} + {bodyshop.ins_rule_set === "SGI" && job.sgi_rcc && ( + + + + )}
} style={{ margin: "0rem .5rem" }} diff --git a/src/components/molecules/sgi-rcc-switch/sgi-rcc-switch.component.jsx b/src/components/molecules/sgi-rcc-switch/sgi-rcc-switch.component.jsx new file mode 100644 index 0000000..a09ab44 --- /dev/null +++ b/src/components/molecules/sgi-rcc-switch/sgi-rcc-switch.component.jsx @@ -0,0 +1,46 @@ +import { CheckOutlined, CloseOutlined } from "@ant-design/icons"; +import { useMutation } from "@apollo/client"; +import { message, Switch } from "antd"; +import React from "react"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { UPDATE_JOB } from "../../../graphql/jobs.queries"; +import { toggleSGIRcc } from "../../../redux/reporting/reporting.actions"; + +const mapStateToProps = createStructuredSelector({}); + +const mapDispatchToProps = (dispatch) => ({ + toggleSGIRcc: (jobId) => dispatch(toggleSGIRcc(jobId)) +}); + +export default connect(mapStateToProps, mapDispatchToProps)(SGIRccSwitch); + +export function SGIRccSwitch({ job, loading, loadingCallback, toggleSGIRcc }) { + const [updateJob] = useMutation(UPDATE_JOB); + + const handleChange = async (val) => { + if (loadingCallback) loadingCallback(true); + const result = await updateJob({ + variables: { jobId: job.id, job: { sgi_rcc: val } } + }); + + if (!result.errors) { + message.success("Vehicle group updated."); + toggleSGIRcc(job.id); + } else { + message.error("Error updating job."); + } + if (loadingCallback) loadingCallback(false); + }; + + return ( + + ); +} diff --git a/src/graphql/jobs.queries.js b/src/graphql/jobs.queries.js index bd9b14f..c0e06e5 100644 --- a/src/graphql/jobs.queries.js +++ b/src/graphql/jobs.queries.js @@ -94,6 +94,7 @@ export const QUERY_JOB_BY_PK = gql` updated_at group group_verified + sgi_rcc v_age v_type loss_date @@ -175,6 +176,7 @@ export const UPDATE_JOB = gql` v_age group group_verified + sgi_rcc requires_reimport v_mileage joblines(order_by: { line_no: asc }) { @@ -218,6 +220,7 @@ export const QUERY_JOB_ESTIMATE_SCRUBBER = gql` updated_at group group_verified + sgi_rcc v_age v_type loss_date diff --git a/src/graphql/reporting.queries.js b/src/graphql/reporting.queries.js index 36b85ef..ee6321c 100644 --- a/src/graphql/reporting.queries.js +++ b/src/graphql/reporting.queries.js @@ -16,6 +16,7 @@ export const REPORTING_GET_JOBS = gql` ins_co_nm group group_verified + sgi_rcc clm_total clm_no close_date diff --git a/src/redux/reporting/reporting.actions.js b/src/redux/reporting/reporting.actions.js index 200c7a7..b37a496 100644 --- a/src/redux/reporting/reporting.actions.js +++ b/src/redux/reporting/reporting.actions.js @@ -26,6 +26,10 @@ export const toggleGroupVerified = (jobId) => ({ type: ReportingActionTypes.TOGGLE_GROUP_VERIFIED, payload: jobId }); +export const toggleSGIRcc = (jobId) => ({ + type: ReportingActionTypes.TOGGLE_SGI_RCC, + payload: jobId +}); export const calculateAudit = (claimsArrayFromAudit) => ({ type: ReportingActionTypes.CALCULATE_AUDIT, payload: claimsArrayFromAudit diff --git a/src/redux/reporting/reporting.reducer.js b/src/redux/reporting/reporting.reducer.js index 609d897..3c421c0 100644 --- a/src/redux/reporting/reporting.reducer.js +++ b/src/redux/reporting/reporting.reducer.js @@ -58,6 +58,17 @@ const applicationReducer = (state = INITIAL_STATE, action) => { } }) }; + case ReportingActionTypes.TOGGLE_SGI_RCC: + return { + ...state, + data: state.data.map((d) => { + if (d.id === action.payload) { + return { ...d, sgi_rcc: !d.sgi_rcc }; + } else { + return d; + } + }) + }; default: return state; } diff --git a/src/redux/reporting/reporting.types.js b/src/redux/reporting/reporting.types.js index fa2fc08..1b7283b 100644 --- a/src/redux/reporting/reporting.types.js +++ b/src/redux/reporting/reporting.types.js @@ -11,6 +11,7 @@ const ReportingActionTypes = { ADD_EXCLUDED_ID: "ADD_EXCLUDED_ID", REMOVE_EXCLUDED_ID: "REMOVE_EXCLUDED_ID", CLEAR_EXCLUDED_IDS: "CLEAR_EXCLUDED_IDS", - SET_CACHED_JOBS: "SET_CACHED_JOBS" + SET_CACHED_JOBS: "SET_CACHED_JOBS", + TOGGLE_SGI_RCC: "TOGGLE_SGI_RCC" }; export default ReportingActionTypes; diff --git a/src/util/GetJobTarget.js b/src/util/GetJobTarget.js index 9d97552..a00e5f0 100644 --- a/src/util/GetJobTarget.js +++ b/src/util/GetJobTarget.js @@ -13,6 +13,10 @@ export default function GetJobTarget({ group, v_age, targets, close_date, v_mile && job.v_age >= f.ageGte && (f.ageLt === null ? true : job.v_age < f.ageLt) ); + //Check if this is an RCC job. + if (job.sgi_rcc) { + return 0; + } return sgiTarget?.target || 0; case "MPI":