ES Schema changes & initial upload attempt.

This commit is contained in:
Patrick Fic
2025-07-09 16:01:38 -07:00
parent 661c562a48
commit a1dfcf4457
40 changed files with 289 additions and 77 deletions

View File

@@ -52,11 +52,18 @@ async function DecodeEstimate(filePath, includeFilePathInReturnJob = false, clos
...(await DecodeVehFile(extensionlessFilePath)),
...(await DecodeTtlFile(extensionlessFilePath)),
...(await DecodeLinFile(extensionlessFilePath, close_date)),
...(await DecodePflFile(extensionlessFilePath,)),
...(await DecodePfmFile(extensionlessFilePath,)),
...(await DecodeStlFile(extensionlessFilePath,)),
...(includeFilePathInReturnJob ? { filePath } : {})
};
const ad2 = await DecodeAd2File(extensionlessFilePath);
job.rates = [...job.rates || [], ...job.mat_rates || []];
delete job.mat_rates
if (job.OWNR_FN === "" || !job.OWNR_FN) job.OWNR_FN = ad2.CLMT_FN;
if (job.OWNR_LN === "" || !job.OWNR_LN) job.OWNR_LN = ad2.CLMT_LN;
if (job.OWNR_CO_NM) job.OWNR_LN = `${job.OWNR_LN} ${job.OWNR_CO_NM}`;
@@ -124,7 +131,7 @@ async function DecodeAd1File(extensionlessFilePath) {
// "INS_EA",
// "POLICY_NO",
// "DED_AMT",
"DED_AMT",
// "DED_STATUS",
// "ASGN_NO",
//"ASGN_DATE",
@@ -177,7 +184,7 @@ async function DecodeAd1File(extensionlessFilePath) {
// "AGT_LIC_NO",
"LOSS_DATE",
"LOSS_TYPE",
// "LOSS_DESC",
"LOSS_DESC",
// "THEFT_IND",
// "CAT_NO",
// "TLOS_IND",
@@ -202,14 +209,14 @@ async function DecodeAd1File(extensionlessFilePath) {
"OWNR_LN",
"OWNR_FN",
// "OWNR_TITLE",
"OWNR_CO_NM"
// "OWNR_ADDR1",
"OWNR_CO_NM",
"OWNR_ADDR1",
// "OWNR_ADDR2",
// "OWNR_CITY",
"OWNR_CITY",
// "OWNR_ST",
// "OWNR_ZIP",
// "OWNR_CTRY",
// "OWNR_PH1",
"OWNR_PH1",
// "OWNR_PH1X",
// "OWNR_PH2",
// "OWNR_PH2X",
@@ -272,7 +279,7 @@ async function DecodeVehFile(extensionlessFilePath) {
"V_MAKEDESC",
"V_MODEL",
"V_TYPE",
"V_MILEAGE"
"V_MILEAGE",
// "V_BSTYLE",
// "V_TRIMCODE",
// "TRIM_COLOR",
@@ -280,7 +287,7 @@ async function DecodeVehFile(extensionlessFilePath) {
// "V_ENGINE",
// "V_COLOR",
// "V_TONE",
// "V_STAGE",
"V_STAGE",
// "PAINT_CD1",
// "PAINT_CD2",
// "PAINT_CD3",
@@ -290,7 +297,7 @@ async function DecodeVehFile(extensionlessFilePath) {
async function DecodeTtlFile(extensionlessFilePath) {
let dbf = await DBFFile.open(`${extensionlessFilePath}.TTL`);
let records = await dbf.readRecords(1);
return { clm_total: records[0]["G_TTL_AMT"] };
return { clm_total: records[0]["G_TTL_AMT"], supp_amt: records[0]["SUPP_AMT"], g_bett_amt: records[0]["G_BETT_AMT"] };
}
async function DecodeLinFile(extensionlessFilePath, close_date) {
@@ -311,17 +318,17 @@ async function DecodeLinFile(extensionlessFilePath, close_date) {
// "PART_DESCJ",
"PRT_DSMK_M",
"OEM_PARTNO",
// "PRICE_INC",
"PRICE_INC",
// "ALT_PART_I",
// "TAX_PART",
"TAX_PART",
"DB_PRICE",
"ACT_PRICE",
"PART_QTY",
"PRICE_J",
"GLASS_FLAG",
// "CERT_PART",
"CERT_PART",
// "ALT_CO_ID",
// "ALT_PARTNO",
"ALT_PARTNO",
// "ALT_OVERRD",
// "ALT_PARTM",
"PRT_DSMK_P",
@@ -333,7 +340,7 @@ async function DecodeLinFile(extensionlessFilePath, close_date) {
"LBR_OP",
"LBR_HRS_J",
// "LBR_TYP_J",
// "LBR_OP_J",
"LBR_OP_J",
// "PAINT_STG",
// "PAINT_TONE",
// "LBR_TAX",
@@ -389,6 +396,52 @@ async function DecodeLinFile(extensionlessFilePath, close_date) {
return { joblines: { data: joblines } };
}
async function DecodePflFile(extensionlessFilePath,) {
let dbf = await DBFFile.open(`${extensionlessFilePath}.PFL`);
let records = await dbf.readRecords();
let pflLines = records.map((record) => {
return _.transform(
_.pick(record, [
"LBR_TYPE", "LBR_DESC", "LBR_RATE"
])
);
});
//Check for discounts that need to be ignored after the fact.
return { rates: pflLines };
}
async function DecodeStlFile(extensionlessFilePath,) {
let dbf = await DBFFile.open(`${extensionlessFilePath}.STL`);
let records = await dbf.readRecords();
let pflLines = records.map((record) => {
return _.transform(
_.pick(record, [
"TTL_TYPECD", "T_AMT", 'T_HRS', "NT_HRS"
])
);
});
//Check for discounts that need to be ignored after the fact.
return { totals: pflLines };
}
async function DecodePfmFile(extensionlessFilePath,) {
let dbf = await DBFFile.open(`${extensionlessFilePath}.PFM`);
let records = await dbf.readRecords();
let pflLines = records.map((record) => {
return _.transform(
_.pick(record, [
"MAT_TYPE", "CAL_PRETHR"
])
);
});
//Check for discounts that need to be ignored after the fact.
return { mat_rates: pflLines };
}
exports.DecodeEstimate = DecodeEstimate;
exports.ImportJob = ImportJob;

View File

@@ -10,20 +10,34 @@ const { BrowserWindow } = require("electron");
async function ScrubEstimate({ job }) {
//These need to be removed.
//TODO: Fetch these from ImEX Online API.
const basicAuthUser = "Imex";
const basicAuthpassword = "Patrick";
const estimateScrubberUrl = "https://insurtechtoolkit.com/api/sendems";
const sendingEntityId = '87330f61-412b-4251-baaa-d026565b23c5'
//Perform data manipulation on the job object
if (!job) {
console.error("No job provided to ScrubEstimate");
return;
}
//Set shop metrics
job.sending_entity_id = sendingEntityId;
job.sending_entity_accept_terms_of_use = true;
job.association_switch = "ATAM";
job.rf_ph1 = "R0G 1Z0";
job.rf_zip = "2043792253";
job.g_ttl_amt = job.clm_total;
const fileName = `RPSTest-${job.id}-${Date.now()}`;
console.log("*** ~ ScrubEstimate ~ job:", job);
//Build the JSON Form Data
const fileName = `RPSTest-${job.id}-${Date.now()}`;
const formData = new FormData();
const jsonString = JSON.stringify(job);
formData.append("file", new Blob([jsonString], { type: "application/json" }), `${fileName}.json`);
console.log("*** ~ ScrubEstimate ~ formData.getHeaders();:", formData);
const result = await axios.post(estimateScrubberUrl, formData, {
auth: {
username: basicAuthUser,
@@ -33,7 +47,7 @@ async function ScrubEstimate({ job }) {
});
console.log("*** ~ handleScrub ~ result:", result.data);
const resultPDFUrl = `https://www.insurtechtoolkit.com/analysis/${fileName}.pdf`;
const resultPDFUrl = result?.data?.[0] || `https://www.insurtechtoolkit.com/analysis/${fileName}.pdf`;
console.log("*** ~ handleScrub ~ resultPDFUrl:", resultPDFUrl);
const pdfWindow = new BrowserWindow({

View File

@@ -16,72 +16,82 @@ insert_permissions:
authid:
_eq: X-Hasura-User-Id
columns:
- act_price
- alerts
- created_at
- db_hrs
- db_price
- db_ref
- cert_part
- glass_flag
- id
- ignore
- jobid
- lbr_amt
- lbr_hrs_j
- lbr_inc
- lbr_op
- line_desc
- line_ind
- lbr_op_j
- price_inc
- price_j
- tax_part
- alerts
- act_price
- db_hrs
- db_price
- lbr_amt
- line_no
- line_ref
- misc_amt
- mod_lb_hrs
- mod_lbr_ty
- oem_partno
- part_qty
- part_type
- price_diff
- price_diff_pc
- price_j
- prt_dsmk_m
- prt_dsmk_p
- alt_partno
- db_ref
- lbr_op
- line_desc
- line_ind
- mod_lbr_ty
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- id
- jobid
select_permissions:
- role: user
permission:
columns:
- act_price
- alerts
- created_at
- db_hrs
- db_price
- db_ref
- cert_part
- glass_flag
- id
- ignore
- jobid
- lbr_amt
- lbr_hrs_j
- lbr_inc
- lbr_op
- line_desc
- line_ind
- lbr_op_j
- price_inc
- price_j
- tax_part
- alerts
- act_price
- db_hrs
- db_price
- lbr_amt
- line_no
- line_ref
- misc_amt
- mod_lb_hrs
- mod_lbr_ty
- oem_partno
- part_qty
- part_type
- price_diff
- price_diff_pc
- price_j
- prt_dsmk_m
- prt_dsmk_p
- alt_partno
- db_ref
- lbr_op
- line_desc
- line_ind
- mod_lbr_ty
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- id
- jobid
filter:
job:
bodyshop:
@@ -93,37 +103,42 @@ update_permissions:
- role: user
permission:
columns:
- act_price
- alerts
- created_at
- db_hrs
- db_price
- db_ref
- cert_part
- glass_flag
- id
- ignore
- jobid
- lbr_amt
- lbr_hrs_j
- lbr_inc
- lbr_op
- line_desc
- line_ind
- lbr_op_j
- price_inc
- price_j
- tax_part
- alerts
- act_price
- db_hrs
- db_price
- lbr_amt
- line_no
- line_ref
- misc_amt
- mod_lb_hrs
- mod_lbr_ty
- oem_partno
- part_qty
- part_type
- price_diff
- price_diff_pc
- price_j
- prt_dsmk_m
- prt_dsmk_p
- alt_partno
- db_ref
- lbr_op
- line_desc
- line_ind
- mod_lbr_ty
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- id
- jobid
filter:
job:
bodyshop:

View File

@@ -28,21 +28,31 @@ insert_permissions:
- clm_total
- close_date
- created_at
- ded_amt
- g_bett_amt
- supp_amt
- group
- group_verified
- id
- ins_co_nm
- loss_date
- loss_desc
- ownr_addr1
- ownr_city
- ownr_fn
- ownr_ln
- ownr_ph1
- rates
- requires_reimport
- ro_number
- totals
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_stage
- v_type
- v_vin
select_permissions:
@@ -54,21 +64,31 @@ select_permissions:
- clm_total
- close_date
- created_at
- ded_amt
- g_bett_amt
- supp_amt
- group
- group_verified
- id
- ins_co_nm
- loss_date
- loss_desc
- ownr_addr1
- ownr_city
- ownr_fn
- ownr_ln
- ownr_ph1
- rates
- requires_reimport
- ro_number
- totals
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_stage
- v_type
- v_vin
filter:
@@ -87,21 +107,31 @@ update_permissions:
- clm_total
- close_date
- created_at
- ded_amt
- g_bett_amt
- supp_amt
- group
- group_verified
- id
- ins_co_nm
- loss_date
- loss_desc
- ownr_addr1
- ownr_city
- ownr_fn
- ownr_ln
- ownr_ph1
- rates
- requires_reimport
- ro_number
- totals
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_stage
- v_type
- v_vin
filter:

View File

@@ -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 "ded_amt" numeric
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "ded_amt" numeric
null;

View File

@@ -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 "loss_desc" text
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "loss_desc" text
null;

View File

@@ -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 "ownr_addr1" text
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "ownr_addr1" text
null;

View File

@@ -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 "ownr_city" text
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "ownr_city" text
null;

View File

@@ -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 "ownr_ph1" text
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "ownr_ph1" text
null;

View File

@@ -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 "v_stage" numeric
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "v_stage" numeric
null;

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."joblines" add column "price_inc" boolean
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."joblines" add column "price_inc" boolean
null;

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."joblines" add column "tax_part" boolean
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."joblines" add column "tax_part" boolean
null;

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."joblines" add column "cert_part" boolean
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."joblines" add column "cert_part" boolean
null;

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."joblines" add column "alt_partno" text
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."joblines" add column "alt_partno" text
null;

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."joblines" add column "lbr_op_j" boolean
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."joblines" add column "lbr_op_j" boolean
null;

View File

@@ -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 "rates" jsonb
-- null default jsonb_build_array();

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "rates" jsonb
null default jsonb_build_array();

View File

@@ -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 "totals" jsonb
-- null default jsonb_build_array();

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "totals" jsonb
null default jsonb_build_array();

View File

@@ -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 "g_supp_amt" numeric
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "g_supp_amt" numeric
null;

View File

@@ -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 "g_bett_amt" numeric
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "g_bett_amt" numeric
null;

View File

@@ -0,0 +1 @@
alter table "public"."jobs" rename column "supp_amt" to "g_supp_amt";

View File

@@ -0,0 +1 @@
alter table "public"."jobs" rename column "g_supp_amt" to "supp_amt";

View File

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

View File

@@ -35,14 +35,7 @@ export function EstimateScrubberButton({ bodyshop, jobid }) {
});
const result = await ipcRenderer.invoke(ipcTypes.app.toMain.scrubEstimate, {
job: {
...jobData.data.jobs_by_pk,
sending_entity_id: "87330f61-412b-4251-baaa-d026565b23c5",
sending_entity_clientid: "",
sending_entity_accept_terms_of_use: true,
profileid: "",
association_switch: "ATAM"
}
job: jobData.data.jobs_by_pk
});
} catch (error) {
message.error("Error scrubbing estimate: " + error.message);

View File

@@ -83,7 +83,7 @@ export function JobsDetailOrganism({ selectedJobId, setSelectedJobTargetPc }) {
<Card
title="Estimate Lines"
// extra={[<EstimateScrubberButton key="es" jobid={data ? data.jobs_by_pk?.id : null} />]}
extra={[<EstimateScrubberButton key="es" jobid={data ? data.jobs_by_pk?.id : null} />]}
>
<JobsLinesTableMolecule loading={loading} job={data ? data.jobs_by_pk : {}} />
</Card>

View File

@@ -225,6 +225,16 @@ export const QUERY_JOB_ESTIMATE_SCRUBBER = gql`
requires_reimport
created_at
v_mileage
rates
totals
ded_amt
loss_desc
ownr_addr1
ownr_city
ownr_ph1
v_stage
supp_amt
g_bett_amt
joblines(order_by: {line_no: asc}) {
line_no
line_ind
@@ -245,6 +255,11 @@ export const QUERY_JOB_ESTIMATE_SCRUBBER = gql`
lbr_hrs_j
lbr_amt
misc_amt
price_inc
tax_part
cert_part
alt_partno
lbr_op_j
}
}
}