Commit Graph
345 Commits
Author SHA1 Message Date
MichaelandClaude Sonnet 4.6 a60e21eb04 fix: exclude suspended products from supplier grid
Add WHERE NOT COALESCE(af.suspendu::boolean, false) AND NOT COALESCE(a.suspendu::boolean, false)
to pgGetArticlesByFournisseur — products flagged as suspended in artfou1
or articles table are no longer shown in the grid.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 12:04:08 +02:00
MichaelandClaude Sonnet 4.6 6b26676836 feat: flag products whose last registered supplier differs from current view
Instead of unreliable preference=1, use artfou1.no_id DESC (most recently
added artfou1 entry) to identify the last supplier for each product.
Shows an amber warning icon in the Désignation column when the last
supplier ≠ current supplier view, with tooltip showing who to attribute
the sales to.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 11:55:42 +02:00
MichaelandClaude Sonnet 4.6 6ef23de317 feat: restrict AI analysis to admin role only
- FloatingSummaryBar: hide BulkAiAnalyzer button for non-admins
- AiInsightBlock: hide individual Analyser button for non-admins
- Both use useSession() to check role === "admin"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 11:43:48 +02:00
MichaelandClaude Sonnet 4.6 bbb04a4d2a fix: immediate AI loading feedback + auto-fallback for deprecated model
- BulkAiAnalyzer: set isAnalyzing=true immediately on click (before
  context fetch), so the spinner appears instantly instead of after
  1-2 seconds of silence
- analyze/route.ts: if configured model returns 400/404 (e.g., deprecated
  google/gemini-flash-1.5), automatically retry with google/gemini-2.0-flash-001
- batch-analyze/route.ts: same fallback logic

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 11:34:14 +02:00
MichaelandClaude Sonnet 4.6 2aa9cbecaa revert: restore grid to pre-infinite-scroll state
Remove infinite grid loading, useInfiniteGrid hook, and server-side
pagination API route. Revert grid components to the simpler version
that avoids 2MB+ cache failures from unstable_cache.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 11:26:13 +02:00
Michael bd21f07c8e feat: implement bulk PostgreSQL client to replace per-article HTTP API calls 2026-04-03 11:21:38 +02:00
Michael e90a567446 feat: implement bulk PostgreSQL data fetching client to replace per-article HTTP requests 2026-04-03 11:17:04 +02:00
Michael b4ea795770 feat: add settings page with database configuration, API status monitoring, and theme toggling 2026-04-03 11:07:34 +02:00
Michael ebd819bfa4 feat: implement PostgreSQL bulk data access client to replace per-article HTTP requests 2026-04-03 10:58:43 +02:00
Michael 83d101ddc1 feat: add interactive client component for Hit Parade data visualization with sorting, filtering, and date range controls 2026-04-03 10:46:09 +02:00
Michael 687009dba1 feat: add HitParadeClient component with filtering, sorting, and date selection capabilities 2026-04-03 07:46:43 +02:00
Michael e9e1fdd246 feat: implement PostgreSQL client for bulk data retrieval to replace per-article HTTP requests 2026-04-03 07:40:05 +02:00
Michael 5a506c750c feat: add pg-ff-client to replace per-article HTTP requests with bulk SQL queries 2026-04-03 07:19:45 +02:00
Michael 659019e722 feat: implement PostgreSQL-based bulk data retrieval client for FF Nancy to replace HTTP API calls 2026-04-03 07:14:56 +02:00
Michael a4debe992b feat: implement dashboard page and add loading skeletons for all dashboard modules 2026-04-03 07:12:15 +02:00
Michael b39e010903 feat: implement infinite grid loading with server-side pagination and client-side integration 2026-04-02 18:39:29 +02:00
Michael 49928e9c08 feat: implement useInfiniteGrid hook for paginated data fetching and state management 2026-04-02 17:53:09 +02:00
Michael 4dfdcc1144 feat: implement infinite scrolling and background data loading for the product grid component 2026-04-02 17:47:10 +02:00
Michael f70249555e feat: implement high-performance virtualized heatmap grid with granular Zustand state management 2026-04-02 17:36:42 +02:00
Michael 43644a7d1d feat: implement server-side product row data fetching with caching and aggregation logic 2026-04-02 17:28:23 +02:00
Michael 88a3121c92 feat: implement grid state management, data fetching, and infinite scroll infrastructure 2026-04-02 17:22:41 +02:00
Michael 2893114fca feat: implement infinite grid pagination with server-side data fetching and custom hook 2026-04-02 17:17:32 +02:00
Michael 4db7faa41f feat: implement server-side product data aggregation and caching for grid view 2026-04-02 17:00:21 +02:00
Michael 557e3ed8e0 feat: implement server-side data loader for product grid rows with caching and aggregation logic 2026-04-02 16:55:46 +02:00
Michael 7e4b370267 feat: implement PostgreSQL client for bulk data retrieval to replace per-article HTTP requests and configure Claude permissions 2026-04-02 16:31:11 +02:00
MichaelandClaude Sonnet 4.6 868886db87 feat: hit-parade date range + fournisseur filter; fix create user button layout
- Replace month dropdown with date picker (Du/Au) + Appliquer button
- Add fournisseur filter dropdown (client-side, all suppliers from current data)
- Totals update live when fournisseur filter changes
- SQL: use BETWEEN date range instead of TO_CHAR month match
- Create user button: proper 3-col form layout so button stays on one line

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 13:42:25 +02:00
MichaelandClaude Sonnet 4.6 05354a0e74 fix: restore apple-btn-primary style for create user button; guard Invalid Date on sync status
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 13:35:35 +02:00
MichaelandClaude Sonnet 4.6 ead53db496 feat: restrict gamme/export/exports-page to admin; fix create user button style
- Non-admin users see gamme as read-only badge (no select)
- Export button hidden for non-admin in grid
- Save drafts button hidden for non-admin
- Exports page hidden in sidebar for non-admin
- Create user button: explicit blue style (was unreadable with apple-btn-primary)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 13:29:52 +02:00
MichaelandClaude Sonnet 4.6 f52532343f refactor: redesign Hit Parade table with color-coded site groups and reset sort button
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 13:11:19 +02:00
MichaelandClaude Sonnet 4.6 7923861947 feat: add Hit Parade page — monthly product sales by store with sort by CA/qty
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 11:22:08 +02:00
MichaelandClaude Sonnet 4.6 8b3ed4c435 chore: improve diag to check mntmvtht vs mntmvtttc totals and artfou1.preference distribution
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 09:40:28 +02:00
MichaelandClaude Sonnet 4.6 63641e9de9 chore: add mvtart column diag to /api/diag, remove unused diag-mvtart
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 09:36:21 +02:00
MichaelandClaude Sonnet 4.6 3e4b320cbe chore: add diag-mvtart to inspect columns and CA totals
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 09:28:53 +02:00
MichaelandClaude Sonnet 4.6 c5fbc85c6c fix: artfou1.preference is integer, use = 1 not = true
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 09:12:11 +02:00
MichaelandClaude Sonnet 4.6 79aadf62eb fix: use artfou1.preference=true and ABS(SUM(mntmvtttc)) for correct CA TTC in analytics
Replace last_reception CTE with direct LEFT JOIN artfou1 WHERE preference=true (fournisseur
principal de l'article). Use ABS(SUM(mntmvtttc)) instead of SUM(-mntmvtttc). Both fournisseur
and nomenclature queries now use LEFT JOIN to include all sold articles.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 09:07:43 +02:00
MichaelandClaude Sonnet 4.6 bc76237f48 feat: sort analytics by name (fournisseur) or code asc (nomenclature); show code in nomenclature label; remove diag-fournisseurs endpoint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 08:42:21 +02:00
MichaelandClaude Sonnet 4.6 65b55b1343 fix: use fouident.nom instead of fouadr1.raisonsociale for supplier names
fouident is the canonical supplier identity table with correct names:
- D005 = 'DEPOT' (not 'BAZAR 5000' which was a historical fouadr1 alias)
- B0071 = 'BAZAR 5000' (suspended, actif=false)
- M0341 = 'MOREL' (not 'MOREL LORY')

Updated: pgGetFournisseurs, pgGetArticlesByFournisseur, pgGetCaByFournisseur
Removed the D005 CASE WHEN hardcode override (no longer needed).
Also remove fouadr1 JOIN from analytics query (replaced by fouident).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 17:40:40 +02:00
Michael f0a360115f chore: inspect fouident table for correct supplier names 2026-03-31 17:32:54 +02:00
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