From 7c73d701acc6f641f7dec824032a674c097be29e Mon Sep 17 00:00:00 2001 From: Manus Date: Wed, 6 May 2026 12:18:03 -0400 Subject: [PATCH] fix: nom fichier export conforme date-fournisseur-numero.pdf --- server/routers.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/routers.ts b/server/routers.ts index b2f278b..77fddb8 100644 --- a/server/routers.ts +++ b/server/routers.ts @@ -1191,8 +1191,13 @@ export const appRouter = router({ // Build source path from fileKey const sourcePath = path.join(STORAGE_BASE_PATH, invoice.fileKey); - // Extract filename from fileKey - const filename = path.basename(invoice.fileKey); + // Build export filename: date-fournisseur-numero.pdf + const invoiceDateStr = invoice.invoiceDate + ? new Date(invoice.invoiceDate).toISOString().slice(0, 10) + : new Date().toISOString().slice(0, 10); + const supplierSafe = (invoice.supplierName || 'INCONNU').replace(/[^a-zA-Z0-9\u00C0-\u017F\s-]/g, '').trim().replace(/\s+/g, '_'); + const invoiceNumSafe = (invoice.invoiceNumber || `id${invoice.id}`).replace(/[^a-zA-Z0-9\u00C0-\u017F\s-]/g, '').trim().replace(/\s+/g, '_'); + const filename = `${invoiceDateStr}-${supplierSafe}-${invoiceNumSafe}.pdf`; const destPath = path.join(exportFolder, filename); // Find signature associated with invoice service