From 1de87a4280d381da9fff9576142420e4b18bfb2c Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 14 Aug 2025 09:32:35 -0700 Subject: [PATCH] Add in ID_PRO_NAM to integration. --- electron/decoder/decoder.js | 16 ++++++++++++++++ electron/estimate-scrubber/estimate-scrubber.js | 9 +++++---- .../databases/default/tables/public_jobs.yaml | 9 ++++++--- .../down.sql | 4 ++++ .../up.sql | 2 ++ package.json | 2 +- src/graphql/jobs.queries.js | 3 ++- 7 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 hasura/migrations/default/1755188805418_alter_table_public_jobs_add_column_id_pro_nam/down.sql create mode 100644 hasura/migrations/default/1755188805418_alter_table_public_jobs_add_column_id_pro_nam/up.sql diff --git a/electron/decoder/decoder.js b/electron/decoder/decoder.js index 8a84e02..ed9a0b2 100644 --- a/electron/decoder/decoder.js +++ b/electron/decoder/decoder.js @@ -54,6 +54,7 @@ async function DecodeEstimate(filePath, includeFilePathInReturnJob = false, clos ...(await DecodeLinFile(extensionlessFilePath, close_date)), ...(await DecodePflFile(extensionlessFilePath,)), ...(await DecodePfmFile(extensionlessFilePath,)), + ...(await DecodePfhFile(extensionlessFilePath,)), ...(await DecodeStlFile(extensionlessFilePath,)), ...(includeFilePathInReturnJob ? { filePath } : {}) }; @@ -255,6 +256,21 @@ async function DecodeAd2File(extensionlessFilePath) { } async function DecodeVehFile(extensionlessFilePath) { + let dbf; + try { + dbf = await DBFFile.open(`${extensionlessFilePath}.PFH`); + } catch (error) { + log.error("Error opening PFH File.", error); + } finally { + if (!dbf) return {}; + let records = await dbf.readRecords(1); + return _.pick(records[0], [ + "ID_PRO_NAM" + ]); + } +} + +async function DecodePfhFile(extensionlessFilePath) { let dbf; try { dbf = await DBFFile.open(`${extensionlessFilePath}V.VEH`); diff --git a/electron/estimate-scrubber/estimate-scrubber.js b/electron/estimate-scrubber/estimate-scrubber.js index d8ce46f..feb6820 100644 --- a/electron/estimate-scrubber/estimate-scrubber.js +++ b/electron/estimate-scrubber/estimate-scrubber.js @@ -28,7 +28,8 @@ async function writeJobToLogsFolder(job, fileName) { } } async function ScrubEstimate({ job }) { - //TODO: Fetch these from ImEX Online API. + //These are hard coded as they are not secure values and checking happens based on other values. + //No secret or private information is exposed. const basicAuthUser = "Imex"; const basicAuthpassword = "Patrick"; const estimateScrubberUrl = "https://insurtechtoolkit.com/api/sendems"; @@ -44,10 +45,11 @@ async function ScrubEstimate({ job }) { job.sending_entity_id = sendingEntityId; job.sending_entity_accept_terms_of_use = true; job.association_switch = "ATAM"; - job.rf_zip = "R0G 1Z0"; - job.rf_ph1 = "2043792253"; + job.rf_zip = job.bodyshop.zip_post; + job.rf_ph1 = job.bodyshop.phone; job.g_ttl_amt = job.clm_total; delete job.clm_total; + delete job.bodyshop //Bodyshop has to be passed through the object as we don't have access to the store here. //Adjust the rates field to be MAT_TYPE instead of MATL_TYPE if (job.rates && Array.isArray(job.rates)) { @@ -58,7 +60,6 @@ async function ScrubEstimate({ job }) { } }); } - delete job.bodyshop //Bodyshop has to be passed through the object as we don't have access to the store here. //Lower case the rates & totals if (job.rates && Array.isArray(job.rates)) { diff --git a/hasura/metadata/databases/default/tables/public_jobs.yaml b/hasura/metadata/databases/default/tables/public_jobs.yaml index 4a6046a..c3e70d1 100644 --- a/hasura/metadata/databases/default/tables/public_jobs.yaml +++ b/hasura/metadata/databases/default/tables/public_jobs.yaml @@ -30,10 +30,10 @@ insert_permissions: - created_at - ded_amt - g_bett_amt - - supp_amt - group - group_verified - id + - id_pro_nam - ins_co_nm - loss_date - loss_desc @@ -45,6 +45,7 @@ insert_permissions: - rates - requires_reimport - ro_number + - supp_amt - totals - updated_at - v_age @@ -66,10 +67,10 @@ select_permissions: - created_at - ded_amt - g_bett_amt - - supp_amt - group - group_verified - id + - id_pro_nam - ins_co_nm - loss_date - loss_desc @@ -81,6 +82,7 @@ select_permissions: - rates - requires_reimport - ro_number + - supp_amt - totals - updated_at - v_age @@ -109,10 +111,10 @@ update_permissions: - created_at - ded_amt - g_bett_amt - - supp_amt - group - group_verified - id + - id_pro_nam - ins_co_nm - loss_date - loss_desc @@ -124,6 +126,7 @@ update_permissions: - rates - requires_reimport - ro_number + - supp_amt - totals - updated_at - v_age diff --git a/hasura/migrations/default/1755188805418_alter_table_public_jobs_add_column_id_pro_nam/down.sql b/hasura/migrations/default/1755188805418_alter_table_public_jobs_add_column_id_pro_nam/down.sql new file mode 100644 index 0000000..bd112ec --- /dev/null +++ b/hasura/migrations/default/1755188805418_alter_table_public_jobs_add_column_id_pro_nam/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 "id_pro_nam" text +-- null; diff --git a/hasura/migrations/default/1755188805418_alter_table_public_jobs_add_column_id_pro_nam/up.sql b/hasura/migrations/default/1755188805418_alter_table_public_jobs_add_column_id_pro_nam/up.sql new file mode 100644 index 0000000..1209c21 --- /dev/null +++ b/hasura/migrations/default/1755188805418_alter_table_public_jobs_add_column_id_pro_nam/up.sql @@ -0,0 +1,2 @@ +alter table "public"."jobs" add column "id_pro_nam" text + null; diff --git a/package.json b/package.json index a579d17..3286f41 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "productName": "ImEX RPS", "author": "ImEX Systems Inc. ", "description": "ImEX RPS", - "version": "1.4.2-alpha.4", + "version": "1.4.2-alpha.6", "main": "electron/main.js", "homepage": "./", "dependencies": { diff --git a/src/graphql/jobs.queries.js b/src/graphql/jobs.queries.js index 59828fe..8f4f1f4 100644 --- a/src/graphql/jobs.queries.js +++ b/src/graphql/jobs.queries.js @@ -234,11 +234,12 @@ export const QUERY_JOB_ESTIMATE_SCRUBBER = gql` ownr_city ownr_ph1 v_stage + id_pro_nam supp_amt g_bett_amt bodyshop { id - post_zip + zip_post phone } joblines(order_by: {line_no: asc}) {