From cb03f222eff86f1746b6009faa0964b2bab5247f Mon Sep 17 00:00:00 2001 From: louispaulb Date: Fri, 24 Jul 2026 14:50:57 -0400 Subject: [PATCH] =?UTF-8?q?feat(legacy-sync):=20filet=20adresse=20?= =?UTF-8?q?=E2=80=94=20g=C3=A9ocodage=20inverse=20(pin=20fibre)=20quand=20?= =?UTF-8?q?coords=20mais=20pas=20d'adresse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Un job avec des coords résolues mais AUCUNE adresse texte (compte/delivery/facturation vides) reçoit maintenant une adresse APPROXIMATIVE via reverseNearestFibre (pin fibre le plus proche), marquée « ≈ … (approx. GPS) » → le dispatch n'est jamais aveugle quand on a au moins une position. Co-Authored-By: Claude Opus 4.8 --- services/targo-hub/lib/legacy-dispatch-sync.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/targo-hub/lib/legacy-dispatch-sync.js b/services/targo-hub/lib/legacy-dispatch-sync.js index 1210bb5..5fd1077 100644 --- a/services/targo-hub/lib/legacy-dispatch-sync.js +++ b/services/targo-hub/lib/legacy-dispatch-sync.js @@ -657,6 +657,12 @@ async function buildJob (t, { dryRun = false } = {}) { const tc = await townCenterFromSubject(t.subject) if (tc) { payload.latitude = tc.lat; payload.longitude = tc.lon; coordSrc = 'ville_centre'; if (!payload.address) payload.address = tc.ville + ' (secteur — adresse à confirmer)' } } + // FILET ADRESSE : des coords résolues mais AUCUNE adresse texte (compte/delivery/facturation vides) → géocodage INVERSE + // sur le pin fibre le plus proche → adresse APPROXIMATIVE (marquée) pour que le dispatch ne soit jamais aveugle. + if (!payload.address && payload.latitude != null && payload.longitude != null) { + const rev = await reverseNearestFibre(payload.latitude, payload.longitude) + if (rev && rev.address) payload.address = ('≈ ' + rev.address + ' (approx. GPS)').slice(0, 140) + } return { legacy_id: String(t.id), payload, matched: { customer: !!cust, service_location: !!sl, customer_name: cname, coords: !!coordSrc, coord_src: coordSrc, delivery_id: t.delivery_id || null, parent: Number(t.parent) || 0 }, dept: t.dept, addr } }