Commit Graph
250 Commits
Author SHA1 Message Date
MichaelandClaude Sonnet 4.6 1cd3ade77e perf: remove actif filter, increase batchSize, exclude Y articles without sales
- Remove actif/suspendu filter that caused wrong stats (893€ CA, 249 units)
  by incorrectly excluding products with sales. The parallel pagination
  and bulk ranking fixes are sufficient to handle large suppliers.
- Increase getMensuelByArticles and getReferentielByArticles batchSize
  from 20 to 50, reducing sequential batch iterations by ~2.5x.
- Filter gamme Y products with zero 12-month sales from returned rows.
  Reduces grid size (e.g. S053: 14775→fewer rows) without affecting
  products that actually sold. Y products with sales are preserved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 21:23:34 +01:00
MichaelandClaude Sonnet 4.6 be3a196744 perf: parallel article pagination + single-call full ranking fetch
Article pagination:
- fetchAllPages fallback now fetches 10 pages in parallel instead of
  sequentially. Stops as soon as any page returns < pageSize items.
  For S053 (30 pages), reduces sequential time by ~10x.

Ranking:
- getRankingByArticles now fetches the entire network ranking in one
  call (GET /api/ranking?limit=30000) and matches by codein.
  Replaces foucentrale bulk (which returned 0) and per-article fallback
  (which would be 8889 calls for S053).
- totalRankedProducts = actual number of entries returned by the API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 20:58:03 +01:00
MichaelandClaude Sonnet 4.6 a16ec24cd7 perf+fix: parallelize article pagination, filter inactive articles, add gamme Y
Performance fixes for large suppliers (14k+ articles):
- fetchAllPages now fetches page 1, reads total count from response,
  then fetches remaining pages in parallel (10 at a time) instead of
  sequentially. Falls back to sequential if no count in response.
- getProductRows filters out suspended/inactive articles before calling
  getMensuelByArticles and getReferentielByArticles, reducing API calls
  from N_total to N_active (e.g. 14775→~2500 for S053).
- getRankingByArticles receives only active articles for bulk fetch.
- FfArticle now exposes actif and suspendu fields.

Gamme Y support:
- GammeSelect: add Y option with violet color
- GridFilterBar: add Y filter button with violet color
- BulkActionToolbar: add Y bulk assignment button

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 20:23:38 +01:00
Michael 69c7d65482 feat: Add Claude settings to allow specific Git and Next.js Bash commands. 2026-03-19 20:06:11 +01:00
MichaelandClaude Sonnet 4.6 dcebf74f31 perf: replace N ranking API calls with 1 bulk fetch per supplier
getRankingByArticles now uses GET /api/ranking?foucentrale=<code>
to fetch all rankings for a supplier in a single request instead of
making one request per article. For a 500-article supplier this goes
from ~500 HTTP calls to 2 (count + bulk), eliminating the timeout
that caused the client-side crash on large suppliers.

Falls back to per-article requests if no codeFournisseur is provided
or if the bulk endpoint fails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 18:53:49 +01:00
MichaelandClaude Opus 4.6 414bf6133d fix: correct snapshot save to detect all gamme changes (drafts + validated)
handleSnapshot was only looking at active draftChanges to build the
snapshot. After validation (Valider), drafts are cleared but changes
are applied to row.codeGamme via applyDraftsToRows. This caused
handleSnapshot (Camera/Export) to save an empty snapshot that
overwrote the real one, losing all gamme changes on page reload.

Now handleSnapshot compares (draftChanges[codein] ?? row.codeGamme)
vs row.codeGammeInit to detect ALL changes, whether drafted or
already validated. Uses codeGammeInit as "before" reference (API
value, never modified).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 17:13:49 +01:00
Michael 01d2dc8b34 feat: add BulkAiAnalyzer component for automatic product classification and AI context profiling. 2026-03-19 15:52:48 +01:00
Michael 41a8b32aff feat: Add API route to export modified gammes data to an Excel file. 2026-03-19 15:28:16 +01:00
Michael 7cdbe8ec21 feat: add Zustand store for grid state and a hook to save draft modifications 2026-03-19 15:17:28 +01:00
Michael aa69637f98 feat: Introduce bulk AI analyzer component to pre-classify products and prepare data for AI analysis, including context profiling. 2026-03-19 13:19:49 +01:00
Michael a4528c6d14 feat: Add HeatmapGrid component for visualizing product data with TanStack Table, virtualization, and performance optimizations. 2026-03-19 13:02:16 +01:00
Michael 34529f3934 feat: add FF Nancy API client for fetching suppliers, articles, and movements with pagination and data mapping. 2026-03-19 12:55:55 +01:00
Michael 8b7d81b20c feat: implement product grid with comprehensive product data fetching, processing, and heatmap display. 2026-03-19 12:41:03 +01:00
Michael 2b7e7bc1f4 feat: Introduce AI analysis engine with detailed system prompt and user message generation for product recommendations, and add an OpenRouter client. 2026-03-19 09:50:28 +01:00
Michael d8a9329075 feat: Introduce AI Copilot feature with product analysis engine, state management, and UI components for insights. 2026-03-19 07:53:56 +01:00
Michael 95795ce7e3 feat: Introduce AI analysis engine for product A/Z recommendations based on detailed business rules. 2026-03-18 22:15:14 +01:00
Michael e96bfa818d feat: Add a percentile composite score engine to calculate product performance based on sales, volume, and margin. 2026-03-18 21:41:29 +01:00
Michael de768128e3 feat: implement AI copilot analysis engine with v5 simplified system prompt and product recommendation rules. 2026-03-18 21:34:31 +01:00
Michael aa02d019bd feat: Implement AI Copilot for product analysis and add comprehensive product grid data fetching. 2026-03-18 21:25:53 +01:00
Michael cefe6060d0 feat: implement virtualized heatmap grid component using TanStack Table and Virtual for product data display. 2026-03-18 20:52:13 +01:00
Michael aa77025d14 feat: introduce virtualized heatmap grid component with client-side filtering, sorting, and optimized Zustand state management. 2026-03-18 20:49:57 +01:00
Michael 9aca3b8ead feat: Add virtualized heatmap grid component with dynamic columns, filtering, and row selection. 2026-03-18 20:34:23 +01:00
Michael 8bd7ae8c45 feat: implement server action to fetch and process product rows with sales, stock, and classification data. 2026-03-18 20:08:15 +01:00
Michael c303427dd0 feat: implement a centralized HTTP client for the FF Nancy REST API, including data types, pagination, and functions for suppliers, articles, and movements. 2026-03-18 20:00:45 +01:00
Michael ab603e3a6f feat: Add a diagnostic API route and implement server-side logic for fetching and scoring product grid data. 2026-03-18 19:54:44 +01:00
Michael d616da8b91 feat: Introduce getProductRows API and related types for fetching and processing comprehensive product data, incorporating sales, stock, and classification. 2026-03-18 19:31:16 +01:00
MichaelandClaude Sonnet 4.6 8986f7d001 feat: integrate /referentiel endpoint for nomenclature, gamme, stock, PA
Replaces ventesProduits DB query with API call to /articles/:no_id/referentiel.
Called in parallel with mensuel and commandes.

Extracts:
- article.nom_code/nom_libelle → code3/libelle3 (nomenclature)
- gammes[0].gamme_code → codeGamme + codeGammeInit (frozen initial)
- prix.achat + fournisseurs[0].pcb → pa/prixAchat/pcb
- stock[] → stockActuel/stockTotal/stockValeur (real-time)
- performance.derniere_vente/derniere_entree → derniereVente/derniereLivraison

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 19:26:47 +01:00
MichaelandClaude Sonnet 4.6 ca467c73f6 chore: probe /api/articles/:no_id/referentiel in diag
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 19:24:09 +01:00
MichaelandClaude Sonnet 4.6 06e1b1a238 chore: add ventesProduits diagnostic to diag endpoint
Shows row counts, gamme/code3 fill rates, and sample rows
for AUXENCE/A025 to diagnose missing classification data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 19:17:22 +01:00
MichaelandClaude Sonnet 4.6 84aa84cf41 fix: use Drizzle inArray() for ventesProduits classification query
Replaces raw sql ANY() template (which had array type issues) with
proper Drizzle inArray(), deduplicating by codein in JS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 19:15:24 +01:00
MichaelandClaude Sonnet 4.6 09be89b557 fix: query ventesProduits by codein array instead of code_fournisseur
The old fournisseur code stored in ventesProduits may differ from the
new API codefou (e.g. "AUXENCE" vs "A025"), causing zero results.
Querying by codein = ANY(...) finds the classification data regardless
of how the supplier was previously keyed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 19:05:58 +01:00
Michael 518838c01e feat: introduce getProductRows API to fetch, process, and score product data from multiple sources. 2026-03-18 18:11:08 +01:00
MichaelandClaude Sonnet 4.6 47e617afd3 feat: restore reference, gtin, gamme initiale and nomenclature
api-ff-client.ts:
- FfArticle: add reference (ref_fou_principale) and gtin fields
- getArticlesByFournisseur: map ref_fou_principale → reference, gtin → gtin

get-product-rows.ts:
- ProductRow seeded with reference and gtin from API articles
- Phase 6: read codeGamme, codeGammeInit, code3, libelle3 from ventesProduits
  (read-only, DISTINCT ON codein ordered by updated_at DESC)
- Phase 7 snapshot still overrides DB gammes when a snapshot exists

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 18:08:21 +01:00
MichaelandClaude Sonnet 4.6 58f17152a1 feat: switch to /articles/:no_id/mensuel endpoint for sales & stock data
Replaces bulk mouvements pagination + per-article stock N+1 with a single
batched call to the new mensuel endpoint (confirmed working via diag).

api-ff-client.ts:
- Remove getStockByFournisseur (no longer needed)
- Add FfMensuelEntry/Ventes/Receptions interfaces
- Add getMensuelByArticles(articles, dateDebut, dateFin, batchSize=20)
  → Map<codein, FfMensuelEntry[]> using no_id as API identifier

get-product-rows.ts:
- Phase 2: getMensuelByArticles + getCommandesByFournisseur in parallel
- Phase 5: aggregate mois×site entries → sales12m, stock12m, workingStores
  - qte_vendue / ca_ht are negative → Math.abs()
  - stock carry-forward for months with no data
  - pa from prmp_fin_mois

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 18:00:55 +01:00
MichaelandClaude Sonnet 4.6 2d37a134d4 chore: update diag to probe new mensuel, stock/periode, and mouvements/types endpoints
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 16:44:01 +01:00
Michael 8aac493a97 feat: Add Claude settings to allow Bash git push operations. 2026-03-18 16:37:16 +01:00
MichaelandClaude Sonnet 4.6 5c40a615c7 fix: correct API field names for articles and mouvements endpoints
Articles:
- noid: r.no_id (was r.noid)
- codefou: r.codefou_principal (was r.codefou)
- nomfou: r.nom_fou_principal (was r.nomfou)
- pcb: r.pcb_principal (was r.pcb)

Mouvements:
- datemvt: r.datmvt (was r.datemvt) — CRITICAL
- qte: r.qtemvt (was r.qte) — CRITICAL
- montant: r.mntmvtht (was r.montant) — CRITICAL
- marge: r.margemvt (was r.marge) — CRITICAL
- URL now uses dateDebut/dateFin params (confirmed working vs datedeb/datefin which ignores filter)

Sites fallback: use real codes 292/579 (Frouard/Houdemont)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 15:03:19 +01:00
MichaelandClaude Sonnet 4.6 c33e22f7eb fix: extractList includes API-specific wrapper keys, diag uses real codefou
- extractList now explicitly checks "mouvements", "articles", "fournisseurs",
  "ventes", "stocks", "commandes" wrapper keys before generic array fallback
- Diag endpoint auto-fetches first real codefou from fournisseurs instead
  of hardcoded "AUXENCE" (which was supplier nom, not actual codefou)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 14:57:49 +01:00
MichaelandClaude Sonnet 4.6 9e500b6650 feat: enhance diag endpoint to probe mouvements API with multiple date param variants
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 14:50:32 +01:00
Michael c056750ea7 feat: implement FF Nancy API client including data models and functions for suppliers, articles, movements, and stock. 2026-03-18 14:44:44 +01:00
Michael 7b209292b9 feat: introduce GridClient component to manage grid state, scoring, and UI orchestration. 2026-03-18 14:35:24 +01:00
Michael 1035489db1 feat: Add FF Nancy API client and status endpoint, implement grid product fetching and draft change saving, and introduce AI Copilot core logic. 2026-03-18 14:31:29 +01:00
Michael 22aa6f101a feat: Implement AI-powered product analysis engine with rules for manager directives, dead stock, and relative supplier performance, supported by a new score engine. 2026-03-13 10:52:40 +01:00
Michael 38e8fc1eac feat: implement AI analysis engine for generating retail product recommendation prompts. 2026-03-13 08:55:30 +01:00
Michael 2d3a90d6c7 feat: add floating summary bar component with grid statistics, draft management, snapshot, and export functionality. 2026-03-12 14:25:39 +01:00
Michael 9faea9df07 feat: Implement AI analysis engine with simplified v5 logic for product recommendations based on relative supplier performance. 2026-03-12 13:38:23 +01:00
Michael 1f38f487b1 feat: implement AI copilot analysis engine with detailed product recommendation logic and system prompt generation. 2026-03-12 13:00:51 +01:00
Michael 97ed6dd829 feat: Add AI copilot analysis engine to generate system and contextual user prompts for product recommendations. 2026-03-12 12:42:19 +01:00
Michael 1a01e084a5 feat: Implement AI copilot analysis engine (v4) with comprehensive product recommendation logic and contextual data generation. 2026-03-12 12:26:54 +01:00
Michael b66867429b feat: implement v4 AI analysis engine with comprehensive product recommendation rules and contextual data for prompt generation. 2026-03-12 12:09:41 +01:00