Fonctionnalités implémentées : ✅ Authentification locale (email/password) + Azure AD + Manus OAuth ✅ Upload drag-and-drop de fichiers PDF avec suivi en temps réel ✅ Extraction automatique avec Mistral AI (OCR + LLM) ✅ Détection de doublons (fournisseur, numéro, date) ✅ Score de qualité d'extraction (0-100) ✅ Tableau de bord avec statistiques ✅ Liste des factures avec recherche et filtres ✅ Paramètres utilisateur (LLM, keywords, SFTP) ✅ Historique des imports avec logs détaillés ✅ Gestion des utilisateurs (admin) ✅ Export SFTP manuel/automatique ✅ Stockage local avec organisation YYYY-MM ✅ Tests unitaires d'authentification Architecture : - Frontend : React 19 + Vite + TailwindCSS + Radix UI - Backend : Express + tRPC + Drizzle ORM - Base de données : MySQL (6 tables) - IA : Mistral AI pour extraction - Stockage : Local filesystem - Export : SFTP Pages : - Login (choix local/Azure/Manus) - Dashboard (statistiques) - Upload (drag-and-drop) - Invoices (liste avec recherche) - Settings (LLM, keywords, SFTP) - History (logs d'import) - Users (gestion admin)
107 lines
4.0 KiB
SQL
107 lines
4.0 KiB
SQL
CREATE TABLE `importLogs` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`userId` int NOT NULL,
|
|
`sourceFileId` int NOT NULL,
|
|
`fileName` varchar(255) NOT NULL,
|
|
`totalInvoicesDetected` int NOT NULL DEFAULT 0,
|
|
`invoicesImported` int NOT NULL DEFAULT 0,
|
|
`duplicatesIgnored` int NOT NULL DEFAULT 0,
|
|
`errors` int NOT NULL DEFAULT 0,
|
|
`duplicateDetails` text,
|
|
`errorDetails` text,
|
|
`importedAt` timestamp NOT NULL DEFAULT (now()),
|
|
CONSTRAINT `importLogs_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `invoices` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`userId` int NOT NULL,
|
|
`sourceFileId` int NOT NULL,
|
|
`invoiceIndexInFile` int NOT NULL DEFAULT 1,
|
|
`fileName` varchar(255) NOT NULL,
|
|
`fileKey` text NOT NULL,
|
|
`fileUrl` text NOT NULL,
|
|
`supplierName` varchar(255),
|
|
`invoiceNumber` varchar(100),
|
|
`invoiceDate` timestamp,
|
|
`deliveryNoteNumber` varchar(100),
|
|
`orderNumber` varchar(100),
|
|
`totalAmount` decimal(10,2),
|
|
`pageRange` varchar(20),
|
|
`qualityScore` int,
|
|
`metadataFileKey` text,
|
|
`metadataFileUrl` text,
|
|
`status` enum('processing','completed','error') NOT NULL DEFAULT 'processing',
|
|
`errorMessage` text,
|
|
`manuallyEdited` int NOT NULL DEFAULT 0,
|
|
`exportedAt` timestamp,
|
|
`exportMode` enum('manual','automatic'),
|
|
`createdAt` timestamp NOT NULL DEFAULT (now()),
|
|
`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
|
|
CONSTRAINT `invoices_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `supplier_invoice_date_unique` UNIQUE(`supplierName`,`invoiceNumber`,`invoiceDate`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `llmLogs` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`userId` int NOT NULL,
|
|
`sourceFileId` int,
|
|
`invoiceId` int,
|
|
`operation` varchar(50) NOT NULL,
|
|
`model` varchar(50) NOT NULL,
|
|
`promptSent` text NOT NULL,
|
|
`rawResponse` text NOT NULL,
|
|
`cleanedResponse` text,
|
|
`success` int NOT NULL DEFAULT 1,
|
|
`errorMessage` text,
|
|
`processingTimeMs` int,
|
|
`pageRange` varchar(50),
|
|
`createdAt` timestamp NOT NULL DEFAULT (now()),
|
|
CONSTRAINT `llmLogs_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `sourceFiles` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`userId` int NOT NULL,
|
|
`fileName` varchar(255) NOT NULL,
|
|
`fileKey` text NOT NULL,
|
|
`fileUrl` text NOT NULL,
|
|
`totalInvoicesDetected` int NOT NULL DEFAULT 0,
|
|
`processingStatus` enum('processing','completed','error') NOT NULL DEFAULT 'processing',
|
|
`processingProgress` varchar(255),
|
|
`createdAt` timestamp NOT NULL DEFAULT (now()),
|
|
`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
|
|
CONSTRAINT `sourceFiles_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `userSettings` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`userId` int NOT NULL,
|
|
`llmModel` varchar(50) NOT NULL DEFAULT 'mistral-large-latest',
|
|
`orderNumberFormat` text,
|
|
`invoiceNumberKeywords` text,
|
|
`deliveryNoteKeywords` text,
|
|
`orderNumberKeywords` text,
|
|
`supplierKeywords` text,
|
|
`totalAmountKeywords` text,
|
|
`sftpHost` varchar(255),
|
|
`sftpPort` int DEFAULT 22,
|
|
`sftpUsername` varchar(255),
|
|
`sftpPassword` text,
|
|
`sftpRemotePath` varchar(500) DEFAULT '/',
|
|
`sftpAutoExport` int NOT NULL DEFAULT 0,
|
|
`llmLogsRetentionMonths` int NOT NULL DEFAULT 3,
|
|
`createdAt` timestamp NOT NULL DEFAULT (now()),
|
|
`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
|
|
CONSTRAINT `userSettings_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `userSettings_userId_unique` UNIQUE(`userId`)
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE `users` MODIFY COLUMN `openId` varchar(64);--> statement-breakpoint
|
|
ALTER TABLE `users` MODIFY COLUMN `email` varchar(320) NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE `users` MODIFY COLUMN `loginMethod` enum('manus','local','azure-ad') NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `azureAdId` varchar(64);--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `passwordHash` varchar(255);--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `isActive` int DEFAULT 1 NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD CONSTRAINT `users_azureAdId_unique` UNIQUE(`azureAdId`);--> statement-breakpoint
|
|
ALTER TABLE `users` ADD CONSTRAINT `users_email_unique` UNIQUE(`email`); |