DPD Fix
This commit is contained in:
@@ -261,17 +261,33 @@ function updateQueuePill() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Barcode extraction ────────────────────────────────────────────────
|
// ── Barcode extraction ────────────────────────────────────────────────
|
||||||
// Scanned codes have 8 space-separated blocks; the 3rd through 6th
|
// Handles multiple formats:
|
||||||
// (0-indexed 2..5) form the real scan code, concatenated without spaces.
|
// 1. DPD barcode starting with %:
|
||||||
// E.g. "0003 580 0626 5027 3077 23 328 040" → "06265027307723"
|
// % + 7-char postcode + 14-digit tracking + 3-digit service + 3-digit country
|
||||||
|
// E.g. "%000460006265029820831328040" → "06265029820831"
|
||||||
|
// 2. Space-separated blocks: 3rd through 6th (0-indexed 2..5) joined
|
||||||
|
// E.g. "0003 580 0626 5027 3077 23 328 040" → "06265027307723"
|
||||||
function extractCode(raw) {
|
function extractCode(raw) {
|
||||||
// Strip parentheses first
|
// Strip parentheses first
|
||||||
const cleaned = raw.trim().replace(/[()]/g, "");
|
const cleaned = raw.trim().replace(/[()]/g, "");
|
||||||
|
|
||||||
|
// Handle %-prefixed DPD barcode
|
||||||
|
if (cleaned.startsWith("%")) {
|
||||||
|
const withoutPct = cleaned.slice(1);
|
||||||
|
if (withoutPct.length >= 21) {
|
||||||
|
// Skip 7-char postcode, take 14-digit tracking number, drop the rest
|
||||||
|
return withoutPct.slice(7, 21);
|
||||||
|
}
|
||||||
|
return withoutPct; // fallback: return everything after %
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle space-separated format
|
||||||
const parts = cleaned.split(/\s+/);
|
const parts = cleaned.split(/\s+/);
|
||||||
if (parts.length >= 6) {
|
if (parts.length >= 6) {
|
||||||
return parts.slice(2, 6).join("");
|
return parts.slice(2, 6).join("");
|
||||||
}
|
}
|
||||||
return cleaned; // fallback: use cleaned input
|
|
||||||
|
return cleaned; // fallback: use as-is
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Enqueue (called immediately on Enter) ──────────────────────────────
|
// ── Enqueue (called immediately on Enter) ──────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user