Succesful test imports to IO.
This commit is contained in:
@@ -33,18 +33,18 @@ const DecodePfh = async (
|
||||
//TODO: Several of these fields will fail. Should extend schema to capture them.
|
||||
//"ID_PRO_NAM", //Remove
|
||||
"TAX_PRETHR",
|
||||
"TAX_THRAMT", //Remove
|
||||
//"TAX_THRAMT", //Remove
|
||||
"TAX_PSTTHR",
|
||||
"TAX_TOW_IN", //Remove
|
||||
//"TAX_TOW_IN", //Remove
|
||||
"TAX_TOW_RT",
|
||||
"TAX_STR_IN", //Remove
|
||||
//"TAX_STR_IN", //Remove
|
||||
"TAX_STR_RT",
|
||||
"TAX_SUB_IN", //Remove
|
||||
//"TAX_SUB_IN", //Remove
|
||||
"TAX_SUB_RT",
|
||||
"TAX_BTR_IN", //Remove
|
||||
//"TAX_BTR_IN", //Remove
|
||||
"TAX_LBR_RT",
|
||||
"TAX_GST_RT",
|
||||
"TAX_GST_IN", //Remove
|
||||
//"TAX_GST_IN", //Remove
|
||||
"ADJ_G_DISC",
|
||||
"ADJ_TOWDIS",
|
||||
"ADJ_STRDIS",
|
||||
|
||||
@@ -137,9 +137,9 @@ const DecodePfm = async (
|
||||
...jobMaterialRates,
|
||||
materials: {
|
||||
mash: mashLine,
|
||||
mapa: mapaLine,
|
||||
mapa: mapaLine, //TODO: Need to verify if more fields are to come in here.
|
||||
},
|
||||
cieca_pfm: rawPfmData,
|
||||
//cieca_pfm: rawPfmData, //TODO: Not currently captured. This may have valu in the future.
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import deepLowerCaseKeys from "../../util/deepLowercaseKeys";
|
||||
import { DecodedVeh, VehicleRecordInterface } from "./decode-veh.interface";
|
||||
import errorTypeCheck from "../../util/errorTypeCheck";
|
||||
import store from "../store/store";
|
||||
import typeCaster from "../../util/typeCaster";
|
||||
|
||||
const DecodeVeh = async (
|
||||
extensionlessFilePath: string,
|
||||
@@ -28,35 +29,43 @@ const DecodeVeh = async (
|
||||
//AD2 will always have only 1 row.
|
||||
//Commented lines have been cross referenced with existing partner fields.
|
||||
|
||||
const rawVehData: VehicleRecordInterface = deepLowerCaseKeys(
|
||||
_.pick(rawDBFRecord[0], [
|
||||
//TODO: Add typings for EMS File Formats.
|
||||
"IMPACT_1",
|
||||
"IMPACT_2",
|
||||
"DB_V_CODE",
|
||||
"PLATE_NO",
|
||||
"PLATE_ST",
|
||||
"V_VIN",
|
||||
"V_COND",
|
||||
"V_PROD_DT",
|
||||
"V_MODEL_YR",
|
||||
"V_MAKECODE",
|
||||
"V_MAKEDESC",
|
||||
"V_MODEL",
|
||||
"V_TYPE",
|
||||
"V_BSTYLE",
|
||||
"V_TRIMCODE",
|
||||
"TRIM_COLOR",
|
||||
"V_MLDGCODE",
|
||||
"V_ENGINE",
|
||||
"V_MILEAGE",
|
||||
"V_COLOR",
|
||||
"V_TONE",
|
||||
"V_STAGE",
|
||||
"PAINT_CD1",
|
||||
"PAINT_CD2",
|
||||
"PAINT_CD3",
|
||||
]),
|
||||
//typeCaster is required as the previous partner sent some of these values toString, and the database was made accordingly rather than keeping their original type.
|
||||
//Alternative is to change the database schema to match the original type.
|
||||
const rawVehData: VehicleRecordInterface = typeCaster(
|
||||
deepLowerCaseKeys(
|
||||
_.pick(rawDBFRecord[0], [
|
||||
//TODO: Add typings for EMS File Formats.
|
||||
"IMPACT_1",
|
||||
"IMPACT_2",
|
||||
"DB_V_CODE",
|
||||
"PLATE_NO",
|
||||
"PLATE_ST",
|
||||
"V_VIN",
|
||||
"V_COND",
|
||||
"V_PROD_DT",
|
||||
"V_MODEL_YR",
|
||||
"V_MAKECODE",
|
||||
"V_MAKEDESC",
|
||||
"V_MODEL",
|
||||
"V_TYPE",
|
||||
"V_BSTYLE",
|
||||
"V_TRIMCODE",
|
||||
"TRIM_COLOR",
|
||||
"V_MLDGCODE",
|
||||
"V_ENGINE",
|
||||
"V_MILEAGE",
|
||||
"V_COLOR",
|
||||
"V_TONE",
|
||||
"V_STAGE",
|
||||
"PAINT_CD1",
|
||||
"PAINT_CD2",
|
||||
"PAINT_CD3",
|
||||
]),
|
||||
),
|
||||
{
|
||||
v_tone: "string",
|
||||
v_stage: "string",
|
||||
},
|
||||
);
|
||||
|
||||
//Apply business logic transfomrations.
|
||||
@@ -69,13 +78,16 @@ const DecodeVeh = async (
|
||||
delete rawVehData.v_model;
|
||||
|
||||
//Consolidate Area of Damage.
|
||||
rawVehData.area_of_damage = {
|
||||
const area_of_damage = {
|
||||
impact1: rawVehData.impact_1 ?? "",
|
||||
impact2: rawVehData.impact_2 ?? "",
|
||||
};
|
||||
delete rawVehData.impact_1;
|
||||
delete rawVehData.impact_2;
|
||||
|
||||
const kmin = rawVehData.v_mileage ?? 0;
|
||||
delete rawVehData.v_mileage;
|
||||
|
||||
//Consolidate Paint Code information.
|
||||
rawVehData.v_paint_codes = {
|
||||
paint_cd1: rawVehData.paint_cd1 ?? "",
|
||||
@@ -97,8 +109,8 @@ const DecodeVeh = async (
|
||||
v_make_desc: rawVehData.v_make_desc,
|
||||
v_model_desc: rawVehData.v_model_desc,
|
||||
v_color: rawVehData.v_color,
|
||||
kmin: rawVehData.v_mileage,
|
||||
area_of_damage: rawVehData.area_of_damage,
|
||||
kmin: kmin,
|
||||
area_of_damage: area_of_damage,
|
||||
vehicle: {
|
||||
data: rawVehData,
|
||||
},
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { UUID } from "crypto";
|
||||
import { Notification } from "electron";
|
||||
import log from "electron-log/main";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import errorTypeCheck from "../../util/errorTypeCheck";
|
||||
import client from "../graphql/graphql-client";
|
||||
import {
|
||||
INSERT_AVAILABLE_JOB_TYPED,
|
||||
InsertAvailableJobResult,
|
||||
QUERY_JOB_BY_CLM_NO_TYPED,
|
||||
QUERY_VEHICLE_BY_VIN_TYPED,
|
||||
QueryJobByClmNoResult,
|
||||
@@ -77,6 +80,7 @@ async function ImportJob(filepath: string): Promise<void> {
|
||||
...stl,
|
||||
...ttl,
|
||||
...pfp,
|
||||
shopid: store.get("app.bodyshop.id") as UUID,
|
||||
};
|
||||
|
||||
// Save jobObject to a timestamped JSON file
|
||||
@@ -100,11 +104,8 @@ async function ImportJob(filepath: string): Promise<void> {
|
||||
jobObject,
|
||||
});
|
||||
|
||||
//Build the request object
|
||||
|
||||
//Insert it
|
||||
const newAvailableJob: AvailableJobSchema = {
|
||||
uploaded_by: store.get("app.user.email"),
|
||||
uploaded_by: store.get("user.email"),
|
||||
bodyshopid: store.get("app.bodyshop.id"),
|
||||
cieca_id: jobObject.ciecaid,
|
||||
est_data: jobObject,
|
||||
@@ -141,8 +142,28 @@ async function ImportJob(filepath: string): Promise<void> {
|
||||
newAvailableJob.issupplement = true;
|
||||
newAvailableJob.jobid = existingJobRecord.jobs[0].id;
|
||||
}
|
||||
|
||||
const insertRecordResult: InsertAvailableJobResult = await client.request(
|
||||
INSERT_AVAILABLE_JOB_TYPED,
|
||||
{
|
||||
jobInput: [newAvailableJob],
|
||||
},
|
||||
);
|
||||
new Notification({
|
||||
title: "Job Imported",
|
||||
body: `Job ${newAvailableJob.cieca_id} imported successfully`,
|
||||
actions: [{ text: "View Job", type: "button" }],
|
||||
subtitle: newAvailableJob.ownr_name,
|
||||
}).show();
|
||||
|
||||
log.debug("Job inserted", insertRecordResult);
|
||||
} catch (error) {
|
||||
log.error("Error encountered while decoding job. ", errorTypeCheck(error));
|
||||
new Notification({
|
||||
title: "Job Upload Failure",
|
||||
body: errorTypeCheck(error).message, //TODO: Remove after debug.
|
||||
actions: [{ text: "View Job", type: "button" }],
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +184,7 @@ export interface RawJobDataObject
|
||||
DecodedTtl,
|
||||
DecodedPfp {
|
||||
vehicleid?: UUID;
|
||||
shopid: UUID;
|
||||
}
|
||||
|
||||
export interface AvailableJobSchema {
|
||||
|
||||
Reference in New Issue
Block a user