Adds a second tab "Sans vente 6 mois" on the grid page listing all
products with no sale in the last 6 months, sorted by oldest last
sale first. Resolves merge conflicts from upstream refactor.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
- 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>
- 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>
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>
- 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>
- 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>
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>
- 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>
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>
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>
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>