From ba9ea1780589d8fd78f3914c93f9282dfdae856d Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 6 Sep 2022 09:41:02 -0700 Subject: [PATCH] Add QBO error for missing insurance company name. --- server/accounting/qbo/qbo-receivables.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/accounting/qbo/qbo-receivables.js b/server/accounting/qbo/qbo-receivables.js index e8d66c136..00827363c 100644 --- a/server/accounting/qbo/qbo-receivables.js +++ b/server/accounting/qbo/qbo-receivables.js @@ -238,6 +238,12 @@ exports.QueryInsuranceCo = QueryInsuranceCo; async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) { const insCo = bodyshop.md_ins_cos.find((i) => i.name === job.ins_co_nm); + if (!insCo) { + throw new Error( + `Insurance Company '${job.ins_co_nm}' not found in shop configuration. Please make sure it exists or change the insurance company name on the job to one that exists.` + ); + return; + } const Customer = { DisplayName: job.ins_co_nm.trim(), BillWithParent: true,