Checkpoint: Correction des montants TTC : utilisation du total_ttc retourné par l'API /api/api_red_october/v1/invoices au lieu de recalculer depuis les lignes CSV. Les montants correspondent maintenant exactement au portail FreePro.
This commit is contained in:
9
.manus/db/db-query-1780928851223.json
Normal file
9
.manus/db/db-query-1780928851223.json
Normal file
@@ -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": 272
|
||||||
|
}
|
||||||
8
.manus/db/db-query-error-1780928841531.json
Normal file
8
.manus/db/db-query-error-1780928841531.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"query": "DELETE FROM freepro_import_lines WHERE importId IN (SELECT id FROM freepro_imports); DELETE FROM freepro_imports;",
|
||||||
|
"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 freepro_import_lines WHERE importId IN (SELECT id FROM freepro_imports); DELETE FROM freepro_imports;",
|
||||||
|
"returncode": 1,
|
||||||
|
"logs": [
|
||||||
|
"ERROR 1146 (42S02) at line 1: Table 'fo4drybgjsuiigfagnluwm.freepro_import_lines' doesn't exist"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -511,6 +511,11 @@ export async function runFreeproAutoImport(userId: number): Promise<AutoImportRe
|
|||||||
const fileName = `Facture_FreePro_${invoice.invoiceNumber}.csv`;
|
const fileName = `Facture_FreePro_${invoice.invoiceNumber}.csv`;
|
||||||
const processed = processFreeproExcel(csvBuffer, invoice.month, fileName);
|
const processed = processFreeproExcel(csvBuffer, invoice.month, fileName);
|
||||||
|
|
||||||
|
// Utiliser le total TTC retourné par l'API FreePro (total_ttc de /api/api_red_october/v1/invoices)
|
||||||
|
// qui correspond au montant affiché sur le portail. Ne pas recalculer depuis les lignes CSV
|
||||||
|
// car la somme ligne par ligne peut différer (remises globales, arrondis, taxes spécifiques).
|
||||||
|
const officialTotalTtc = invoice.amount > 0 ? invoice.amount : processed.totalTtc;
|
||||||
|
|
||||||
await createFreeproImport(
|
await createFreeproImport(
|
||||||
{
|
{
|
||||||
userId,
|
userId,
|
||||||
@@ -520,7 +525,7 @@ export async function runFreeproAutoImport(userId: number): Promise<AutoImportRe
|
|||||||
refPiece: processed.refPiece ?? null,
|
refPiece: processed.refPiece ?? null,
|
||||||
fileName,
|
fileName,
|
||||||
nbLignes: processed.nbLignes,
|
nbLignes: processed.nbLignes,
|
||||||
totalTtc: processed.totalTtc.toFixed(2),
|
totalTtc: officialTotalTtc.toFixed(2),
|
||||||
},
|
},
|
||||||
processed.lines.map((l) => ({
|
processed.lines.map((l) => ({
|
||||||
structure: l.structure ?? null,
|
structure: l.structure ?? null,
|
||||||
|
|||||||
Reference in New Issue
Block a user