feature/IO-3255-simplified-parts-management - Bug Fixes

This commit is contained in:
Dave
2025-08-15 13:07:32 -04:00
parent 73e103f2df
commit 5e90504e56
2 changed files with 18 additions and 11 deletions

View File

@@ -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 });