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

This commit is contained in:
Dave
2025-11-20 21:57:49 -05:00
parent 9b1c8fa72b
commit b2184a2d11
4 changed files with 794 additions and 24 deletions

View File

@@ -187,33 +187,20 @@ const ensureRRServiceVehicle = async (args = {}) => {
});
}
// --- Attempt insert (idempotent) ---
// IMPORTANT: The current RR lib build validates `vehicleServInfo.customerNo`.
// To be future-proof, we also include top-level `customerNo`.
const insertPayload = {
// === Core Vehicle Identity (MANDATORY for success) ===
vin: vinStr.toUpperCase(), // "1FDWX34Y28EB01395"
// Required: 2-character make code (from v_make_desc → known mapping)
// 2-character make code (from v_make_desc → known mapping)
vehicleMake: deriveMakeCode(job.v_make_desc), // → "FR" for Ford
// Required: 2-digit year (last 2 digits of v_model_yr)
year: job?.v_model_yr || undefined,
// Required: Model number — fallback strategy per ERA behavior
// Model number — fallback strategy per ERA behavior
// Most Ford trucks use "T" = Truck. Some systems accept actual code.
// CAN BE (P)assenger , (T)ruck, (O)ther
mdlNo: undefined,
// === Descriptive Fields (highly recommended) ===
modelDesc: job?.v_model_desc?.trim() || undefined, // "F-350 SD"
carline: job?.v_model_desc?.trim() || undefined, // Series line
extClrDesc: job?.v_color?.trim() || undefined, // "Red"
// Optional but helpful
accentClr: undefined,
// === VehicleDetail Flags (CRITICAL — cause silent fails or error 303 if missing) ===
aircond: undefined, // "Y", // Nearly all modern vehicles have A/C
pwrstr: undefined, // "Y", // Power steering = yes on 99% of vehicles post-1990
transm: undefined, // "A", // Default to Automatic — change to "M" only if known manual
@@ -224,22 +211,16 @@ const ensureRRServiceVehicle = async (args = {}) => {
// License plate
licNo: license ? String(license).trim() : undefined,
// === VehicleServInfo (attributes on the element) ===
customerNo: custNoStr, // fallback (some builds read this)
customerNo: custNoStr,
stockId: job.ro_number || undefined, // Use RO as stock# — common pattern
vehicleServInfo: {
customerNo: custNoStr, // REQUIRED — this is what toServiceVehicleView() validates
// Optional but increases success rate
salesmanNo: undefined, // You don't have advisor yet — omit
inServiceDate: undefined,
// Optional — safe to include if you want
productionDate: undefined,
modelMaintCode: undefined,
teamCode: undefined,
// Extended warranty — omit unless you sell contracts
vehExtWarranty: undefined,
// Advisor — omit unless you know who the service advisor is
advisor: undefined
}
};