# Plan d'ImplĂ©mentation - Architecture UnionFlow v3.0 **Date** : 2025-01-29 **Objectif** : Aligner le code actuel avec l'architecture cible (union-flow.puml) --- ## 📊 État Actuel vs Architecture Cible ### ✅ EntitĂ©s Existantes - ✅ BaseEntity - ✅ Organisation - ✅ TypeOrganisationEntity - ✅ Membre - ✅ Cotisation - ✅ Adhesion - ✅ Evenement - ✅ InscriptionEvenement - ✅ DemandeAide - ✅ AuditLog ### ❌ EntitĂ©s Manquantes 1. **Paiements** : Paiement, PaiementCotisation, PaiementAdhesion, PaiementEvenement, PaiementAide 2. **Wave** : CompteWave, TransactionWave, WebhookWave, ConfigurationWave 3. **ComptabilitĂ©** : CompteComptable, JournalComptable, EcritureComptable, LigneEcriture 4. **Documents** : Document, PieceJointe 5. **Notifications** : Notification, TemplateNotification 6. **RĂŽles/Permissions** : Role, Permission, MembreRole, RolePermission 7. **Adresses** : Adresse (sĂ©parĂ©e) --- ## 🎯 Plan d'ImplĂ©mentation par Étapes ### **PHASE 1 : FONDATIONS - Adresses et RĂŽles** (PrioritĂ© HAUTE) **DurĂ©e estimĂ©e** : 2-3 jours #### Étape 1.1 : EntitĂ© Adresse - [ ] CrĂ©er `Adresse.java` (entitĂ© sĂ©parĂ©e) - [ ] Types d'adresse : SIEGE_SOCIAL, BUREAU, DOMICILE, AUTRE - [ ] Relations : Organisation ↔ Adresse (0..*), Membre ↔ Adresse (0..*) - [ ] Migration : Extraire adresses de Organisation et Membre - [ ] Repository : `AdresseRepository` - [ ] Service : `AdresseService` - [ ] DTO : `AdresseDTO` #### Étape 1.2 : SystĂšme de RĂŽles et Permissions - [ ] CrĂ©er `Role.java` (entitĂ©) - [ ] CrĂ©er `Permission.java` (entitĂ©) - [ ] CrĂ©er `MembreRole.java` (table de liaison) - [ ] CrĂ©er `RolePermission.java` (table de liaison) - [ ] Enums : TypeRole, TypePermission - [ ] Repository : `RoleRepository`, `PermissionRepository`, `MembreRoleRepository`, `RolePermissionRepository` - [ ] Service : `RoleService`, `PermissionService` - [ ] DTOs : `RoleDTO`, `PermissionDTO`, `MembreRoleDTO` --- ### **PHASE 2 : SYSTÈME DE PAIEMENTS CENTRALISÉ** (PrioritĂ© CRITIQUE) **DurĂ©e estimĂ©e** : 3-4 jours #### Étape 2.1 : EntitĂ© Paiement - [ ] CrĂ©er `Paiement.java` (entitĂ© centrale) - [ ] Enum : `MethodePaiement` (WAVE_MOBILE_MONEY, ORANGE_MONEY, MTN_MOBILE_MONEY, etc.) - [ ] Enum : `StatutPaiement` (EN_ATTENTE, EN_COURS, VALIDE, ECHOUE, ANNULE, REMBOURSE) - [ ] Champs : montant, devise, datePaiement, dateValidation, validateur, references externes - [ ] Relation : Paiement → Membre (1-N) - [ ] Repository : `PaiementRepository` - [ ] Service : `PaiementService` - [ ] DTO : `PaiementDTO` #### Étape 2.2 : Tables de Liaison Paiements - [ ] CrĂ©er `PaiementCotisation.java` (table de liaison) - [ ] CrĂ©er `PaiementAdhesion.java` (table de liaison) - [ ] CrĂ©er `PaiementEvenement.java` (table de liaison) - [ ] CrĂ©er `PaiementAide.java` (table de liaison) - [ ] Champs communs : montantApplique, dateApplication - [ ] Relations : Paiement ↔ Cotisation/Adhesion/Evenement/Aide - [ ] Repositories : `PaiementCotisationRepository`, etc. - [ ] Services : Logique d'application des paiements #### Étape 2.3 : Refactoring Cotisation et Adhesion - [ ] Modifier `Cotisation.java` : Retirer montantPaye, utiliser PaiementCotisation - [ ] Modifier `Adhesion.java` : Retirer montantPaye, utiliser PaiementAdhesion - [ ] Mettre Ă  jour `CotisationService` : Utiliser PaiementService - [ ] Mettre Ă  jour `AdhesionService` : Utiliser PaiementService - [ ] Migration des donnĂ©es existantes --- ### **PHASE 3 : INTÉGRATION WAVE MOBILE MONEY** (PrioritĂ© CRITIQUE) **DurĂ©e estimĂ©e** : 4-5 jours #### Étape 3.1 : EntitĂ©s Wave - [ ] CrĂ©er `CompteWave.java` - NumĂ©ro tĂ©lĂ©phone (+225XXXXXXXX) - Statut : NON_VERIFIE, VERIFIE, SUSPENDU, BLOQUE - Relations : Organisation (1-N), Membre (0..1) - Identifiants API encryptĂ©s - [ ] CrĂ©er `TransactionWave.java` - Identifiants Wave (transactionId, requestId, reference) - Type : DEPOT, RETRAIT, TRANSFERT, PAIEMENT, REMBOURSEMENT - Statut : INITIALISE, EN_ATTENTE, EN_COURS, REUSSIE, ECHOUE, ANNULEE, EXPIRED - Montant, frais, montant net - MĂ©tadonnĂ©es JSON - Relation : CompteWave (1-N), Paiement (0..1) - [ ] CrĂ©er `WebhookWave.java` - Wave event ID - Type d'Ă©vĂ©nement - Statut traitement : EN_ATTENTE, EN_TRAITEMENT, TRAITE, ECHOUE, IGNORE - Payload JSON - Relation : TransactionWave (0..1), Paiement (0..1) - [ ] CrĂ©er `ConfigurationWave.java` - ClĂ©-valeur pour configuration - Support sandbox/production #### Étape 3.2 : Repositories et Services Wave - [ ] Repositories : `CompteWaveRepository`, `TransactionWaveRepository`, `WebhookWaveRepository`, `ConfigurationWaveRepository` - [ ] Service : `WaveService` (intĂ©gration API Wave) - MĂ©thodes : initierPaiement, verifierTransaction, traiterWebhook - Gestion retry avec backoff exponentiel - Validation de signature webhook - Chiffrement des clĂ©s API #### Étape 3.3 : IntĂ©gration avec PaiementService - [ ] Modifier `PaiementService` : Support Wave - [ ] Workflow : Initiation → TransactionWave → Webhook → Validation - [ ] Gestion des erreurs et retry --- ### **PHASE 4 : COMPTABILITÉ** (PrioritĂ© MOYENNE) **DurĂ©e estimĂ©e** : 3-4 jours #### Étape 4.1 : Plan Comptable - [ ] CrĂ©er `CompteComptable.java` - NumĂ©ro compte unique - Type : ACTIF, PASSIF, CHARGES, PRODUITS, TRESORERIE, AUTRE - Classe comptable (1-7) - Solde initial, solde actuel - [ ] Repository : `CompteComptableRepository` - [ ] Service : `CompteComptableService` - [ ] DTO : `CompteComptableDTO` #### Étape 4.2 : Journaux et Écritures - [ ] CrĂ©er `JournalComptable.java` - Code unique - Type : ACHATS, VENTES, BANQUE, CAISSE, OD - PĂ©riode, statut - [ ] CrĂ©er `EcritureComptable.java` - NumĂ©ro piĂšce unique - Date, libellĂ©, rĂ©fĂ©rence - Lettrage, pointage - Relation : JournalComptable (1-N), Organisation (1-N), Paiement (0..1) - [ ] CrĂ©er `LigneEcriture.java` - NumĂ©ro ligne - Compte dĂ©biteur/crĂ©diteur - Montant dĂ©bit/crĂ©dit - Relation : EcritureComptable (1-N), CompteComptable (1-N) - Validation : DĂ©bit = CrĂ©dit #### Étape 4.3 : Service Comptable - [ ] Service : `ComptabiliteService` - GĂ©nĂ©ration automatique d'Ă©critures pour paiements - Rapprochement bancaire - Pointage et lettrage - [ ] IntĂ©gration avec PaiementService --- ### **PHASE 5 : GESTION DOCUMENTAIRE** (PrioritĂ© MOYENNE) **DurĂ©e estimĂ©e** : 2-3 jours #### Étape 5.1 : EntitĂ©s Documents - [ ] CrĂ©er `Document.java` - Nom fichier, nom original - Chemin stockage - Type MIME, taille - Hash MD5, SHA256 - Type : IDENTITE, JUSTIFICATIF_DOMICILE, PHOTO, CONTRAT, FACTURE, RECU, RAPPORT, AUTRE - [ ] CrĂ©er `PieceJointe.java` - Ordre d'affichage - LibellĂ©, commentaire - Relations flexibles : Membre, Organisation, Cotisation, Adhesion, DemandeAide, TransactionWave #### Étape 5.2 : Services Documents - [ ] Repositories : `DocumentRepository`, `PieceJointeRepository` - [ ] Service : `DocumentService` - Upload sĂ©curisĂ© - VĂ©rification intĂ©gritĂ© (hash) - ContrĂŽle d'accĂšs - Audit tĂ©lĂ©chargements --- ### **PHASE 6 : SYSTÈME DE NOTIFICATIONS** (PrioritĂ© MOYENNE) **DurĂ©e estimĂ©e** : 2-3 jours #### Étape 6.1 : EntitĂ©s Notifications - [ ] CrĂ©er `TemplateNotification.java` - Code unique - Sujet, corps (texte et HTML) - Variables disponibles (JSON) - Canaux supportĂ©s - Support multi-langues - [ ] CrĂ©er `Notification.java` - Type : EMAIL, SMS, PUSH, IN_APP, SYSTEME - PrioritĂ© : CRITIQUE, HAUTE, NORMALE, BASSE - Statut : EN_ATTENTE, ENVOYEE, LUE, ECHOUE, ANNULEE - Relations : Membre (1-N), Organisation (0..1), TemplateNotification (0..1) #### Étape 6.2 : Service Notifications - [ ] Repositories : `NotificationRepository`, `TemplateNotificationRepository` - [ ] Service : `NotificationService` - Envoi multi-canaux - Retry automatique - Priorisation - Templates rĂ©utilisables --- ### **PHASE 7 : MISE À JOUR MEMBRE** (PrioritĂ© HAUTE) **DurĂ©e estimĂ©e** : 1-2 jours #### Étape 7.1 : Ajout Champs Membre - [ ] Ajouter `telephoneWave` (String, format +225XXXXXXXX) - [ ] Ajouter `photoUrl` (String) - [ ] Relation : Membre → CompteWave (0..1) - [ ] Relation : Membre → Adresse (0..*) - [ ] Relation : Membre → MembreRole (1-N) #### Étape 7.2 : Migration DonnĂ©es - [ ] Script de migration pour extraire adresses - [ ] Attribution rĂŽles par dĂ©faut - [ ] Validation format tĂ©lĂ©phone Wave --- ### **PHASE 8 : MISE À JOUR ORGANISATION** (PrioritĂ© MOYENNE) **DurĂ©e estimĂ©e** : 1 jour #### Étape 8.1 : Relations Organisation - [ ] Relation : Organisation → CompteWave (1-N) - [ ] Relation : Organisation → Adresse (0..*) - [ ] Migration : Extraire adresses vers entitĂ© Adresse --- ### **PHASE 9 : MISE À JOUR ÉVÉNEMENT** (PrioritĂ© MOYENNE) **DurĂ©e estimĂ©e** : 1 jour #### Étape 9.1 : Relations Evenement - [ ] Relation : Evenement → Adresse (0..1) - [ ] Relation : Evenement → PaiementEvenement (0..*) - [ ] Migration : Extraire adresse vers entitĂ© Adresse --- ### **PHASE 10 : RESSOURCES REST ET DTOs** (PrioritĂ© HAUTE) **DurĂ©e estimĂ©e** : 3-4 jours #### Étape 10.1 : DTOs API - [ ] CrĂ©er tous les DTOs manquants dans `unionflow-server-api` - [ ] Enums dans `unionflow-server-api` #### Étape 10.2 : Resources REST - [ ] `PaiementResource` - [ ] `WaveResource` (CompteWave, TransactionWave, WebhookWave) - [ ] `ComptabiliteResource` (CompteComptable, JournalComptable, EcritureComptable) - [ ] `DocumentResource` - [ ] `NotificationResource` - [ ] `RoleResource`, `PermissionResource` - [ ] `AdresseResource` --- ### **PHASE 11 : TESTS ET VALIDATION** (PrioritĂ© HAUTE) **DurĂ©e estimĂ©e** : 2-3 jours #### Étape 11.1 : Tests Unitaires - [ ] Tests pour toutes les nouvelles entitĂ©s - [ ] Tests pour tous les services - [ ] Tests d'intĂ©gration Wave (mock) #### Étape 11.2 : Tests d'IntĂ©gration - [ ] Tests de workflow complet paiement - [ ] Tests webhooks Wave - [ ] Tests gĂ©nĂ©ration Ă©critures comptables --- ## 📋 Ordre d'ImplĂ©mentation RecommandĂ© 1. **PHASE 1** : Adresses et RĂŽles (fondations) 2. **PHASE 2** : SystĂšme de Paiements (critique) 3. **PHASE 7** : Mise Ă  jour Membre (dĂ©pend de Phase 1) 4. **PHASE 3** : IntĂ©gration Wave (dĂ©pend de Phase 2) 5. **PHASE 4** : ComptabilitĂ© (dĂ©pend de Phase 2) 6. **PHASE 5** : Documents 7. **PHASE 6** : Notifications 8. **PHASE 8-9** : Mises Ă  jour Organisation/Evenement 9. **PHASE 10** : Resources REST 10. **PHASE 11** : Tests --- ## 🚀 DĂ©marrage de l'ImplĂ©mentation **Prochaine Ă©tape** : Commencer par la PHASE 1 - Étape 1.1 : CrĂ©ation de l'entitĂ© Adresse