Add opcode and bodyshop query to main

This commit is contained in:
Patrick Fic
2025-03-21 08:33:41 -07:00
parent 6345b5a9a8
commit 6da5822197
9 changed files with 199 additions and 40 deletions

View File

@@ -28,6 +28,8 @@ import { DecodedVeh } from "./decode-veh.interface";
import { DecodedEnv } from "./decode-env.interface";
import DecodeEnv from "./decode-env";
import fs from "fs";
import store from "../store/store";
import client from "../graphql/graphql-client";
async function ImportJob(filepath: string): Promise<void> {
const parsedFilePath = path.parse(filepath);
@@ -90,6 +92,52 @@ async function ImportJob(filepath: string): Promise<void> {
log.debug("Job Object", {
jobObject,
});
//Build the request object
//Insert it
const newAvailableJob = {
// newJob.uploaded_by = Auth.authlink.User.Email;
// newJob.bodyshopid = AppMetaData.ActiveShopId;
// newJob.cieca_id = item.Job.ciecaid;
// newJob.est_data = item.Job;
// newJob.ownr_name = item.Job.ownr_fn?.Value + " " + item.Job.ownr_ln?.Value + " " + item.Job.ownr_co_nm?.Value;
// newJob.ins_co_nm = item.Job.ins_co_nm?.Value;
// newJob.vehicle_info = item.Job.vehicle.data.v_model_yr?.Value + " " + item.Job.vehicle.data.v_make_desc?.Value + " " + item.Job.vehicle.data.v_model_desc?.Value;
// newJob.clm_no = item.Job.clm_no?.Value;
// newJob.clm_amt = item.Job.clm_total?.Value;
// newJob.source_system = item.Job.source_system?.Value;
uploaded_by: store.get("app.user.email"),
bodyshopid: store.get("app.bodyshop.id"),
cieca_id: jobObject.ciecaid,
est_data: jobObject,
ownr_name: `${jobObject.ownr_fn} ${jobObject.ownr_ln} ${jobObject.ownr_co_nm}`,
ins_co_nm: jobObject.ins_co_nm,
vehicle_info: `${jobObject.v_model_yr} ${jobObject.v_make_desc} ${jobObject.v_model_desc}`,
clm_no: jobObject.clm_no,
clm_amt: jobObject.clm_total,
// source_system: jobObject.source_system, //TODO: Add back source system if needed.
};
const existingVehicleId: uuid = await client.query ()
// var vehuuid = await Utils.Queries.VehicleQueries.GetVehicleUuidByVin(item?.Job?.vehicle?.data?.v_vin?.Value ?? "");
// if (!string.IsNullOrEmpty(vehuuid))
// {
// newJob.est_data.vehicle = null;
// newJob.est_data.vehicleid = vehuuid;
// }
// string jobId = await Utils.Queries.JobsQueries.CheckSupplementByClaimNo(item.Job.clm_no?.Value ?? "");
// if (!string.IsNullOrEmpty(jobId))
// {
// newJob.issupplement = true;
// newJob.jobid = jobId;
// };
//Check if the vehicle exists, if it does, use that UUID, if not, keep it to insert it.
} catch (error) {
log.error("Error encountered while decoding job. ", errorTypeCheck(error));
}