fix: correct factorZona zero handling and confidence for unresolved selections

This commit is contained in:
Carlos Narro
2026-05-30 12:28:10 +02:00
parent 58d3f62a76
commit e6f8b47205
2 changed files with 29 additions and 2 deletions

View File

@@ -81,10 +81,12 @@ export function computeBudget(
}));
const subtotal = partidas.reduce((s, p) => s + p.importe, 0);
const factorZona = (inputs.provincia && config.factorZona[inputs.provincia]) || 1;
const factorZona = config.factorZona[inputs.provincia ?? ''] ?? 1;
const total = Math.round(subtotal * factorZona);
const hasExact = Object.keys(inputs.materialSelections).length > 0;
const hasExact = (Object.values(inputs.materialSelections) as string[]).some(
(id) => catalog.some((c) => c.id === id),
);
const hasM2 = inputs.m2Suelo != null && inputs.m2Suelo > 0;
let confianza: BudgetResult['confianza'];
let band: number;