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

This commit is contained in:
Dave
2025-11-12 16:13:23 -05:00
parent e3b4620d0c
commit 556cd993b9
6 changed files with 510 additions and 91 deletions

View File

@@ -70,31 +70,6 @@ const normalizeCustomerCandidates = (res, { ownersSet = null } = {}) => {
const country = chosen?.Country ?? chosen?.CountryCode ?? chosen?.country ?? undefined;
const county = chosen?.County ?? chosen?.county ?? undefined; // << added
// instrumentation (kept minimal; County is now expected)
if ((process.env.RR_DEBUG_ADDR ?? "1") !== "0") {
const allowed = new Set([
"Type",
"Addr1",
"AddressLine1",
"Line1",
"Street1",
"Addr2",
"AddressLine2",
"Line2",
"Street2",
"City",
"State",
"StateOrProvince",
"Zip",
"PostalCode",
"Country",
"CountryCode",
"County"
]);
const unknown = Object.keys(chosen || {}).filter((k) => !allowed.has(k));
if (unknown.length) console.log("[RR:normCandidates] Unexpected address keys seen:", unknown);
}
if (!line1 && !city && !state && !postalCode && !country && !county) return null;
return { line1, line2, city, state, postalCode, country, county };
};
@@ -113,7 +88,7 @@ const normalizeCustomerCandidates = (res, { ownersSet = null } = {}) => {
const address = pickAddr(nci?.Address);
// NEW: fallback to NameRecId when no ServVehicle/CustomerNo exists (e.g., pure name search)
// fallback to NameRecId when no ServVehicle/CustomerNo exists (e.g., pure name search)
const nameRecIdRaw = nci?.NameId?.NameRecId;
const nameRecId = nameRecIdRaw != null ? String(nameRecIdRaw).trim() : "";
@@ -136,14 +111,13 @@ const normalizeCustomerCandidates = (res, { ownersSet = null } = {}) => {
out.push(item);
}
} else if (nameRecId) {
// Use NameRecId as the identifier; this is what the RR "name" search provides
// Use NameRecId as the identifier
const cno = nameRecId;
const item = {
custNo: cno,
name: name || `Customer ${cno}`,
address: address || undefined
};
// owner flag cannot be inferred without a VIN owner set
out.push(item);
}
}
@@ -186,7 +160,7 @@ const readAdvisorNo = (payload, cached) => {
/**
* Cache enum keys for RR session transaction data
* @type {{txEnvelope: string, JobData: string, SelectedCustomer: string, AdvisorNo: string, VINCandidates: string, SelectedVin: string, ExportResult: string}}
* @type {{txEnvelope: string, JobData: string, SelectedCustomer: string, AdvisorNo: string, VINCandidates: string, SelectedVin: string, ExportResult: string, PendingRO: string}}
*/
const RRCacheEnums = {
txEnvelope: "RR.txEnvelope",
@@ -195,7 +169,8 @@ const RRCacheEnums = {
AdvisorNo: "RR.AdvisorNo",
VINCandidates: "RR.VINCandidates",
SelectedVin: "RR.SelectedVin",
ExportResult: "RR.ExportResult"
ExportResult: "RR.ExportResult",
PendingRO: "RR.PendingRO" // NEW: cache created RO to finalize later
};
/**