feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Checkpoint

This commit is contained in:
Dave
2025-10-14 14:55:10 -04:00
parent 6671db1724
commit e514cf8d6a
4 changed files with 13 additions and 10 deletions

View File

@@ -46,7 +46,7 @@ function stageFail(name, error) {
* @param {Object} options - { insertVehicleIfMissing: boolean }
* @returns {Promise<Object>} normalized result
*/
async function exportJobToRome(socket, job, bodyshopConfig, options = {}) {
async function exportJobToRR(socket, job, bodyshopConfig, options = {}) {
const { customer = {}, vehicle = {} } = job || {};
const { insertVehicleIfMissing = true } = options;
@@ -154,5 +154,5 @@ async function exportJobToRome(socket, job, bodyshopConfig, options = {}) {
}
module.exports = {
exportJobToRome
exportJobToRR
};

View File

@@ -10,6 +10,7 @@
const path = require("path");
const fs = require("fs/promises");
const { RR_ACTIONS, RR_SOAP_HEADERS } = require("./rr-constants");
const mustache = require("mustache");
// ---- Action <-> Template wiring ----
// Keep action names consistent with rr-helpers / rr-lookup / rr-repair-orders / rr-customer
@@ -84,9 +85,12 @@ async function verifyTemplatesExist() {
for (const [action, tpl] of Object.entries(ACTION_TEMPLATES)) {
const filePath = path.join(baseDir, `${tpl}.xml`);
try {
const stat = await fs.stat(filePath);
if (!stat.isFile()) {
issues.push({ action, template: tpl, error: "Not a regular file" });
const contents = await fs.readFile(filePath, "utf8"); // throws if missing
try {
// Parse-only to catch “Unclosed section …” and similar
mustache.parse(contents);
} catch (parseErr) {
issues.push({ action, template: tpl, error: `Mustache parse error: ${parseErr.message}`, filePath });
}
} catch {
issues.push({ action, template: tpl, error: `Missing file: ${filePath}` });
@@ -94,7 +98,6 @@ async function verifyTemplatesExist() {
}
return issues;
}
/**
* Quick assert that throws if any template is missing.
* You can call this once during boot and log the result.

View File

@@ -24,7 +24,7 @@ const { RrApiError } = require("./rr-error");
const customerApi = require("./rr-customer"); // insertCustomer, updateCustomer
const roApi = require("./rr-repair-orders"); // createRepairOrder, updateRepairOrder
const lookupApi = require("./rr-lookup"); // getAdvisors, getParts, combinedSearch
const { exportJobToRome } = require("./rr-job-export"); // orchestrator
const { exportJobToRR } = require("./rr-job-export"); // orchestrator
// Diagnostics
const { listActions, verifyTemplatesExist } = require("./rr-wsdl");
@@ -188,7 +188,7 @@ router.post("/rr/export/job", async (req, res) => {
try {
if (!job) throw new RrApiError("Missing 'job' in request body", "BAD_REQUEST");
const cfg = await resolveRRConfigHttp(req);
const result = await exportJobToRome(socket, job, cfg, options);
const result = await exportJobToRR(socket, job, cfg, options);
return ok(res, result);
} catch (err) {
RRLogger(socket, "error", "RR /export/job failed", { err: err.message });

View File

@@ -3,7 +3,7 @@ const FortellisLogger = require("../fortellis/fortellis-logger");
const RRLogger = require("../rr/rr-logger");
const { FortellisJobExport, FortellisSelectedCustomer } = require("../fortellis/fortellis");
const CdkCalculateAllocations = require("../cdk/cdk-calculate-allocations").default;
const { exportJobToRome } = require("../rr/rr-job-export");
const { exportJobToRR } = require("../rr/rr-job-export");
const lookupApi = require("../rr/rr-lookup");
const { getRRConfigForBodyshop } = require("../rr/rr-config");
@@ -358,7 +358,7 @@ const redisSocketEvents = ({
return;
}
const result = await exportJobToRome(socket, job, cfg, options);
const result = await exportJobToRR(socket, job, cfg, options);
// Broadcast to bodyshop room for UI to pick up
const room = getBodyshopRoom(socket.bodyshopId);
io.to(room).emit("rr-export-job:result", { jobid: job.id, result });