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

This commit is contained in:
Dave Richer
2025-06-23 14:24:15 -04:00
parent 4b83330db9
commit 09e1887609

View File

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