Almost matching export.

This commit is contained in:
Patrick Fic
2025-03-20 12:50:47 -07:00
parent 2e5fe7c99d
commit 45209bd9e4
32 changed files with 490 additions and 120 deletions

View File

@@ -3,6 +3,7 @@ import log from "electron-log/main";
import _ from "lodash";
import deepLowerCaseKeys from "../../util/deepLowercaseKeys";
import errorTypeCheck from "../../util/errorTypeCheck";
import store from "../store/store";
import { DecodedAd1, OwnerRecordInterface } from "./decode-ad1.interface";
const DecodeAD1 = async (
@@ -26,7 +27,9 @@ const DecodeAD1 = async (
//AD1 will always have only 1 row.
//Commented lines have been cross referenced with existing partner fields.
const d = rawDBFRecord[0].ASGN_DATE;
console.log(d);
console.log(typeof rawDBFRecord[0].ASGN_DATE);
const rawAd1Data: DecodedAd1 = deepLowerCaseKeys(
_.pick(rawDBFRecord[0], [
//TODO: Add typings for EMS File Formats.
@@ -149,6 +152,11 @@ const DecodeAD1 = async (
//Copy specific logic for manipulation.
//If ownr_ph1 is missing, use ownr_ph2
if (rawAd1Data.asgn_date) {
const newAsgnDate = new Date(rawAd1Data.asgn_date);
rawAd1Data.asgn_date = newAsgnDate.toISOString().split("T")[0];
}
if (!rawAd1Data.ownr_ph1) {
rawAd1Data.ownr_ph1 = rawAd1Data.ownr_ph2;
}
@@ -161,7 +169,8 @@ const DecodeAD1 = async (
_.isEmpty(rawAd1Data.ownr_co_nm)
) {
//They're all empty. Using the insured information as a fallback.
// //Build up the owner record to insert it alongside the job.
// Build up the owner record to insert it alongside the job.
//TODO: Verify that this should be the insured, and not the claimant.
ownerRecord = {
ownr_ln: rawAd1Data.insd_ln,
ownr_fn: rawAd1Data.insd_fn,
@@ -176,8 +185,7 @@ const DecodeAD1 = async (
ownr_ph1: rawAd1Data.insd_ph1,
ownr_ph2: rawAd1Data.insd_ph2,
ownr_ea: rawAd1Data.insd_ea,
shopid: "UUID", //TODO: Need to add the shop uuid to this set of functions.
shopid: store.get("app.bodyshop.id"),
};
} else {
//Use the owner information.
@@ -195,10 +203,11 @@ const DecodeAD1 = async (
ownr_ph1: rawAd1Data.ownr_ph1,
ownr_ph2: rawAd1Data.ownr_ph2,
ownr_ea: rawAd1Data.ownr_ea,
shopid: "UUID", //TODO: Need to add the shop uuid to this set of functions.
shopid: store.get("app.bodyshop.id"),
};
}
const s = store.get("app");
console.log(s);
return { ...rawAd1Data, owner: { data: ownerRecord } };
};
export default DecodeAD1;