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
|
||||
// 🩹 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 = {
|
||||
"Nombre Cliente": name,
|
||||
"Teléfono": phone,
|
||||
"Dirección": address,
|
||||
"Código Postal": cpDetectado,
|
||||
"Descripción": description,
|
||||
"guild_id": guild_id,
|
||||
"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}`, {
|
||||
method: 'POST',
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user