FIx date issue & ES fields.
This commit is contained in:
@@ -433,7 +433,7 @@ async function DecodePfmFile(extensionlessFilePath,) {
|
||||
let pflLines = records.map((record) => {
|
||||
return (
|
||||
_.pick(record, [
|
||||
"MAT_TYPE", "CAL_PRETHR"
|
||||
"MATL_TYPE", "CAL_PRETHR"
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
@@ -8,6 +8,31 @@ const axios = require("axios");
|
||||
const TestJson = require("./A.json");
|
||||
const { BrowserWindow } = require("electron");
|
||||
|
||||
// Function to write job object to logs subfolder
|
||||
async function writeJobToLogsFolder(job, fileName) {
|
||||
try {
|
||||
// Get the directory where electron-log stores its files
|
||||
const logFilePath = log.transports.file.getFile().path;
|
||||
const logsDir = path.dirname(logFilePath);
|
||||
|
||||
// Create a subfolder for job objects
|
||||
const jobLogsDir = path.join(logsDir, 'esjson');
|
||||
|
||||
// Ensure the directory exists
|
||||
await fsPromises.mkdir(jobLogsDir, { recursive: true });
|
||||
|
||||
// Write the job object as JSON
|
||||
const jobFilePath = path.join(jobLogsDir, `${fileName}.json`);
|
||||
await fsPromises.writeFile(jobFilePath, JSON.stringify(job, null, 2), 'utf8');
|
||||
|
||||
log.log(`Job object written to: ${jobFilePath}`);
|
||||
return jobFilePath;
|
||||
} catch (error) {
|
||||
log.error('Error writing job object to logs folder:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function ScrubEstimate({ job }) {
|
||||
//TODO: Fetch these from ImEX Online API.
|
||||
const basicAuthUser = "Imex";
|
||||
@@ -30,11 +55,31 @@ async function ScrubEstimate({ job }) {
|
||||
job.g_ttl_amt = job.clm_total;
|
||||
delete job.clm_total;
|
||||
|
||||
//Adjust the rates field to be MAT_TYPE instead of MATL_TYPE
|
||||
if (job.rates && Array.isArray(job.rates)) {
|
||||
job.rates.forEach(rate => {
|
||||
if (rate.MATL_TYPE) {
|
||||
rate.MAT_TYPE = rate.MATL_TYPE;
|
||||
delete rate.MATL_TYPE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
console.log("*** ~ ScrubEstimate ~ job:", job);
|
||||
log.debug("Estimate Scrubber Job Data:", job);
|
||||
log.log("Estimate Scrubber Job Data:", job);
|
||||
|
||||
//Build the JSON Form Data
|
||||
const fileName = `RPSTest-${job.id}-${Date.now()}`;
|
||||
|
||||
// Write job object to logs subfolder
|
||||
try {
|
||||
await writeJobToLogsFolder(job, fileName);
|
||||
} catch (error) {
|
||||
log.error('Failed to write job to logs folder:', error);
|
||||
// Continue with the rest of the function even if this fails
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
const jsonString = JSON.stringify(job);
|
||||
formData.append("file", new Blob([jsonString], { type: "application/json" }), `${fileName}.json`);
|
||||
@@ -49,7 +94,7 @@ async function ScrubEstimate({ job }) {
|
||||
|
||||
const resultPDFUrl = result?.data?.[0] || `https://www.insurtechtoolkit.com/analysis/${fileName}.pdf`;
|
||||
|
||||
log.debug("Estimate Scrubber Result:", result.data, resultPDFUrl);
|
||||
log.log("Estimate Scrubber Result:", result.data, resultPDFUrl);
|
||||
const pdfWindow = new BrowserWindow({
|
||||
|
||||
webPreferences: {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"productName": "ImEX RPS",
|
||||
"author": "ImEX Systems Inc. <support@thinkimex.com>",
|
||||
"description": "ImEX RPS",
|
||||
"version": "1.4.2-alpha.1",
|
||||
"version": "1.4.2-alpha.2",
|
||||
"main": "electron/main.js",
|
||||
"homepage": "./",
|
||||
"dependencies": {
|
||||
|
||||
@@ -20,7 +20,7 @@ export function CalculateVehicleAge(job) {
|
||||
const parsedYr = parseInt(job.v_model_yr);
|
||||
const vehicleYr = dayjs().year() + 1 - 2000 >= parsedYr ? 2000 + parsedYr : 1900 + parsedYr;
|
||||
const closeDate = job.close_date ? dayjs(job.close_date) : dayjs();
|
||||
const lossDate = job.loss_date ? dayjs(job.loss_date) : dayjs();
|
||||
const lossDate = job.loss_date ? dayjs.utc(job.loss_date) : dayjs();
|
||||
let ret;
|
||||
|
||||
if (closeDate.isSameOrAfter(dayjs("2023-04-01"))) {
|
||||
|
||||
Reference in New Issue
Block a user