From 1cdc34249a588fb38ed7b735c88b1be363886992 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 13 Oct 2021 15:48:43 -0700 Subject: [PATCH] IO-256 Fix null handling for missing metadata. --- server/accounting/qbo/qbo-payables.js | 3 +++ server/accounting/qbo/qbo-payments.js | 1 + server/accounting/qbo/qbo-receivables.js | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/accounting/qbo/qbo-payables.js b/server/accounting/qbo/qbo-payables.js index a473ffab2..32ee0e2d9 100644 --- a/server/accounting/qbo/qbo-payables.js +++ b/server/accounting/qbo/qbo-payables.js @@ -280,6 +280,7 @@ async function QueryMetaData(oauthClient, req) { taxCodes.json && taxCodes.json.QueryResponse && + taxCodes.json.QueryResponse.TaxCode && taxCodes.json.QueryResponse.TaxCode.forEach((t) => { taxCodeMapping[t.Name] = t.Id; }); @@ -288,6 +289,7 @@ async function QueryMetaData(oauthClient, req) { accounts.json && accounts.json.QueryResponse && + accounts.json.QueryResponse.Account && accounts.json.QueryResponse.Account.forEach((t) => { accountMapping[t.Name] = t.Id; }); @@ -295,6 +297,7 @@ async function QueryMetaData(oauthClient, req) { const classMapping = {}; classes.json && classes.json.QueryResponse && + classes.json.QueryResponse.Class && classes.json.QueryResponse.Class.forEach((t) => { accountMapping[t.Name] = t.Id; }); diff --git a/server/accounting/qbo/qbo-payments.js b/server/accounting/qbo/qbo-payments.js index 149a4779f..e1042b739 100644 --- a/server/accounting/qbo/qbo-payments.js +++ b/server/accounting/qbo/qbo-payments.js @@ -251,6 +251,7 @@ async function QueryMetaData(oauthClient, req, ro_number) { paymentMethods.json && paymentMethods.json.QueryResponse && + paymentMethods.json.QueryResponse.PaymentMethod && paymentMethods.json.QueryResponse.PaymentMethod.forEach((t) => { paymentMethodMapping[t.Name] = t.Id; }); diff --git a/server/accounting/qbo/qbo-receivables.js b/server/accounting/qbo/qbo-receivables.js index b0e3ea758..e28af80f2 100644 --- a/server/accounting/qbo/qbo-receivables.js +++ b/server/accounting/qbo/qbo-receivables.js @@ -347,6 +347,7 @@ async function QueryMetaData(oauthClient, req) { taxCodes.json && taxCodes.json.QueryResponse && + taxCodes.json.QueryResponse.TaxCode && taxCodes.json.QueryResponse.TaxCode.forEach((t) => { taxCodeMapping[t.Name] = t.Id; }); @@ -355,6 +356,7 @@ async function QueryMetaData(oauthClient, req) { items.json && items.json.QueryResponse && + items.json.QueryResponse.Item && items.json.QueryResponse.Item.forEach((t) => { itemMapping[t.Name] = t.Id; }); @@ -362,6 +364,7 @@ async function QueryMetaData(oauthClient, req) { const classMapping = {}; classes.json && classes.json.QueryResponse && + classes.json.QueryResponse.Class && classes.json.QueryResponse.Class.forEach((t) => { itemMapping[t.Name] = t.Id; }); @@ -394,7 +397,7 @@ async function InsertInvoice(oauthClient, req, job, bodyshop, parentTierRef) { ...(bodyshop.accountingconfig.printlater ? { PrintStatus: "NeedToPrint" } : {}), - ...(bodyshop.accountingconfig.emaillater + ...(bodyshop.accountingconfig.emaillater && job.ownr_ea ? { EmailStatus: "NeedToSend" } : {}), };