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

@@ -0,0 +1,12 @@
CREATE TABLE `invoiceLearnings` (
`id` int AUTO_INCREMENT NOT NULL,
`userId` int NOT NULL,
`supplierKey` varchar(255) NOT NULL,
`fieldName` varchar(100) NOT NULL,
`originalValue` varchar(255),
`correctedValue` varchar(255) NOT NULL,
`applyCount` int NOT NULL DEFAULT 1,
`createdAt` timestamp NOT NULL DEFAULT (now()),
`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT `invoiceLearnings_id` PRIMARY KEY(`id`)
);

File diff suppressed because it is too large Load Diff

View File

@@ -127,6 +127,13 @@
"when": 1775987314108,
"tag": "0017_clammy_toad",
"breakpoints": true
},
{
"idx": 18,
"version": "5",
"when": 1776019747088,
"tag": "0018_warm_changeling",
"breakpoints": true
}
]
}

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;