IO-2054 RO Splitting for QBO

This commit is contained in:
Patrick Fic
2022-09-26 11:33:58 -07:00
parent 220e863482
commit acd3f545b3
6 changed files with 149 additions and 9 deletions

View File

@@ -100,7 +100,9 @@ exports.default = async (req, res) => {
oauthClient,
qbo_realmId,
req,
job
job,
isThreeTier,
insCoCustomerTier
);
//Query for the owner itself.
if (!ownerCustomerTier) {
@@ -121,7 +123,11 @@ exports.default = async (req, res) => {
qbo_realmId,
req,
job,
isThreeTier ? ownerCustomerTier : null // ownerCustomerTier || insCoCustomerTier
isThreeTier
? ownerCustomerTier
: twoTierPref === "source"
? insCoCustomerTier
: ownerCustomerTier
);
// Need to validate that the job tier is associated to the right individual?
@@ -342,7 +348,14 @@ async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) {
}
exports.InsertInsuranceCo = InsertInsuranceCo;
async function QueryOwner(oauthClient, qbo_realmId, req, job) {
async function QueryOwner(
oauthClient,
qbo_realmId,
req,
job,
isThreeTier,
parentTierRef
) {
const ownerName = generateOwnerTier(job, true, null);
const result = await oauthClient.makeApiCall({
url: urlBuilder(
@@ -362,7 +375,9 @@ async function QueryOwner(oauthClient, qbo_realmId, req, job) {
result.json &&
result.json.QueryResponse &&
result.json.QueryResponse.Customer &&
result.json.QueryResponse.Customer[0]
result.json.QueryResponse.Customer.find(
(x) => x.ParentRef?.value === parentTierRef?.Id
)
);
}
exports.QueryOwner = QueryOwner;