From 0a5df69b12828dfae86a87f1e8c870d6ac2c0839 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 12 Sep 2024 13:03:23 -0700 Subject: [PATCH 1/3] IO-2927 Update QBO Payable to use ITC. --- server/accounting/qbo/qbo-payables.js | 4 +++- server/accounting/qbo/qbo-receivables.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/accounting/qbo/qbo-payables.js b/server/accounting/qbo/qbo-payables.js index 27523c78e..6c68a2cbf 100644 --- a/server/accounting/qbo/qbo-payables.js +++ b/server/accounting/qbo/qbo-payables.js @@ -209,7 +209,7 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop) AccountBasedExpenseLineDetail: { ...(bill.job.class ? { ClassRef: { value: classes[bill.job.class] } } : {}), AccountRef: { - value: accounts[bodyshop.md_responsibility_centers.taxes.federal.accountdesc] + value: accounts[bodyshop.md_responsibility_centers.taxes.federal_itc.accountdesc] // 373559-1 } }, @@ -274,6 +274,8 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop) } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { error: error, //(error && error.authResponse && error.authResponse.body) || (error && error.message), + validationError: JSON.stringify(error?.response?.data), + accountmeta: JSON.stringify({ accounts, taxCodes, classes }), method: "InsertBill" }); throw error; diff --git a/server/accounting/qbo/qbo-receivables.js b/server/accounting/qbo/qbo-receivables.js index 11ba20bc5..663a5b4b6 100644 --- a/server/accounting/qbo/qbo-receivables.js +++ b/server/accounting/qbo/qbo-receivables.js @@ -575,7 +575,9 @@ async function InsertInvoice(oauthClient, qbo_realmId, req, job, bodyshop, paren } catch (error) { logger.log("qbo-receivables-error", "DEBUG", req.user.email, job.id, { error, - method: "InsertOwner" + method: "InsertInvoice", + validationError: JSON.stringify(error?.response?.data), + accountmeta: JSON.stringify({ accounts, taxCodes, classes }) }); throw error; } From 2858a5e87136083f2a9b9cfce166dfade82d893f Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 12 Sep 2024 13:23:53 -0700 Subject: [PATCH 2/3] IO-2997 Add better error handling for 400 requests. --- .circleci/config.yml | 2 +- server/accounting/qbo/qbo-payables.js | 5 ++++- server/accounting/qbo/qbo-receivables.js | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4f35873a2..1c3856997 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -433,7 +433,7 @@ workflows: branches: only: master-AIO - rome-hasura-migrate: - secret: ${HASURA_PROD_SECRET} + secret: ${HASURA_ROME_PROD_SECRET} filters: branches: only: master-AIO diff --git a/server/accounting/qbo/qbo-payables.js b/server/accounting/qbo/qbo-payables.js index 6c68a2cbf..dbe99ddd1 100644 --- a/server/accounting/qbo/qbo-payables.js +++ b/server/accounting/qbo/qbo-payables.js @@ -94,7 +94,10 @@ exports.default = async (req, res) => { ret.push({ billid: bill.id, success: false, - errorMessage: (error && error.authResponse && error.authResponse.body) || (error && error.message) + errorMessage: + (error && error.authResponse && error.authResponse.body) || + error.response?.data?.Fault?.Error.map((e) => e.Detail).join(", ") || + (error && error.message) }); //Add the export log error. diff --git a/server/accounting/qbo/qbo-receivables.js b/server/accounting/qbo/qbo-receivables.js index 663a5b4b6..0fcbb0ce7 100644 --- a/server/accounting/qbo/qbo-receivables.js +++ b/server/accounting/qbo/qbo-receivables.js @@ -179,7 +179,10 @@ exports.default = async (req, res) => { ret.push({ jobid: job.id, success: false, - errorMessage: (error && error.authResponse && error.authResponse.body) || (error && error.message) + errorMessage: + (error && error.authResponse && error.authResponse.body) || + error.response?.data?.Fault?.Error.map((e) => e.Detail).join(", ") || + (error && error.message) }); console.log(error); logger.log("qbo-receivable-create-error", "ERROR", req.user.email, { From 4acf0c59ca2d8fbdacd87ab52af7ac329bb72501 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 12 Sep 2024 13:25:14 -0700 Subject: [PATCH 3/3] IO-2997 Remove unnecessary comment. --- server/accounting/qbo/qbo-payables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/accounting/qbo/qbo-payables.js b/server/accounting/qbo/qbo-payables.js index dbe99ddd1..eacf36f4d 100644 --- a/server/accounting/qbo/qbo-payables.js +++ b/server/accounting/qbo/qbo-payables.js @@ -212,7 +212,7 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop) AccountBasedExpenseLineDetail: { ...(bill.job.class ? { ClassRef: { value: classes[bill.job.class] } } : {}), AccountRef: { - value: accounts[bodyshop.md_responsibility_centers.taxes.federal_itc.accountdesc] // 373559-1 + value: accounts[bodyshop.md_responsibility_centers.taxes.federal_itc.accountdesc] } },