From 09e1887609c6e543a8b99a4894d2a1928731e680 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Mon, 23 Jun 2025 14:24:15 -0400 Subject: [PATCH] feature/IO-3255-simplified-parts-management - Checkpoint --- ...rtsManagementVehicleDamageEstimateAddRq.js | 52 ++++++++++++------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/server/integrations/partsManagement/partsManagementVehicleDamageEstimateAddRq.js b/server/integrations/partsManagement/partsManagementVehicleDamageEstimateAddRq.js index fde4b2082..31ca61031 100644 --- a/server/integrations/partsManagement/partsManagementVehicleDamageEstimateAddRq.js +++ b/server/integrations/partsManagement/partsManagementVehicleDamageEstimateAddRq.js @@ -94,6 +94,7 @@ const partsManagementVehicleDamageEstimateAddRq = async (req, res) => { // ── PARTS TAX RATES STRUCTURE ─────────────────────────────────────────────── // Known rate types that map to your parts_tax_rates keys + // If this has become an issue, default it to an empty object for version 1 const knownPartRateTypes = [ "PAA", "PAC", @@ -269,27 +270,41 @@ const partsManagementVehicleDamageEstimateAddRq = async (req, res) => { // ── DAMAGE LINES → joblinesData ──────────────────────────────────────────── const damageLines = Array.isArray(rq.DamageLineInfo) ? rq.DamageLineInfo : [rq.DamageLineInfo]; - const joblinesData = damageLines.map((line) => ({ - line_no: parseInt(line.LineNum, 10), - unq_seq: parseInt(line.UniqueSequenceNum, 10), - status: line.LineStatusCode || null, - line_desc: line.LineDesc || null, + const joblinesData = damageLines.map((line) => { + const jobLine = { + line_no: parseInt(line.LineNum, 10), + unq_seq: parseInt(line.UniqueSequenceNum, 10), + status: line.LineStatusCode || null, + line_desc: line.LineDesc || null, - // parts - part_type: line.PartInfo?.PartType || null, - part_qty: parseFloat(line.PartInfo?.Quantity || 0), - oem_partno: line.PartInfo?.OEMPartNum || null, - db_price: parseFloat(line.PartInfo?.PartPrice || 0), - act_price: parseFloat(line.PartInfo?.PartPrice || 0), + // parts + part_type: line.PartInfo?.PartType || null, + part_qty: parseFloat(line.PartInfo?.Quantity || 0), + oem_partno: line.PartInfo?.OEMPartNum || null, + db_price: parseFloat(line.PartInfo?.PartPrice || 0), + act_price: parseFloat(line.PartInfo?.PartPrice || 0), - // labor - mod_lbr_ty: line.LaborInfo?.LaborType || null, - mod_lb_hrs: parseFloat(line.LaborInfo?.LaborHours || 0), - lbr_op: line.LaborInfo?.LaborOperation || null, - lbr_amt: parseFloat(line.LaborInfo?.LaborAmt || 0), + // labor + mod_lbr_ty: line.LaborInfo?.LaborType || null, + mod_lb_hrs: parseFloat(line.LaborInfo?.LaborHours || 0), + lbr_op: line.LaborInfo?.LaborOperation || null, + lbr_amt: parseFloat(line.LaborInfo?.LaborAmt || 0), - notes: line.LineMemo || null - })); + notes: line.LineMemo || null + }; + + // TODO: Commented out as not clear if needed for version 1, this only applies to Imex and not rome on the front + // end + + // if ((jobLine.part_type === "PASL" || jobLine.part_type === "PAS") && jobLine.lbr_op !== "OP11") { + // jobLine.tax_part = true; + // } + // if (line.db_ref === "900510") { + // jobLine.tax_part = true; + // } + + return jobLine; + }); const ownerInput = { shopid: shopId, @@ -308,6 +323,7 @@ const partsManagementVehicleDamageEstimateAddRq = async (req, res) => { }; let ownerid = null; + try { const { insert_owners_one } = await client.request(INSERT_OWNER, { owner: ownerInput }); ownerid = insert_owners_one?.id;