diff --git a/client/src/pages/manage/manage.page.component.jsx b/client/src/pages/manage/manage.page.component.jsx index 2c071102b..469911b4b 100644 --- a/client/src/pages/manage/manage.page.component.jsx +++ b/client/src/pages/manage/manage.page.component.jsx @@ -134,7 +134,8 @@ export function Manage({ conflict, bodyshop, partsManagementOnly }) { }); }, [t]); - if (partsManagementOnly) { + // This is a required safety check to prevent parts management only users from accessing /manage based routes + if (partsManagementOnly && !import.meta.env.DEV) { // This NEEDS to be done this way, DO NOT use the react router, it will cause a ton of side effects window.location = "/parts"; return null; // Prevent further rendering diff --git a/server/integrations/partsManagement/endpoints/vehicleDamageEstimateAddRq.js b/server/integrations/partsManagement/endpoints/vehicleDamageEstimateAddRq.js index e28e03685..67ca8deb3 100644 --- a/server/integrations/partsManagement/endpoints/vehicleDamageEstimateAddRq.js +++ b/server/integrations/partsManagement/endpoints/vehicleDamageEstimateAddRq.js @@ -406,18 +406,25 @@ const extractJobLines = (rq) => { const price = parseFloat(partInfo.PartPrice || partInfo.ListPrice || 0); out.push({ ...base, - part_type: partInfo.PartType || null, + part_type: partInfo.PartType || null ? String(partInfo.PartType).toUpperCase() : null, part_qty: parseFloat(partInfo.Quantity || 0) || 1, - oem_partno: partInfo.OEMPartNum || null, + oem_partno: partInfo.OEMPartNum || partInfo.PartNum || null, db_price: price, act_price: price, - // Labor fields if present on same line - mod_lbr_ty: laborInfo.LaborType || null, - mod_lb_hrs: parseFloat(laborInfo.LaborHours || 0), - lbr_op: laborInfo.LaborOperation || null, - lbr_amt: INCLUDE_LABOR ? parseFloat(laborInfo.LaborAmt || 0) : 0, + // Labor fields only when INCLUDE_LABOR is enabled + ...(INCLUDE_LABOR + ? { + mod_lbr_ty: laborInfo.LaborType || null, + mod_lb_hrs: parseFloat(laborInfo.LaborHours || 0), + lbr_op: laborInfo.LaborOperation || null, + lbr_amt: parseFloat(laborInfo.LaborAmt || 0) + } + : {}), // Tax flag from PartInfo.TaxableInd when provided - ...(partInfo.TaxableInd !== undefined + ...(partInfo.TaxableInd !== undefined && + (typeof partInfo.TaxableInd === "string" || + typeof partInfo.TaxableInd === "number" || + typeof partInfo.TaxableInd === "boolean") ? { tax_part: partInfo.TaxableInd === true || @@ -674,8 +681,7 @@ const vehicleDamageEstimateAddRq = async (req, res) => { // Insert job const { insert_jobs_one: newJob } = await client.request(INSERT_JOB_WITH_LINES, { job: jobInput }); - logger.log("parts-job-created", "info", newJob.id, null); - + return res.status(200).json({ success: true, jobId: newJob.id }); } catch (err) { logger.log("parts-route-error", "error", null, null, { error: err });