fix(pl24): Mercedes year from 'Teslimat tarihi' (delivery date) #108
@@ -154,3 +154,27 @@ describe("PL24Service.parseVehicleResponse — p5bmw (no prNr; chassis in 'Seri'
|
||||
expect(r.engineCode).toBe("B48B16M0");
|
||||
});
|
||||
});
|
||||
|
||||
describe("PL24Service.parseVehicleResponse — p5daimler (year from 'Teslimat tarihi')", () => {
|
||||
// Mercedes has no model_yili/üretim tarihi — only "Teslimat tarihi" (delivery). Without reading
|
||||
// it, year falls to the VIN year-char: WDD…1… → 2001 even for a 2009 car.
|
||||
const mbData = {
|
||||
resultStatus: "VEHICLE_IDENTIFIED",
|
||||
description: "C 180 KOMPRESSOR Sedan",
|
||||
link: { path: "/p5daimler/extern/groups/vin/maingroups?vin=WDD" },
|
||||
segments: {
|
||||
vinfoBasic: {
|
||||
records: [
|
||||
{ values: { description: "Piyasa adı", value: "C 180 KOMPRESSOR Sedan" } },
|
||||
{ values: { description: "Teslimat tarihi", value: "04.05.2009" } },
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
it("reads year from the delivery date instead of the (wrong) VIN year-char", () => {
|
||||
const r = p.parseVehicleResponse("WDD2040451A292277", mbData as never, "mercedes_parts");
|
||||
expect(r.year).toBe(2009); // not 2001 (VIN 10th char "1")
|
||||
expect(r.model).toBe("C 180 KOMPRESSOR Sedan");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1092,12 +1092,16 @@ export class PL24Service {
|
||||
return {
|
||||
brand: SERVICE_TO_BRAND[serviceName] || serviceName.replace("_parts", ""),
|
||||
model,
|
||||
// p5fiat has no plain model-year field; derive it from "MY" ("… = 2014 YILI") or the
|
||||
// production date ("05/09/2014"). Other P5 backends use a plain model_yili/year number.
|
||||
// Some P5 backends have no plain model-year field: p5fiat → "MY" ("… = 2014 YILI") or
|
||||
// production date ("05/09/2014"); p5daimler → only "Teslimat tarihi" (delivery, "04.05.2009").
|
||||
// Falling through to the VIN year-char (extractModelYear) is the last resort and is often
|
||||
// wrong for Mercedes (10th-char "1" → 2001 for a 2015 car), so read the dates first.
|
||||
year:
|
||||
Number.parseInt(lookup("model_yili", "year") || "", 10) ||
|
||||
Number.parseInt(
|
||||
(lookup("my", "üretim_tarihi", "uretim_tarihi") || "").match(/(19|20)\d{2}/)?.[0] || "",
|
||||
(lookup("my", "üretim_tarihi", "uretim_tarihi", "teslimat_tarihi") || "").match(
|
||||
/(19|20)\d{2}/,
|
||||
)?.[0] || "",
|
||||
10,
|
||||
) ||
|
||||
extractModelYear(vin) ||
|
||||
|
||||
Reference in New Issue
Block a user