Checkpoint: Ajout du champ Abonnement (OUI/NON) aux factures avec détection automatique par mots-clés et édition directe dans la liste
This commit is contained in:
@@ -74,6 +74,7 @@ async function processEmailAttachment(
|
||||
orderNumber: settings.orderNumberKeywords,
|
||||
supplier: settings.supplierKeywords,
|
||||
totalAmount: settings.totalAmountKeywords,
|
||||
subscription: settings.subscriptionKeywords,
|
||||
} : undefined;
|
||||
|
||||
const model = settings?.llmModel || "mistral-large-latest";
|
||||
|
||||
@@ -75,6 +75,7 @@ async function processFolderFile(
|
||||
orderNumber: settings.orderNumberKeywords,
|
||||
supplier: settings.supplierKeywords,
|
||||
totalAmount: settings.totalAmountKeywords,
|
||||
subscription: settings.subscriptionKeywords,
|
||||
} : undefined;
|
||||
|
||||
const model = settings?.llmModel || "mistral-large-latest";
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface ExtractedInvoiceData {
|
||||
pageRange: string;
|
||||
qualityScore: number; // 0-100
|
||||
extractedText: string | null; // Full text extracted from the invoice PDF
|
||||
isSubscription: boolean; // True if subscription keywords detected
|
||||
}
|
||||
|
||||
export interface MultiInvoiceResult {
|
||||
@@ -102,6 +103,7 @@ export async function extractInvoicesWithMistral(
|
||||
orderNumber?: string | null;
|
||||
supplier?: string | null;
|
||||
totalAmount?: string | null;
|
||||
subscription?: string | null;
|
||||
}
|
||||
): Promise<MultiInvoiceResult> {
|
||||
const startTime = Date.now();
|
||||
@@ -127,6 +129,7 @@ export async function extractInvoicesWithMistral(
|
||||
if (customKeywords.orderNumber) hints.push(`Numéro de commande: ${customKeywords.orderNumber}`);
|
||||
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 (hints.length > 0) {
|
||||
keywordsHint = `\n\nMots-clés personnalisés à rechercher:\n${hints.join("\n")}`;
|
||||
@@ -145,7 +148,8 @@ Pour chaque facture trouvée, extrais les informations suivantes:
|
||||
- totalAmount: Montant total TTC (nombre décimal)
|
||||
- pageRange: Plage de pages de cette facture (ex: "1-2" ou "5")
|
||||
- qualityScore: Score de qualité de l'extraction de 0 à 100 (100 = toutes les informations trouvées et claires)
|
||||
- extractedText: Texte complet extrait de la facture (tout le texte visible sur les pages de cette facture)${keywordsHint}
|
||||
- extractedText: Texte complet extrait de la facture (tout le texte visible sur les pages de cette facture)
|
||||
- isSubscription: true si la facture contient des mots-clés liés à un abonnement (abonnement, subscription, mensuel, annuel, recurring, etc.), false sinon${keywordsHint}
|
||||
|
||||
Réponds UNIQUEMENT avec un objet JSON valide au format suivant:
|
||||
{
|
||||
@@ -161,7 +165,8 @@ Réponds UNIQUEMENT avec un objet JSON valide au format suivant:
|
||||
"totalAmount": 123.45,
|
||||
"pageRange": "1-2",
|
||||
"qualityScore": 85,
|
||||
"extractedText": "Texte complet de la facture..."
|
||||
"extractedText": "Texte complet de la facture...",
|
||||
"isSubscription": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ export const appRouter = router({
|
||||
orderNumber: settings.orderNumberKeywords,
|
||||
supplier: settings.supplierKeywords,
|
||||
totalAmount: settings.totalAmountKeywords,
|
||||
subscription: settings.subscriptionKeywords,
|
||||
} : undefined;
|
||||
|
||||
const model = settings?.llmModel || "mistral-large-latest";
|
||||
@@ -235,6 +236,7 @@ export const appRouter = router({
|
||||
pageRange: invoiceData.pageRange,
|
||||
qualityScore: invoiceData.qualityScore,
|
||||
extractedText: invoiceData.extractedText,
|
||||
isSubscription: invoiceData.isSubscription ? 1 : 0,
|
||||
metadataFileKey: metadataKey,
|
||||
metadataFileUrl: metadataUrl,
|
||||
status: "completed",
|
||||
@@ -308,6 +310,7 @@ export const appRouter = router({
|
||||
serviceConcerne: z.string().optional(),
|
||||
typeAchat: z.enum(["CAPEX", "OPEX"]).optional(),
|
||||
ventilationComptable: z.string().optional(),
|
||||
isSubscription: z.number().min(0).max(1).optional(),
|
||||
}),
|
||||
}))
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
@@ -374,6 +377,7 @@ export const appRouter = router({
|
||||
orderNumberKeywords: z.string().optional(),
|
||||
supplierKeywords: z.string().optional(),
|
||||
totalAmountKeywords: z.string().optional(),
|
||||
subscriptionKeywords: z.string().optional(),
|
||||
sftpHost: z.string().optional(),
|
||||
sftpPort: z.number().optional(),
|
||||
sftpUsername: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user