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,6 +378,18 @@ 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.
if (hasMahwLine) {
//Update it
job.joblines.forEach((jl) => {
if (jl.id === hasMahwLine.id) {
jl.act_price = stlMahw.ttl_amt;
}
});
await client.request(queries.UPDATE_JOB_LINE, {
lineId: hasMahwLine.id,
line: { act_price: stlMahw.ttl_amt },
});
} else {
const newMahwLine = { const newMahwLine = {
line_desc: "Hazardous Waste Removal*", line_desc: "Hazardous Waste Removal*",
part_type: "PAS", part_type: "PAS",
@@ -401,6 +413,7 @@ async function CalculateRatesTotals({ job, client }) {
lineInput: [newMahwLine], lineInput: [newMahwLine],
}); });
} }
}
//Materials Scrubbing as required by CCC. //Materials Scrubbing as required by CCC.
let matTotalLine = job.cieca_stl.data.find((l) => l.ttl_typecd === "MAT"); let matTotalLine = job.cieca_stl.data.find((l) => l.ttl_typecd === "MAT");
@@ -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);
} }