Checkpoint: Apprentissage déclenché depuis les selects serviceConcerne/typeAchat/ventilation dans la liste Factures BAP. Page Apprentissages IA refaite avec indicateur de confiance (Confirmé/En observation) et seuil configurable.
This commit is contained in:
@@ -158,6 +158,8 @@ export default function InvoicesBAP() {
|
||||
},
|
||||
});
|
||||
|
||||
const upsertLearningMutation = trpc.learnings.upsert.useMutation();
|
||||
|
||||
const reprocessMutation = trpc.invoices.reprocessSelected.useMutation({
|
||||
onSuccess: (data) => {
|
||||
if (data.errors > 0) {
|
||||
@@ -624,10 +626,20 @@ export default function InvoicesBAP() {
|
||||
// Remove field from autoFilledFields when manually edited
|
||||
const autoFilledFields = invoice.autoFilledFields ? JSON.parse(invoice.autoFilledFields) : [];
|
||||
const updatedAutoFields = autoFilledFields.filter((f: string) => f !== "serviceConcerne");
|
||||
const newVal = e.target.value || undefined;
|
||||
// Apprentissage : mémoriser la correction manuelle
|
||||
if (invoice.supplierName && newVal !== (invoice.serviceConcerne || undefined)) {
|
||||
upsertLearningMutation.mutate({
|
||||
supplierName: invoice.supplierName,
|
||||
fieldName: 'serviceConcerne',
|
||||
originalValue: invoice.serviceConcerne || undefined,
|
||||
correctedValue: newVal || '',
|
||||
});
|
||||
}
|
||||
updateFieldMutation.mutate({
|
||||
id: invoice.id,
|
||||
data: {
|
||||
serviceConcerne: e.target.value || undefined,
|
||||
serviceConcerne: newVal,
|
||||
autoFilledFields: updatedAutoFields.length > 0 ? JSON.stringify(updatedAutoFields) : null
|
||||
},
|
||||
});
|
||||
@@ -649,10 +661,20 @@ export default function InvoicesBAP() {
|
||||
// Remove field from autoFilledFields when manually edited
|
||||
const autoFilledFields = invoice.autoFilledFields ? JSON.parse(invoice.autoFilledFields) : [];
|
||||
const updatedAutoFields = autoFilledFields.filter((f: string) => f !== "typeAchat");
|
||||
const newTypeAchat = e.target.value as "CAPEX" | "OPEX" | undefined;
|
||||
// Apprentissage : mémoriser la correction manuelle
|
||||
if (invoice.supplierName && newTypeAchat !== (invoice.typeAchat || undefined)) {
|
||||
upsertLearningMutation.mutate({
|
||||
supplierName: invoice.supplierName,
|
||||
fieldName: 'typeAchat',
|
||||
originalValue: invoice.typeAchat || undefined,
|
||||
correctedValue: newTypeAchat || '',
|
||||
});
|
||||
}
|
||||
updateFieldMutation.mutate({
|
||||
id: invoice.id,
|
||||
data: {
|
||||
typeAchat: e.target.value as "CAPEX" | "OPEX" | undefined,
|
||||
typeAchat: newTypeAchat,
|
||||
autoFilledFields: updatedAutoFields.length > 0 ? JSON.stringify(updatedAutoFields) : null
|
||||
},
|
||||
});
|
||||
@@ -677,10 +699,20 @@ export default function InvoicesBAP() {
|
||||
// Remove field from autoFilledFields when manually edited
|
||||
const autoFilledFields = invoice.autoFilledFields ? JSON.parse(invoice.autoFilledFields) : [];
|
||||
const updatedAutoFields = autoFilledFields.filter((f: string) => f !== "ventilationComptable");
|
||||
const newVentil = e.target.value || undefined;
|
||||
// Apprentissage : mémoriser la correction manuelle
|
||||
if (invoice.supplierName && newVentil !== (invoice.ventilationComptable || undefined)) {
|
||||
upsertLearningMutation.mutate({
|
||||
supplierName: invoice.supplierName,
|
||||
fieldName: 'ventilationComptable',
|
||||
originalValue: invoice.ventilationComptable || undefined,
|
||||
correctedValue: newVentil || '',
|
||||
});
|
||||
}
|
||||
updateFieldMutation.mutate({
|
||||
id: invoice.id,
|
||||
data: {
|
||||
ventilationComptable: e.target.value || undefined,
|
||||
ventilationComptable: newVentil,
|
||||
autoFilledFields: updatedAutoFields.length > 0 ? JSON.stringify(updatedAutoFields) : null
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user