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,14 +82,27 @@ 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;
|
||||||
|
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,
|
lineId: jobline.id,
|
||||||
line: { [update_field]: update_value, manual_line: true }
|
line: { [actualUpdateField]: update_value, manual_line: true }
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const auditResult = await client
|
await client.setHeaders({ Authorization: BearerToken }).request(queries.INSERT_AUDIT_TRAIL, {
|
||||||
.setHeaders({ Authorization: BearerToken })
|
|
||||||
.request(queries.INSERT_AUDIT_TRAIL, {
|
|
||||||
auditObj: {
|
auditObj: {
|
||||||
bodyshopid: data.jobs_by_pk.bodyshop.id,
|
bodyshopid: data.jobs_by_pk.bodyshop.id,
|
||||||
jobid,
|
jobid,
|
||||||
|
|||||||
Reference in New Issue
Block a user