From b718f49071e0ea636e1078779389b56a353f27df Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 25 Oct 2021 17:05:21 -0700 Subject: [PATCH 1/3] IO-256 Resolve QBO Payable Vendor Insert. --- server/accounting/qbo/qbo-payables.js | 2 +- server/accounting/qbo/qbo-receivables.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/accounting/qbo/qbo-payables.js b/server/accounting/qbo/qbo-payables.js index 5a26fc978..ce96dc3de 100644 --- a/server/accounting/qbo/qbo-payables.js +++ b/server/accounting/qbo/qbo-payables.js @@ -152,7 +152,7 @@ async function InsertVendorRecord(oauthClient, qbo_realmId, req, bill) { body: JSON.stringify(Vendor), }); setNewRefreshToken(req.user.email, result); - return result && result.Vendor; + return result && result.json && result.json.Vendor; } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { error: diff --git a/server/accounting/qbo/qbo-receivables.js b/server/accounting/qbo/qbo-receivables.js index 0a797435a..7f2991234 100644 --- a/server/accounting/qbo/qbo-receivables.js +++ b/server/accounting/qbo/qbo-receivables.js @@ -458,7 +458,7 @@ async function InsertInvoice( body: JSON.stringify(invoiceObj), }); setNewRefreshToken(req.user.email, result); - return result && result.Invoice; + return result && result.json && result.json.Invoice; } catch (error) { logger.log("qbo-receivables-error", "DEBUG", req.user.email, job.id, { error, From 9c3e4b7b83f1a355110d7bc63f93e9c7f8472f9d Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 25 Oct 2021 17:25:29 -0700 Subject: [PATCH 2/3] IO-1489 Resolve payables memo for QBO. --- .gitignore | 1 + server/accounting/qbo/qbo-payables.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 16e920044..fe7c402dc 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,4 @@ firebase/.env .elasticbeanstalk/* !.elasticbeanstalk/*.cfg.yml !.elasticbeanstalk/*.global.yml +logs/oAuthClient-log.log diff --git a/server/accounting/qbo/qbo-payables.js b/server/accounting/qbo/qbo-payables.js index ce96dc3de..7d03f4172 100644 --- a/server/accounting/qbo/qbo-payables.js +++ b/server/accounting/qbo/qbo-payables.js @@ -180,9 +180,9 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor) { DocNumber: bill.invoice_number, ...(bill.job.class ? { ClassRef: { Id: classes[bill.job.class] } } : {}), - Memo: `RO ${bill.job.ro_number || ""} OWNER ${bill.job.ownr_fn || ""} ${ - bill.job.ownr_ln || "" - } ${bill.job.ownr_co_nm || ""}`, + PrivateNote: `RO ${bill.job.ro_number || ""} OWNER ${ + bill.job.ownr_fn || "" + } ${bill.job.ownr_ln || ""} ${bill.job.ownr_co_nm || ""}`, Line: bill.billlines.map((il) => generateBillLine( il, @@ -211,7 +211,7 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor) { body: JSON.stringify(billQbo), }); setNewRefreshToken(req.user.email, result); - return result && result.Bill; + return result && result.json && result.json.Bill; } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { error: @@ -245,6 +245,8 @@ const generateBillLine = ( costCenters ) => { const account = costCenters.find((c) => c.name === billLine.cost_center); + + console.log(account.accountname, accounts[account.accountname]); return { DetailType: "AccountBasedExpenseLineDetail", From 1511b879591eb46621402e2fcbb5c8e15155192b Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 26 Oct 2021 13:10:07 -0700 Subject: [PATCH 3/3] IO-1487 MPI Totals Adjustments --- client/src/graphql/jobs.queries.js | 1 + server/graphql-client/queries.js | 1 + server/job/job-totals.js | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 84d3341c4..a389c8f76 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -535,6 +535,7 @@ export const GET_JOB_BY_PK = gql` unq_seq line_ind line_desc + line_ref part_type oem_partno db_price diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index 61294e008..d5674fd5c 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -797,6 +797,7 @@ exports.GET_JOB_BY_PK = ` query GET_JOB_BY_PK($id: uuid!) { line_ind line_desc part_type + line_ref oem_partno db_price act_price diff --git a/server/job/job-totals.js b/server/job/job-totals.js index 74fabff78..7262a332a 100644 --- a/server/job/job-totals.js +++ b/server/job/job-totals.js @@ -486,7 +486,9 @@ function CalculateTaxesTotals(job, otherTotals) { Dinero({ amount: Math.round((val.act_price || 0) * 100) }) .multiply(val.part_qty || 0) .add( - val.prt_dsmk_m && val.prt_dsmk_m !== 0 + val.prt_dsmk_m && + val.prt_dsmk_m !== 0 && + DiscountNotAlreadyCounted(val, job.joblines) ? Dinero({ amount: Math.round(val.prt_dsmk_m * 100) }) : Dinero({ amount: Math.round(val.act_price * 100), @@ -566,3 +568,9 @@ function CalculateTaxesTotals(job, otherTotals) { } exports.default = Totals; + +function DiscountNotAlreadyCounted(jobline, joblines) { + if (jobline.db_ref !== "900510") return true; + const ParentLine = joblines.find((j) => j.unq_seq === jobline.line_ref); + return ParentLine && !(ParentLine.prt_dsmk_m && ParentLine.prt_dsmk_m !== 0); +}