IO-256 QBO Improvements.

This commit is contained in:
Patrick Fic
2021-10-13 21:12:02 -07:00
parent b54d5beb76
commit b56742bcb2
8 changed files with 88 additions and 20 deletions

View File

@@ -66,7 +66,7 @@ exports.default = async (req, res) => {
//Replace this with a for-each loop to check every single Job that's included in the list.
let insCoCustomerTier, ownerCustomerTier, jobTier;
if (isThreeTier || twoTierPref === "source") {
if (isThreeTier || (!isThreeTier && twoTierPref === "source")) {
//Insert the insurance company tier.
//Query for top level customer, the insurance company name.
insCoCustomerTier = await QueryInsuranceCo(oauthClient, req, job);
@@ -81,7 +81,7 @@ exports.default = async (req, res) => {
}
}
if (isThreeTier || twoTierPref === "name") {
if (isThreeTier || (!isThreeTier && twoTierPref === "name")) {
//Insert the name/owner and account for whether the source should be the ins co in 3 tier..
ownerCustomerTier = await QueryOwner(oauthClient, req, job);
//Query for the owner itself.
@@ -106,8 +106,8 @@ exports.default = async (req, res) => {
oauthClient,
req,
job,
isThreeTier,
ownerCustomerTier
ownerCustomerTier || insCoCustomerTier
);
}
@@ -279,7 +279,7 @@ async function QueryJob(oauthClient, req, job) {
);
}
exports.QueryJob = QueryJob;
async function InsertJob(oauthClient, req, job, isThreeTier, parentTierRef) {
async function InsertJob(oauthClient, req, job, parentTierRef) {
const Customer = {
DisplayName: job.ro_number,
BillAddr: {
@@ -289,14 +289,11 @@ async function InsertJob(oauthClient, req, job, isThreeTier, parentTierRef) {
PostalCode: job.ownr_zip,
CountrySubDivisionCode: job.ownr_st,
},
...(isThreeTier
? {
Job: true,
ParentRef: {
value: parentTierRef.Id,
},
}
: {}),
Job: true,
ParentRef: {
value: parentTierRef.Id,
},
};
try {
const result = await oauthClient.makeApiCall({