From 77ed64969e910d795d89b76b8330cc0644173bcf Mon Sep 17 00:00:00 2001
From: Patrick Fic <>
Date: Wed, 13 Apr 2022 12:34:31 -0700
Subject: [PATCH] IO-1822 Add manual ATS calculation.
---
bodyshop_translations.babel | 42 +++++++++
.../jobs-detail-rates.component.jsx | 35 ++++++-
client/src/graphql/jobs.queries.js | 2 +
client/src/translations/en_us/common.json | 2 +
client/src/translations/es/common.json | 2 +
client/src/translations/fr/common.json | 2 +
server/graphql-client/queries.js | 34 +++++++
server/job/job-totals.js | 93 ++++++++++++++++++-
8 files changed, 209 insertions(+), 3 deletions(-)
diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel
index 0d5fae5eb..41d273976 100644
--- a/bodyshop_translations.babel
+++ b/bodyshop_translations.babel
@@ -20355,6 +20355,27 @@
+
+ auto_add_ats
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
ca_bc_pvrt
false
@@ -23257,6 +23278,27 @@
+
+ rate_ats
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
rate_la1
false
diff --git a/client/src/components/jobs-detail-rates/jobs-detail-rates.component.jsx b/client/src/components/jobs-detail-rates/jobs-detail-rates.component.jsx
index a91e9b65d..bff0440c0 100644
--- a/client/src/components/jobs-detail-rates/jobs-detail-rates.component.jsx
+++ b/client/src/components/jobs-detail-rates/jobs-detail-rates.component.jsx
@@ -88,6 +88,33 @@ export function JobsDetailRates({ jobRO, form, job, bodyshop }) {
+
+
+
+
+ prev.auto_add_ats !== cur.auto_add_ats}
+ >
+ {() => {
+ if (form.getFieldValue("auto_add_ats"))
+ return (
+
+
+
+ );
+
+ return null;
+ }}
+
-
+
{
+ if (val.line_desc && val.line_desc.toLowerCase() === "ats amount") {
+ atsLineIndex = index;
+ }
+
+ if (
+ val.mod_lbr_ty !== "LA1" &&
+ val.mod_lbr_ty !== "LA2" &&
+ val.mod_lbr_ty !== "LA3" &&
+ val.mod_lbr_ty !== "LA4" &&
+ val.mod_lbr_ty !== "LAU" &&
+ val.mod_lbr_ty !== "LAG" &&
+ val.mod_lbr_ty !== "LAS" &&
+ val.mod_lbr_ty !== "LAA"
+ ) {
+ acc = acc + val.mod_lb_hrs;
+ }
+
+ return acc;
+ }, 0);
+
+ const atsAmount = atsHours * (job.rate_ats || 0);
+ //If it does, update it in place, and make sure it is updated for local calculations.
+ if (atsLineIndex === null) {
+ const newAtsLine = {
+ jobid: job.id,
+ alt_partm: null,
+ line_no: 35,
+ unq_seq: 0,
+ line_ind: "E",
+ line_desc: "ATS Amount",
+ line_ref: 0.0,
+ part_type: null,
+ oem_partno: null,
+ db_price: 0.0,
+ act_price: atsAmount,
+ part_qty: 1,
+ mod_lbr_ty: null,
+ db_hrs: 0.0,
+ mod_lb_hrs: 0.0,
+ lbr_op: "OP13",
+ lbr_amt: 0.0,
+ op_code_desc: "ADDITIONAL COSTS",
+ status: null,
+ location: null,
+ tax_part: true,
+ db_ref: null,
+ manual_line: true,
+ prt_dsmk_p: 0.0,
+ prt_dsmk_m: 0.0,
+ };
+
+ const result = await client.request(queries.INSERT_NEW_JOB_LINE, {
+ lineInput: [newAtsLine],
+ });
+
+ job.joblines.push(newAtsLine);
+ }
+ //If it does not, create one for local calculations and insert it.
+ else {
+ const result = await client.request(queries.UPDATE_JOB_LINE, {
+ line: { act_price: atsAmount },
+ lineId: job.joblines[atsLineIndex].id,
+ });
+ job.joblines[atsLineIndex].act_price = atsAmount;
+ }
+
+ console.log(job.jobLines);
+ }
+}
+
function CalculateRatesTotals(ratesList) {
const jobLines = ratesList.joblines.filter((jl) => !jl.removed);