============================================ Nouvelles Fonctionnalités 2025 - KoproGo ============================================ :Date: 2025-11-18 :Version: 1.0 :Statut: Implémenté Ce document centralise toutes les nouvelles fonctionnalités implémentées en 2025, organisées par jalon et par domaine fonctionnel. .. contents:: Table des matières :depth: 3 :local: ============================================ Vue d'Ensemble des Implémentations 2025 ============================================ **Statistiques Globales** - **73 endpoints API REST** implémentés - **~50,000 lignes de code** Rust (backend) - **45+ entités de domaine** avec validation métier - **100+ migrations PostgreSQL** appliquées - **Couverture tests**: Unit (90%+), Integration (85%+), E2E (80%+), BDD (70%+) **Architecture** - **Hexagonal (Ports & Adapters)** stricte - **Domain-Driven Design (DDD)** avec aggregates - **Event Sourcing** pour audit GDPR - **CQRS partiel** (séparation lecture/écriture pour analytics) ============================================ Jalon 1: Sécurité & GDPR 🔒 (COMPLET) ============================================ 1.1 GDPR Complémentaire (Issue #90) ------------------------------------ **Articles GDPR Implémentés** - ✅ Article 15: Right to Access (export données) - ✅ Article 16: Right to Rectification (correction données) - ✅ Article 17: Right to Erasure (droit à l'oubli avec anonymisation) - ✅ Article 18: Right to Restriction (limitation traitement) - ✅ Article 21: Right to Object (opt-out marketing) **Endpoints API** - ``GET /gdpr/export`` - Export complet données utilisateur (JSON) - ``DELETE /gdpr/erase`` - Anonymisation GDPR-compliant - ``GET /gdpr/can-erase`` - Vérification éligibilité effacement - ``PUT /gdpr/rectify`` - Correction données personnelles - ``PUT /gdpr/restrict-processing`` - Restriction traitement - ``PUT /gdpr/marketing-preference`` - Gestion consentement marketing **Implémentation** - Migration: ``20251120000000_add_gdpr_complementary_fields.sql`` - Domain: ``backend/src/domain/entities/user.rs`` (8 nouvelles méthodes) - Use Cases: ``backend/src/application/use_cases/gdpr_use_cases.rs`` - Handlers: ``backend/src/infrastructure/web/handlers/gdpr_handlers.rs`` - Audit: 7 types d'événements GDPR (Article 30 compliance) **Documentation**: Voir ``GDPR_ADDITIONAL_RIGHTS.md`` 1.2 Two-Factor Authentication (2FA) ------------------------------------ **Type**: TOTP (Time-based One-Time Password) compatible RFC 6238 **Fonctionnalités** - ✅ Génération QR codes (Google Authenticator, Authy, Microsoft Authenticator) - ✅ Backup codes (10 codes à usage unique, SHA-256 hashed) - ✅ Vérification TOTP avec fenêtre de tolérance (±30s) - ✅ Chiffrement secrets 2FA (AES-256-GCM) - ✅ Rate limiting (5 tentatives / 15 min) - ✅ Révocation 2FA par admin **Endpoints API** - ``POST /auth/2fa/enable`` - Activer 2FA (retourne QR code) - ``POST /auth/2fa/verify`` - Vérifier code TOTP - ``POST /auth/2fa/disable`` - Désactiver 2FA - ``GET /auth/2fa/backup-codes`` - Régénérer backup codes - ``POST /auth/2fa/verify-backup`` - Utiliser backup code **Implémentation** - Migration: ``20251202000000_create_two_factor_secrets.sql`` - Domain: ``backend/src/domain/entities/two_factor_secret.rs`` (319 lignes) - TOTP Generator: ``backend/src/infrastructure/totp/totp_generator.rs`` (444 lignes) - Use Cases: ``backend/src/application/use_cases/two_factor_use_cases.rs`` (449 lignes) - Handlers: ``backend/src/infrastructure/web/handlers/two_factor_handlers.rs`` (429 lignes) **Sécurité** - Secrets stockés chiffrés (AES-256-GCM avec clé 32 bytes) - Backup codes hashed (SHA-256, pas de stockage plaintext) - Rate limiting anti-bruteforce (fail2ban compatible) - Audit complet (création, vérification, révocation) **Documentation**: Voir ``JWT_REFRESH_TOKENS.md`` (section 2FA) ============================================= Jalon 2: Conformité Légale Belge 📋 (COMPLET) ============================================= 2.1 Budget Annuel (Issue #81) ------------------------------ **Obligation Légale**: Vote budget AG avant début exercice fiscal **Fonctionnalités** - ✅ Budget ordinaire (charges courantes) - ✅ Budget extraordinaire (travaux) - ✅ Variance analysis mensuelle (budget vs actual) - ✅ Provisions mensuelles automatiques - ✅ Alertes dépassements budgétaires - ✅ États: Draft → Voted → Active → Closed **Endpoints API** - ``POST /buildings/:id/budgets`` - Créer budget annuel - ``GET /budgets/:id`` - Détails budget - ``GET /buildings/:id/budgets`` - Liste budgets bâtiment - ``GET /budgets/:id/variance`` - Analyse écarts (budget vs réel) - ``PUT /budgets/:id/vote`` - Vote AG (Draft → Voted) - ``PUT /budgets/:id/activate`` - Activation (début exercice) - ``PUT /budgets/:id/close`` - Clôture exercice - ``DELETE /budgets/:id`` - Suppression budget (Draft only) **Implémentation** - Migration: ``20251115000001_create_budgets.sql`` - Domain: ``backend/src/domain/entities/budget.rs`` (409 lignes) - Use Cases: ``backend/src/application/use_cases/budget_use_cases.rs`` (269 lignes) - Handlers: ``backend/src/infrastructure/web/handlers/budget_handlers.rs`` (467 lignes) - Tests: ``backend/tests/e2e_budget.rs``, ``backend/tests/features/budget.feature`` **Règles Métier** - Fiscal year obligatoire (1-9999) - Budgets positifs uniquement (>= 0) - Un seul budget actif par exercice fiscal - Validation vote AG requis avant activation - Variance analysis = (actual - budgeted) / budgeted * 100 **Documentation**: Nouvelle (ce document) 2.2 Appels de Fonds (Call for Funds) ------------------------------------- **Contexte**: Appels trimestriels de provisions (charges ordinaires + extraordinaires) **Fonctionnalités** - ✅ Calcul automatique provisions par propriétaire (basé sur quote-part) - ✅ Périodes: Quarterly, Monthly, Yearly, OneTime - ✅ Support charges ordinaires + extraordinaires - ✅ Génération PDF automatique (avec détails par lot) - ✅ États: Draft → Sent → Paid → Overdue - ✅ Intégration payment reminders (relances impayés) **Endpoints API** - ``POST /buildings/:id/call-for-funds`` - Créer appel de fonds - ``GET /call-for-funds/:id`` - Détails appel - ``GET /buildings/:id/call-for-funds`` - Liste appels bâtiment - ``PUT /call-for-funds/:id/send`` - Envoyer aux propriétaires (email + PDF) - ``PUT /call-for-funds/:id/mark-paid`` - Marquer payé - ``DELETE /call-for-funds/:id`` - Supprimer (Draft only) **Implémentation** - Migration: ``20251111015338_create_call_for_funds.sql`` - Domain: ``backend/src/domain/entities/call_for_funds.rs`` (263 lignes) - Use Cases: ``backend/src/application/use_cases/call_for_funds_use_cases.rs`` (198 lignes) - Handlers: ``backend/src/infrastructure/web/handlers/call_for_funds_handlers.rs`` (215 lignes) **Calcul Provisions** .. code-block:: text Total provisions = ordinary_amount + extraordinary_amount Provision par owner = total * ownership_percentage Exemple: - Charges ordinaires: 10,000 EUR - Charges extraordinaires: 5,000 EUR - Quote-part owner: 10% (100/1000 millièmes) → Provision owner = 15,000 * 0.10 = 1,500 EUR **Documentation**: Nouvelle (ce document) 2.3 État Daté (Issue #80) -------------------------- **Obligation Légale**: Article 577-2 Code Civil belge - Document obligatoire pour toute vente de lot **16 Sections Légales Requises** 1. Identification immeuble et lot 2. Quote-part charges ordinaires/extraordinaires 3. Situation financière propriétaire 4. Montant provisions pour charges 5. Solde créditeur/débiteur 6. Travaux votés non encore payés 7. Litiges en cours 8. Procédures judiciaires 9. Sinistres déclarés (3 dernières années) 10. État règlement copropriété 11. Procès-verbaux 2 dernières AG 12. Contrats assurance 13. Contrats prestataires 14. Historique charges (3 ans) 15. Fonds de réserve 16. Coordonnées syndic **Endpoints API** - ``POST /units/:id/etat-date`` - Demander état daté - ``GET /etat-dates/:id`` - Détails état daté - ``GET /etat-dates/:id/pdf`` - Télécharger PDF - ``GET /buildings/:id/etat-dates`` - Liste états datés bâtiment - ``PUT /etat-dates/:id/generate`` - Générer PDF (avec 16 sections) - ``PUT /etat-dates/:id/deliver`` - Délivrer à notaire - ``DELETE /etat-dates/:id`` - Annuler demande **Implémentation** - Migration: ``20251115000000_create_etats_dates.sql`` - Domain: ``backend/src/domain/entities/etat_date.rs`` (619 lignes) - Use Cases: ``backend/src/application/use_cases/etat_date_use_cases.rs`` (262 lignes) - Handlers: ``backend/src/infrastructure/web/handlers/etat_date_handlers.rs`` (399 lignes) - Tests: ``backend/tests/e2e_etat_date.rs``, ``backend/tests/features/etat_date.feature`` **Délai Légal**: Maximum 15 jours ouvrables après demande **Documentation**: Nouvelle (ce document) 2.4 Écritures Comptables (Journal Entries) ------------------------------------------- **Contexte**: Comptabilité belge double-entrée conforme PCMN **Fonctionnalités** - ✅ Double-entrée automatique (débit/crédit) - ✅ Validation balance (∑ débits = ∑ crédits) - ✅ Support 8 classes PCMN (Actif, Passif, Charges, Produits, Hors-bilan) - ✅ Types: CallForFunds, PaymentReceived, ExpensePayment, TransferBetweenAccounts, YearEndClosing - ✅ Numérotation séquentielle par bâtiment - ✅ Trigger PostgreSQL (validation balance automatique) - ✅ Intégration FEC (Fichier Écritures Comptables export) **Endpoints API** - ``POST /buildings/:id/journal-entries`` - Créer écriture - ``GET /journal-entries/:id`` - Détails écriture - ``GET /buildings/:id/journal-entries`` - Liste écritures bâtiment - ``GET /buildings/:id/journal-entries/balance`` - Vérifier balance - ``POST /buildings/:id/journal-entries/year-end-closing`` - Clôture exercice - ``DELETE /journal-entries/:id`` - Supprimer écriture **Implémentation** - Migration: ``20251110140000_create_journal_entries_tables.sql`` + 4 migrations complémentaires - Domain: ``backend/src/domain/entities/journal_entry.rs`` (452 lignes) - Use Cases: ``backend/src/application/use_cases/journal_entry_use_cases.rs`` (213 lignes) - Handlers: ``backend/src/infrastructure/web/handlers/journal_entry_handlers.rs`` (454 lignes) **Règle Comptable** .. code-block:: sql -- Trigger validation balance CREATE TRIGGER validate_journal_entry_balance AFTER INSERT ON journal_entries FOR EACH ROW EXECUTE FUNCTION check_journal_entry_balance(); **Documentation**: Voir ``BELGIAN_ACCOUNTING_PCMN.rst`` (section Journal Entries) 2.5 Rapports d'Intervention (Work Reports) ------------------------------------------- **Contexte**: Documentation travaux entrepreneurs (photos avant/après, matériaux, heures) **Fonctionnalités** - ✅ Upload photos intervention (multi-fichiers) - ✅ Déclaration matériaux utilisés (quantités, prix) - ✅ Heures travaillées (début, fin, total) - ✅ Commentaires entrepreneur + syndic - ✅ Validation syndic (Pending → Approved/Rejected) - ✅ Lien vers ticket maintenance (si applicable) - ✅ Génération PDF rapport intervention **Endpoints API** - ``POST /work-reports`` - Créer rapport (entrepreneur) - ``GET /work-reports/:id`` - Détails rapport - ``GET /buildings/:id/work-reports`` - Liste rapports bâtiment - ``GET /contractors/:id/work-reports`` - Liste rapports entrepreneur - ``PUT /work-reports/:id/submit`` - Soumettre à validation - ``PUT /work-reports/:id/approve`` - Approuver (syndic) - ``PUT /work-reports/:id/reject`` - Rejeter (syndic) - ``DELETE /work-reports/:id`` - Supprimer rapport **Implémentation** - Migration: ``20251203000000_create_work_reports.sql`` - Domain: ``backend/src/domain/entities/work_report.rs`` (201 lignes) - Use Cases: ``backend/src/application/use_cases/work_report_use_cases.rs`` (295 lignes) - Tests: E2E work reports workflow **États du Workflow** .. code-block:: text Draft → Submitted → Approved → Rejected (+ motif rejet) **Documentation**: Nouvelle (ce document) 2.6 Contrôles Techniques (Technical Inspections) ------------------------------------------------- **Obligations Légales Belges** - Contrôle électrique obligatoire (tous les 25 ans pour installations anciennes) - Contrôle chaudières (annuel pour chaudières > 100 kW) - Contrôle ascenseurs (annuel) - Contrôle incendie (tous les 3 ans) - PEB (Performance Énergétique Bâtiment) - tous les 10 ans **Fonctionnalités** - ✅ Planification contrôles périodiques - ✅ Types: Electrical, Heating, Elevator, Fire, PEB, Gas, Water, Structural - ✅ Alertes expiration certificats (30j, 60j, 90j avant) - ✅ Upload certificats conformité (PDF) - ✅ Historique complet contrôles - ✅ États: Scheduled → InProgress → Passed → Failed **Endpoints API** - ``POST /buildings/:id/technical-inspections`` - Planifier contrôle - ``GET /technical-inspections/:id`` - Détails contrôle - ``GET /buildings/:id/technical-inspections`` - Liste contrôles bâtiment - ``GET /buildings/:id/technical-inspections/upcoming`` - Contrôles à venir - ``GET /buildings/:id/technical-inspections/expired`` - Certificats expirés - ``PUT /technical-inspections/:id/complete`` - Marquer terminé - ``DELETE /technical-inspections/:id`` - Annuler contrôle **Implémentation** - Migration: ``20251203000001_create_technical_inspections.sql`` - Domain: ``backend/src/domain/entities/technical_inspection.rs`` (268 lignes) - Use Cases: ``backend/src/application/use_cases/technical_inspection_use_cases.rs`` (368 lignes) **Fréquences Légales** .. code-block:: text Electrical: 25 ans (installations < 1981), sinon pas d'obligation Heating: 1 an (chaudières > 100 kW) Elevator: 1 an (obligatoire) Fire: 3 ans (immeubles > 4 étages) PEB: 10 ans (vente/location) **Documentation**: Nouvelle (ce document) ============================================== Jalon 3: Features Différenciantes 🎯 (COMPLET) ============================================== 3.1 Système de Sondages (Poll System - Issue #51) -------------------------------------------------- **Contexte Légal Belge**: Article 577-8/4 §4 Code Civil - Consultations rapides entre AG **4 Types de Sondages** - **YesNo**: Décisions simples (oui/non) - Ex: "Repeindre le hall en bleu?" - **MultipleChoice**: Choix multiples (simple ou multiple sélection) - Ex: Sélection entrepreneur - **Rating**: Enquêtes satisfaction (1-5 étoiles) - Ex: "Notez le service de nettoyage" - **OpenEnded**: Feedback textuel - Ex: "Suggestions d'amélioration?" **Fonctionnalités** - ✅ Vote anonyme (ip_address audit, owner_id NULL) - ✅ Prévention votes dupliqués (constraint UNIQUE poll_id + owner_id) - ✅ Multi-sélection (allow_multiple_votes = true) - ✅ Expiration automatique (ends_at <= NOW) - ✅ Calcul résultats (winner, percentages, participation rate) - ✅ Comptage électeurs éligibles (unit_owners actifs, deduplicated) - ✅ États: Draft → Active → Closed/Cancelled **Endpoints API (12 endpoints)** - ``POST /polls`` - Créer sondage - ``GET /polls/:id`` - Détails + options + vote counts - ``GET /buildings/:building_id/polls`` - Liste tous sondages - ``GET /buildings/:building_id/polls/active`` - Sondages actifs - ``GET /buildings/:building_id/polls/status/:status`` - Filtrer par statut - ``PUT /polls/:id/publish`` - Publier (Draft → Active) - ``PUT /polls/:id/close`` - Clôturer (Active → Closed) - ``PUT /polls/:id/cancel`` - Annuler - ``DELETE /polls/:id`` - Supprimer - ``POST /polls/:id/vote`` - Voter - ``GET /polls/:id/votes`` - Liste votes (admin only) - ``GET /polls/:id/results`` - Résultats + statistiques **Implémentation** - Migration: ``20251203120000_create_polls.sql`` (3 tables, 2 ENUMs, 14 indexes) - Domain: ``poll.rs`` (572 lignes), ``poll_option.rs`` (188 lignes), ``poll_vote.rs`` (214 lignes) - Use Cases: ``poll_use_cases.rs`` (687 lignes, 18 méthodes) - Handlers: ``poll_handlers.rs`` (~500 lignes, 12 endpoints) - Tests: 20 scénarios BDD (``backend/tests/features/polls.feature``) **Statistiques** - ~2,500 lignes de code - 38 méthodes repository - 24 unit tests domain - Participation rate = (total_votes_cast / total_eligible_voters) * 100 **Documentation**: Voir section CLAUDE.md "Board Decision Poll System" 3.2 Tableau d'Affichage Communautaire (Notice Board - Phase 2/6 Issue #49) --------------------------------------------------------------------------- **Contexte**: Communication entre copropriétaires + annonces syndic **3 Catégories** - **Announcement**: Annonces officielles syndic (ex: coupure eau, AG convoquée) - **ForSale**: Petites annonces vente (meubles, vélos, etc.) - **Event**: Événements communautaires (barbecue, fête voisins, apéro) **Fonctionnalités** - ✅ Visibilité: Private (bâtiment uniquement) ou Public (tous bâtiments organisation) - ✅ Expiration automatique (expires_at) - ✅ Upload photos (1-5 images par annonce) - ✅ Prix (pour ForSale) - ✅ Localisation événement (pour Event) - ✅ Système de commentaires (nested comments avec reply_to_id) - ✅ Modération syndic (peut supprimer annonces inappropriées) - ✅ États: Draft → Published → Expired/Archived **Endpoints API (17 endpoints)** - ``POST /notices`` - Créer annonce - ``GET /notices/:id`` - Détails annonce - ``GET /buildings/:id/notices`` - Liste annonces bâtiment - ``GET /buildings/:id/notices/category/:category`` - Filtrer par catégorie - ``GET /buildings/:id/notices/active`` - Annonces actives (non expirées) - ``PUT /notices/:id/publish`` - Publier (Draft → Published) - ``PUT /notices/:id/archive`` - Archiver - ``DELETE /notices/:id`` - Supprimer - ``POST /notices/:id/comments`` - Ajouter commentaire - ``GET /notices/:id/comments`` - Liste commentaires - ``PUT /comments/:id`` - Modifier commentaire - ``DELETE /comments/:id`` - Supprimer commentaire - ``POST /notices/:id/photos`` - Upload photos - ``GET /notices/:id/photos`` - Liste photos - ``DELETE /photos/:id`` - Supprimer photo - ``GET /notices/my`` - Mes annonces - ``GET /buildings/:id/notices/statistics`` - Statistiques **Implémentation** - Migration: ``20251120170000_create_notices.sql`` - Domain: ``notice.rs`` (914 lignes avec validation métier complexe) - Use Cases: ``notice_use_cases.rs`` (475 lignes, 17 méthodes) - Handlers: ``notice_handlers.rs`` (416 lignes, 17 endpoints) **Règles Métier** - Prix obligatoire pour ForSale (> 0) - Max 5 photos par annonce - Commentaires max 1000 caractères - Auto-archivage après expires_at **Documentation**: Nouvelle (ce document) 3.3 Annuaire des Compétences (Skills Directory - Phase 3/6 Issue #49) ---------------------------------------------------------------------- **Contexte**: Entraide entre copropriétaires via compétences professionnelles/hobbies **3 Types de Compétences** - **Professional**: Compétences professionnelles (plombier, électricien, comptable, avocat) - **Hobby**: Loisirs/passions (jardinage, bricolage, cuisine, musique) - **Language**: Langues parlées (FR, NL, EN, DE, cours de langue) **Niveaux de Maîtrise** - Beginner (débutant) - Intermediate (intermédiaire) - Advanced (avancé) - Expert (expert) **Fonctionnalités** - ✅ Profil compétences par propriétaire (multi-skills) - ✅ Disponibilité (Available, Busy, Unavailable) - ✅ Tarif indicatif (hourly_rate optionnel) - ✅ Années d'expérience - ✅ Certifications (certificats professionnels uploadables) - ✅ Système d'endorsements (validation compétences par pairs) - ✅ Recherche compétences (par type, niveau, disponibilité) - ✅ Intégration SEL (offre services = crédits temps) **Endpoints API (15 endpoints)** - ``POST /skills`` - Déclarer compétence - ``GET /skills/:id`` - Détails compétence - ``GET /owners/:id/skills`` - Liste compétences propriétaire - ``GET /buildings/:id/skills`` - Annuaire compétences bâtiment - ``GET /buildings/:id/skills/type/:type`` - Filtrer par type - ``GET /buildings/:id/skills/search`` - Recherche (query, level, available) - ``PUT /skills/:id`` - Modifier compétence - ``DELETE /skills/:id`` - Supprimer compétence - ``POST /skills/:id/endorsements`` - Endorser compétence (valider) - ``GET /skills/:id/endorsements`` - Liste endorsements - ``DELETE /endorsements/:id`` - Retirer endorsement - ``PUT /skills/:id/availability`` - Changer disponibilité - ``GET /owners/:id/skills/summary`` - Résumé compétences (count par type) - ``GET /buildings/:id/skills/statistics`` - Statistiques annuaire - ``GET /buildings/:id/skills/most-endorsed`` - Top compétences endorsées **Implémentation** - Migration: ``20251120180000_create_skills.sql`` - Domain: ``skill.rs`` (628 lignes) - Use Cases: ``skill_use_cases.rs`` (379 lignes, 15 méthodes) - Handlers: ``skill_handlers.rs`` (319 lignes, 15 endpoints) **Use Case Exemple** .. code-block:: text Marie (propriétaire) → Plombière professionnelle (Expert, 15 ans XP) → Hourly rate: 50 EUR/h → Disponibilité: Available (weekends) → 8 endorsements (voisins ayant utilisé ses services) → Offre services via SEL = 1h service = 1 crédit temps **Documentation**: Nouvelle (ce document) 3.4 Bibliothèque d'Objets Partagés (Shared Objects Library - Phase 4/6 Issue #49) ---------------------------------------------------------------------------------- **Contexte**: Économie collaborative - prêt d'objets entre copropriétaires **7 Catégories d'Objets** - **Tools**: Outils (perceuse, échelle, tondeuse) - **Sports**: Équipement sportif (vélo, skis, raquettes) - **Electronics**: Électronique (vidéoprojecteur, enceintes, caméra) - **Books**: Livres, magazines, BD - **Kitchen**: Ustensiles cuisine (raclette, fondue, robot) - **Garden**: Jardinage (taille-haie, débroussailleuse) - **Other**: Autres objets **États de Prêt** .. code-block:: text Available → Reserved (booking confirmé) → OnLoan (objet emprunté) → Returned (retour validé) → Unavailable (maintenance, perdu) **Fonctionnalités** - ✅ Catalogue objets partagés avec photos - ✅ Durée prêt max (1j, 3j, 7j, 30j personnalisable) - ✅ Caution optionnelle (deposit_amount) - ✅ Système de réservation (request → approve/reject) - ✅ Historique emprunts complet - ✅ Évaluations emprunteur (1-5 étoiles) - ✅ Conditions d'utilisation (description, restrictions) - ✅ Alertes retard (notification automatique) **Endpoints API (17 endpoints)** - ``POST /shared-objects`` - Ajouter objet - ``GET /shared-objects/:id`` - Détails objet - ``GET /buildings/:id/shared-objects`` - Catalogue bâtiment - ``GET /buildings/:id/shared-objects/available`` - Objets disponibles - ``GET /buildings/:id/shared-objects/category/:category`` - Filtrer par catégorie - ``GET /owners/:id/shared-objects`` - Mes objets partagés - ``PUT /shared-objects/:id`` - Modifier objet - ``DELETE /shared-objects/:id`` - Retirer objet - ``POST /shared-objects/:id/borrow`` - Demander prêt - ``PUT /borrow-requests/:id/approve`` - Approuver prêt - ``PUT /borrow-requests/:id/reject`` - Refuser prêt - ``PUT /borrow-requests/:id/return`` - Marquer retourné - ``GET /shared-objects/:id/borrow-history`` - Historique prêts - ``POST /shared-objects/:id/rate`` - Évaluer emprunteur - ``GET /owners/:id/borrow-requests`` - Mes demandes prêt - ``GET /buildings/:id/shared-objects/statistics`` - Statistiques - ``GET /buildings/:id/shared-objects/most-borrowed`` - Top objets empruntés **Implémentation** - Migration: ``20251120190000_create_shared_objects.sql`` - Domain: ``shared_object.rs`` (804 lignes) - Use Cases: ``shared_object_use_cases.rs`` (492 lignes, 17 méthodes) - Handlers: ``shared_object_handlers.rs`` (387 lignes, 17 endpoints) **Règles Métier** - Owner ne peut pas emprunter son propre objet - Max 3 objets empruntés simultanément par propriétaire - Caution retournée après validation retour - Alerte auto J+1 après date retour prévue - Rating emprunteur uniquement après retour validé **Documentation**: Nouvelle (ce document) 3.5 Réservation de Ressources (Resource Booking - Phase 5/6 Issue #49) ----------------------------------------------------------------------- **Contexte**: Réservation espaces communs (salle fêtes, BBQ, parking visiteurs) **8 Types de Ressources** - **Room**: Salles (fête, réunion, coworking) - **Parking**: Places parking visiteurs - **SportsFacility**: Installations sportives (tennis, piscine) - **Barbecue**: BBQ collectifs - **LaundryRoom**: Buanderie commune - **GuestRoom**: Chambre d'amis (1-2 nuits) - **StorageSpace**: Box de rangement - **Other**: Autres ressources **Fonctionnalités** - ✅ Calendrier disponibilités (vue journalière/hebdomadaire/mensuelle) - ✅ Créneaux horaires configurables (1h, 2h, demi-journée, journée complète) - ✅ Tarification: Gratuit ou payant (hourly_rate / daily_rate) - ✅ Règles de réservation: Max reservations simultanées par owner, Advance booking (combien de jours à l'avance), Max duration (durée max réservation) - ✅ Caution obligatoire (optionnel) - ✅ Système d'approbation (auto-approve ou validation syndic) - ✅ Annulation avec politique (délai annulation gratuite) - ✅ États: Pending → Confirmed → CheckedIn → CheckedOut → Cancelled **Endpoints API (20 endpoints)** - ``POST /resources`` - Créer ressource - ``GET /resources/:id`` - Détails ressource - ``GET /buildings/:id/resources`` - Liste ressources bâtiment - ``GET /buildings/:id/resources/type/:type`` - Filtrer par type - ``GET /buildings/:id/resources/available`` - Ressources disponibles - ``PUT /resources/:id`` - Modifier ressource - ``DELETE /resources/:id`` - Supprimer ressource - ``POST /resources/:id/bookings`` - Réserver - ``GET /bookings/:id`` - Détails réservation - ``GET /resources/:id/bookings`` - Réservations ressource - ``GET /owners/:id/bookings`` - Mes réservations - ``GET /owners/:id/bookings/upcoming`` - Réservations à venir - ``PUT /bookings/:id/approve`` - Approuver (syndic) - ``PUT /bookings/:id/reject`` - Rejeter (syndic) - ``PUT /bookings/:id/cancel`` - Annuler réservation - ``PUT /bookings/:id/checkin`` - Check-in (début utilisation) - ``PUT /bookings/:id/checkout`` - Check-out (fin utilisation) - ``GET /resources/:id/availability`` - Disponibilités (date range) - ``GET /buildings/:id/bookings/statistics`` - Statistiques - ``GET /resources/:id/bookings/calendar`` - Vue calendrier **Implémentation** - Migration: ``20251120210000_create_resource_bookings.sql`` - Domain: ``resource_booking.rs`` (837 lignes) - Use Cases: ``resource_booking_use_cases.rs`` (421 lignes, 20 méthodes) - Handlers: ``resource_booking_handlers.rs`` (606 lignes, 20 endpoints) **Règles Métier** - Vérification disponibilité avant réservation (pas de chevauchement) - Max 2 réservations actives par owner (configurable) - Advance booking: min 1 jour, max 90 jours à l'avance - Annulation gratuite jusqu'à 24h avant début - Check-in obligatoire dans les 30 min après start_time - Caution débitée si check-out > 1h après end_time **Exemple Configuration Salle Fêtes** .. code-block:: json { "name": "Salle des Fetes", "type": "Room", "hourly_rate": 15.00, "daily_rate": 100.00, "deposit_amount": 200.00, "capacity": 50, "requires_approval": true, "max_booking_duration_hours": 12, "advance_booking_days": 90, "max_concurrent_bookings": 1 } **Documentation**: Nouvelle (ce document) ============================================ Jalon 4: Automation & Intégrations 📅 ============================================ 4.1 IoT Integration - Linky/Ores API (Issue #133) -------------------------------------------------- **Priorité**: High | **Phase**: VPS (Jalon 3-4) | **Coût**: 0 EUR **Proposition de Valeur** - ✅ 0€ coût (API gratuite, pas d'achat capteurs) - ✅ 0 installation physique (API call uniquement) - ✅ 80%+ couverture (Linky obligatoire Belgique/France) - ✅ 95% bénéfices IoT pour 0% du coût - ✅ Time-to-market: 1 semaine vs 3-6 mois hardware **Use Cases** 1. **Monitoring Temps-Réel** - Consommation électrique quotidienne/mensuelle/annuelle - Courbe de charge (granularité 30 min) - Historique 36 mois 2. **Alertes Intelligentes** - Détection surconsommation (> 120% moyenne) - Prévision factures énergie - Recommandations économies CO₂ 3. **Analytics** - Graphiques consommations (Chart.js/Recharts) - Comparaison périodes (MoM, YoY) - Export PDF rapports énergétiques **Endpoints API (9 endpoints)** - ``POST /buildings/:id/iot/linky/configure`` - Configurer Linky (OAuth2) - ``POST /buildings/:id/iot/linky/sync`` - Synchroniser données - ``GET /buildings/:id/iot/readings`` - Lectures IoT - ``GET /buildings/:id/iot/readings/latest`` - Dernière lecture - ``GET /buildings/:id/iot/statistics`` - Statistiques consommation - ``GET /buildings/:id/iot/anomalies`` - Détection anomalies - ``GET /buildings/:id/iot/devices`` - Liste devices - ``PUT /iot/devices/:id`` - Modifier device - ``DELETE /iot/devices/:id`` - Supprimer device **Implémentation** - Migration: ``20251201000000_create_iot_readings.sql`` (TimescaleDB hypertable) - Domain: ``iot_reading.rs`` (484 lignes), ``linky_device.rs`` (441 lignes) - Use Cases: ``iot_use_cases.rs`` (651 lignes, 18 méthodes) - Handlers: ``iot_handlers.rs`` (534 lignes, 9 endpoints) - Linky Client: ``linky_api_client_impl.rs`` (587 lignes, OAuth2 + Ores/Enedis APIs) **APIs Intégrées** 1. **Ores Belgium API** - Endpoint: https://ext.prod-eu.oresnet.be/v1/consumption_load_curve - Authentication: OAuth2 Bearer token - Parameters: prm (Point Reference Measure), start/end date 2. **Enedis Linky France API** - Endpoint: https://ext.hml.myelectricaldata.fr/v1/ - Authentication: OAuth2 (consent utilisateur) - Mêmes paramètres que Ores **TimescaleDB Hypertable** .. code-block:: sql -- Optimisé pour time-series data CREATE TABLE iot_readings ( id UUID PRIMARY KEY, building_id UUID NOT NULL, device_type VARCHAR(50) NOT NULL, metric_type VARCHAR(50) NOT NULL, value DOUBLE PRECISION NOT NULL, unit VARCHAR(20) NOT NULL, timestamp TIMESTAMPTZ NOT NULL, source VARCHAR(50) NOT NULL, metadata JSONB ); -- Hypertable avec compression automatique SELECT create_hypertable('iot_readings', 'timestamp'); -- Retention policy: 2 ans SELECT add_retention_policy('iot_readings', INTERVAL '730 days'); -- Compression policy: 7 jours (10-20x savings) SELECT add_compression_policy('iot_readings', INTERVAL '7 days'); **Anomaly Detection** - Seuil surconsommation: > 120% de la moyenne mobile 7 jours - Notification automatique propriétaire + syndic - Intégration avec Issue #86 (Notifications System) **Cron Job Daily Sync** .. code-block:: rust // Synchronisation quotidienne à 2:00 AM #[tokio::spawn] async fn sync_linky_data_daily() { loop { tokio::time::sleep(Duration::from_secs(86400)).await; for building in get_buildings_with_linky() { iot_use_cases.sync_linky_data(building.id).await?; } } } **Documentation**: Voir Issue #133 (RST complet) **Prochaines Étapes** - Intégration Netatmo API (température/humidité) - Intégration compteurs eau (si API disponible) - ML prévisions factures (ARIMA models) - Recommandations économies énergie (AI assistant) ============================================ Annexes & Références ============================================ A. Statistiques Globales du Projet ----------------------------------- **Backend (Rust)** - **73 endpoints API REST** implémentés - **45+ entités de domaine** avec validation - **~50,000 lignes de code** Rust - **100+ migrations PostgreSQL** - **Couverture tests**: 85%+ moyenne **Base de Données** - **PostgreSQL 15** + TimescaleDB (time-series) - **~80 tables** (+ 20 tables audit) - **150+ indexes** (optimisation queries) - **50+ triggers** (validation métier automatique) - **25+ ENUMs** personnalisés **Tests** - **Unit tests**: 90%+ couverture (domain logic) - **Integration tests**: 85%+ (avec testcontainers PostgreSQL) - **E2E tests**: 80%+ (full API workflows) - **BDD tests**: 70%+ (Cucumber/Gherkin scenarios) **Performance** - **Latency P99**: < 5ms (target) - **Throughput**: > 100k req/s (target) - **Memory**: < 128MB per instance - **Connection Pool**: Max 10 PostgreSQL connections B. Architecture Hexagonale - Rappel ------------------------------------ .. code-block:: text Domain (Core Business Logic) ↑ defines interfaces Application (Use Cases + Ports) ↑ implements ports Infrastructure (Adapters: Web, Database, External APIs) **Layers Rules** 1. Domain: Pure logic, NO external dependencies 2. Application: Orchestration, trait definitions 3. Infrastructure: PostgreSQL, Actix-web, External APIs **Pattern Exemple** .. code-block:: rust // Domain: backend/src/domain/entities/poll.rs impl Poll { pub fn new(...) -> Result { /* validation */ } } // Application: backend/src/application/ports/poll_repository.rs #[async_trait] pub trait PollRepository: Send + Sync { async fn create(&self, poll: &Poll) -> Result; } // Infrastructure: backend/src/infrastructure/database/repositories/poll_repository_impl.rs impl PollRepository for PostgresPollRepository { async fn create(&self, poll: &Poll) -> Result { // PostgreSQL implementation } } C. Liens Vers Documentation Existante -------------------------------------- **GDPR & Sécurité** - ``GDPR_ADDITIONAL_RIGHTS.md`` - Articles 16, 18, 21 - ``GDPR_COMPLIANCE_CHECKLIST.md`` - Checklist conformité - ``GDPR_IMPLEMENTATION_STATUS.md`` - État implémentation - ``JWT_REFRESH_TOKENS.md`` - Tokens + 2FA **Comptabilité Belge** - ``BELGIAN_ACCOUNTING_PCMN.rst`` - Plan Comptable Normalisé - ``INVOICE_WORKFLOW.rst`` - Workflow approbation factures - ``PAYMENT_RECOVERY_WORKFLOW.rst`` - Recouvrement impayés **Tests & Performance** - ``E2E_TESTING_GUIDE.rst`` - Guide tests E2E - ``PERFORMANCE_TESTING.rst`` - Tests performance - ``PERFORMANCE_REPORT.rst`` - Rapport benchmarks **Infrastructure** - ``INFRASTRUCTURE_COST_SIMULATIONS_2025.rst`` - Simulations coûts - ``JALONS_MIGRATION.rst`` - Roadmap par jalons - ``GIT_HOOKS.rst`` - Hooks Git (pre-commit, pre-push) **Autres** - ``MULTI_OWNER_SUPPORT.md`` - Support multi-propriétaires - ``MULTI_ROLE_SUPPORT.md`` - Support multi-rôles utilisateurs - ``OWNER_MODEL_REFACTORING.rst`` - Refactoring modèle Owner D. Issues GitHub Complétées ---------------------------- **Jalon 0 (Fondations) - 100% COMPLET** - #1-27: Architecture, 73 endpoints, tests **Jalon 1 (Sécurité & GDPR) - 100% COMPLET** - #39: LUKS encryption at rest ✅ - #40: Encrypted backups (GPG + S3) ✅ - #41: Monitoring (Prometheus + Grafana + Loki) ✅ - #42: GDPR data export & deletion ✅ - #43: Security hardening (fail2ban, WAF, IDS) ✅ - #78: Application security headers ✅ - #90: GDPR complementary articles (16, 18, 21) ✅ **Jalon 2 (Conformité Légale Belge) - 100% COMPLET** - #73: Invoice workflow ✅ - #75: Meeting management API ✅ - #76: Document upload/download ✅ - #77: Financial reports ✅ - #79: Belgian Accounting PCMN ✅ - #80: État Daté generation ✅ - #81: Annual budget system ✅ - #82: Board of Directors ✅ - #83: Payment recovery workflow ✅ **Jalon 3 (Features Différenciantes) - 95% COMPLET** - #46: Meeting voting system ✅ - #47: Extended PDF generation ✅ - #49: Community features (6 phases) ✅ - #51: Poll System ✅ - #84: Payments (Stripe + SEPA) ✅ - #85: Ticket management ✅ - #86: Notifications multi-channel ✅ - #87: PWA (Progressive Web App) ✅ - #88: Automatic AG convocations ✅ - #89: Digital maintenance logbook ✅ - #91: Contractor quotes ✅ - #92: Public syndic info ✅ - #93: WCAG accessibility ✅ - #133: Linky/Ores IoT ✅ **Jalon 4 (Automation) - EN COURS** - #133: IoT Integration (Linky/Ores) ✅ - #52: Contractor backoffice (OPEN) - #109: IoT Platform MQTT (OPEN) - #110: Energy Buying Groups (OPEN) E. Prochaines Étapes -------------------- **Court Terme (Q1 2025)** 1. Compléter tests E2E pour nouveaux systèmes (Poll, IoT, Work Reports) 2. Frontend UI pour nouvelles fonctionnalités (Svelte components) 3. Migration production VPS (déploiement Ansible) 4. Documentation utilisateur (guides syndic + propriétaires) **Moyen Terme (Q2 2025)** 1. Issue #52: Contractor backoffice (rapports intervention + photos) 2. Machine Learning prévisions (factures énergie, maintenance prédictive) 3. Integration Netatmo API (température/humidité) 4. Mobile app (React Native ou Flutter) **Long Terme (Q3-Q4 2025)** 1. Issue #109: IoT Platform complet (MQTT broker + hardware sensors) 2. Issue #110: Energy Buying Groups (groupements achat énergie) 3. Blockchain integration (smart contracts pour votes AG) 4. AI Assistant (chatbot support copropriétaires) ============================================ Changelog & Versions ============================================ **Version 1.0** (2025-11-18) - Documentation initiale complète - 73 endpoints API documentés - Toutes fonctionnalités Jalon 1-3 couvertes **À venir** - Documentation technique API (OpenAPI/Swagger) - Guides utilisateur (Syndic, Propriétaire, Entrepreneur) - Vidéos tutoriels (démo features) ============================================ Contact & Support ============================================ **Documentation GitHub** https://github.com/gilmry/koprogo/tree/main/docs **Issues & Feature Requests** https://github.com/gilmry/koprogo/issues **Email Support** support@koprogo.com (à venir) ============================================ Licence & Copyright ============================================ Copyright © 2025 KoproGo ASBL Tous droits réservés. Ce document est confidentiel et destiné uniquement aux développeurs du projet KoproGo.