Add job status & correct claimant info checks.

This commit is contained in:
Patrick Fic
2025-03-21 15:38:30 -07:00
parent b312532121
commit 2fd226d43a
5 changed files with 106 additions and 40 deletions

View File

@@ -30,23 +30,23 @@ const DecodeAD2 = async (
const rawAd2Data: DecodedAD2 = deepLowerCaseKeys( const rawAd2Data: DecodedAD2 = deepLowerCaseKeys(
_.pick(rawDBFRecord[0], [ _.pick(rawDBFRecord[0], [
//TODO: Add typings for EMS File Formats. //TODO: Add typings for EMS File Formats.
// "CLMT_LN", //TODO: This claimant info shouldnt be passed back. Just for the owner info. "CLMT_LN", //TODO: This claimant info shouldnt be passed back. Just for the owner info.
// "CLMT_FN", "CLMT_FN",
// "CLMT_TITLE", "CLMT_TITLE",
// "CLMT_CO_NM", "CLMT_CO_NM",
// "CLMT_ADDR1", "CLMT_ADDR1",
// "CLMT_ADDR2", "CLMT_ADDR2",
// "CLMT_CITY", "CLMT_CITY",
// "CLMT_ST", "CLMT_ST",
// "CLMT_ZIP", "CLMT_ZIP",
// "CLMT_CTRY", "CLMT_CTRY",
// "CLMT_PH1", "CLMT_PH1",
//"CLMT_PH1X", "CLMT_PH1X",
//"CLMT_PH2", "CLMT_PH2",
//"CLMT_PH2X", "CLMT_PH2X",
//"CLMT_FAX", "CLMT_FAX",
//"CLMT_FAXX", "CLMT_FAXX",
//"CLMT_EA", "CLMT_EA",
//"EST_CO_ID", //"EST_CO_ID",
"EST_CO_NM", "EST_CO_NM",
"EST_ADDR1", "EST_ADDR1",

View File

@@ -2,6 +2,7 @@ import { UUID } from "crypto";
import { Notification } from "electron"; import { Notification } from "electron";
import log from "electron-log/main"; import log from "electron-log/main";
import fs from "fs"; import fs from "fs";
import _ from "lodash";
import path from "path"; import path from "path";
import errorTypeCheck from "../../util/errorTypeCheck"; import errorTypeCheck from "../../util/errorTypeCheck";
import client from "../graphql/graphql-client"; import client from "../graphql/graphql-client";
@@ -83,6 +84,57 @@ async function ImportJob(filepath: string): Promise<void> {
shopid: store.get("app.bodyshop.id") as UUID, shopid: store.get("app.bodyshop.id") as UUID,
}; };
//In some scenarios, the owner information is missing. So we use the claimant instead.
//We pull the claimant info for this, but we don't store it in our system, so it needs to be deleted regardless.
if (
_.isEmpty(jobObject.ownr_ln) &&
_.isEmpty(jobObject.ownr_fn) &&
_.isEmpty(jobObject.ownr_co_nm)
) {
jobObject.ownr_ln = jobObject.clmt_ln;
jobObject.ownr_fn = jobObject.clmt_fn;
jobObject.ownr_title = jobObject.clmt_title;
jobObject.ownr_co_nm = jobObject.clmt_co_nm;
jobObject.ownr_addr1 = jobObject.clmt_addr1;
jobObject.ownr_addr2 = jobObject.clmt_addr2;
jobObject.ownr_city = jobObject.clmt_city;
jobObject.ownr_st = jobObject.clmt_st;
jobObject.ownr_zip = jobObject.clmt_zip;
jobObject.ownr_ctry = jobObject.clmt_ctry;
jobObject.ownr_ph1 = jobObject.clmt_ph1;
jobObject.ownr_ph2 = jobObject.clmt_ph2;
jobObject.ownr_ea = jobObject.clmt_ea;
jobObject.owner.data.ownr_ln = jobObject.clmt_ln;
jobObject.owner.data.ownr_fn = jobObject.clmt_fn;
jobObject.owner.data.ownr_title = jobObject.clmt_title;
jobObject.owner.data.ownr_co_nm = jobObject.clmt_co_nm;
jobObject.owner.data.ownr_addr1 = jobObject.clmt_addr1;
jobObject.owner.data.ownr_addr2 = jobObject.clmt_addr2;
jobObject.owner.data.ownr_city = jobObject.clmt_city;
jobObject.owner.data.ownr_st = jobObject.clmt_st;
jobObject.owner.data.ownr_zip = jobObject.clmt_zip;
jobObject.owner.data.ownr_ctry = jobObject.clmt_ctry;
jobObject.owner.data.ownr_ph1 = jobObject.clmt_ph1;
jobObject.owner.data.ownr_ph2 = jobObject.clmt_ph2;
jobObject.owner.data.ownr_ea = jobObject.clmt_ea;
}
//Delete the claimant info as it's not needed.
delete jobObject.clmt_ln;
delete jobObject.clmt_fn;
delete jobObject.clmt_title;
delete jobObject.clmt_co_nm;
delete jobObject.clmt_addr1;
delete jobObject.clmt_addr2;
delete jobObject.clmt_city;
delete jobObject.clmt_st;
delete jobObject.clmt_zip;
delete jobObject.clmt_ctry;
delete jobObject.clmt_ph1;
delete jobObject.clmt_ph2;
delete jobObject.clmt_ea;
// Save jobObject to a timestamped JSON file // Save jobObject to a timestamped JSON file
const timestamp = new Date() const timestamp = new Date()
.toISOString() .toISOString()

View File

@@ -121,8 +121,8 @@ async function StopWatcher(): Promise<boolean> {
} }
async function HandleNewFile(path): Promise<void> { async function HandleNewFile(path): Promise<void> {
await ImportJob(path);
log.log("Received a new file", path); log.log("Received a new file", path);
await ImportJob(path);
} }
export { export {

View File

@@ -1,10 +1,13 @@
import { Layout, Menu } from "antd"; import { selectWatcherStatus } from "@renderer/redux/app.slice";
import { useAppSelector } from "@renderer/redux/reduxHooks";
import { Badge, Layout, Menu } from "antd";
import { MenuItemType } from "antd/es/menu/interface"; import { MenuItemType } from "antd/es/menu/interface";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { NavLink } from "react-router"; import { NavLink } from "react-router";
const NavigationHeader: React.FC = () => { const NavigationHeader: React.FC = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const isWatcherStarted = useAppSelector(selectWatcherStatus);
const menuItems: MenuItemType[] = [ const menuItems: MenuItemType[] = [
{ label: <NavLink to="/">{t("navigation.home")}</NavLink>, key: "home" }, { label: <NavLink to="/">{t("navigation.home")}</NavLink>, key: "home" },
{ {
@@ -13,16 +16,24 @@ const NavigationHeader: React.FC = () => {
}, },
]; ];
return ( return (
<Layout.Header style={{ display: "flex", alignItems: "center" }}> <Badge.Ribbon
<div className="demo-logo" /> text={
<Menu isWatcherStarted
theme="dark" ? t("settings.labels.started")
mode="horizontal" : t("settings.labels.stopped")
defaultSelectedKeys={["2"]} }
items={menuItems} color={isWatcherStarted ? "green" : "red"}
style={{ flex: 1, minWidth: 0 }} >
/> <Layout.Header style={{ display: "flex", alignItems: "center" }}>
</Layout.Header> <Menu
theme="dark"
mode="horizontal"
defaultSelectedKeys={["2"]}
items={menuItems}
style={{ flex: 1, minWidth: 0 }}
/>
</Layout.Header>
</Badge.Ribbon>
); );
}; };

View File

@@ -6,8 +6,8 @@ import {
selectWatcherError, selectWatcherError,
selectWatcherStatus, selectWatcherStatus,
} from "@renderer/redux/app.slice"; } from "@renderer/redux/app.slice";
import { useAppDispatch, useAppSelector } from "@renderer/redux/reduxHooks"; import { useAppSelector } from "@renderer/redux/reduxHooks";
import { Button, Space } from "antd"; import { Alert, Button, Space } from "antd";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import ipcTypes from "../../../../util/ipcTypes.json"; import ipcTypes from "../../../../util/ipcTypes.json";
@@ -15,7 +15,6 @@ const SettingsWatcher: React.FC = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const isWatcherStarted = useAppSelector(selectWatcherStatus); const isWatcherStarted = useAppSelector(selectWatcherStatus);
const watcherError = useAppSelector(selectWatcherError); const watcherError = useAppSelector(selectWatcherError);
const dispatch = useAppDispatch();
const handleStart = (): void => { const handleStart = (): void => {
window.electron.ipcRenderer.send(ipcTypes.toMain.watcher.start); window.electron.ipcRenderer.send(ipcTypes.toMain.watcher.start);
@@ -26,13 +25,16 @@ const SettingsWatcher: React.FC = () => {
}; };
return ( return (
<> <Space>
<Button onClick={handleStart}> {isWatcherStarted ? (
{t("settings.actions.startwatcher")} <Button onClick={handleStop}>
</Button> {t("settings.actions.stopwatcher")}
<Button onClick={handleStop}>{t("settings.actions.stopwatcher")}</Button> </Button>
{isWatcherStarted} ) : (
{watcherError} <Button onClick={handleStart}>
{t("settings.actions.startwatcher")}
</Button>
)}
{isWatcherStarted ? ( {isWatcherStarted ? (
<Space> <Space>
<CheckCircleOutlined style={{ color: "green" }} /> <CheckCircleOutlined style={{ color: "green" }} />
@@ -44,7 +46,8 @@ const SettingsWatcher: React.FC = () => {
{t("settings.labels.stopped")} {t("settings.labels.stopped")}
</Space> </Space>
)} )}
</> {watcherError && <Alert message={watcherError} />}
</Space>
); );
}; };
export default SettingsWatcher; export default SettingsWatcher;