diff --git a/electron/decoder/decoder.js b/electron/decoder/decoder.js index fff6c3a..49a517e 100644 --- a/electron/decoder/decoder.js +++ b/electron/decoder/decoder.js @@ -52,18 +52,17 @@ async function DecodeEstimate(filePath, includeFilePathInReturnJob = false, clos ...(await DecodeVehFile(extensionlessFilePath)), ...(await DecodeTtlFile(extensionlessFilePath)), ...(await DecodeLinFile(extensionlessFilePath, close_date)), - ...(await DecodePflFile(extensionlessFilePath,)), - ...(await DecodePfmFile(extensionlessFilePath,)), - ...(await DecodePfhFile(extensionlessFilePath,)), - ...(await DecodeStlFile(extensionlessFilePath,)), + ...(await DecodePflFile(extensionlessFilePath)), + ...(await DecodePfmFile(extensionlessFilePath)), + ...(await DecodePfhFile(extensionlessFilePath)), + ...(await DecodeStlFile(extensionlessFilePath)), ...(includeFilePathInReturnJob ? { filePath } : {}) }; const ad2 = await DecodeAd2File(extensionlessFilePath); - - job.rates = [...job.rates || [], ...job.mat_rates || []]; - delete job.mat_rates + job.rates = [...(job.rates || []), ...(job.mat_rates || [])]; + delete job.mat_rates; job.insp_date = ad2.INSP_DATE; if (job.OWNR_FN === "" || !job.OWNR_FN) job.OWNR_FN = ad2.CLMT_FN; @@ -78,6 +77,8 @@ async function DecodeEstimate(filePath, includeFilePathInReturnJob = false, clos // returnValue = { ERROR: "Vehicle mileage is less than 20,000kms." }; // } else + const ins_rule_set = store.get("ins_rule_set"); + if (!accepted_ins_co.includes(job.INS_CO_NM)) { returnValue = { ERROR: `Insurance Company Name is not valid for RPS. (${job.INS_CO_NM || "No name set"})` @@ -87,7 +88,7 @@ async function DecodeEstimate(filePath, includeFilePathInReturnJob = false, clos returnValue = { ERROR: `An unique claim number must be set for all jobs sent to RPS.` }; - } else if (!(job.CLM_NO.match("-01$") || job.CLM_NO.match("-99$"))) { + } else if (ins_rule_set === "MPI" && !(job.CLM_NO.match("-01$") || job.CLM_NO.match("-99$"))) { // 2024-05-10 Only -01 and -99 apply. Refactor logic. log.info("Job ignored. This is not a -01 or -99 claim. Claim #. " + job.CLM_NO); returnValue = { @@ -218,7 +219,7 @@ async function DecodeAd1File(extensionlessFilePath) { // "OWNR_ST", // "OWNR_ZIP", // "OWNR_CTRY", - "OWNR_PH1", + "OWNR_PH1" // "OWNR_PH1X", // "OWNR_PH2", // "OWNR_PH2X", @@ -265,9 +266,7 @@ async function DecodePfhFile(extensionlessFilePath) { } finally { if (!dbf) return {}; let records = await dbf.readRecords(1); - return _.pick(records[0], [ - "ID_PRO_NAM" - ]); + return _.pick(records[0], ["ID_PRO_NAM"]); } } @@ -304,7 +303,7 @@ async function DecodeVehFile(extensionlessFilePath) { // "V_ENGINE", // "V_COLOR", // "V_TONE", - "V_STAGE", + "V_STAGE" // "PAINT_CD1", // "PAINT_CD2", // "PAINT_CD3", @@ -426,30 +425,22 @@ async function DecodeLinFile(extensionlessFilePath, close_date) { return { joblines: { data: joblines } }; } -async function DecodePflFile(extensionlessFilePath,) { +async function DecodePflFile(extensionlessFilePath) { let dbf = await DBFFile.open(`${extensionlessFilePath}.PFL`); let records = await dbf.readRecords(); let pflLines = records.map((record) => { - return ( - _.pick(record, [ - "LBR_TYPE", "LBR_DESC", "LBR_RATE" - ]) - ); + return _.pick(record, ["LBR_TYPE", "LBR_DESC", "LBR_RATE"]); }); //Check for discounts that need to be ignored after the fact. return { rates: pflLines }; } -async function DecodeStlFile(extensionlessFilePath,) { +async function DecodeStlFile(extensionlessFilePath) { let dbf = await DBFFile.open(`${extensionlessFilePath}.STL`); let records = await dbf.readRecords(); let pflLines = records.map((record) => { - return ( - _.pick(record, [ - "TTL_TYPECD", "T_AMT", 'T_HRS', "NT_HRS" - ]) - ); + return _.pick(record, ["TTL_TYPECD", "T_AMT", "T_HRS", "NT_HRS"]); }); //Check for discounts that need to be ignored after the fact. @@ -457,15 +448,11 @@ async function DecodeStlFile(extensionlessFilePath,) { return { totals: pflLines }; } -async function DecodePfmFile(extensionlessFilePath,) { +async function DecodePfmFile(extensionlessFilePath) { let dbf = await DBFFile.open(`${extensionlessFilePath}.PFM`); let records = await dbf.readRecords(); let pflLines = records.map((record) => { - return ( - _.pick(record, [ - "MATL_TYPE", "CAL_PRETHR" - ]) - ); + return _.pick(record, ["MATL_TYPE", "CAL_PRETHR"]); }); //Check for discounts that need to be ignored after the fact. diff --git a/package-lock.json b/package-lock.json index 7404ce5..743bd23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "imexrps", - "version": "1.5.0-alpha.10", + "version": "1.6.0-alpha.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "imexrps", - "version": "1.5.0-alpha.10", + "version": "1.6.0-alpha.1", "hasInstallScript": true, "dependencies": { "@amplitude/analytics-node": "^1.5.10", @@ -58,6 +58,7 @@ "electron": "^35.0.1", "electron-builder": "^25.1.8", "electron-devtools-installer": "^4.0.0", + "esbuild": "^0.25.1", "eslint-config-react": "^1.1.7", "sass-embedded": "^1.93.1", "vite": "^6.2.1", diff --git a/package.json b/package.json index 570c311..da4a253 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "productName": "ImEX RPS", "author": "ImEX Systems Inc. ", "description": "ImEX RPS", - "version": "1.6.0-alpha.2", + "version": "1.6.0-alpha.3", "main": "electron/main.js", "homepage": "./", "dependencies": {