Checkpoint: isSubscription appliqué lors des imports. Seuil de confiance persisté en base (champ learningConfidenceThreshold dans userSettings). LearningSettings.tsx charge et sauvegarde le seuil via settings.get/upsert.

This commit is contained in:
Manus
2026-04-12 15:27:19 -04:00
parent 95aee693ea
commit 132f8ccec2
6 changed files with 1752 additions and 9 deletions

View File

@@ -299,11 +299,16 @@ export const appRouter = router({
const learnings = await getLearningsBySupplier(userId, newInvoice.supplierName);
if (learnings.length > 0) {
const learningUpdates: Record<string, string> = {};
const isSubscriptionLearning = learnings.find(l => l.fieldName === 'isSubscription');
for (const learning of learnings) {
if (learning.fieldName === 'typeAchat' || learning.fieldName === 'serviceConcerne' || learning.fieldName === 'ventilationComptable') {
learningUpdates[learning.fieldName] = learning.correctedValue;
}
}
// Appliquer l'apprentissage isSubscription
if (isSubscriptionLearning) {
(learningUpdates as any)['isSubscription'] = isSubscriptionLearning.correctedValue === 'OUI' ? 1 : 0;
}
if (Object.keys(learningUpdates).length > 0) {
await updateInvoice(newInvoice.id, learningUpdates as any);
console.log(`[Learning] Applied ${Object.keys(learningUpdates).length} learning(s) to invoice ${newInvoice.id} (${newInvoice.supplierName})`);
@@ -990,6 +995,7 @@ export const appRouter = router({
sftpRemotePath: z.string().optional(),
sftpAutoExport: z.number().optional(),
llmLogsRetentionMonths: z.number().optional(),
learningConfidenceThreshold: z.number().min(1).optional(),
}))
.mutation(async ({ input, ctx }) => {
await upsertUserSettings({