Add job status & correct claimant info checks.
This commit is contained in:
@@ -2,6 +2,7 @@ import { UUID } from "crypto";
|
||||
import { Notification } from "electron";
|
||||
import log from "electron-log/main";
|
||||
import fs from "fs";
|
||||
import _ from "lodash";
|
||||
import path from "path";
|
||||
import errorTypeCheck from "../../util/errorTypeCheck";
|
||||
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,
|
||||
};
|
||||
|
||||
//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
|
||||
const timestamp = new Date()
|
||||
.toISOString()
|
||||
|
||||
Reference in New Issue
Block a user