Added vehicle groups and age calculations.

This commit is contained in:
Patrick Fic
2020-10-16 11:51:53 -07:00
parent 827243e11f
commit 4582bd0f4d
70 changed files with 1793 additions and 213 deletions

View File

@@ -4,14 +4,20 @@ const _ = require("lodash");
async function DecodeEstimate(filePath) {
const parsedFilePath = path.parse(filePath);
let extensionlessFilePath = `${parsedFilePath.dir}\\${parsedFilePath.name}`;
let extensionlessFilePath = path.join(
parsedFilePath.dir,
parsedFilePath.name
);
console.log("DecodeEstimate -> extensionlessFilePath", extensionlessFilePath);
const ret = {
...(await DecodeAd1File(extensionlessFilePath)),
...(await DecodeVehFile(extensionlessFilePath)),
...(await DecodeTtlFile(extensionlessFilePath)),
...(await DecodeLinFile(extensionlessFilePath)),
};
return ret;
if (ret.V_MILEAGE > 20000) return ret;
return null;
}
async function DecodeAd1File(extensionlessFilePath) {
@@ -32,7 +38,7 @@ async function DecodeAd1File(extensionlessFilePath) {
// "DED_AMT",
// "DED_STATUS",
// "ASGN_NO",
// "ASGN_DATE",
//"ASGN_DATE",
// "ASGN_TYPE",
"CLM_NO",
// "CLM_OFC_ID",
@@ -80,7 +86,7 @@ async function DecodeAd1File(extensionlessFilePath) {
// "AGT_CT_PHX",
// "AGT_EA",
// "AGT_LIC_NO",
// "LOSS_DATE",
"LOSS_DATE",
// "LOSS_TYPE",
// "LOSS_DESC",
// "THEFT_IND",
@@ -152,6 +158,7 @@ async function DecodeVehFile(extensionlessFilePath) {
"V_MAKEDESC",
"V_MODEL",
"V_TYPE",
"V_MILEAGE",
// "V_BSTYLE",
// "V_TRIMCODE",
// "TRIM_COLOR",
@@ -178,17 +185,17 @@ async function DecodeLinFile(extensionlessFilePath) {
let joblines = records.map((record) =>
_.transform(
_.pick(record, [
// "LINE_NO",
"LINE_NO",
"LINE_IND",
// "LINE_REF",
// "TRAN_CODE",
// "DB_REF",
"DB_REF",
"UNQ_SEQ",
// "WHO_PAYS",
"LINE_DESC",
"PART_TYPE",
// "PART_DESCJ",
// "GLASS_FLAG",
"GLASS_FLAG",
"OEM_PARTNO",
// "PRICE_INC",
// "ALT_PART_I",
@@ -225,6 +232,7 @@ async function DecodeLinFile(extensionlessFilePath) {
// "BETT_TAX",
]),
function (result, val, key) {
//Required because unq_seq gets pulled as a numeric instaed of a string.
if (key === "UNQ_SEQ") {
return (result[key.toLowerCase()] = val.toString());
}
@@ -232,7 +240,39 @@ async function DecodeLinFile(extensionlessFilePath) {
}
)
);
return { joblines: { data: joblines } };
//Perform required RPS Validations.
//Update DB Prices.
const massagedJobLines = joblines
.filter(
(jobline) =>
!jobline.db_ref.startsWith("900") &&
(jobline.part_type && jobline.part_type.toUpperCase()) !== "PAG" &&
jobline.glass_flag === false
)
.map((jobline) => {
//
if (
(jobline.db_price === null || jobline.db_price === 0) &&
!!jobline.act_price &&
jobline.act_price > 0
) {
jobline.db_price = jobline.act_price;
}
if (
jobline.db_price &&
jobline.act_price &&
jobline.act_price > jobline.db_price
) {
jobline.db_price = jobline.act_price;
}
delete jobline.glass_flag;
return jobline;
});
return { joblines: { data: massagedJobLines } };
}
exports.DecodeEstimate = DecodeEstimate;

View File

@@ -11,7 +11,7 @@ const {
var watcher;
function StartWatcher() {
async function StartWatcher() {
const filePaths =
store.get("filePaths").map((fp) => path.join(fp, "**.[eE][nN][vV]")) || [];
console.log("StartWatcher -> filePaths", filePaths);
@@ -26,8 +26,10 @@ function StartWatcher() {
if (watcher) {
try {
console.log("Trying to close watcher - it already existed.");
watcher.close().then();
console.log("Trying to close watcher - it already existed.111");
await watcher.close();
console.log("Watcher closed successfully!");
} catch (error) {
console.log("Error trying to close Watcher.", error);
}
@@ -71,6 +73,7 @@ function StartWatcher() {
// This event should be triggered everytime something happens.
// console.log("Raw event info:", event, path, details);
});
return filePaths;
}
@@ -107,13 +110,21 @@ async function HandleNewFile(path) {
result[key.toLowerCase()] = val;
});
b.webContents.send(
ipcTypes.default.estimate.toRenderer.estimateDecodeSuccess,
newJobLow
);
if (newJobLow && newJob) {
b.webContents.send(
ipcTypes.default.estimate.toRenderer.estimateDecodeSuccess,
newJobLow
);
NewNotification({
title: "Job Uploaded",
body: "A new job has been uploaded.",
}).show();
NewNotification({
title: "Job Uploaded",
body: "A new job has been uploaded.",
}).show();
} else {
NewNotification({
title: "Job Ignored",
body:
"The job was not uploaded because it does not meet RPS requirements.",
}).show();
}
}

View File

@@ -86,6 +86,7 @@ app.whenReady().then(() => {
if (isDev) {
console.log(`Path to Settings File: ${store.path}`);
console.log(`Path to Log File: ${log.log}`);
installExtension(REACT_DEVELOPER_TOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((error) => console.log(`An error occurred: , ${error}`));

View File

@@ -1,7 +1,26 @@
console.log("Running preloader!");
const { contextBridge, ipcRenderer } = require("electron");
const log = require("electron-log");
//ipcRenderer.removeAllListeners();
contextBridge.exposeInMainWorld("logger", {
info: (...msg) => {
log.info(...msg);
},
debug: (...msg) => {
log.debug(...msg);
},
warn: (...msg) => {
log.warn(...msg);
},
error: (...msg) => {
log.error(...msg);
},
silly: (...msg) => {
log.silly(...msg);
},
});
ipcRenderer.removeAllListeners();
contextBridge.exposeInMainWorld("ipcRenderer", {
send: (channel, data) => {
// whitelist channels

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."joblines" DROP COLUMN "db_ref";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."joblines" ADD COLUMN "db_ref" text NULL;
type: run_sql

View File

@@ -0,0 +1,35 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- act_price
- db_price
- part_qty
- line_desc
- line_ind
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- id
- jobid
set: {}
role: user
table:
name: joblines
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
set: {}
role: user
table:
name: joblines
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,35 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- act_price
- db_price
- part_qty
- line_desc
- line_ind
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- id
- jobid
computed_fields: []
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: joblines
schema: public
type: create_select_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
computed_fields: []
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: joblines
schema: public
type: create_select_permission

View File

@@ -0,0 +1,34 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_update_permission
- args:
permission:
columns:
- act_price
- db_price
- part_qty
- line_desc
- line_ind
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- id
- jobid
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: joblines
schema: public
type: create_update_permission

View File

@@ -0,0 +1,35 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_update_permission
- args:
permission:
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: joblines
schema: public
type: create_update_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."joblines" DROP COLUMN "line_no";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."joblines" ADD COLUMN "line_no" numeric NULL;
type: run_sql

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
set: {}
role: user
table:
name: joblines
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,37 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
set: {}
role: user
table:
name: joblines
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
computed_fields: []
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: joblines
schema: public
type: create_select_permission

View File

@@ -0,0 +1,37 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
computed_fields: []
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: joblines
schema: public
type: create_select_permission

View File

@@ -0,0 +1,35 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_update_permission
- args:
permission:
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: joblines
schema: public
type: create_update_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_update_permission
- args:
permission:
columns:
- act_price
- created_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: joblines
schema: public
type: create_update_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: joblines
schema: public
type: drop_delete_permission

View File

@@ -0,0 +1,15 @@
- args:
permission:
backend_only: false
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: joblines
schema: public
type: create_delete_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" DROP COLUMN "group";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" ADD COLUMN "group" text NULL;
type: run_sql

View File

@@ -0,0 +1,37 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
bodyshop:
associations:
user:
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
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,38 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_model
- v_model_yr
- v_type
- v_vin
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,37 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- clm_total
- clm_no
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- v_makedesc
- v_model
- v_model_yr
- v_type
- v_vin
- created_at
- updated_at
- bodyshopid
- id
computed_fields: []
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,38 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_model
- v_model_yr
- v_type
- v_vin
computed_fields: []
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- clm_total
- clm_no
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- v_makedesc
- v_model
- v_model_yr
- v_type
- v_vin
- created_at
- updated_at
- bodyshopid
- id
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,37 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" DROP COLUMN "v_mileage";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" ADD COLUMN "v_mileage" numeric NULL;
type: run_sql

View File

@@ -0,0 +1,38 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_model
- v_model_yr
- v_type
- v_vin
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,38 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_model
- v_model_yr
- v_type
- v_vin
computed_fields: []
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
computed_fields: []
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,37 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,38 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."veh_groups";
type: run_sql

View File

@@ -0,0 +1,23 @@
- args:
cascade: false
read_only: false
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
cascade: false
read_only: false
sql: "CREATE TABLE \"public\".\"veh_groups\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"make\" text NOT NULL, \"type\" text NOT NULL, \"group\"
text NOT NULL, PRIMARY KEY (\"id\") );\nCREATE OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_veh_groups_updated_at\"\nBEFORE
UPDATE ON \"public\".\"veh_groups\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_veh_groups_updated_at\" ON \"public\".\"veh_groups\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: veh_groups
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: veh_groups
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,19 @@
- args:
permission:
allow_aggregations: false
backend_only: false
columns:
- id
- created_at
- updated_at
- make
- type
- group
computed_fields: []
filter: {}
limit: null
role: user
table:
name: veh_groups
schema: public
type: create_select_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."veh_groups" ALTER COLUMN "type" SET NOT NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."veh_groups" ALTER COLUMN "type" DROP NOT NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" DROP COLUMN "v_age";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" ADD COLUMN "v_age" numeric NULL;
type: run_sql

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,40 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
computed_fields: []
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,40 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
computed_fields: []
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,38 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" DROP COLUMN "asgn_date";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."jobs" ADD COLUMN "asgn_date" date NULL;
type: run_sql

View File

@@ -0,0 +1,40 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,41 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_insert_permission
- args:
permission:
backend_only: false
check:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
columns:
- asgn_date
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
set: {}
role: user
table:
name: jobs
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,40 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
computed_fields: []
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,41 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- asgn_date
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
computed_fields: []
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: jobs
schema: public
type: create_select_permission

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,40 @@
- args:
role: user
table:
name: jobs
schema: public
type: drop_update_permission
- args:
permission:
columns:
- asgn_date
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
filter:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: jobs
schema: public
type: create_update_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."jobs" rename column "loss_date" to "asgn_date";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."jobs" rename column "asgn_date" to "loss_date";
type: run_sql

View File

@@ -70,34 +70,38 @@ tables:
_eq: X-Hasura-User-Id
columns:
- act_price
- db_price
- part_qty
- line_desc
- line_ind
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
backend_only: false
select_permissions:
- role: user
permission:
columns:
- act_price
- db_price
- part_qty
- line_desc
- line_ind
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
filter:
job:
bodyshop:
@@ -110,17 +114,19 @@ tables:
permission:
columns:
- act_price
- db_price
- part_qty
- line_desc
- line_ind
- oem_partno
- part_type
- unq_seq
- created_at
- updated_at
- db_price
- db_ref
- id
- jobid
- line_desc
- line_ind
- line_no
- oem_partno
- part_qty
- part_type
- unq_seq
- updated_at
filter:
job:
bodyshop:
@@ -129,6 +135,16 @@ tables:
authid:
_eq: X-Hasura-User-Id
check: null
delete_permissions:
- role: user
permission:
filter:
job:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
- table:
schema: public
name: jobs
@@ -154,41 +170,49 @@ tables:
authid:
_eq: X-Hasura-User-Id
columns:
- id
- loss_date
- bodyshopid
- created_at
- updated_at
- ro_number
- ins_co_nm
- clm_no
- clm_total
- ownr_ln
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- v_vin
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
backend_only: false
select_permissions:
- role: user
permission:
columns:
- clm_total
- loss_date
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
- created_at
- updated_at
- bodyshopid
- id
filter:
bodyshop:
associations:
@@ -200,21 +224,25 @@ tables:
- role: user
permission:
columns:
- clm_total
- loss_date
- bodyshopid
- clm_no
- clm_total
- created_at
- group
- id
- ins_co_nm
- ownr_fn
- ownr_ln
- ro_number
- updated_at
- v_age
- v_makedesc
- v_mileage
- v_model
- v_model_yr
- v_type
- v_vin
- created_at
- updated_at
- bodyshopid
- id
filter:
bodyshop:
associations:
@@ -263,3 +291,17 @@ tables:
authid:
_eq: X-Hasura-User-Id
check: null
- table:
schema: public
name: veh_groups
select_permissions:
- role: user
permission:
columns:
- id
- created_at
- updated_at
- make
- type
- group
filter: {}

26
package-lock.json generated
View File

@@ -4368,6 +4368,15 @@
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz",
"integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ=="
},
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"block-stream": {
"version": "0.0.9",
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
@@ -6974,6 +6983,14 @@
"mime": "^2.4.6"
}
},
"electron-reload": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/electron-reload/-/electron-reload-1.5.0.tgz",
"integrity": "sha512-L9X6LzsL3Bt2j0eJ4/MBrI9Vt902KvVUtBB7J4qrL1A9sXqC2fE0lpvUAlOThpJYh6zWO1l86U/YiEN9bDURHw==",
"requires": {
"chokidar": "^3.0.2"
}
},
"electron-store": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/electron-store/-/electron-store-6.0.1.tgz",
@@ -8265,6 +8282,12 @@
"schema-utils": "^2.5.0"
}
},
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"optional": true
},
"filelist": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz",
@@ -10743,6 +10766,7 @@
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
}
@@ -19419,6 +19443,7 @@
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
},
@@ -19763,6 +19788,7 @@
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
},

View File

@@ -17,6 +17,7 @@
"dotenv": "^8.2.0",
"electron-is-dev": "^1.2.0",
"electron-log": "^4.2.4",
"electron-reload": "^1.5.0",
"electron-store": "^6.0.1",
"electron-updater": "^4.3.5",
"firebase": "^7.23.0",
@@ -44,6 +45,7 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"dev": "concurrently -k \"npm start\" \"npm:electron\"",
"electron": "wait-on tcp:3000 && electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"postinstall": "electron-builder install-app-deps"

View File

@@ -22,9 +22,11 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
</Descriptions.Item>
<Descriptions.Item label="Owner">{`${job.ownr_fn} ${job.ownr_ln}`}</Descriptions.Item>
<Descriptions.Item label="Vehicle">{`${job.v_model_yr} ${job.v_makedesc} ${job.v_model}`}</Descriptions.Item>
<Descriptions.Item label="Claim Total.">
<Descriptions.Item label="Claim Total">
<CurrencyFormatterAtom>{job.clm_total}</CurrencyFormatterAtom>
</Descriptions.Item>
<Descriptions.Item label="Group">{job.group}</Descriptions.Item>
<Descriptions.Item label="Age">{job.v_age}</Descriptions.Item>
</Descriptions>
</div>
);

View File

@@ -68,6 +68,8 @@ export const QUERY_JOB_BY_PK = gql`
clm_total
ro_number
updated_at
group
v_age
joblines(order_by: { unq_seq: asc }) {
id
act_price

View File

@@ -0,0 +1,14 @@
import gql from "graphql-tag";
export const QUERY_GROUPS_BY_MAKE_TYPE = gql`
query QUERY_GROUPS_BY_MAKE_TYPE($make: String!, $type: String) {
veh_groups(
where: { _and: { make: { _eq: $make } }, type: { _eq: $type } }
) {
id
group
make
type
}
}
`;

View File

@@ -6,22 +6,43 @@ import {
QUERY_JOB_BY_CLM_NO,
UPDATE_JOB,
} from "../graphql/jobs.queries";
import { QUERY_GROUPS_BY_MAKE_TYPE } from "../graphql/veh_group.queries";
import { store } from "../redux/store";
import moment from "moment";
const { logger } = window;
export async function UpsertEstimate(job) {
const shopId = store.getState().user.bodyshop.id;
logger.info("Beginning Upserting job from Renderer.");
const parsedYr = parseInt(job.v_model_yr);
console.log("UpsertEstimate -> parsedYr", parsedYr);
logger.info(
moment(job.loss_date).year() -
(parsedYr >= 0 ? 2000 + parsedYr : 1900 + parsedYr)
);
job = {
...job,
group: await DetermineVehicleGroup(job),
v_age:
moment(job.loss_date).year() -
(parsedYr >= 0 ? 2000 + parsedYr : 1900 + parsedYr),
};
//Using the claim number, find out if the job exists. If it doesnt, then we need to create it.
const existingJobs = await client.query({
query: QUERY_JOB_BY_CLM_NO,
variables: { clm_no: job.clm_no },
});
if (existingJobs.data.jobs.length === 1) {
let suppDelta = await GetSupplementDelta(
existingJobs.data.jobs[0].id,
existingJobs.data.jobs[0].joblines,
job.joblines.data
);
logger.info("Attemping to update job record.");
await client.mutate({
mutation: gql`
${suppDelta}
@@ -33,10 +54,12 @@ export async function UpsertEstimate(job) {
mutation: UPDATE_JOB,
variables: { jobId: existingJobs.data.jobs[0].id, job: job },
});
logger.info("Job updated succesfully.");
console.log("UpsertEstimate -> updatedJob", updatedJob);
} else {
console.log("Insert a new job recort.", job);
logger.info("Attemping to insert job record.");
const result = await client.mutate({
mutation: INSERT_NEW_JOB,
variables: {
@@ -44,6 +67,8 @@ export async function UpsertEstimate(job) {
},
refetchQueries: ["QUERY_ALL_JOBS_PAGINATED"],
});
logger.info("Job inserted succesfully.");
console.log("UpsertEstimate -> result", result);
}
}
@@ -129,3 +154,38 @@ const generateRemoveQuery = (lineToRemove, index) => {
id
}`;
};
const DetermineVehicleGroup = async (job) => {
logger.info(
"Searching for vehicle groups.!",
job.v_makedesc.toUpperCase(),
job.v_type ? job.v_type.toUpperCase() : null
);
const vehicleGroups = await client.query({
query: QUERY_GROUPS_BY_MAKE_TYPE,
variables: {
make: job.v_makedesc.toUpperCase(),
type: job.v_type ? job.v_type.toUpperCase() : null,
},
});
if (vehicleGroups.data.veh_groups.length === 1) {
logger.info("Found 1 vehicle group.!", vehicleGroups.data.veh_groups[0]);
return vehicleGroups.data.veh_groups[0].group;
} else if (vehicleGroups.data.veh_groups.length === 0) {
//Uh-oh, should only be 1.
logger.info("No vehicle groups found.");
return null;
} else {
//Should never be here.
alert("Fatal error. Multiple vehicle groups found for this claim.");
logger.error(
"Found multiple vehicle groups!",
job.v_makedesc.toUpperCase(),
job.v_type ? job.v_type.toUpperCase() : null
);
}
return "";
};

View File

@@ -1,149 +0,0 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === "localhost" ||
// [::1] is the IPv6 localhost address.
window.location.hostname === "[::1]" ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener("load", () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
"This web app is being served cache-first by a service " +
"worker. To learn more, visit https://bit.ly/CRA-PWA"
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then((registration) => {
// Start addition---
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#manual_updates
// Added code, as our application will be open for a long time and we are a SPA, we need
// to trigger checks for updates frequently
setInterval(() => {
console.log("Checking if service worker was updated in server");
registration.update();
}, 15 * 60 * 1000); // Every 15 mins check
// End addition---
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === "installed") {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
"New content is available and will be used when all " +
"tabs for this page are closed. See https://bit.ly/CRA-PWA."
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log("Content is cached for offline use.");
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch((error) => {
console.error("Error during service worker registration:", error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
console.log("Seeing if service worker cna be found.");
fetch(swUrl)
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get("content-type");
if (
response.status === 404 ||
(contentType != null && contentType.indexOf("javascript") === -1)
) {
// No service worker found. Probably a different app. Reload the page.
console.log("No service worker found. Unregistering.");
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
console.log("Service worker found. Registering.");
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
"No internet connection found. App is running in offline mode."
);
});
}
export function unregister() {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister();
});
}
}