From 43cacda7adcae0f7b6270e51da9a7c12551acb41 Mon Sep 17 00:00:00 2001 From: Manus Date: Mon, 8 Jun 2026 10:38:58 -0400 Subject: [PATCH] =?UTF-8?q?Checkpoint:=20Correction=20des=20montants=20des?= =?UTF-8?q?=20lignes=20de=20ventilation=20:=20application=20d'un=20coeffic?= =?UTF-8?q?ient=20de=20redistribution=20proportionnel=20(totalTtc=5Foffici?= =?UTF-8?q?el=20/=20totalTtc=5Fcalcul=C3=A9)=20sur=20chaque=20ligne=20pour?= =?UTF-8?q?=20que=20leur=20somme=20corresponde=20exactement=20au=20total?= =?UTF-8?q?=20TTC=20officiel=20FreePro.=20Les=20montants=20sont=20maintena?= =?UTF-8?q?nt=20coh=C3=A9rents=20avec=20le=20portail.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .manus/db/db-query-1780929418216.json | 9 +++++++++ server/freeproAutoImport.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .manus/db/db-query-1780929418216.json diff --git a/.manus/db/db-query-1780929418216.json b/.manus/db/db-query-1780929418216.json new file mode 100644 index 0000000..2a7ee5c --- /dev/null +++ b/.manus/db/db-query-1780929418216.json @@ -0,0 +1,9 @@ +{ + "query": "DELETE FROM freeproVentilationLines WHERE importId IN (SELECT id FROM freeproImports); DELETE FROM freeproImports;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.bd4328423008 --database fo4DRyBgjsuiigFAgNLuWm --execute DELETE FROM freeproVentilationLines WHERE importId IN (SELECT id FROM freeproImports); DELETE FROM freeproImports;", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 370 +} \ No newline at end of file diff --git a/server/freeproAutoImport.ts b/server/freeproAutoImport.ts index 48a1b1d..549b0f5 100644 --- a/server/freeproAutoImport.ts +++ b/server/freeproAutoImport.ts @@ -516,6 +516,14 @@ export async function runFreeproAutoImport(userId: number): Promise 0 ? invoice.amount : processed.totalTtc; + // Calculer le coefficient de redistribution pour que la somme des lignes + // corresponde exactement au total TTC officiel FreePro. + // Si le total calculé depuis les lignes (processed.totalTtc) diffère du total + // officiel (officialTotalTtc), on applique un facteur proportionnel sur chaque ligne. + const calculatedTotal = processed.totalTtc; + const redistributionFactor = + calculatedTotal > 0 ? officialTotalTtc / calculatedTotal : 1; + await createFreeproImport( { userId, @@ -530,7 +538,7 @@ export async function runFreeproAutoImport(userId: number): Promise ({ structure: l.structure ?? null, type: l.type, - montantCentimes: Math.round(l.montant * 100), + montantCentimes: Math.round(l.montant * redistributionFactor * 100), })) );