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

This commit is contained in:
Dave
2025-11-04 14:19:26 -05:00
parent ccf3d7df5b
commit 5bbda89fb9
10 changed files with 532 additions and 337 deletions

View File

@@ -1,6 +1,3 @@
// server/rr/rr-customers.js
// Minimal RR customer create helper (maps dmsRecKey -> custNo for callers)
const { RRClient } = require("./lib/index.cjs");
const { getRRConfigFromBodyshop } = require("./rr-config");
const RRLogger = require("./rr-logger");
@@ -35,7 +32,7 @@ function buildClientAndOpts(bodyshop) {
// minimal field extraction
function digitsOnly(s) {
return String(s || "").replace(/[^\d]/g, "");
return String(s || "").replace(/\D/g, "");
}
function buildCustomerPayloadFromJob(job, overrides = {}) {
@@ -94,15 +91,7 @@ async function createRRCustomer({ bodyshop, job, overrides = {}, socket }) {
const trx = res?.statusBlocks?.transaction;
// Primary: map dmsRecKey -> custNo
let custNo =
data?.dmsRecKey ??
// legacy fallbacks (if shapes ever change)
data?.custNo ??
data?.CustNo ??
data?.customerNo ??
data?.CustomerNo ??
data?.customer?.custNo ??
data?.Customer?.CustNo;
let custNo = data?.dmsRecKey;
if (!custNo) {
log("error", "RR insertCustomer returned no dmsRecKey/custNo", {