Arregla CP alta manual
This commit is contained in:
@@ -3969,10 +3969,17 @@ app.post("/services/manual-high", authMiddleware, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. Crear el Expediente
|
// 2. Crear el Expediente
|
||||||
|
// 🩹 FIX: extraemos el Código Postal de la dirección en texto libre. Antes este campo
|
||||||
|
// nunca se guardaba en las altas manuales, así que la asignación automática (que exige
|
||||||
|
// que el CP coincida exactamente con una zona del operario) siempre fallaba al usar "00000".
|
||||||
|
const cpMatchAlta = (address || "").match(/\b\d{5}\b/);
|
||||||
|
const cpDetectado = cpMatchAlta ? cpMatchAlta[0] : "00000";
|
||||||
|
|
||||||
const rawData = {
|
const rawData = {
|
||||||
"Nombre Cliente": name,
|
"Nombre Cliente": name,
|
||||||
"Teléfono": phone,
|
"Teléfono": phone,
|
||||||
"Dirección": address,
|
"Dirección": address,
|
||||||
|
"Código Postal": cpDetectado,
|
||||||
"Descripción": description,
|
"Descripción": description,
|
||||||
"guild_id": guild_id,
|
"guild_id": guild_id,
|
||||||
"scheduled_date": "",
|
"scheduled_date": "",
|
||||||
@@ -4003,7 +4010,7 @@ app.post("/services/manual-high", authMiddleware, async (req, res) => {
|
|||||||
fetch(`http://127.0.0.1:${port}/providers/automate/${newId}`, {
|
fetch(`http://127.0.0.1:${port}/providers/automate/${newId}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json', 'Authorization': req.headers.authorization },
|
headers: { 'Content-Type': 'application/json', 'Authorization': req.headers.authorization },
|
||||||
body: JSON.stringify({ guild_id, cp: "00000" })
|
body: JSON.stringify({ guild_id, cp: cpDetectado })
|
||||||
}).catch(e => console.error("Error lanzando bolsa:", e));
|
}).catch(e => console.error("Error lanzando bolsa:", e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user