Checkpoint: Bouton Relancer corrigé (automatismes uniquement, sans LLM). Système d'apprentissage complet : table invoiceLearnings, routes tRPC, déclenchement depuis InvoiceDetail, application lors des imports, page LearningSettings dans Configuration > Apprentissages IA.

This commit is contained in:
Manus
2026-04-12 14:54:29 -04:00
parent 120f56bb23
commit 3ae1e47ca6
10 changed files with 2187 additions and 74 deletions

View File

@@ -372,3 +372,28 @@ export const bapHistory = mysqlTable("bapHistory", {
});
export type BapHistory = typeof bapHistory.$inferSelect;
export type InsertBapHistory = typeof bapHistory.$inferInsert;
/**
* Invoice learnings table — corrections manuelles apprises par le système
* Quand l'utilisateur modifie un champ détecté par le LLM, le système mémorise
* la correction pour l'appliquer automatiquement aux prochains imports similaires.
*/
export const invoiceLearnings = mysqlTable("invoiceLearnings", {
id: int("id").autoincrement().primaryKey(),
userId: int("userId").notNull(),
/** Clé de correspondance : fournisseur normalisé (minuscules, sans espaces superflus) */
supplierKey: varchar("supplierKey", { length: 255 }).notNull(),
/** Champ corrigé : 'isSubscription' | 'typeAchat' | 'serviceConcerne' | 'ventilationComptable' */
fieldName: varchar("fieldName", { length: 100 }).notNull(),
/** Valeur originale détectée par le LLM (pour affichage dans la page de gestion) */
originalValue: varchar("originalValue", { length: 255 }),
/** Valeur corrigée manuellement par l'utilisateur */
correctedValue: varchar("correctedValue", { length: 255 }).notNull(),
/** Nombre de fois que cette correction a été appliquée */
applyCount: int("applyCount").default(1).notNull(),
createdAt: timestamp("createdAt").defaultNow().notNull(),
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
});
export type InvoiceLearning = typeof invoiceLearnings.$inferSelect;
export type InsertInvoiceLearning = typeof invoiceLearnings.$inferInsert;