diff --git a/src/features/ai-copilot/business/analysis-engine.ts b/src/features/ai-copilot/business/analysis-engine.ts index 800e5e3..3c38a27 100644 --- a/src/features/ai-copilot/business/analysis-engine.ts +++ b/src/features/ai-copilot/business/analysis-engine.ts @@ -23,6 +23,7 @@ IMPORTANT : La gamme C est RÉSERVÉE aux produits saisonniers et gérée MANUEL --- ORDRE DE PRIORITÉ (STRICT) --- 1. GARDE-FOU PROTECTION : Si isProtected = true (Nouveauté / Dernier Produit / Top30) → A obligatoire. + EXCEPTION : La protection est déjà neutralisée pour les produits à CA réseau < 10€ ou marge ≤ 0%. Si tu ne vois pas le signal 🛡️, le produit n'est PAS protégé. 2. SEUIL PLANCHER ABSOLU (règle critique) : Si isLowContribution = true [poids CA < 0.5% ET poids QTÉ < 0.5% du fournisseur] diff --git a/src/features/ai-copilot/business/context-profiler.ts b/src/features/ai-copilot/business/context-profiler.ts index 6439af2..bd6c1e9 100644 --- a/src/features/ai-copilot/business/context-profiler.ts +++ b/src/features/ai-copilot/business/context-profiler.ts @@ -270,15 +270,24 @@ export class ContextProfiler { ); // 8. Gardes-fous - const isProtected = + // Neutralisation : un produit à CA réseau trivial (< 10€) ou marge ≤ 0% + // n'a pas d'activité économique réelle. Le protéger serait absurde. + const rawCa = target.totalCa ?? 0; + const rawMarge = target.tauxMarge ?? 0; + const isEconomicallyViable = rawCa >= 10 && rawMarge > 0; + + const isProtected = isEconomicallyViable && ( scoring.decision.isRecent || scoring.decision.isTop30Supplier || - scoring.decision.isLastProduct; + scoring.decision.isLastProduct + ); let protectionReason = ""; - if (scoring.decision.isRecent) protectionReason = "Nouveauté (< 3 mois de données)"; - else if (scoring.decision.isTop30Supplier) protectionReason = "Top 30% CA Fournisseur"; - else if (scoring.decision.isLastProduct) protectionReason = "Dernière référence du fournisseur"; + if (isProtected) { + if (scoring.decision.isRecent) protectionReason = "Nouveauté (< 3 mois de données)"; + else if (scoring.decision.isTop30Supplier) protectionReason = "Top 30% CA Fournisseur"; + else if (scoring.decision.isLastProduct) protectionReason = "Dernière référence du fournisseur"; + } // 9. Règle absolue const scoreCritique = (target.score ?? 0) < 20;