feature/IO-3255-simplified-parts-management - Checkpoint
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
const client = require("../../../graphql-client/graphql-client").client;
|
||||
const { parseXml, normalizeXmlObject } = require("../partsManagementUtils");
|
||||
const { extractPartsTaxRates } = require("./lib/extractPartsTaxRates");
|
||||
const opCodes = require("./lib/opCodes.json");
|
||||
|
||||
const {
|
||||
GET_JOB_BY_ID,
|
||||
@@ -55,6 +56,11 @@ const extractUpdatedJobData = (rq) => {
|
||||
out.parts_tax_rates = extractPartsTaxRates(rq.ProfileInfo);
|
||||
}
|
||||
|
||||
// Mirror AddRq: update driveable if present
|
||||
if (rq.VehicleInfo?.Condition?.DrivableInd !== undefined) {
|
||||
out.driveable = !!rq.VehicleInfo.Condition.DrivableInd;
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
@@ -118,12 +124,14 @@ const extractUpdatedJobLines = (addsChgs = {}, jobId, currentJobLineNotes = {})
|
||||
const hasSublet = Object.keys(subletInfo).length > 0;
|
||||
|
||||
if (hasPart) {
|
||||
const price = parseFloat(partInfo.PartPrice || partInfo.ListPrice || 0);
|
||||
lineOut.part_type = partInfo.PartType ? String(partInfo.PartType).toUpperCase() : null;
|
||||
// Mirror AddRq behavior: use OEMPartNum fields and parse prices directly
|
||||
lineOut.part_qty = parseFloat(partInfo.Quantity || 0) || 1;
|
||||
lineOut.oem_partno = partInfo.OEMPartNum || partInfo.PartNum || null;
|
||||
lineOut.db_price = isNaN(price) ? 0 : price;
|
||||
lineOut.act_price = isNaN(price) ? 0 : price;
|
||||
lineOut.oem_partno = partInfo.OEMPartNum;
|
||||
lineOut.alt_partno = partInfo?.NonOEM?.NonOEMPartNum;
|
||||
|
||||
// Pricing: act_price from PartPrice, db_price from OEMPartPrice
|
||||
lineOut.act_price = parseFloat(partInfo?.PartPrice || 0);
|
||||
lineOut.db_price = parseFloat(partInfo?.OEMPartPrice || 0);
|
||||
|
||||
// Optional: taxability flag for parts
|
||||
if (
|
||||
@@ -155,7 +163,12 @@ const extractUpdatedJobLines = (addsChgs = {}, jobId, currentJobLineNotes = {})
|
||||
if (hasLabor) {
|
||||
lineOut.mod_lbr_ty = laborInfo.LaborType || null;
|
||||
lineOut.mod_lb_hrs = isNaN(hrs) ? 0 : hrs;
|
||||
lineOut.lbr_op = laborInfo.LaborOperation || null;
|
||||
|
||||
// Map operation code description from opCodes.json (case-insensitive)
|
||||
const opCodeKey =
|
||||
typeof laborInfo.LaborOperation === "string" ? laborInfo.LaborOperation.trim().toUpperCase() : null;
|
||||
lineOut.op_code_desc = opCodeKey && opCodes?.[opCodeKey]?.desc ? opCodes[opCodeKey].desc : null;
|
||||
|
||||
lineOut.lbr_amt = isNaN(amt) ? 0 : amt;
|
||||
}
|
||||
|
||||
@@ -250,6 +263,9 @@ const partsManagementVehicleDamageEstimateChgRq = async (req, res) => {
|
||||
|
||||
//TODO: for changed lines, are they deleted and then reinserted?
|
||||
//TODO: Updated lines should get an upsert to update things like desc, price, etc.
|
||||
// Updated Seqs should not be soft deleted
|
||||
// logic in available jobs container
|
||||
// Encapsulate so it is not multiple queries
|
||||
if (deletedLineIds?.length || updatedSeqs?.length) {
|
||||
const allToDelete = Array.from(new Set([...(deletedLineIds || []), ...(updatedSeqs || [])]));
|
||||
if (allToDelete.length) {
|
||||
|
||||
Reference in New Issue
Block a user