diff --git a/server/accounting/qbo/qbo-payables.js b/server/accounting/qbo/qbo-payables.js index 57d357c50..a473ffab2 100644 --- a/server/accounting/qbo/qbo-payables.js +++ b/server/accounting/qbo/qbo-payables.js @@ -79,7 +79,8 @@ exports.default = async (req, res) => { billid: bill.id, success: false, errorMessage: - (error && error.authResponse.body) || JSON.stringify(error), + (error && error.authResponse && error.authResponse.body) || + JSON.stringify(error), }); } } @@ -114,7 +115,9 @@ async function QueryVendorRecord(oauthClient, req, bill) { ); } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { - error: (error && error.authResponse.body) || JSON.stringify(error), + error: + (error && error.authResponse && error.authResponse.body) || + JSON.stringify(error), method: "QueryVendorRecord", }); throw error; @@ -137,7 +140,9 @@ async function InsertVendorRecord(oauthClient, req, bill) { return result && result.Vendor; } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { - error: (error && error.authResponse.body) || JSON.stringify(error), + error: + (error && error.authResponse && error.authResponse.body) || + JSON.stringify(error), method: "InsertVendorRecord", }); throw error; @@ -170,6 +175,9 @@ async function InsertBill(oauthClient, req, bill, vendor) { ) ), }; + logger.log("qbo-payable-objectlog", "DEBUG", req.user.email, bill.id, { + billQbo, + }); try { const result = await oauthClient.makeApiCall({ url: urlBuilder( @@ -186,7 +194,9 @@ async function InsertBill(oauthClient, req, bill, vendor) { return result && result.Bill; } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { - error: (error && error.authResponse.body) || JSON.stringify(error), + error: + (error && error.authResponse && error.authResponse.body) || + JSON.stringify(error), method: "InsertBill", }); throw error; diff --git a/server/accounting/qbo/qbo-payments.js b/server/accounting/qbo/qbo-payments.js index 99ae12fc9..149a4779f 100644 --- a/server/accounting/qbo/qbo-payments.js +++ b/server/accounting/qbo/qbo-payments.js @@ -128,14 +128,17 @@ exports.default = async (req, res) => { ret.push({ paymentid: payment.id, success: true }); } catch (error) { logger.log("qbo-payment-create-error", "ERROR", req.user.email, { - error: (error && error.authResponse.body) || JSON.stringify(error), + error: + (error && error.authResponse && error.authResponse.body) || + JSON.stringify(error), }); ret.push({ paymentid: payment.id, success: false, errorMessage: - (error && error.authResponse.body) || JSON.stringify(error), + (error && error.authResponse && error.authResponse.body) || + JSON.stringify(error), }); } } @@ -188,6 +191,9 @@ async function InsertPayment(oauthClient, req, payment, parentRef) { }, ], }; + logger.log("qbo-payments-objectlog", "DEBUG", req.user.email, payment.id, { + paymentQbo, + }); try { const result = await oauthClient.makeApiCall({ url: urlBuilder(req.cookies.qbo_realmId, "payment"), diff --git a/server/accounting/qbo/qbo-receivables.js b/server/accounting/qbo/qbo-receivables.js index 3a9eafb31..b0e3ea758 100644 --- a/server/accounting/qbo/qbo-receivables.js +++ b/server/accounting/qbo/qbo-receivables.js @@ -118,7 +118,8 @@ exports.default = async (req, res) => { jobid: job.id, success: false, errorMessage: - (error && error.authResponse.body) || JSON.stringify(error), + (error && error.authResponse && error.authResponse.body) || + JSON.stringify(error), }); } } @@ -398,10 +399,15 @@ async function InsertInvoice(oauthClient, req, job, bodyshop, parentTierRef) { : {}), }; + logger.log("qbo-receivable-objectlog", "DEBUG", req.user.email, job.id, { + invoiceObj, + }); + try { const result = await oauthClient.makeApiCall({ url: urlBuilder(req.cookies.qbo_realmId, "invoice"), method: "POST", + headers: { "Content-Type": "application/json", },