gigafibre-fsm/docs/CHANGELOG.md
louispaulb 93dd7a525f feat: migration legacy → ERPNext phases 1-4 complete
Phase 1: 833 Items + 34 Item Groups + custom fields (ISP speeds, RADIUS, legacy IDs)
Phase 2: 6,667 Customers + Contacts + Addresses via direct PG (~30s)
Phase 3: Tax template QC TPS+TVQ + 92 Subscription Plans
Phase 4: 21,876 Subscriptions with RADIUS data

CRITICAL: ERPNext scheduler is PAUSED — do not reactivate without explicit go.

Includes:
- ARCHITECTURE-COMPARE.md: full schema mapping legacy vs ERPNext
- CHANGELOG.md: detailed migration log
- MIGRATION-PLAN.md: strategy and next steps
- scripts/migration/: idempotent Python scripts (direct PG method)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 14:35:02 -04:00

112 lines
4.7 KiB
Markdown

# Changelog — Migration Legacy → ERPNext
## 2026-03-28 — Phase 1 : Données maîtres
### Infrastructure
- **Frappe Assistant Core v2.3.3** installé sur ERPNext — MCP connecté à Claude Code
- **Connexion MariaDB legacy** (10.100.80.100) → ERPNext (10.100.5.61) établie
- GRANT SELECT pour `facturation@10.100.5.61` sur `gestionclient`
- **2 Workspaces** créés sur ERPNext Desk : Dispatch (icône tool) + Gigafibre FSM (icône map)
### Item Groups (34)
Hiérarchie créée sous 3 parents :
- **Services** (16) : Mensualités fibre/sans fil/télévision, Téléphonie, IP Fixe, Hébergement, Nom de domaine, Location P2P, Internet camping, Cloud, Site internet, Services info, Location espace, Garantie, Téléchargement supp, Honoraires
- **Products** (8) : Installation fibre/sans fil/télé, Équipement fibre/sans fil, Quincaillerie, Pièces info, Technicien
- **Frais et ajustements** (10) : Intérêts, Activation, Frais divers taxables, Créances, Recouvrement, Transport, Impression, Infographie, SPECIAL
### Items (833)
- **833/833** produits importés via script Python (`/tmp/import_items.py`)
- Source : `gestionclient.product` → ERPNext `Item`
- Mapping : SKU → item_code, price → standard_rate, category → item_group
- Items sans services actifs ET inactive dans legacy → `disabled=1`
- Script exécuté depuis le container `erpnext-backend-1`
### Custom Fields créés
**Sur Item (section "ISP Settings")** :
| Fieldname | Type | Description |
|-----------|------|-------------|
| legacy_product_id | Int | ID dans gestionclient.product |
| download_speed | Int | Vitesse download en Kbps |
| upload_speed | Int | Vitesse upload en Kbps |
| quota_day_gb | Float | Quota jour en GB |
| quota_night_gb | Float | Quota nuit en GB |
| fibre_lineprofile | Data | Profil OLT ligne |
| fibre_serviceprofile | Data | Profil OLT service |
**Sur Customer (section "Legacy Settings")** :
| Fieldname | Type | Description |
|-----------|------|-------------|
| legacy_account_id | Int | ID dans gestionclient.account |
| legacy_customer_id | Data | customer_id legacy (ex: DR2, LOUIS4502470070) |
| ppa_enabled | Check | Paiement pré-autorisé AccesD actif |
| stripe_id | Data | Stripe customer ID |
**Sur Subscription (section "ISP Settings")** :
| Fieldname | Type | Description |
|-----------|------|-------------|
| radius_user | Data | Utilisateur RADIUS (ex: tci44166) |
| radius_pwd | Data | Mot de passe RADIUS |
| legacy_service_id | Int | ID dans gestionclient.service |
### Données mises à jour
- **833** Items : legacy_product_id peuplé
- **98** Items : vitesses download/upload + quotas en GB + profils fibre
---
## 2026-03-28 — Phase 2 : Customers, Contacts, Addresses
### Méthode
- **Direct PostgreSQL** (`migrate_direct.py`) au lieu de l'API REST
- Temps d'exécution : ~30 secondes vs plusieurs heures via API REST
- PostgreSQL `max_connections` augmenté à **200** pour supporter la charge
### Résultats
- **6,667 Customers** importés (comptes actifs + suspendus)
- **~6,600 Contacts** créés avec email, téléphone, cellulaire
- **~6,700 Addresses** créées avec géolocalisation (latitude/longitude)
- Liens Customer ↔ Contact ↔ Address établis
---
## 2026-03-28 — Phase 3 : Tax Templates + Subscription Plans
### Tax Templates
- **QC TPS 5%** — Sales Taxes and Charges Template
- **QC TVQ 9.975%** — Sales Taxes and Charges Template
### Subscription Plans
- **92 Subscription Plans** créés à partir des produits actifs avec services
- Mapping : Item → Subscription Plan (billing_interval=Month, currency=CAD)
---
## 2026-03-28 — Phase 4 : Subscriptions
### Résultats
- **21,876 Subscriptions** importées avec données RADIUS (radius_user, radius_pwd)
- legacy_service_id peuplé pour chaque Subscription
- Lien Customer ↔ Subscription Plan établi
### ATTENTION CRITIQUE
- **Le scheduler ERPNext est PAUSED** — les Subscriptions ne génèrent PAS de factures automatiquement
- **NE PAS réactiver le scheduler sans instruction explicite** — la réactivation déclencherait la facturation automatique pour les 21,876 abonnements
---
## Connexions et accès
| Système | Accès | Méthode |
|---------|-------|---------|
| ERPNext API | `token b273a666c86d2d0:06120709db5e414` | REST API |
| ERPNext MCP | Frappe Assistant Core | StreamableHTTP |
| Legacy MariaDB | `facturation@10.100.80.100` | pymysql depuis container ERPNext |
| Legacy SSH | `root@96.125.192.252` (clé SSH copiée) | SSH |
| DB server SSH | `root@10.100.80.100` via sshpass depuis legacy | SSH |
## Scripts de migration
- `/tmp/import_items.py` — Import 833 produits → Items
- `/tmp/update_items_speeds.py` — MAJ vitesses/quotas sur Items
- Tous exécutés depuis `erpnext-backend-1` container