diff --git a/electron/decoder/decoder.js b/electron/decoder/decoder.js index 24e0cc3..be0f8a8 100644 --- a/electron/decoder/decoder.js +++ b/electron/decoder/decoder.js @@ -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; diff --git a/electron/file-watcher/file-watcher.js b/electron/file-watcher/file-watcher.js index 669acf8..18360c1 100644 --- a/electron/file-watcher/file-watcher.js +++ b/electron/file-watcher/file-watcher.js @@ -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(); + } } diff --git a/electron/main.js b/electron/main.js index 72785a6..9b4edeb 100644 --- a/electron/main.js +++ b/electron/main.js @@ -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}`)); diff --git a/electron/preload.js b/electron/preload.js index 621d085..8b7886e 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -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 diff --git a/hasura/migrations/1602868358764_alter_table_public_joblines_add_column_db_ref/down.yaml b/hasura/migrations/1602868358764_alter_table_public_joblines_add_column_db_ref/down.yaml new file mode 100644 index 0000000..f33849d --- /dev/null +++ b/hasura/migrations/1602868358764_alter_table_public_joblines_add_column_db_ref/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."joblines" DROP COLUMN "db_ref"; + type: run_sql diff --git a/hasura/migrations/1602868358764_alter_table_public_joblines_add_column_db_ref/up.yaml b/hasura/migrations/1602868358764_alter_table_public_joblines_add_column_db_ref/up.yaml new file mode 100644 index 0000000..9130dc0 --- /dev/null +++ b/hasura/migrations/1602868358764_alter_table_public_joblines_add_column_db_ref/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."joblines" ADD COLUMN "db_ref" text NULL; + type: run_sql diff --git a/hasura/migrations/1602868366028_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1602868366028_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 0000000..aa74653 --- /dev/null +++ b/hasura/migrations/1602868366028_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1602868366028_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1602868366028_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 0000000..68abca3 --- /dev/null +++ b/hasura/migrations/1602868366028_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1602868376590_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1602868376590_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 0000000..6b78152 --- /dev/null +++ b/hasura/migrations/1602868376590_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1602868376590_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1602868376590_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 0000000..ec4e275 --- /dev/null +++ b/hasura/migrations/1602868376590_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1602868382612_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1602868382612_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 0000000..2cbdb6a --- /dev/null +++ b/hasura/migrations/1602868382612_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1602868382612_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1602868382612_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 0000000..3c71d3e --- /dev/null +++ b/hasura/migrations/1602868382612_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1602868441871_alter_table_public_joblines_add_column_line_no/down.yaml b/hasura/migrations/1602868441871_alter_table_public_joblines_add_column_line_no/down.yaml new file mode 100644 index 0000000..d5935b1 --- /dev/null +++ b/hasura/migrations/1602868441871_alter_table_public_joblines_add_column_line_no/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."joblines" DROP COLUMN "line_no"; + type: run_sql diff --git a/hasura/migrations/1602868441871_alter_table_public_joblines_add_column_line_no/up.yaml b/hasura/migrations/1602868441871_alter_table_public_joblines_add_column_line_no/up.yaml new file mode 100644 index 0000000..a7b184b --- /dev/null +++ b/hasura/migrations/1602868441871_alter_table_public_joblines_add_column_line_no/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."joblines" ADD COLUMN "line_no" numeric NULL; + type: run_sql diff --git a/hasura/migrations/1602868447595_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1602868447595_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 0000000..68abca3 --- /dev/null +++ b/hasura/migrations/1602868447595_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1602868447595_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1602868447595_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 0000000..07751de --- /dev/null +++ b/hasura/migrations/1602868447595_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1602868452712_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1602868452712_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 0000000..ec4e275 --- /dev/null +++ b/hasura/migrations/1602868452712_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1602868452712_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1602868452712_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 0000000..3d184ad --- /dev/null +++ b/hasura/migrations/1602868452712_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1602868457785_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1602868457785_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 0000000..3c71d3e --- /dev/null +++ b/hasura/migrations/1602868457785_update_permission_user_public_table_joblines/down.yaml @@ -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 diff --git a/hasura/migrations/1602868457785_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1602868457785_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 0000000..09fb18d --- /dev/null +++ b/hasura/migrations/1602868457785_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1602869347189_update_permission_user_public_table_joblines/down.yaml b/hasura/migrations/1602869347189_update_permission_user_public_table_joblines/down.yaml new file mode 100644 index 0000000..0578ffd --- /dev/null +++ b/hasura/migrations/1602869347189_update_permission_user_public_table_joblines/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: joblines + schema: public + type: drop_delete_permission diff --git a/hasura/migrations/1602869347189_update_permission_user_public_table_joblines/up.yaml b/hasura/migrations/1602869347189_update_permission_user_public_table_joblines/up.yaml new file mode 100644 index 0000000..ea3daa7 --- /dev/null +++ b/hasura/migrations/1602869347189_update_permission_user_public_table_joblines/up.yaml @@ -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 diff --git a/hasura/migrations/1602869404642_alter_table_public_jobs_add_column_group/down.yaml b/hasura/migrations/1602869404642_alter_table_public_jobs_add_column_group/down.yaml new file mode 100644 index 0000000..9bd67b5 --- /dev/null +++ b/hasura/migrations/1602869404642_alter_table_public_jobs_add_column_group/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."jobs" DROP COLUMN "group"; + type: run_sql diff --git a/hasura/migrations/1602869404642_alter_table_public_jobs_add_column_group/up.yaml b/hasura/migrations/1602869404642_alter_table_public_jobs_add_column_group/up.yaml new file mode 100644 index 0000000..b5e3304 --- /dev/null +++ b/hasura/migrations/1602869404642_alter_table_public_jobs_add_column_group/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."jobs" ADD COLUMN "group" text NULL; + type: run_sql diff --git a/hasura/migrations/1602869421937_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602869421937_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..3b7af84 --- /dev/null +++ b/hasura/migrations/1602869421937_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602869421937_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602869421937_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..cb24b7d --- /dev/null +++ b/hasura/migrations/1602869421937_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602869426871_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602869426871_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..f390ffb --- /dev/null +++ b/hasura/migrations/1602869426871_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602869426871_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602869426871_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..5f92597 --- /dev/null +++ b/hasura/migrations/1602869426871_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602869432212_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602869432212_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..1dc7e1e --- /dev/null +++ b/hasura/migrations/1602869432212_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602869432212_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602869432212_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..687f130 --- /dev/null +++ b/hasura/migrations/1602869432212_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602869698796_alter_table_public_jobs_add_column_v_mileage/down.yaml b/hasura/migrations/1602869698796_alter_table_public_jobs_add_column_v_mileage/down.yaml new file mode 100644 index 0000000..80bb4c0 --- /dev/null +++ b/hasura/migrations/1602869698796_alter_table_public_jobs_add_column_v_mileage/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."jobs" DROP COLUMN "v_mileage"; + type: run_sql diff --git a/hasura/migrations/1602869698796_alter_table_public_jobs_add_column_v_mileage/up.yaml b/hasura/migrations/1602869698796_alter_table_public_jobs_add_column_v_mileage/up.yaml new file mode 100644 index 0000000..14ca21b --- /dev/null +++ b/hasura/migrations/1602869698796_alter_table_public_jobs_add_column_v_mileage/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."jobs" ADD COLUMN "v_mileage" numeric NULL; + type: run_sql diff --git a/hasura/migrations/1602869708868_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602869708868_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..cb24b7d --- /dev/null +++ b/hasura/migrations/1602869708868_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602869708868_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602869708868_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..f5e3c98 --- /dev/null +++ b/hasura/migrations/1602869708868_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602869715323_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602869715323_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..5f92597 --- /dev/null +++ b/hasura/migrations/1602869715323_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602869715323_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602869715323_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..32ee08b --- /dev/null +++ b/hasura/migrations/1602869715323_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602869720762_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602869720762_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..687f130 --- /dev/null +++ b/hasura/migrations/1602869720762_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602869720762_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602869720762_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..aa046ff --- /dev/null +++ b/hasura/migrations/1602869720762_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602870360794_create_table_public_veh_groups/down.yaml b/hasura/migrations/1602870360794_create_table_public_veh_groups/down.yaml new file mode 100644 index 0000000..d3b93f5 --- /dev/null +++ b/hasura/migrations/1602870360794_create_table_public_veh_groups/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: DROP TABLE "public"."veh_groups"; + type: run_sql diff --git a/hasura/migrations/1602870360794_create_table_public_veh_groups/up.yaml b/hasura/migrations/1602870360794_create_table_public_veh_groups/up.yaml new file mode 100644 index 0000000..3055334 --- /dev/null +++ b/hasura/migrations/1602870360794_create_table_public_veh_groups/up.yaml @@ -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 diff --git a/hasura/migrations/1602870372897_update_permission_user_public_table_veh_groups/down.yaml b/hasura/migrations/1602870372897_update_permission_user_public_table_veh_groups/down.yaml new file mode 100644 index 0000000..7d52713 --- /dev/null +++ b/hasura/migrations/1602870372897_update_permission_user_public_table_veh_groups/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: veh_groups + schema: public + type: drop_select_permission diff --git a/hasura/migrations/1602870372897_update_permission_user_public_table_veh_groups/up.yaml b/hasura/migrations/1602870372897_update_permission_user_public_table_veh_groups/up.yaml new file mode 100644 index 0000000..7d4f270 --- /dev/null +++ b/hasura/migrations/1602870372897_update_permission_user_public_table_veh_groups/up.yaml @@ -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 diff --git a/hasura/migrations/1602870431650_alter_table_public_veh_groups_alter_column_type/down.yaml b/hasura/migrations/1602870431650_alter_table_public_veh_groups_alter_column_type/down.yaml new file mode 100644 index 0000000..ea4b767 --- /dev/null +++ b/hasura/migrations/1602870431650_alter_table_public_veh_groups_alter_column_type/down.yaml @@ -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 diff --git a/hasura/migrations/1602870431650_alter_table_public_veh_groups_alter_column_type/up.yaml b/hasura/migrations/1602870431650_alter_table_public_veh_groups_alter_column_type/up.yaml new file mode 100644 index 0000000..b6e61f7 --- /dev/null +++ b/hasura/migrations/1602870431650_alter_table_public_veh_groups_alter_column_type/up.yaml @@ -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 diff --git a/hasura/migrations/1602873078741_alter_table_public_jobs_add_column_v_age/down.yaml b/hasura/migrations/1602873078741_alter_table_public_jobs_add_column_v_age/down.yaml new file mode 100644 index 0000000..d371886 --- /dev/null +++ b/hasura/migrations/1602873078741_alter_table_public_jobs_add_column_v_age/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."jobs" DROP COLUMN "v_age"; + type: run_sql diff --git a/hasura/migrations/1602873078741_alter_table_public_jobs_add_column_v_age/up.yaml b/hasura/migrations/1602873078741_alter_table_public_jobs_add_column_v_age/up.yaml new file mode 100644 index 0000000..6ac8779 --- /dev/null +++ b/hasura/migrations/1602873078741_alter_table_public_jobs_add_column_v_age/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."jobs" ADD COLUMN "v_age" numeric NULL; + type: run_sql diff --git a/hasura/migrations/1602873087099_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602873087099_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..f5e3c98 --- /dev/null +++ b/hasura/migrations/1602873087099_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602873087099_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602873087099_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..f990b45 --- /dev/null +++ b/hasura/migrations/1602873087099_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602873093113_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602873093113_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..32ee08b --- /dev/null +++ b/hasura/migrations/1602873093113_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602873093113_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602873093113_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..99f24da --- /dev/null +++ b/hasura/migrations/1602873093113_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602873098109_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602873098109_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..aa046ff --- /dev/null +++ b/hasura/migrations/1602873098109_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602873098109_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602873098109_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..4626eb8 --- /dev/null +++ b/hasura/migrations/1602873098109_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602873194803_alter_table_public_jobs_add_column_asgn_date/down.yaml b/hasura/migrations/1602873194803_alter_table_public_jobs_add_column_asgn_date/down.yaml new file mode 100644 index 0000000..ef01a96 --- /dev/null +++ b/hasura/migrations/1602873194803_alter_table_public_jobs_add_column_asgn_date/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."jobs" DROP COLUMN "asgn_date"; + type: run_sql diff --git a/hasura/migrations/1602873194803_alter_table_public_jobs_add_column_asgn_date/up.yaml b/hasura/migrations/1602873194803_alter_table_public_jobs_add_column_asgn_date/up.yaml new file mode 100644 index 0000000..a231d38 --- /dev/null +++ b/hasura/migrations/1602873194803_alter_table_public_jobs_add_column_asgn_date/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."jobs" ADD COLUMN "asgn_date" date NULL; + type: run_sql diff --git a/hasura/migrations/1602873201653_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602873201653_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..f990b45 --- /dev/null +++ b/hasura/migrations/1602873201653_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602873201653_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602873201653_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..fe5811f --- /dev/null +++ b/hasura/migrations/1602873201653_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602873207955_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602873207955_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..99f24da --- /dev/null +++ b/hasura/migrations/1602873207955_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602873207955_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602873207955_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..e715d98 --- /dev/null +++ b/hasura/migrations/1602873207955_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602873213716_update_permission_user_public_table_jobs/down.yaml b/hasura/migrations/1602873213716_update_permission_user_public_table_jobs/down.yaml new file mode 100644 index 0000000..4626eb8 --- /dev/null +++ b/hasura/migrations/1602873213716_update_permission_user_public_table_jobs/down.yaml @@ -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 diff --git a/hasura/migrations/1602873213716_update_permission_user_public_table_jobs/up.yaml b/hasura/migrations/1602873213716_update_permission_user_public_table_jobs/up.yaml new file mode 100644 index 0000000..b7f688a --- /dev/null +++ b/hasura/migrations/1602873213716_update_permission_user_public_table_jobs/up.yaml @@ -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 diff --git a/hasura/migrations/1602873825801_alter_table_public_jobs_alter_column_asgn_date/down.yaml b/hasura/migrations/1602873825801_alter_table_public_jobs_alter_column_asgn_date/down.yaml new file mode 100644 index 0000000..bc1c975 --- /dev/null +++ b/hasura/migrations/1602873825801_alter_table_public_jobs_alter_column_asgn_date/down.yaml @@ -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 diff --git a/hasura/migrations/1602873825801_alter_table_public_jobs_alter_column_asgn_date/up.yaml b/hasura/migrations/1602873825801_alter_table_public_jobs_alter_column_asgn_date/up.yaml new file mode 100644 index 0000000..1f5f622 --- /dev/null +++ b/hasura/migrations/1602873825801_alter_table_public_jobs_alter_column_asgn_date/up.yaml @@ -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 diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index d660583..6905f65 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -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: {} diff --git a/package-lock.json b/package-lock.json index 5ce8bc1..2b5b10e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } }, diff --git a/package.json b/package.json index 9a5d1f1..d5d51a3 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx b/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx index bb0b16c..efc66e3 100644 --- a/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx +++ b/src/components/molecules/jobs-detail-description/jobs-detail-description.molecule.jsx @@ -22,9 +22,11 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) { {`${job.ownr_fn} ${job.ownr_ln}`} {`${job.v_model_yr} ${job.v_makedesc} ${job.v_model}`} - + {job.clm_total} + {job.group} + {job.v_age} ); diff --git a/src/graphql/jobs.queries.js b/src/graphql/jobs.queries.js index 094d56c..749b1aa 100644 --- a/src/graphql/jobs.queries.js +++ b/src/graphql/jobs.queries.js @@ -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 diff --git a/src/graphql/veh_group.queries.js b/src/graphql/veh_group.queries.js new file mode 100644 index 0000000..70f59a2 --- /dev/null +++ b/src/graphql/veh_group.queries.js @@ -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 + } + } +`; diff --git a/src/ipc/ipc-estimate-utils.js b/src/ipc/ipc-estimate-utils.js index 586fffd..312ace7 100644 --- a/src/ipc/ipc-estimate-utils.js +++ b/src/ipc/ipc-estimate-utils.js @@ -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 ""; +}; diff --git a/src/serviceWorker.js b/src/serviceWorker.js deleted file mode 100644 index 4562ae5..0000000 --- a/src/serviceWorker.js +++ /dev/null @@ -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(); - }); - } -}