Load vehicle QR numbers from the client's sheet into the Plant Register

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
David 2026-10-22 13:47:49 +02:00
parent 8f3a74cf6e
commit fd2d9262ae
2 changed files with 25 additions and 1 deletions

22
data/source/asset-qr.json Normal file
View file

@ -0,0 +1,22 @@
{
"TLB01": "1080",
"TLB02": "1009",
"TLB03": "1173",
"TLB04": "1167",
"TLB05": "1120",
"TLB06": "4704",
"TLB07": "1010",
"SS01": "1137",
"SS02": "1008",
"RV01": "1037",
"RV03": "1002",
"RV04": "1006",
"MG01": "1088",
"MG02": "1123",
"CT01": "1976",
"TP601": "1128",
"TP602": "1072",
"WB01": "1103",
"WB02": "1091",
"DT01": "1143"
}

View file

@ -272,6 +272,8 @@ let existingSiteByCode = new Map();
let existingSiteByName = new Map();
// QR text typed into the Plant Register is entered by hand and exists nowhere on disk.
const existingQrByCode = new Map();
// Vehicle sticker numbers from the client's sheet. A value typed in the app wins; this fills the rest.
const sheetQrByCode = JSON.parse(readFileSync(resolve(DATA_DIR, "asset-qr.json"), "utf8"));
try {
const siteIdToName = new Map();
for (const s of await pb.collection(SITES_COLL).getFullList()) {
@ -333,7 +335,7 @@ for (const a of assets) {
on_operator_sheet: operatorSheetCodes.has(a.code),
is_active: a.is_active !== false, // default true; only "AEB Plant Versekering" is false
site: siteId,
qr_code: existingQrByCode.get(a.code) || "",
qr_code: existingQrByCode.get(a.code) || sheetQrByCode[a.code] || "",
// Plant Map — falls back to the shared placeholder pin until the
// on-site scan sheet supplies a real coordinate for this machine.
latitude: a.latitude ?? DEFAULT_GEO.latitude,