feature/IO-3255-simplified-parts-management - Checkpoint

This commit is contained in:
Dave
2025-08-28 14:24:35 -04:00
parent 67002b8443
commit f071a5cc9e
6 changed files with 173 additions and 152 deletions

View File

@@ -38,13 +38,15 @@ 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.
//TODO: In the full BMS world, much more can change, this will need to be expanded
// before it can be considered an generic BMS importer, currently it is bespoke to webest
const policyNo = claim.PolicyInfo?.PolicyInfo?.PolicyNum || claim.PolicyInfo?.PolicyNum || null;
const out = {
comment: doc.Comment || null,
clm_no: claim.ClaimNum || null,
status: claim.ClaimStatus || null,
// TODO: Commented out so they do not blow over with 'Auth Cust'
// status: claim.ClaimStatus || null,
policy_no: policyNo
};
@@ -239,7 +241,6 @@ 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);
@@ -247,12 +248,13 @@ 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.
//TODO: for changed lines, are they deleted and then reinserted?
//TODO: 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 }); //PF: appears to soft delete updated lines as well.
await client.request(SOFT_DELETE_JOBLINES_BY_IDS, { jobid: job.id, unqSeqs: allToDelete });
//TODO: appears to soft delete updated lines as well.
}
}