diff --git a/posClient.js b/posClient.js index 1d7adcc..12b0188 100644 --- a/posClient.js +++ b/posClient.js @@ -54,7 +54,9 @@ async function processQrSetup(qrPayload) { throw new Error('Ungültiger QR-Code-Typ: $type muss "ww-setup" sein'); } - const { url, servicepasslink, mdcDeviceId } = data; + const { url, servicepasslink } = data; + const mdcDeviceId = data.mdcDeviceId || data.cr || data.cashRegisterNumber || '1'; + if (!url || !servicepasslink) { throw new Error('Fehlende Pflichtfelder (url oder servicepasslink) im QR-Code'); } @@ -86,10 +88,10 @@ async function processQrSetup(qrPayload) { upsert.run('pos_url', cleanUrl); upsert.run('pos_pass_id', passId); upsert.run('pos_app_id', appId); - if (mdcDeviceId) upsert.run('pos_cash_register', String(mdcDeviceId)); + upsert.run('pos_cash_register', String(mdcDeviceId)); db.prepare('INSERT INTO sync_logs (status, message) VALUES (?, ?)') - .run('SUCCESS', `QR-Code Handshake erfolgreich. Pass-ID: ${passId}, Kasse: ${mdcDeviceId || '1'}`); + .run('SUCCESS', `QR-Code Handshake erfolgreich. Pass-ID: ${passId}, Kasse: ${mdcDeviceId}`); // 3. Direkt automatischen Initial-Sync ausführen let syncResult = null; @@ -104,7 +106,7 @@ async function processQrSetup(qrPayload) { url: cleanUrl, passId, appId, - mdcDeviceId: mdcDeviceId || '1', + mdcDeviceId: String(mdcDeviceId), syncResult }; } @@ -231,7 +233,6 @@ async function parseAndStoreZip(buffer) { if (Array.isArray(item.prices) && item.prices.length > 0) { const vk1Obj = item.prices.find(p => String(p.level) === '1') || item.prices[0]; if (vk1Obj && vk1Obj.value !== undefined) { - // Deutsches Zahlenformat "2,86" -> 2.86 preis1 = parseFloat(String(vk1Obj.value).replace(',', '.')); } } else if (typeof item.prices === 'object' && item.prices !== null) { @@ -267,7 +268,6 @@ async function parseAndStoreZip(buffer) { try { parsed = await parser.parseStringPromise(rawContent); } catch(e) {} const root = parsed.root || parsed; - // Warengruppen let groups = root.ProductGroups?.ProductGroup || root.productGroups?.productGroup || []; if (!Array.isArray(groups)) groups = [groups]; for (const g of groups) { @@ -276,7 +276,6 @@ async function parseAndStoreZip(buffer) { if (id) { insertGroup.run(id, name, 0); groupsCount++; } } - // Artikel let items = root.Products?.Product || root.products?.product || []; if (!Array.isArray(items)) items = [items]; for (const item of items) { diff --git a/public/admin.html b/public/admin.html index 8b9a4da..76df576 100644 --- a/public/admin.html +++ b/public/admin.html @@ -7,7 +7,7 @@ - +