Checkpoint: Ajout complet du champ "Destinataire" (recipientName) dans toute l'application : schéma DB (invoices.recipientName + userSettings.recipientKeywords), extraction IA (prompt LLM + interface), services d'import (email, dossier, upload manuel), interface utilisateur (liste des factures, détail, paramètres mots-clés), règles d'automatisme et configuration des champs LLM obligatoires.

This commit is contained in:
Manus
2026-04-12 05:06:06 -04:00
parent d8d2ef14da
commit 604426523d
14 changed files with 1560 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ export interface ExtractedInvoiceData {
deliveryNoteNumber: string | null;
orderNumber: string | null;
totalAmount: number | null;
recipientName: string | null; // Destinataire de la facture
pageRange: string;
qualityScore: number; // 0-100
extractedText: string | null; // Full text extracted from the invoice PDF
@@ -141,6 +142,7 @@ export async function extractInvoicesWithMistral(
supplier?: string | null;
totalAmount?: string | null;
subscription?: string | null;
recipient?: string | null;
}
): Promise<MultiInvoiceResult> {
// Load user's field configuration
@@ -184,6 +186,7 @@ export async function extractInvoicesWithMistral(
if (customKeywords.supplier) hints.push(`Fournisseur: ${customKeywords.supplier}`);
if (customKeywords.totalAmount) hints.push(`Montant total: ${customKeywords.totalAmount}`);
if (customKeywords.subscription) hints.push(`Abonnement: ${customKeywords.subscription}`);
if (customKeywords.recipient) hints.push(`Destinataire: ${customKeywords.recipient}`);
if (hints.length > 0) {
keywordsHint = `\n\nMots-clés personnalisés à rechercher:\n${hints.join("\n")}`;
@@ -200,12 +203,13 @@ export async function extractInvoicesWithMistral(
const prompt = `Tu es un expert en extraction de données de factures. Analyse ce document PDF et extrais toutes les factures qu'il contient.
Pour chaque facture trouvée, extrais les informations suivantes:
- supplierName: Nom du fournisseur/vendeur
- supplierName: Nom du fournisseur/vendeur (émetteur de la facture)
- invoiceNumber: Numéro de la facture
- invoiceDate: Date de la facture (format ISO 8601: YYYY-MM-DD)
- deliveryNoteNumber: Numéro du bon de livraison (si présent)
- orderNumber: Numéro de commande client (si présent)
- totalAmount: Montant total TTC (nombre décimal)
- recipientName: Nom du destinataire/client (société ou personne à qui la facture est adressée)
- pageRange: Plage de pages de cette facture (ex: "1-2" ou "5")
${qualityScoreInstruction}
- extractedText: Texte complet extrait de la facture (tout le texte visible sur les pages de cette facture)
@@ -223,6 +227,7 @@ Réponds UNIQUEMENT avec un objet JSON valide au format suivant:
"deliveryNoteNumber": "...",
"orderNumber": "...",
"totalAmount": 123.45,
"recipientName": "...",
"pageRange": "1-2",
"qualityScore": 85,
"extractedText": "Texte complet de la facture...",
@@ -318,6 +323,7 @@ export function generateMetadataJSON(invoice: ExtractedInvoiceData): string {
deliveryNoteNumber: invoice.deliveryNoteNumber,
orderNumber: invoice.orderNumber,
totalAmount: invoice.totalAmount,
recipientName: invoice.recipientName,
pageRange: invoice.pageRange,
qualityScore: invoice.qualityScore,
extractedAt: new Date().toISOString(),