Commit Graph
307 Commits
Author SHA1 Message Date
Michael 67b0c8c74f chore: inspect v_ca_fournisseur view structure 2026-03-31 13:52:22 +02:00
Michael 072479b30f chore: fix diag-fournisseurs to inspect real fouadr1 column structure 2026-03-31 13:44:19 +02:00
Michael 09f80b35cb chore: add diag-fournisseurs endpoint to investigate fouadr1 sit_code and naming 2026-03-31 13:40:08 +02:00
MichaelandClaude Sonnet 4.6 853a36cb97 fix: override D005 display name from 'BAZAR 5000' to 'Dépôt'
D005 is the main active supplier (95k+ articles, fournisseur principal)
but its historical name in the FF Nancy ERP is 'BAZAR 5000' since 2004.
The store no longer associates this code with BAZAR 5000 — it is their
Dépôt. Override via CASE WHEN in SQL since the ERP name cannot be changed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 13:38:41 +02:00
MichaelandClaude Sonnet 4.6 cfd3a7e601 chore: remove temporary diag-supplier investigation endpoint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 12:08:15 +02:00
MichaelandClaude Sonnet 4.6 51adac0349 fix: attribute CA to supplier of last stock entry (dernière entrée en stock)
Previous approach (artfou1 DISTINCT ON no_id DESC) picked the most recent
artfou1 record, but artfou1 is a commercial reference table that may not
reflect actual current sourcing.

New approach: for each article, find the most recent reception movement
(genremvt IN (1,2)) in mvtart — this is the actual last delivery. Join
artfou1 to get the supplier code (ORDER BY datmvt DESC, af.no_id DESC to
break ties). This correctly attributes CA to whoever last physically
delivered the goods, not to a historical commercial reference.

Articles with no reception history are excluded (no INNER JOIN fallback
needed as all sold articles must have been received at least once).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 12:05:38 +02:00
MichaelandClaude Sonnet 4.6 3d77f6b879 chore: add diag-supplier endpoint for artfou1 supplier attribution investigation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 11:08:23 +02:00
MichaelandClaude Sonnet 4.6 5436513e30 fix: use most recent artfou1 entry (no_id DESC) for supplier attribution
DISTINCT ON with ORDER BY no_id ASC was picking the oldest supplier entry
(BAZAR 5000 historically), attributing CA to a supplier the store no longer
uses. Changing to DESC picks the most recently inserted artfou1 row, which
represents the current active supplier for each article.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 10:44:50 +02:00
MichaelandClaude Sonnet 4.6 b420dc2a2b fix: prevent CA multiplication in analytics by using DISTINCT ON per article
artfou1 has multiple rows per article (multi-supplier), causing each mvtart
movement to be counted N times in the JOIN. Use a CTE with DISTINCT ON
(art_no_id) ORDER BY no_id to pick one canonical supplier per article,
matching the same pattern used in pgGetArticlesByFournisseur.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 10:36:19 +02:00
MichaelandClaude Sonnet 4.6 7e8b50e143 fix: remove function prop, unused import and useSearchParams in analytics
- page.tsx: move formatCA into client component (functions not serializable
  across server→client boundary in Next.js — root cause of 500)
- client.tsx: remove unused BarChart2 import
- client.tsx: replace useSearchParams() with direct URL construction to
  avoid Suspense boundary requirement
- pg-ff-client: use OR conditions instead of IN() for Drizzle compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 10:32:21 +02:00
MichaelandClaude Sonnet 4.6 c9df9feccd fix: replace IN() with OR conditions in analytics SQL for Drizzle compatibility
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 10:27:32 +02:00
Michael d8a9bf80a0 fix: correct SQL parameterization in analytics queries and use distinct icons
- pg-ff-client: replace ANY(ARRAY[...]) with IN(...) for Drizzle compatibility
- sidebar: change Analytics icon from BarChart2 (duplicate) to TrendingUp

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
EOF
2026-03-31 10:02:44 +02:00
MichaelandClaude Sonnet 4.6 740aed3181 feat: add analytics page with CA TTC comparison by supplier/nomenclature
- pg-ff-client: add pgGetCaByFournisseur() and pgGetCaByNomenclature()
  returning CA TTC per site and month for monthly N vs N-1 comparison
- analytics/page.tsx: server component with pivot logic to reshape raw
  query data into store-separated columns (292/579/total) with evolution %
- analytics/client.tsx: client controls (mode dropdown, month selector)
  and responsive table with color-coded evolution badges
- sidebar: add "Analytics" link to navigation

Features:
- Switch between "Fournisseur" and "Nomenclature" views
- Select any month for comparison vs same month prior year
- Columns split by store: Frouard/Nancy (292), Houdemont (579), Total
- Each store shows: CA this month, CA N-1, evolution %
- Footer totals row matching sum of detail rows
- FR locale currency formatting (€)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 09:40:31 +02:00
MichaelandClaude Sonnet 4.6 7a30783285 fix: force score=0 for zero-sale products and fix reception SQL sign
- score-engine: add hard guard (wQty=0 && wCa=0 → score=0) before any
  calculation to prevent edge cases (residual margin, percentile rank)
  from producing non-zero scores on unsold articles
- score-engine: set inactivity=24 when product has never sold, so the
  regularityMultiplier penalty (0.3) is correctly applied instead of 1
- pg-ff-client: remove erroneous negation on qte_recue — entry movements
  have positive qtemvt in the DB, negating them produced negative values
  that failed the > 0 check, hiding all entrées in tooltips and modals

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 09:19:57 +01:00
Michael 76b06419a0 feat: add PostgreSQL client to replace per-article HTTP calls with bulk SQL queries for FF Nancy data. 2026-03-23 16:56:22 +01:00
Michael 8ecba594cf feat: introduce virtualized heatmap grid component with dynamic monthly data and optimized cell rendering. 2026-03-23 16:20:17 +01:00
Michael ffa257fda1 feat: Implement product heatmap grid with comprehensive data aggregation and PostgreSQL client for product rows. 2026-03-23 16:09:09 +01:00
Michael bba6fe05e8 feat: implement client-side grid orchestrator and core heatmap table component. 2026-03-23 14:13:39 +01:00
Michael 53b85381fa feat: add server-side API for fetching and processing comprehensive product data for the grid. 2026-03-23 14:00:27 +01:00
Michael 99954fb001 feat: Add AI Copilot Zustand store for managing and persisting product insights. 2026-03-23 13:34:36 +01:00
Michael 86df5d6f29 feat: introduce BulkAiAnalyzer component for bulk product classification and AI context profiling. 2026-03-23 12:43:02 +01:00
Michael c63a60c0cf feat: implement PostgreSQL client for FF Nancy API data with bulk SQL queries, replacing per-article HTTP calls. 2026-03-23 11:58:50 +01:00
Michael 2eb196861b feat: Implement initial dashboard page displaying network-level KPIs and individual store statistics. 2026-03-22 10:41:32 +01:00
Michael 38979debb8 feat: implement dashboard page with network KPIs and store statistics. 2026-03-21 19:41:59 +01:00
Michael 33deb033b5 feat: implement dashboard page with network-wide and site-specific KPIs, and top 10 items display. 2026-03-21 19:36:02 +01:00
Michael f24da605af feat: Implement direct PostgreSQL client for FF Nancy data, replacing per-article HTTP API calls. 2026-03-21 19:24:51 +01:00
Michael 46c799bd60 feat: Add dashboard page displaying network KPIs and store statistics, along with a new PostgreSQL data client. 2026-03-21 19:18:41 +01:00
Michael a705d0043d feat: Add dashboard page displaying network KPIs, site statistics, and top-selling items. 2026-03-21 18:55:33 +01:00
Michael 3a74689f31 feat: Add PostgreSQL client for bulk fetching FF Nancy data, replacing per-article HTTP API calls. 2026-03-21 17:11:54 +01:00
Michael 6ee0e3294d feat: Introduce direct PostgreSQL client for FF Nancy data to replace HTTP API calls and add a new dashboard page. 2026-03-21 14:37:02 +01:00
Michael d1bbe290da feat: Implement dashboard layout and a new PostgreSQL client for optimized FF Nancy data fetching via bulk SQL queries. 2026-03-21 13:07:59 +01:00
Michael e3d241a5ff feat: add PostgreSQL client for FF Nancy to replace per-article HTTP API calls with bulk SQL queries. 2026-03-21 11:59:36 +01:00
Michael 1664aaf4cc feat: Implement initial dashboard page displaying key performance indicators, site statistics, top items, and monthly evolution. 2026-03-21 08:54:52 +01:00
Michael 1e393753fa feat: Implement PostgreSQL client for FF Nancy to replace per-article HTTP calls with bulk SQL queries. 2026-03-21 08:37:33 +01:00
Michael eb8ca92847 feat: Add PostgreSQL client for FF Nancy to replace per-article HTTP calls with bulk SQL queries. 2026-03-21 00:56:36 +01:00
Michael 966b13cdf0 feat: implement dashboard page displaying KPIs, site statistics, top items, and monthly evolution using a new PostgreSQL client. 2026-03-21 00:22:14 +01:00
Michael 7cb96966aa feat: implement PostgreSQL client for FF Nancy data, replacing per-article HTTP calls with bulk SQL queries. 2026-03-20 16:09:22 +01:00
Michael d5a422e738 feat: Implement dashboard page, its data fetching client, and shared sidebar component. 2026-03-20 14:43:19 +01:00
Michael e391550a30 feat: Introduce product assortment grid client and direct PostgreSQL data access for FF Nancy. 2026-03-20 14:25:30 +01:00
Michael 2e1988a6f5 feat: Implement PostgreSQL client for FF Nancy, replacing per-article HTTP API calls with bulk SQL queries. 2026-03-20 14:18:22 +01:00
Michael 8c5f1c16be feat: add PostgreSQL client for FF Nancy data, replacing per-article HTTP calls with bulk SQL queries. 2026-03-20 14:07:53 +01:00
Michael 1aed954606 feat: Replace per-article HTTP calls with direct bulk SQL queries via new PostgreSQL client for FF Nancy data. 2026-03-20 13:59:30 +01:00
Michael 4996e126b3 feat: implement PostgreSQL client to replace per-article HTTP API calls with bulk SQL queries for FF Nancy data. 2026-03-20 13:31:19 +01:00
Michael dd846247c9 feat: add PostgreSQL client to fetch FF Nancy data via bulk SQL queries, replacing per-article HTTP requests. 2026-03-20 13:23:07 +01:00
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