Update hazard waste calculation.

This commit is contained in:
Patrick Fic
2023-09-13 14:39:58 -07:00
parent 536f8d9cb9
commit d1ba90408d

View File

@@ -378,28 +378,41 @@ async function CalculateRatesTotals({ job, client }) {
(!hasMahwLine || hasMahwLine.act_price !== stlMahw.ttl_amt) (!hasMahwLine || hasMahwLine.act_price !== stlMahw.ttl_amt)
) { ) {
//Add a hazardous waste material line in case there isn't one on the estimate. //Add a hazardous waste material line in case there isn't one on the estimate.
const newMahwLine = { if (hasMahwLine) {
line_desc: "Hazardous Waste Removal*", //Update it
part_type: "PAS", job.joblines.forEach((jl) => {
oem_partno: null, if (jl.id === hasMahwLine.id) {
db_price: 0, jl.act_price = stlMahw.ttl_amt;
act_price: stlMahw.ttl_amt, }
part_qty: 1, });
//mod_lbr_ty: "LAB", await client.request(queries.UPDATE_JOB_LINE, {
db_hrs: 0, lineId: hasMahwLine.id,
mod_lb_hrs: 0, line: { act_price: stlMahw.ttl_amt },
lbr_op: "OP11", });
lbr_amt: 0, } else {
op_code_desc: "REMOVE / REPLACE", const newMahwLine = {
tax_part: stlMahw.tax_amt > 0 ? true : false, line_desc: "Hazardous Waste Removal*",
db_ref: null, part_type: "PAS",
manual_line: true, oem_partno: null,
jobid: job.id, db_price: 0,
}; act_price: stlMahw.ttl_amt,
job.joblines.push(newMahwLine); part_qty: 1,
await client.request(queries.INSERT_NEW_JOB_LINE, { //mod_lbr_ty: "LAB",
lineInput: [newMahwLine], db_hrs: 0,
}); mod_lb_hrs: 0,
lbr_op: "OP11",
lbr_amt: 0,
op_code_desc: "REMOVE / REPLACE",
tax_part: stlMahw.tax_amt > 0 ? true : false,
db_ref: null,
manual_line: true,
jobid: job.id,
};
job.joblines.push(newMahwLine);
await client.request(queries.INSERT_NEW_JOB_LINE, {
lineInput: [newMahwLine],
});
}
} }
//Materials Scrubbing as required by CCC. //Materials Scrubbing as required by CCC.
@@ -1061,10 +1074,10 @@ async function UpdateJobLines(joblinesToUpdate) {
generateUpdateQuery(_.pick(line, ["id", "prt_dsmk_m", "prt_dsmk_p"]), index) generateUpdateQuery(_.pick(line, ["id", "prt_dsmk_m", "prt_dsmk_p"]), index)
); );
const query = ` const query = `
mutation UPDATE_EST_LINES{ mutation UPDATE_EST_LINES{
${updateQueries} ${updateQueries}
} }
`; `;
const result = await adminClient.request(query); const result = await adminClient.request(query);
} }