---
suivi: 1358
date: 2026-08-14
sujet: siwi_fournisseur_suggestion
chantier: marches_reprise
type: feat
statut: poussé
hash: f4ebb888
fichiers:
  - database/migrations/2026_08_14_170000_add_fournisseur_hectarion_id_to_siwi_marches_table.php
  - app/Services/SiwiImportPageService.php
  - app/Services/SiwiRepriseActionService.php
  - app/Http/Controllers/SiwiImportController.php
  - routes/web.php
  - resources/js/Pages/SiwiImport/Index.vue
  - tests/Unit/SiwiFournisseurSuggestion1358Test.php
  - tools/diag/inventaire_siwi_fournisseur_1358.php
  - database/data/journal_mises_a_jour_post_2026_06_12.php
  - public/build/
  - docs/suivi/SUIVI_1358_siwi_fournisseur_suggestion.md
---

## PROMPT ENVOYÉ

SUIVI #1358 — afficher / modifier le fournisseur ERP dans Suggestion SIWI ;
obligatoire à la création (serveur) ; inventaire OBJET 1 d’abord.

## FICHES LUES

- `#1335` : plus de garde-fou poste ; celui-ci (fournisseur) est voulu.
- `#1345` : compteurs qualification / créables 1128 — non touchés.
- `#1356`/`#1357` : SiwiImportController zone commune — rebasé main.

## OBJET 1 (lecture)

a) Résolution avant #1358 : `SiwiRepriseActionService::resoudreFournisseur`
   LOWER(nom)=fournisseur_nom SIWI. Racine `0FAIRWA0` **non utilisée**.
b) Colonnes SHOW COLUMNS : `fournisseur_id` (SIWI varchar), racine, nom, siren,
   `signal_sans_fournisseur_nom` — **pas** d’id ERP retenu → migration
   `fournisseur_hectarion_id` justifiée.
c) Compteurs prod : script
   `tools/diag/inventaire_siwi_fournisseur_1358.php` (Cursor sans staging 1128).
d) Sans match : RuntimeException (échec création) — pas de null / défaut.
e) Motif UI `sans_fournisseur` = `signal_sans_fournisseur_nom` (peuplé à l’import).
   Pas de littéral « fournisseur inconnu » en qualification_motif.
⛔ Aucun sélecteur fournisseur préexistant sur Suggestion → ajout (pas second).

## SYNTHÈSE

- Champ Fournisseur ERP * dans Suggestion ; AutoComplete →
  `GET /siwi-import/fournisseurs/search` (mêmes critères que
  `FournisseurController::search`, droits GS_GROUPE).
- Prérempli si LOWER(nom) match (batch 2 requêtes / programme) ou id retenu ;
  vide sinon. Création refuse sans `fournisseur_hectarion_id` (422/flash).
- Lot : préflight — aucune création partielle.
- Demande fournisseur : `DemandeFournisseurDialog` (pas création libre).
- Mapping : libellé `intacct_id — nom` ↔ `fournisseur_hectarion_id` ↔
  `siwi_marches.fournisseur_hectarion_id` / `marches.fournisseur_id`.

## DÉPLOIEMENT-TEST

```bash
git pull origin main
php artisan migrate --force
php artisan migrate:status   # Pending = 0 (seul)
php artisan route:clear
php artisan optimize:clear && php artisan view:clear
php artisan journal:sync
php tools/diag/inventaire_siwi_fournisseur_1358.php
```

## LEÇON

1. `fournisseur_id` SIWI ≠ id ERP — colonnes SHOW COLUMNS avant `??`.
2. Recherche fournisseurs SIWI sous GS_GROUPE (pas `/fournisseurs/search`
   commercialisation.*).
3. Préflight lot avant boucle pour zéro création partielle.
