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);