From 58c6ba2f87f1f1ab27c1f2b93c5dbebdeeda7b0d Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 27 May 2021 16:49:21 -0700 Subject: [PATCH] IO-1152 Add missing fields to query. --- server/accounting/qbxml/qbxml-receivables.js | 17 ++++++++--------- server/graphql-client/queries.js | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/accounting/qbxml/qbxml-receivables.js b/server/accounting/qbxml/qbxml-receivables.js index 375a99d88..2138c5b50 100644 --- a/server/accounting/qbxml/qbxml-receivables.js +++ b/server/accounting/qbxml/qbxml-receivables.js @@ -212,17 +212,16 @@ const generateInvoiceQbxml = ( } if (jobline.profitcenter_part && jobline.act_price) { - const DineroAmount = Dinero({ + let DineroAmount = Dinero({ amount: Math.round(jobline.act_price * 100), - }) - .multiply(jobline.part_qty || 1) - .add( - Dinero({ - amount: Math.round((jobline.act_price || 0) * 100), - }) - .multiply(jobline.part_qty || 0) - .percentage(jobline.prt_dsmk_p || 0) + }).multiply(jobline.part_qty || 1); + + if (jobline.prt_dsmk_p && jobline.prt_dsmk_p !== 0) { + console.log("Have a part discount", jobline); + DineroAmount = DineroAmount.add( + DineroAmount.percentage(jobline.prt_dsmk_p || 0) ); + } const account = responsibilityCenters.profits.find( (i) => jobline.profitcenter_part.toLowerCase() === i.name.toLowerCase() ); diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index 9b7b3677c..ee3de5cf9 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -101,6 +101,7 @@ query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($ids: [uuid!]!) { profitcenter_labor profitcenter_part db_ref + prt_dsmk_p } } bodyshops(where: {associations: {active: {_eq: true}}}) {