ES Schema changes & initial upload attempt.
This commit is contained in:
@@ -52,11 +52,18 @@ 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 DecodeStlFile(extensionlessFilePath,)),
|
||||
...(includeFilePathInReturnJob ? { filePath } : {})
|
||||
};
|
||||
|
||||
const ad2 = await DecodeAd2File(extensionlessFilePath);
|
||||
|
||||
|
||||
job.rates = [...job.rates || [], ...job.mat_rates || []];
|
||||
delete job.mat_rates
|
||||
|
||||
if (job.OWNR_FN === "" || !job.OWNR_FN) job.OWNR_FN = ad2.CLMT_FN;
|
||||
if (job.OWNR_LN === "" || !job.OWNR_LN) job.OWNR_LN = ad2.CLMT_LN;
|
||||
if (job.OWNR_CO_NM) job.OWNR_LN = `${job.OWNR_LN} ${job.OWNR_CO_NM}`;
|
||||
@@ -124,7 +131,7 @@ async function DecodeAd1File(extensionlessFilePath) {
|
||||
|
||||
// "INS_EA",
|
||||
// "POLICY_NO",
|
||||
// "DED_AMT",
|
||||
"DED_AMT",
|
||||
// "DED_STATUS",
|
||||
// "ASGN_NO",
|
||||
//"ASGN_DATE",
|
||||
@@ -177,7 +184,7 @@ async function DecodeAd1File(extensionlessFilePath) {
|
||||
// "AGT_LIC_NO",
|
||||
"LOSS_DATE",
|
||||
"LOSS_TYPE",
|
||||
// "LOSS_DESC",
|
||||
"LOSS_DESC",
|
||||
// "THEFT_IND",
|
||||
// "CAT_NO",
|
||||
// "TLOS_IND",
|
||||
@@ -202,14 +209,14 @@ async function DecodeAd1File(extensionlessFilePath) {
|
||||
"OWNR_LN",
|
||||
"OWNR_FN",
|
||||
// "OWNR_TITLE",
|
||||
"OWNR_CO_NM"
|
||||
// "OWNR_ADDR1",
|
||||
"OWNR_CO_NM",
|
||||
"OWNR_ADDR1",
|
||||
// "OWNR_ADDR2",
|
||||
// "OWNR_CITY",
|
||||
"OWNR_CITY",
|
||||
// "OWNR_ST",
|
||||
// "OWNR_ZIP",
|
||||
// "OWNR_CTRY",
|
||||
// "OWNR_PH1",
|
||||
"OWNR_PH1",
|
||||
// "OWNR_PH1X",
|
||||
// "OWNR_PH2",
|
||||
// "OWNR_PH2X",
|
||||
@@ -272,7 +279,7 @@ async function DecodeVehFile(extensionlessFilePath) {
|
||||
"V_MAKEDESC",
|
||||
"V_MODEL",
|
||||
"V_TYPE",
|
||||
"V_MILEAGE"
|
||||
"V_MILEAGE",
|
||||
// "V_BSTYLE",
|
||||
// "V_TRIMCODE",
|
||||
// "TRIM_COLOR",
|
||||
@@ -280,7 +287,7 @@ async function DecodeVehFile(extensionlessFilePath) {
|
||||
// "V_ENGINE",
|
||||
// "V_COLOR",
|
||||
// "V_TONE",
|
||||
// "V_STAGE",
|
||||
"V_STAGE",
|
||||
// "PAINT_CD1",
|
||||
// "PAINT_CD2",
|
||||
// "PAINT_CD3",
|
||||
@@ -290,7 +297,7 @@ async function DecodeVehFile(extensionlessFilePath) {
|
||||
async function DecodeTtlFile(extensionlessFilePath) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}.TTL`);
|
||||
let records = await dbf.readRecords(1);
|
||||
return { clm_total: records[0]["G_TTL_AMT"] };
|
||||
return { clm_total: records[0]["G_TTL_AMT"], supp_amt: records[0]["SUPP_AMT"], g_bett_amt: records[0]["G_BETT_AMT"] };
|
||||
}
|
||||
|
||||
async function DecodeLinFile(extensionlessFilePath, close_date) {
|
||||
@@ -311,17 +318,17 @@ async function DecodeLinFile(extensionlessFilePath, close_date) {
|
||||
// "PART_DESCJ",
|
||||
"PRT_DSMK_M",
|
||||
"OEM_PARTNO",
|
||||
// "PRICE_INC",
|
||||
"PRICE_INC",
|
||||
// "ALT_PART_I",
|
||||
// "TAX_PART",
|
||||
"TAX_PART",
|
||||
"DB_PRICE",
|
||||
"ACT_PRICE",
|
||||
"PART_QTY",
|
||||
"PRICE_J",
|
||||
"GLASS_FLAG",
|
||||
// "CERT_PART",
|
||||
"CERT_PART",
|
||||
// "ALT_CO_ID",
|
||||
// "ALT_PARTNO",
|
||||
"ALT_PARTNO",
|
||||
// "ALT_OVERRD",
|
||||
// "ALT_PARTM",
|
||||
"PRT_DSMK_P",
|
||||
@@ -333,7 +340,7 @@ async function DecodeLinFile(extensionlessFilePath, close_date) {
|
||||
"LBR_OP",
|
||||
"LBR_HRS_J",
|
||||
// "LBR_TYP_J",
|
||||
// "LBR_OP_J",
|
||||
"LBR_OP_J",
|
||||
// "PAINT_STG",
|
||||
// "PAINT_TONE",
|
||||
// "LBR_TAX",
|
||||
@@ -389,6 +396,52 @@ async function DecodeLinFile(extensionlessFilePath, close_date) {
|
||||
|
||||
return { joblines: { data: joblines } };
|
||||
}
|
||||
async function DecodePflFile(extensionlessFilePath,) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}.PFL`);
|
||||
let records = await dbf.readRecords();
|
||||
let pflLines = records.map((record) => {
|
||||
return _.transform(
|
||||
_.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,) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}.STL`);
|
||||
let records = await dbf.readRecords();
|
||||
let pflLines = records.map((record) => {
|
||||
return _.transform(
|
||||
_.pick(record, [
|
||||
"TTL_TYPECD", "T_AMT", 'T_HRS', "NT_HRS"
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
//Check for discounts that need to be ignored after the fact.
|
||||
|
||||
return { totals: pflLines };
|
||||
}
|
||||
|
||||
async function DecodePfmFile(extensionlessFilePath,) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}.PFM`);
|
||||
let records = await dbf.readRecords();
|
||||
let pflLines = records.map((record) => {
|
||||
return _.transform(
|
||||
_.pick(record, [
|
||||
"MAT_TYPE", "CAL_PRETHR"
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
//Check for discounts that need to be ignored after the fact.
|
||||
|
||||
return { mat_rates: pflLines };
|
||||
}
|
||||
|
||||
exports.DecodeEstimate = DecodeEstimate;
|
||||
exports.ImportJob = ImportJob;
|
||||
|
||||
@@ -10,20 +10,34 @@ const { BrowserWindow } = require("electron");
|
||||
|
||||
|
||||
async function ScrubEstimate({ job }) {
|
||||
//These need to be removed.
|
||||
//TODO: Fetch these from ImEX Online API.
|
||||
const basicAuthUser = "Imex";
|
||||
const basicAuthpassword = "Patrick";
|
||||
const estimateScrubberUrl = "https://insurtechtoolkit.com/api/sendems";
|
||||
const sendingEntityId = '87330f61-412b-4251-baaa-d026565b23c5'
|
||||
|
||||
//Perform data manipulation on the job object
|
||||
if (!job) {
|
||||
console.error("No job provided to ScrubEstimate");
|
||||
return;
|
||||
}
|
||||
|
||||
//Set shop metrics
|
||||
job.sending_entity_id = sendingEntityId;
|
||||
job.sending_entity_accept_terms_of_use = true;
|
||||
job.association_switch = "ATAM";
|
||||
job.rf_ph1 = "R0G 1Z0";
|
||||
job.rf_zip = "2043792253";
|
||||
job.g_ttl_amt = job.clm_total;
|
||||
|
||||
|
||||
const fileName = `RPSTest-${job.id}-${Date.now()}`;
|
||||
console.log("*** ~ ScrubEstimate ~ job:", job);
|
||||
|
||||
//Build the JSON Form Data
|
||||
const fileName = `RPSTest-${job.id}-${Date.now()}`;
|
||||
const formData = new FormData();
|
||||
const jsonString = JSON.stringify(job);
|
||||
formData.append("file", new Blob([jsonString], { type: "application/json" }), `${fileName}.json`);
|
||||
|
||||
console.log("*** ~ ScrubEstimate ~ formData.getHeaders();:", formData);
|
||||
const result = await axios.post(estimateScrubberUrl, formData, {
|
||||
auth: {
|
||||
username: basicAuthUser,
|
||||
@@ -33,7 +47,7 @@ async function ScrubEstimate({ job }) {
|
||||
});
|
||||
console.log("*** ~ handleScrub ~ result:", result.data);
|
||||
|
||||
const resultPDFUrl = `https://www.insurtechtoolkit.com/analysis/${fileName}.pdf`;
|
||||
const resultPDFUrl = result?.data?.[0] || `https://www.insurtechtoolkit.com/analysis/${fileName}.pdf`;
|
||||
|
||||
console.log("*** ~ handleScrub ~ resultPDFUrl:", resultPDFUrl);
|
||||
const pdfWindow = new BrowserWindow({
|
||||
|
||||
Reference in New Issue
Block a user