Commit Graph
263 Commits
Author SHA1 Message Date
Michael 6827257f95 feat: Add PostgreSQL client for FF Nancy data, replacing HTTP API calls with efficient bulk SQL queries. 2026-03-20 13:07:09 +01:00
Michael b4f583415b feat: Add PostgreSQL client for FF Nancy data, replacing HTTP API calls with bulk SQL queries for improved performance. 2026-03-20 11:39:40 +01:00
Michael d5b518477a feat: Add PostgreSQL client for FF Nancy data, replacing per-article HTTP calls with bulk SQL queries for improved performance. 2026-03-20 11:30:54 +01:00
Michael 750017de14 feat: Add PostgreSQL client for FF Nancy data, replacing per-article HTTP API calls with bulk SQL queries for improved performance. 2026-03-20 11:17:24 +01:00
Michael 4b84b56aa6 feat: Introduce a PostgreSQL client for direct FF Nancy data access, replacing per-article HTTP API calls with bulk SQL queries. 2026-03-20 10:57:21 +01:00
Michael eb0fb14021 feat: Add PostgreSQL client for direct FF Nancy database access, replacing per-article HTTP API calls with bulk SQL queries. 2026-03-20 10:44:49 +01:00
Michael a875dbda86 feat: Add PostgreSQL client for FF Nancy to replace per-article HTTP calls with bulk SQL queries. 2026-03-20 10:37:47 +01:00
Michael 70b49c5c56 feat: Introduce getProductRows server action for fetching and processing comprehensive product data from PostgreSQL. 2026-03-20 10:25:24 +01:00
Michael f94d7753b4 feat: Implement direct PostgreSQL client for FF Nancy data, replacing HTTP API calls with bulk SQL queries for improved performance. 2026-03-20 10:12:39 +01:00
Michael 4dd1b5f7c7 feat: Introduce PostgreSQL client for bulk data retrieval and integrate it into product grid data fetching actions. 2026-03-20 10:05:30 +01:00
Michael 58d467a7ea feat: implement product row data retrieval and processing logic for the grid. 2026-03-20 09:58:32 +01:00
MichaelandClaude Sonnet 4.6 65f455b4e2 perf: referentiel+ranking only for articles with sales, per-article ranking
The ranking bulk endpoint is capped at 500 by the API server, making
it useless for full supplier matching. Per-article ranking (codein filter)
works correctly and is now called only for articles WITH sales data.

getProductRows restructured:
- Phase 2A: mensuel + commandes in parallel (all articles)
- Phase 2B: referentiel + ranking in parallel, only for articlesWithData
  (articles that appear in mensuelMap)

For a 45060-article supplier with 5446 with sales:
- Referentiel: 45060 → 5446 calls (88% reduction)
- Ranking: 45060 → 5446 calls (88% reduction)

totalRankedProducts fetched from GET /api/ranking?limit=500 count.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 22:02:12 +01:00
MichaelandClaude Sonnet 4.6 383b8ccac7 fix: ranking bulk match by codein AND gencod/gtin, add entry key logging
The bulk ranking response (GET /api/ranking?limit=30000) may use
'gencod' instead of 'codein' as the article identifier. Added:
- gtin→codein lookup map built from article gtin fields
- Match entries by entry.codein first, then by entry.gencod→article.gtin
- Diagnostic logging of the first entry's keys and values to identify
  the correct identifier field in the API response
- Increased fallback per-article batchSize from 20 to 50

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 21:51:42 +01:00
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