IO-3255 Review comments.
This commit is contained in:
@@ -38,7 +38,7 @@ const findJob = async (shopId, jobId, logger) => {
|
||||
const extractUpdatedJobData = (rq) => {
|
||||
const doc = rq.DocumentInfo || {};
|
||||
const claim = rq.ClaimInfo || {};
|
||||
|
||||
//PF: In the full BMS world, much more can change.
|
||||
const policyNo = claim.PolicyInfo?.PolicyInfo?.PolicyNum || claim.PolicyInfo?.PolicyNum || null;
|
||||
|
||||
const out = {
|
||||
@@ -239,6 +239,7 @@ const partsManagementVehicleDamageEstimateChgRq = async (req, res) => {
|
||||
}
|
||||
}
|
||||
// --- End fetch current notes ---
|
||||
//PF: These are several different calls that can be pulled together to make the operation faster.
|
||||
|
||||
const updatedJobData = extractUpdatedJobData(rq);
|
||||
const updatedLines = extractUpdatedJobLines(rq.AddsChgs, job.id, currentJobLineNotes);
|
||||
@@ -246,10 +247,12 @@ const partsManagementVehicleDamageEstimateChgRq = async (req, res) => {
|
||||
|
||||
await client.request(UPDATE_JOB_BY_ID, { id: job.id, job: updatedJobData });
|
||||
|
||||
//PF: for changed lines, are they deleted and then reinserted?
|
||||
//PF: Updated lines should get an upsert to update things like desc, price, etc.
|
||||
if (deletedLineIds?.length || updatedSeqs?.length) {
|
||||
const allToDelete = Array.from(new Set([...(deletedLineIds || []), ...(updatedSeqs || [])]));
|
||||
if (allToDelete.length) {
|
||||
await client.request(SOFT_DELETE_JOBLINES_BY_IDS, { jobid: job.id, unqSeqs: allToDelete });
|
||||
await client.request(SOFT_DELETE_JOBLINES_BY_IDS, { jobid: job.id, unqSeqs: allToDelete }); //PF: appears to soft delete updated lines as well.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user