This commit is contained in:
Dave
2026-03-20 14:55:08 -04:00
parent 8af8c8039c
commit 0622696650
4 changed files with 33 additions and 18 deletions

View File

@@ -205,8 +205,7 @@ const updateRRRepairOrderWithFullData = async (args) => {
const { client, opts } = buildClientAndOpts(bodyshop);
// For full data update after early RO, we still use "Insert" referenceId
// because we're inserting the job operations for the first time
// For full data update after early RO, use the RR update route.
const finalOpts = {
...opts,
envelope: {
@@ -214,7 +213,7 @@ const updateRRRepairOrderWithFullData = async (args) => {
sender: {
...(opts?.envelope?.sender || {}),
task: "BSMRO",
referenceId: "Insert"
referenceId: "Update"
}
}
};
@@ -317,32 +316,45 @@ const updateRRRepairOrderWithFullData = async (args) => {
opCode
});
// Add roNo for linking to existing RO
// Update the existing RO created during the early RO step.
payload.finalUpdate = "N";
payload.roNo = String(roNo);
payload.outsdRoNo = job?.ro_number || job?.id || undefined;
// Keep rolabor - it's needed to register the job/OpCode accounts in Reynolds
// Without this, Reynolds won't recognize the OpCode when we send rogg operations
// The rolabor section tells Reynolds "these jobs exist" even with minimal data
// RR update rejects placeholder non-labor ROLABOR rows with zero labor prices.
// Keep only the actual labor jobs in ROLABOR and let ROGOG carry parts/extras.
if (payload.rolabor?.ops?.length && payload.rogg?.ops?.length) {
const laborJobNos = new Set(
payload.rogg.ops
.filter((op) => op?.segmentKind === "laborTaxable" || op?.segmentKind === "laborNonTaxable")
.map((op) => String(op.jobNo))
);
CreateRRLogEvent(socket, "INFO", "Preparing full data for early RO (using create with roNo)", {
payload.rolabor.ops = payload.rolabor.ops.filter((op) => laborJobNos.has(String(op?.jobNo)));
if (!payload.rolabor.ops.length) {
delete payload.rolabor;
}
}
CreateRRLogEvent(socket, "INFO", "Preparing full data update for existing RR RO", {
roNo: String(roNo),
hasRolabor: !!payload.rolabor,
rolaborCount: payload.rolabor?.ops?.length || 0,
hasRogg: !!payload.rogg,
payload
});
// Use createRepairOrder (not update) with the roNo to link to the existing early RO
// Reynolds will merge this with the existing RO header
const response = await client.createRepairOrder(payload, finalOpts);
const response = await client.updateRepairOrder(payload, finalOpts);
CreateRRLogEvent(
socket,
"INFO",
"Sending full data for early RO (using create with roNo)",
"RR full data update sent for existing RO",
withRRRequestXml(response, {
roNo: String(roNo),
hasRolabor: !!payload.rolabor,
rolaborCount: payload.rolabor?.ops?.length || 0,
hasRogg: !!payload.rogg,
payload,
response