diff --git a/electron/estimate-scrubber/estimate-scrubber.js b/electron/estimate-scrubber/estimate-scrubber.js index 17d3833..a644b3f 100644 --- a/electron/estimate-scrubber/estimate-scrubber.js +++ b/electron/estimate-scrubber/estimate-scrubber.js @@ -1,11 +1,7 @@ -const path = require("path"); const fs = require("fs"); -const { store } = require("../electron-store"); const log = require("electron-log"); -const fsPromises = fs.promises; -const { DecodeEstimate } = require("../decoder/decoder"); const axios = require("axios"); -const TestJson = require("./A.json"); + const { BrowserWindow } = require("electron"); async function ScrubEstimate({ job }) { @@ -30,10 +26,28 @@ async function ScrubEstimate({ job }) { job.g_ttl_amt = job.clm_total; delete job.clm_total; + //Lower case the rates & totals + if (job.rates && Array.isArray(job.rates)) { + job.rates = job.rates.map(rate => { + const lowercasedRate = {}; + for (const [key, value] of Object.entries(rate)) { + lowercasedRate[key.toLowerCase()] = value; + } + return lowercasedRate; + }); + } + if (job.totals && Array.isArray(job.totals)) { + job.totals = job.totals.map(total => { + const lowercasedTotal = {}; + for (const [key, value] of Object.entries(total)) { + lowercasedTotal[key.toLowerCase()] = value; + } + return lowercasedTotal; + }); + } console.log("*** ~ ScrubEstimate ~ job:", job); log.debug("Estimate Scrubber Job Data:", job); - //Build the JSON Form Data const fileName = `RPSTest-${job.id}-${Date.now()}`; const formData = new FormData(); const jsonString = JSON.stringify(job);