diff --git a/server/freeproService.ts b/server/freeproService.ts index 9de73b1..421175f 100644 --- a/server/freeproService.ts +++ b/server/freeproService.ts @@ -129,23 +129,25 @@ export function processFreeproExcel( const description = String(row.description || ""); const labelClient = String(row.label_client || ""); - const structure = row.structure ? String(row.structure) : null; + // Les lignes sans structure sont affectées à 3069UDA par convention + const structureRaw = row.structure ? String(row.structure).trim() : ""; + const structure = structureRaw !== "" ? structureRaw : "3069UDA"; const totalHt = parseFloat(String(row.total || "0").replace(",", ".")) || 0; const script = getScript(description); const ttc = getTtc(totalHt); const type = getType(labelClient, script); - const key = `${structure ?? ""}|||${type}`; + const key = `${structure}|||${type}`; aggregation.set(key, (aggregation.get(key) || 0) + Math.round(ttc * 100)); } // Construire les lignes de résultat const lines: FreeproVentilationResult["lines"] = []; for (const [key, centimes] of Array.from(aggregation.entries())) { - const [structureRaw, type] = key.split("|||"); + const [structureVal, type] = key.split("|||"); lines.push({ - structure: structureRaw === "" ? null : structureRaw, + structure: structureVal || null, type, montant: centimes / 100, });