# 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 ✅ COMPLÉTÉE - [x] CrĂ©er `Adresse.java` (entitĂ© sĂ©parĂ©e) - [x] Types d'adresse : SIEGE_SOCIAL, BUREAU, DOMICILE, AUTRE - [x] Relations : Organisation ↔ Adresse (0..*), Membre ↔ Adresse (0..*), Evenement ↔ Adresse (0..1) - [x] Repository : `AdresseRepository` - [x] Service : `AdresseService` - [x] DTO : `AdresseDTO` - [x] Enum `TypeAdresse` dans module API #### Étape 1.2 : SystĂšme de RĂŽles et Permissions ✅ COMPLÉTÉE - [x] CrĂ©er `Role.java` (entitĂ©) - [x] CrĂ©er `Permission.java` (entitĂ©) - [x] CrĂ©er `MembreRole.java` (table de liaison) - [x] CrĂ©er `RolePermission.java` (table de liaison) - [x] Enum TypeRole dans entitĂ© - [x] Repository : `RoleRepository`, `PermissionRepository`, `MembreRoleRepository`, `RolePermissionRepository` - [x] Service : `RoleService`, `PermissionService` - [ ] DTOs : `RoleDTO`, `PermissionDTO`, `MembreRoleDTO` (Ă  crĂ©er) --- ### **PHASE 2 : SYSTÈME DE PAIEMENTS CENTRALISÉ** (PrioritĂ© CRITIQUE) **DurĂ©e estimĂ©e** : 3-4 jours #### Étape 2.1 : EntitĂ© Paiement ✅ COMPLÉTÉE - [x] CrĂ©er `Paiement.java` (entitĂ© centrale) - [x] Enum : `MethodePaiement` (WAVE_MOBILE_MONEY, ORANGE_MONEY, MTN_MOBILE_MONEY, etc.) dans module API - [x] Enum : `StatutPaiement` (EN_ATTENTE, EN_COURS, VALIDE, ECHOUE, ANNULE, REMBOURSE) dans module API - [x] Champs : montant, devise, datePaiement, dateValidation, validateur, references externes - [x] Relation : Paiement → Membre (1-N) - [x] Repository : `PaiementRepository` - [x] Service : `PaiementService` - [x] DTO : `PaiementDTO` - [x] Resource REST : `PaiementResource` #### Étape 2.2 : Tables de Liaison Paiements ✅ COMPLÉTÉE - [x] CrĂ©er `PaiementCotisation.java` (table de liaison) - [x] CrĂ©er `PaiementAdhesion.java` (table de liaison) - [x] CrĂ©er `PaiementEvenement.java` (table de liaison) - [x] CrĂ©er `PaiementAide.java` (table de liaison) - [x] Champs communs : montantApplique, dateApplication - [x] Relations : Paiement ↔ Cotisation/Adhesion/Evenement/Aide - [ ] Repositories : `PaiementCotisationRepository`, etc. (Ă  crĂ©er si nĂ©cessaire) - [ ] Services : Logique d'application des paiements (intĂ©grĂ©e dans PaiementService) #### É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 ✅ COMPLÉTÉE - [x] CrĂ©er `CompteWave.java` - NumĂ©ro tĂ©lĂ©phone (+225XXXXXXXX) - Statut : NON_VERIFIE, VERIFIE, SUSPENDU, BLOQUE (enum dans module API) - Relations : Organisation (1-N), Membre (0..1) - Identifiants API encryptĂ©s - [x] CrĂ©er `TransactionWave.java` - Identifiants Wave (transactionId, requestId, reference) - Type : DEPOT, RETRAIT, TRANSFERT, PAIEMENT, REMBOURSEMENT (enum dans module API) - Statut : INITIALISE, EN_ATTENTE, EN_COURS, REUSSIE, ECHOUE, ANNULEE, EXPIRED (enum dans module API) - Montant, frais, montant net - MĂ©tadonnĂ©es JSON - Relation : CompteWave (1-N), Paiement (0..1) - [x] CrĂ©er `WebhookWave.java` - Wave event ID - Type d'Ă©vĂ©nement (enum dans module API) - Statut traitement : EN_ATTENTE, EN_TRAITEMENT, TRAITE, ECHOUE, IGNORE (enum dans module API) - Payload JSON - Relation : TransactionWave (0..1), Paiement (0..1) - [x] CrĂ©er `ConfigurationWave.java` - ClĂ©-valeur pour configuration - Support sandbox/production #### Étape 3.2 : Repositories et Services Wave ✅ COMPLÉTÉE - [x] Repositories : `CompteWaveRepository`, `TransactionWaveRepository`, `WebhookWaveRepository`, `ConfigurationWaveRepository` - [x] Service : `WaveService` (structure de base créée) - [x] MĂ©thodes : CRUD comptes, CRUD transactions, vĂ©rification - [ ] MĂ©thodes : initierPaiement, verifierTransaction, traiterWebhook (Ă  implĂ©menter avec API rĂ©elle) - [ ] Gestion retry avec backoff exponentiel (Ă  implĂ©menter) - [ ] Validation de signature webhook (Ă  implĂ©menter) - [ ] Chiffrement des clĂ©s API (Ă  implĂ©menter) - [x] DTOs : `CompteWaveDTO`, `TransactionWaveDTO` - [x] Resource REST : `WaveResource` #### Étape 3.3 : IntĂ©gration avec PaiementService - [ ] Modifier `PaiementService` : Support Wave - [ ] Workflow : Initiation → TransactionWave → Webhook → Validation - [ ] Gestion des erreurs et retry --- ### **PHASE 4 : COMPTABILITÉ** ✅ COMPLÉTÉE **DurĂ©e estimĂ©e** : 3-4 jours #### Étape 4.1 : Plan Comptable ✅ COMPLÉTÉE - [x] CrĂ©er `CompteComptable.java` - NumĂ©ro compte unique - Type : ACTIF, PASSIF, CHARGES, PRODUITS, TRESORERIE, AUTRE (enum dans module API) - Classe comptable (1-7) - Solde initial, solde actuel - [x] Repository : `CompteComptableRepository` - [x] DTO : `CompteComptableDTO` #### Étape 4.2 : Journaux et Écritures ✅ COMPLÉTÉE - [x] CrĂ©er `JournalComptable.java` - Code unique - Type : ACHATS, VENTES, BANQUE, CAISSE, OD (enum dans module API) - PĂ©riode, statut - [x] CrĂ©er `EcritureComptable.java` - NumĂ©ro piĂšce unique (auto-gĂ©nĂ©rĂ©) - Date, libellĂ©, rĂ©fĂ©rence - Lettrage, pointage - Relation : JournalComptable (1-N), Organisation (1-N), Paiement (0..1) - [x] 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 ✅ COMPLÉTÉE - [x] Service : `ComptabiliteService` - CRUD complet pour comptes, journaux, Ă©critures - Validation Ă©quilibre Ă©critures (DĂ©bit = CrĂ©dit) - Calcul automatique des totaux - [ ] GĂ©nĂ©ration automatique d'Ă©critures pour paiements (Ă  implĂ©menter) - [ ] Rapprochement bancaire (Ă  implĂ©menter) - [ ] Pointage et lettrage (Ă  implĂ©menter) - [x] Resource REST : `ComptabiliteResource` --- ### **PHASE 5 : GESTION DOCUMENTAIRE** ✅ COMPLÉTÉE **DurĂ©e estimĂ©e** : 2-3 jours #### Étape 5.1 : EntitĂ©s Documents ✅ COMPLÉTÉE - [x] 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 (enum dans module API) - [x] CrĂ©er `PieceJointe.java` - Ordre d'affichage - LibellĂ©, commentaire - Relations flexibles : Membre, Organisation, Cotisation, Adhesion, DemandeAide, TransactionWave #### Étape 5.2 : Services Documents ✅ COMPLÉTÉE - [x] Repositories : `DocumentRepository`, `PieceJointeRepository` - [x] Service : `DocumentService` - CRUD documents - Enregistrement tĂ©lĂ©chargements - Gestion piĂšces jointes - Validation relations - [x] DTOs : `DocumentDTO`, `PieceJointeDTO` - [x] Resource REST : `DocumentResource` - [ ] Upload sĂ©curisĂ© (Ă  implĂ©menter cĂŽtĂ© fichier) - [ ] ContrĂŽle d'accĂšs (Ă  implĂ©menter) --- ### **PHASE 6 : SYSTÈME DE NOTIFICATIONS** ✅ COMPLÉTÉE **DurĂ©e estimĂ©e** : 2-3 jours #### Étape 6.1 : EntitĂ©s Notifications ✅ COMPLÉTÉE - [x] CrĂ©er `TemplateNotification.java` - Code unique - Sujet, corps (texte et HTML) - Variables disponibles (JSON) - Canaux supportĂ©s - Support multi-langues - [x] CrĂ©er `Notification.java` - Type : EMAIL, SMS, PUSH, IN_APP, SYSTEME (enum dans module API) - PrioritĂ© : CRITIQUE, HAUTE, NORMALE, BASSE (enum dans module API) - Statut : Utilise `StatutNotification` existant (20+ statuts) - Relations : Membre (1-N), Organisation (0..1), TemplateNotification (0..1) #### Étape 6.2 : Service Notifications ✅ COMPLÉTÉE - [x] Repositories : `NotificationRepository`, `TemplateNotificationRepository` - [x] Service : `NotificationService` - CRUD templates, CRUD notifications - Marquer comme lue - Liste par membre, non lues, en attente - [x] DTOs : `NotificationDTO`, `TemplateNotificationDTO` - [x] Resource REST : `NotificationResource` - [ ] Envoi multi-canaux (Ă  implĂ©menter avec services externes) - [ ] Retry automatique (Ă  implĂ©menter) - [ ] Priorisation (structure prĂȘte) --- ### **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