Merged in IO-3389-Parts-Scanning-Part-# (pull request #2605)
IO-3389 Parts Scanning with Part # Update Approved-by: Patrick Fic
This commit is contained in:
@@ -82,22 +82,35 @@ exports.partsScan = async function (req, res) {
|
||||
criticalIds.add(jobline.id);
|
||||
}
|
||||
if (update_field && update_value) {
|
||||
const result = await client.setHeaders({ Authorization: BearerToken }).request(queries.UPDATE_JOB_LINE, {
|
||||
lineId: jobline.id,
|
||||
line: { [update_field]: update_value, manual_line: true }
|
||||
});
|
||||
|
||||
const auditResult = 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
|
||||
let actualUpdateField = update_field;
|
||||
if (update_field === "part_number") {
|
||||
// Determine which part number field to update based on the match
|
||||
if (!jobline.oem_partno) {
|
||||
actualUpdateField = "oem_partno";
|
||||
} else {
|
||||
if (regex) {
|
||||
actualUpdateField = regex.test(jobline.oem_partno || "") ? "oem_partno" : "alt_partno";
|
||||
} else {
|
||||
actualUpdateField = jobline.oem_partno === value ? "oem_partno" : "alt_partno";
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user