From 1511b879591eb46621402e2fcbb5c8e15155192b Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 26 Oct 2021 13:10:07 -0700 Subject: [PATCH] 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); +}