IO-3389 Parts Scanning with Part # Update
Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -82,22 +82,35 @@ exports.partsScan = async function (req, res) {
|
|||||||
criticalIds.add(jobline.id);
|
criticalIds.add(jobline.id);
|
||||||
}
|
}
|
||||||
if (update_field && update_value) {
|
if (update_field && update_value) {
|
||||||
const result = await client.setHeaders({ Authorization: BearerToken }).request(queries.UPDATE_JOB_LINE, {
|
let actualUpdateField = update_field;
|
||||||
lineId: jobline.id,
|
if (update_field === "part_number") {
|
||||||
line: { [update_field]: update_value, manual_line: true }
|
// Determine which part number field to update based on the match
|
||||||
});
|
if (!jobline.oem_partno) {
|
||||||
|
actualUpdateField = "oem_partno";
|
||||||
const auditResult = await client
|
} else {
|
||||||
.setHeaders({ Authorization: BearerToken })
|
if (regex) {
|
||||||
.request(queries.INSERT_AUDIT_TRAIL, {
|
actualUpdateField = regex.test(jobline.oem_partno || "") ? "oem_partno" : "alt_partno";
|
||||||
auditObj: {
|
} else {
|
||||||
bodyshopid: data.jobs_by_pk.bodyshop.id,
|
actualUpdateField = jobline.oem_partno === value ? "oem_partno" : "alt_partno";
|
||||||
jobid,
|
|
||||||
operation: `Jobline (#${jobline.line_no} ${jobline.line_desc}/${jobline.id}) ${update_field} updated from ${jobline[update_field]} to ${update_value}. Lined marked as manual line.`,
|
|
||||||
type: "partscanupdate",
|
|
||||||
useremail: req.user.email
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (actualUpdateField) {
|
||||||
|
await client.setHeaders({ Authorization: BearerToken }).request(queries.UPDATE_JOB_LINE, {
|
||||||
|
lineId: jobline.id,
|
||||||
|
line: { [actualUpdateField]: update_value, manual_line: true }
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await client.setHeaders({ Authorization: BearerToken }).request(queries.INSERT_AUDIT_TRAIL, {
|
||||||
|
auditObj: {
|
||||||
|
bodyshopid: data.jobs_by_pk.bodyshop.id,
|
||||||
|
jobid,
|
||||||
|
operation: `Jobline (#${jobline.line_no} ${jobline.line_desc}/${jobline.id}) ${update_field} updated from ${jobline[update_field]} to ${update_value}. Lined marked as manual line.`,
|
||||||
|
type: "partscanupdate",
|
||||||
|
useremail: req.user.email
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//break; // No need to evaluate further rules for this jobline
|
//break; // No need to evaluate further rules for this jobline
|
||||||
|
|||||||
Reference in New Issue
Block a user