Outils pour utilisateurs

Outils du site


ujusum:3-codage:2-sprints:6-sprint-6

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
ujusum:3-codage:2-sprints:6-sprint-6 [2026/06/10 18:16] – créée 83.202.252.200ujusum:3-codage:2-sprints:6-sprint-6 [2026/06/11 02:07] (Version actuelle) 83.202.252.200
Ligne 186: Ligne 186:
 ---- ----
  
-====== Étape suivante ======+====== Sprint 6-A.1 — Implémentation Prisma Portfolio Core ======
  
-===== Sprint 6-A.1 =====+===== Objectif =====
  
-Implémentation Prisma Portfolio Core+Créer la fondation Multi-Propriétés Enterprise.
  
-Objectif :+Cette couche permet de regrouper plusieurs propriétés dans des structures hiérarchiques :
  
-Créer les modèles :+<code> 
 +Tenant 
 + 
 +↓ 
 + 
 +Portfolio 
 + 
 +↓ 
 + 
 +Property Group 
 + 
 +↓ 
 + 
 +Properties 
 +</code> 
 + 
 +avec gestion des : 
 + 
 +<code> 
 +Propriétaires 
 + 
 +Exploitants 
 + 
 +Groupes 
 + 
 +Portefeuilles 
 +</code> 
 + 
 +À l'issue de cette étape : 
 + 
 +<code> 
 +✓ Portfolio 
 + 
 +✓ PropertyGroup 
 + 
 +✓ Owner 
 + 
 +✓ Operator 
 + 
 +✓ Multi-Property Ready 
 + 
 +✓ Finance Ready 
 + 
 +✓ Reservation Ready 
 + 
 +✓ Analytics Ready 
 +</code> 
 + 
 +---- 
 + 
 +====== Architecture cible ====== 
 + 
 +<code> 
 +Tenant 
 + 
 +↓ 
 + 
 +Portfolio 
 + 
 +├── Property Groups 
 +│ 
 +├── Owners 
 +│ 
 +├── Operators 
 +│ 
 +└── Properties 
 + 
 +↓ 
 + 
 +Reservations 
 + 
 +↓ 
 + 
 +Finance 
 + 
 +↓ 
 + 
 +Analytics 
 +</code> 
 + 
 +---- 
 + 
 +====== Sprint 6-A.1-A ====== 
 + 
 +===== Extension Prisma ===== 
 + 
 +---- 
 + 
 +====== Étape 1 — Portfolio ====== 
 + 
 +===== Ajouter dans schema.prisma ===== 
 + 
 +<code prisma> 
 +model Portfolio { 
 + 
 +  id                    String 
 +                        @id 
 +                        @default(uuid()) 
 + 
 +  tenantId              String 
 + 
 +  name                  String 
 + 
 +  code                  String 
 +                        @unique 
 + 
 +  description           String? 
 + 
 +  active                Boolean 
 +                        @default(true) 
 + 
 +  createdAt             DateTime 
 +                        @default(now()) 
 + 
 +  updatedAt             DateTime 
 +                        @updatedAt 
 + 
 +  tenant                Tenant 
 +                        @relation( 
 +                          fields:[tenantId], 
 +                          references:[id] 
 +                        ) 
 + 
 +  propertyGroups        PropertyGroup[] 
 + 
 +  properties            Property[] 
 + 
 +  @@index([tenantId]) 
 + 
 +  @@index([active]) 
 + 
 +  @@index([code]) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 2 — PropertyGroup ====== 
 + 
 +===== Ajouter ===== 
 + 
 +<code prisma> 
 +model PropertyGroup { 
 + 
 +  id                    String 
 +                        @id 
 +                        @default(uuid()) 
 + 
 +  tenantId              String 
 + 
 +  portfolioId           String 
 + 
 +  name                  String 
 + 
 +  code                  String 
 + 
 +  description           String? 
 + 
 +  active                Boolean 
 +                        @default(true) 
 + 
 +  createdAt             DateTime 
 +                        @default(now()) 
 + 
 +  updatedAt             DateTime 
 +                        @updatedAt 
 + 
 +  portfolio             Portfolio 
 +                        @relation( 
 +                          fields:[portfolioId], 
 +                          references:[id], 
 +                          onDelete:Cascade 
 +                        ) 
 + 
 +  properties            Property[] 
 + 
 +  @@unique([ 
 +    portfolioId, 
 +    code 
 +  ]) 
 + 
 +  @@index([tenantId]) 
 + 
 +  @@index([portfolioId]) 
 + 
 +  @@index([active]) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 3 — Owner ====== 
 + 
 +===== Ajouter ===== 
 + 
 +<code prisma> 
 +model Owner { 
 + 
 +  id                    String 
 +                        @id 
 +                        @default(uuid()) 
 + 
 +  tenantId              String 
 + 
 +  ownerCode             String 
 +                        @unique 
 + 
 +  type                  OwnerType 
 + 
 +  companyName           String? 
 + 
 +  firstName             String? 
 + 
 +  lastName              String? 
 + 
 +  email                 String? 
 + 
 +  phone                 String? 
 + 
 +  taxIdentifier         String? 
 + 
 +  active                Boolean 
 +                        @default(true) 
 + 
 +  createdAt             DateTime 
 +                        @default(now()) 
 + 
 +  updatedAt             DateTime 
 +                        @updatedAt 
 + 
 +  properties            Property[] 
 + 
 +  @@index([tenantId]) 
 + 
 +  @@index([ownerCode]) 
 + 
 +  @@index([active]) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 4 — Operator ====== 
 + 
 +===== Ajouter ===== 
 + 
 +<code prisma> 
 +model Operator { 
 + 
 +  id                    String 
 +                        @id 
 +                        @default(uuid()) 
 + 
 +  tenantId              String 
 + 
 +  operatorCode          String 
 +                        @unique 
 + 
 +  companyName           String 
 + 
 +  email                 String? 
 + 
 +  phone                 String? 
 + 
 +  active                Boolean 
 +                        @default(true) 
 + 
 +  createdAt             DateTime 
 +                        @default(now()) 
 + 
 +  updatedAt             DateTime 
 +                        @updatedAt 
 + 
 +  properties            Property[] 
 + 
 +  @@index([tenantId]) 
 + 
 +  @@index([operatorCode]) 
 + 
 +  @@index([active]) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 5 — OwnerType ====== 
 + 
 +===== Ajouter ===== 
 + 
 +<code prisma> 
 +enum OwnerType { 
 + 
 +  INDIVIDUAL 
 + 
 +  COMPANY 
 + 
 +  INVESTMENT_FUND 
 + 
 +  REIT 
 + 
 +  GOVERNMENT 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Sprint 6-A.1-B ====== 
 + 
 +===== Extension du modèle Property ===== 
 + 
 +---- 
 + 
 +====== Étape 6 — Ajouter Portfolio ====== 
 + 
 +===== Dans Property ===== 
 + 
 +<code prisma> 
 +portfolioId            String? 
 + 
 +portfolio              Portfolio? 
 +                        @relation( 
 +                          fields:[portfolioId], 
 +                          references:[id] 
 +                        ) 
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 7 — Ajouter Property Group ====== 
 + 
 +===== Dans Property ===== 
 + 
 +<code prisma> 
 +propertyGroupId        String? 
 + 
 +propertyGroup          PropertyGroup? 
 +                        @relation( 
 +                          fields:[propertyGroupId], 
 +                          references:[id] 
 +                        ) 
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 8 — Ajouter Owner ====== 
 + 
 +===== Dans Property ===== 
 + 
 +<code prisma> 
 +ownerId                String? 
 + 
 +owner                  Owner? 
 +                        @relation( 
 +                          fields:[ownerId], 
 +                          references:[id] 
 +                        ) 
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 9 — Ajouter Operator ====== 
 + 
 +===== Dans Property ===== 
 + 
 +<code prisma> 
 +operatorId             String? 
 + 
 +operator               Operator? 
 +                        @relation( 
 +                          fields:[operatorId], 
 +                          references:[id] 
 +                        ) 
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 10 — Ajouter Index ====== 
 + 
 +<code prisma> 
 +@@index([portfolioId]) 
 + 
 +@@index([propertyGroupId]) 
 + 
 +@@index([ownerId]) 
 + 
 +@@index([operatorId]) 
 +</code> 
 + 
 +---- 
 + 
 +====== Sprint 6-A.1-C ====== 
 + 
 +===== Relations Tenant ===== 
 + 
 +---- 
 + 
 +====== Étape 11 — Ajouter ====== 
 + 
 +===== Dans Tenant ===== 
 + 
 +<code prisma> 
 +portfolios Portfolio[] 
 + 
 +owners Owner[] 
 + 
 +operators Operator[] 
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 12 — Multi-Tenant ====== 
 + 
 +===== Garantir ===== 
 + 
 +que :
  
 <code> <code>
Ligne 206: Ligne 620:
 </code> </code>
  
-dans :+appartiennent toujours au même :
  
 <code> <code>
-apps/api/prisma/schema.prisma+tenantId
 </code> </code>
  
-avec :+---- 
 + 
 +====== Sprint 6-A.1-D ====== 
 + 
 +===== Contraintes Métier ===== 
 + 
 +---- 
 + 
 +====== Étape 13 — Portfolio ====== 
 + 
 +===== Supporter =====
  
 <code> <code>
-Multi-tenant+1 Tenant
  
-Multi-property+
  
-Reservation Ready+N Portfolios 
 +</code>
  
-Finance Ready+----
  
-Analytics Ready+====== Étape 14 — Property Group ====== 
 + 
 +===== Supporter ===== 
 + 
 +<code> 
 +1 Portfolio 
 + 
 +↓ 
 + 
 +N Property Groups
 </code> </code>
 +
 +----
 +
 +====== Étape 15 — Owner ======
 +
 +===== Supporter =====
 +
 +<code>
 +1 Owner
 +
 +
 +
 +N Properties
 +</code>
 +
 +----
 +
 +====== Étape 16 — Operator ======
 +
 +===== Supporter =====
 +
 +<code>
 +1 Operator
 +
 +
 +
 +N Properties
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.1-E ======
 +
 +===== Finance Ready =====
 +
 +----
 +
 +====== Étape 17 — Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +Revenue Sharing
 +
 +Owner Statements
 +
 +Commission Engine
 +
 +Asset Accounting
 +</code>
 +
 +----
 +
 +====== Étape 18 — Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +Multi-Owner Properties
 +
 +Operator Contracts
 +
 +Portfolio Finance
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.1-F ======
 +
 +===== Reservation Ready =====
 +
 +----
 +
 +====== Étape 19 — Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +Portfolio Occupancy
 +
 +Group Reservations
 +
 +Multi-Site Reporting
 +</code>
 +
 +----
 +
 +====== Étape 20 — Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +Cross Property Search
 +
 +Portfolio Analytics
 +
 +Enterprise Reporting
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.1-G ======
 +
 +===== Analytics Ready =====
 +
 +----
 +
 +====== Étape 21 — Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +Portfolio Revenue
 +
 +Portfolio Occupancy
 +
 +Benchmarking
 +
 +Forecasting
 +
 +Asset Performance
 +</code>
 +
 +----
 +
 +====== Étape 22 — Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +Executive Dashboard
 +
 +Owner Dashboard
 +
 +Operator Dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.1-H ======
 +
 +===== Migration =====
 +
 +----
 +
 +====== Étape 23 — Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name portfolio_core
 +</code>
 +
 +----
 +
 +====== Étape 24 — Générer =====
 +
 +<code bash>
 +npx prisma generate
 +</code>
 +
 +----
 +
 +====== Étape 25 — Vérifier =====
 +
 +<code bash>
 +npx prisma studio
 +</code>
 +
 +Présence de :
 +
 +<code>
 +Portfolio
 +
 +PropertyGroup
 +
 +Owner
 +
 +Operator
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-A.1 est terminé lorsque :
 +
 +<code>
 +✓ Portfolio créé
 +
 +✓ PropertyGroup créé
 +
 +✓ Owner créé
 +
 +✓ Operator créé
 +
 +✓ Relations Property créées
 +
 +✓ Relations Tenant créées
 +
 +✓ Multi-Tenant Ready
 +
 +✓ Finance Ready
 +
 +✓ Analytics Ready
 +
 +✓ Migration exécutée
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +Portfolio
 +
 +PropertyGroup
 +
 +Owner
 +
 +Operator
 +
 +OwnerType
 +
 +Portfolio Core Schema
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.2 — Gestion Multi-Propriétés Enterprise ======
 +
 +===== Objectif =====
 +
 +Construire la couche métier Multi-Propriétés Enterprise.
 +
 +Cette couche permet de gérer :
 +
 +<code>
 +Portefeuilles
 +
 +Groupes de propriétés
 +
 +Propriétaires
 +
 +Exploitants
 +
 +Hiérarchie multi-sites
 +
 +Sécurité multi-niveaux
 +</code>
 +
 +à partir d'une interface unique.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ PortfolioModule
 +
 +✓ PropertyGroupModule
 +
 +✓ OwnerModule
 +
 +✓ OperatorModule
 +
 +✓ Portfolio Hierarchy
 +
 +✓ Portfolio Security
 +
 +✓ Portfolio Dashboard
 +
 +✓ Enterprise Multi-Site Management
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Portfolio
 +
 +├── Property Groups
 +
 +├── Properties
 +
 +├── Owners
 +
 +├── Operators
 +
 +└── Portfolio Dashboard
 +
 +
 +
 +Reservations
 +
 +
 +
 +Finance
 +
 +
 +
 +Analytics
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.2-A ======
 +
 +===== Modules Métier =====
 +
 +----
 +
 +====== Étape 1 — Création ======
 +
 +<code>
 +src/modules/portfolio
 +
 +├── portfolio
 +
 +├── property-groups
 +
 +├── owners
 +
 +├── operators
 +
 +├── dashboard
 +
 +└── portfolio.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 2 — Services ======
 +
 +===== Créer =====
 +
 +<code>
 +PortfolioService
 +
 +PropertyGroupService
 +
 +OwnerService
 +
 +OperatorService
 +
 +PortfolioHierarchyService
 +
 +PortfolioDashboardService
 +</code>
 +
 +----
 +
 +====== Étape 3 — Controllers ======
 +
 +===== Créer =====
 +
 +<code>
 +PortfolioController
 +
 +PropertyGroupController
 +
 +OwnerController
 +
 +OperatorController
 +
 +PortfolioDashboardController
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.2-B ======
 +
 +===== Gestion des Portefeuilles =====
 +
 +----
 +
 +====== Étape 4 — PortfolioService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createPortfolio()
 +
 +updatePortfolio()
 +
 +archivePortfolio()
 +
 +getPortfolio()
 +
 +getPortfolioSummary()
 +</code>
 +
 +----
 +
 +====== Étape 5 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET    /portfolios
 +
 +GET    /portfolios/{id}
 +
 +POST   /portfolios
 +
 +PUT    /portfolios/{id}
 +
 +DELETE /portfolios/{id}
 +</code>
 +
 +----
 +
 +====== Étape 6 — Validation ======
 +
 +===== Vérifier =====
 +
 +<code>
 +tenantId
 +
 +unicité code
 +
 +ownership
 +</code>
 +
 +sur chaque opération.
 +
 +----
 +
 +====== Sprint 6-A.2-C ======
 +
 +===== Gestion des Groupes =====
 +
 +----
 +
 +====== Étape 7 — PropertyGroupService ======
 +
 +===== Créer =====
 +
 +<code>
 +property-group.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createGroup()
 +
 +assignProperty()
 +
 +removeProperty()
 +
 +moveProperty()
 +</code>
 +
 +----
 +
 +====== Étape 8 — Structure ======
 +
 +===== Supporter =====
 +
 +<code>
 +Portfolio
 +
 +
 +
 +Region
 +
 +
 +
 +City
 +
 +
 +
 +Properties
 +</code>
 +
 +----
 +
 +====== Étape 9 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET    /property-groups
 +
 +POST   /property-groups
 +
 +PUT    /property-groups/{id}
 +
 +DELETE /property-groups/{id}
 +
 +POST   /property-groups/{id}/properties
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.2-D ======
 +
 +===== Gestion des Propriétaires =====
 +
 +----
 +
 +====== Étape 10 — OwnerService ======
 +
 +===== Créer =====
 +
 +<code>
 +owner.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createOwner()
 +
 +updateOwner()
 +
 +assignProperty()
 +
 +getOwnerPortfolio()
 +</code>
 +
 +----
 +
 +====== Étape 11 — Informations ======
 +
 +===== Gérer =====
 +
 +<code>
 +Personne physique
 +
 +Société
 +
 +Coordonnées
 +
 +Fiscalité
 +
 +Contrats
 +</code>
 +
 +----
 +
 +====== Étape 12 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET    /owners
 +
 +GET    /owners/{id}
 +
 +POST   /owners
 +
 +PUT    /owners/{id}
 +
 +DELETE /owners/{id}
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.2-E ======
 +
 +===== Gestion des Exploitants =====
 +
 +----
 +
 +====== Étape 13 — OperatorService ======
 +
 +===== Créer =====
 +
 +<code>
 +operator.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createOperator()
 +
 +updateOperator()
 +
 +assignProperty()
 +
 +getOperatorPerformance()
 +</code>
 +
 +----
 +
 +====== Étape 14 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET    /operators
 +
 +GET    /operators/{id}
 +
 +POST   /operators
 +
 +PUT    /operators/{id}
 +
 +DELETE /operators/{id}
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.2-F ======
 +
 +===== Hiérarchie Enterprise =====
 +
 +----
 +
 +====== Étape 15 — PortfolioHierarchyService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-hierarchy.service.ts
 +</code>
 +
 +----
 +
 +===== Construire =====
 +
 +<code>
 +Portfolio
 +
 +
 +
 +PropertyGroup
 +
 +
 +
 +Property
 +</code>
 +
 +----
 +
 +====== Étape 16 — Fonctions ======
 +
 +===== Supporter =====
 +
 +<code ts>
 +getTree()
 +
 +getChildren()
 +
 +getAncestors()
 +
 +calculateAggregates()
 +</code>
 +
 +----
 +
 +====== Étape 17 — Agrégations ======
 +
 +===== Calculer =====
 +
 +<code>
 +Properties Count
 +
 +Revenue
 +
 +Occupancy
 +
 +Reservations
 +
 +Reviews
 +</code>
 +
 +par niveau.
 +
 +----
 +
 +====== Sprint 6-A.2-G ======
 +
 +===== Portfolio Security =====
 +
 +----
 +
 +====== Étape 18 — Portfolio Scope ======
 +
 +===== Ajouter =====
 +
 +<code>
 +portfolioId
 +
 +propertyGroupId
 +
 +propertyId
 +</code>
 +
 +comme scopes de sécurité.
 +
 +----
 +
 +====== Étape 19 — RBAC ======
 +
 +===== Supporter =====
 +
 +<code>
 +Portfolio Admin
 +
 +Portfolio Manager
 +
 +Group Manager
 +
 +Property Manager
 +
 +Owner Viewer
 +</code>
 +
 +----
 +
 +====== Étape 20 — Filtrage ======
 +
 +===== Imposer =====
 +
 +sur toutes les requêtes :
 +
 +<code>
 +tenantId
 +
 +portfolioId
 +</code>
 +
 +afin d'éviter toute fuite de données.
 +
 +----
 +
 +====== Étape 21 — Decorators ======
 +
 +===== Créer =====
 +
 +<code ts>
 +@PortfolioScope()
 +
 +@PropertyGroupScope()
 +</code>
 +
 +pour les futurs modules.
 +
 +----
 +
 +====== Sprint 6-A.2-H ======
 +
 +===== Dashboard Portfolio =====
 +
 +----
 +
 +====== Étape 22 — PortfolioDashboardService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-dashboard.service.ts
 +</code>
 +
 +----
 +
 +===== Agréger =====
 +
 +<code>
 +Properties
 +
 +Reservations
 +
 +Revenue
 +
 +Occupancy
 +
 +Reviews
 +
 +Incidents
 +</code>
 +
 +----
 +
 +====== Étape 23 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /portfolios/{id}/dashboard
 +</code>
 +
 +----
 +
 +====== Étape 24 — Exemple ======
 +
 +===== Réponse =====
 +
 +<code json>
 +{
 +  "properties":124,
 +  "occupancy":81.4,
 +  "revenue":2450000,
 +  "reservations":8421,
 +  "rating":4.7
 +}
 +</code>
 +
 +----
 +
 +====== Étape 25 — KPIs ======
 +
 +===== Mesurer =====
 +
 +<code>
 +Revenue
 +
 +Occupancy
 +
 +ADR
 +
 +RevPAR
 +
 +Reservations
 +
 +Guest Satisfaction
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.2-I ======
 +
 +===== API Enterprise =====
 +
 +----
 +
 +====== Étape 26 — Recherche ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /portfolios/search
 +
 +GET /owners/search
 +
 +GET /operators/search
 +</code>
 +
 +----
 +
 +====== Étape 27 — Pagination ======
 +
 +===== Supporter =====
 +
 +<code>
 +Page
 +
 +Limit
 +
 +Sort
 +
 +Filters
 +</code>
 +
 +sur tous les endpoints.
 +
 +----
 +
 +====== Étape 28 — Export ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /portfolios/{id}/export
 +</code>
 +
 +Formats :
 +
 +<code>
 +CSV
 +
 +Excel
 +
 +PDF
 +</code>
 +
 +----
 +
 +====== Sprint 6-A.2-J ======
 +
 +===== Gouvernance =====
 +
 +----
 +
 +====== Étape 29 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +portfolio.read
 +
 +portfolio.create
 +
 +portfolio.update
 +
 +portfolio.delete
 +
 +portfolio.dashboard
 +
 +owner.manage
 +
 +operator.manage
 +</code>
 +
 +----
 +
 +====== Étape 30 — Audit ======
 +
 +===== Journaliser =====
 +
 +<code>
 +PORTFOLIO_CREATED
 +
 +PORTFOLIO_UPDATED
 +
 +PROPERTY_ASSIGNED
 +
 +OWNER_ASSIGNED
 +
 +OPERATOR_ASSIGNED
 +
 +PORTFOLIO_DASHBOARD_VIEWED
 +</code>
 +
 +----
 +
 +====== Étape 31 — Préparation Sprint 6-B =====
 +
 +Compatible avec :
 +
 +<code>
 +Assets
 +
 +Equipment
 +
 +Lifecycle
 +
 +Depreciation
 +
 +Capital Expenditure
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-A.2 est terminé lorsque :
 +
 +<code>
 +✓ PortfolioModule créé
 +
 +✓ PropertyGroupModule créé
 +
 +✓ OwnerModule créé
 +
 +✓ OperatorModule créé
 +
 +✓ Portfolio Hierarchy créée
 +
 +✓ Portfolio Security créée
 +
 +✓ Portfolio Dashboard créé
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +PortfolioModule
 +
 +PropertyGroupModule
 +
 +OwnerModule
 +
 +OperatorModule
 +
 +PortfolioHierarchyService
 +
 +PortfolioDashboardService
 +
 +Portfolio Security Layer
 +
 +Enterprise Multi-Property Platform
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.1 — Asset Management Core ======
 +
 +===== Objectif =====
 +
 +Mettre en place le moteur de gestion des actifs physiques du parc immobilier.
 +
 +Cette couche permet de gérer :
 +
 +<code>
 +Mobilier
 +
 +Équipements
 +
 +Électroménager
 +
 +Matériel technique
 +
 +Inventaire
 +
 +Cycle de vie
 +</code>
 +
 +sur l'ensemble du portefeuille immobilier.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Asset
 +
 +✓ AssetCategory
 +
 +✓ AssetAssignment
 +
 +✓ AssetLifecycle
 +
 +✓ AssetInventory
 +
 +✓ AssetTracking
 +
 +✓ Enterprise Asset Management
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Portfolio
 +
 +
 +
 +Properties
 +
 +
 +
 +Asset Management
 +
 +├── Asset Catalog
 +├── Asset Assignment
 +├── Lifecycle
 +├── Inventory
 +├── Tracking
 +└── Maintenance Integration
 +
 +
 +
 +Operations
 +
 +
 +
 +Finance
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.1-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — AssetCategory ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model AssetCategory {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  name                  String
 +
 +  code                  String
 +
 +  description           String?
 +
 +  depreciationYears     Int?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  assets                Asset[]
 +
 +  @@unique([
 +    tenantId,
 +    code
 +  ])
 +
 +  @@index([tenantId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — Asset ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model Asset {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  assetCode             String
 +                        @unique
 +
 +  categoryId            String
 +
 +  propertyId            String?
 +
 +  name                  String
 +
 +  description           String?
 +
 +  serialNumber          String?
 +
 +  manufacturer          String?
 +
 +  model                 String?
 +
 +  purchaseDate          DateTime?
 +
 +  purchasePrice         Decimal?
 +                        @db.Decimal(14,2)
 +
 +  currentValue          Decimal?
 +                        @db.Decimal(14,2)
 +
 +  status                AssetStatus
 +
 +  condition             AssetCondition
 +
 +  warrantyUntil         DateTime?
 +
 +  qrCode                String?
 +
 +  barcode               String?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  category              AssetCategory
 +                        @relation(
 +                          fields:[categoryId],
 +                          references:[id]
 +                        )
 +
 +  assignments           AssetAssignment[]
 +
 +  lifecycleEvents       AssetLifecycle[]
 +
 +  @@index([tenantId])
 +
 +  @@index([categoryId])
 +
 +  @@index([propertyId])
 +
 +  @@index([status])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — AssetAssignment ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AssetAssignment {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  assetId               String
 +
 +  propertyId            String
 +
 +  assignedAt            DateTime
 +                        @default(now())
 +
 +  unassignedAt          DateTime?
 +
 +  assignedBy            String?
 +
 +  notes                 String?
 +
 +  asset                 Asset
 +                        @relation(
 +                          fields:[assetId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  @@index([assetId])
 +
 +  @@index([propertyId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — AssetLifecycle ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AssetLifecycle {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  assetId               String
 +
 +  eventType             AssetLifecycleEvent
 +
 +  eventDate             DateTime
 +                        @default(now())
 +
 +  description           String?
 +
 +  cost                  Decimal?
 +                        @db.Decimal(14,2)
 +
 +  metadata              Json?
 +
 +  asset                 Asset
 +                        @relation(
 +                          fields:[assetId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  @@index([assetId])
 +
 +  @@index([eventType])
 +
 +  @@index([eventDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — AssetInventory ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AssetInventory {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  propertyId            String?
 +
 +  inventoryDate         DateTime
 +
 +  totalAssets           Int
 +
 +  verifiedAssets        Int
 +
 +  missingAssets         Int
 +
 +  notes                 String?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([propertyId])
 +
 +  @@index([inventoryDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — AssetTracking ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AssetTracking {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  assetId               String
 +
 +  propertyId            String?
 +
 +  locationDescription   String?
 +
 +  trackedAt             DateTime
 +                        @default(now())
 +
 +  source                TrackingSource
 +
 +  metadata              Json?
 +
 +  @@index([assetId])
 +
 +  @@index([trackedAt])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 7 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum AssetStatus {
 +
 +  ACTIVE
 +
 +  IN_STOCK
 +
 +  IN_MAINTENANCE
 +
 +  RETIRED
 +
 +  LOST
 +
 +  DISPOSED
 +}
 +
 +enum AssetCondition {
 +
 +  EXCELLENT
 +
 +  GOOD
 +
 +  FAIR
 +
 +  POOR
 +
 +  DAMAGED
 +}
 +
 +enum AssetLifecycleEvent {
 +
 +  PURCHASED
 +
 +  ASSIGNED
 +
 +  MOVED
 +
 +  INSPECTED
 +
 +  MAINTAINED
 +
 +  REPAIRED
 +
 +  RETIRED
 +
 +  DISPOSED
 +}
 +
 +enum TrackingSource {
 +
 +  MANUAL
 +
 +  QR_CODE
 +
 +  BARCODE
 +
 +  RFID
 +
 +  NFC
 +
 +  IOT
 +}
 +</code>
 +
 +----
 +
 +====== Étape 8 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name asset_management_core
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.1-B ======
 +
 +===== Asset Management Module =====
 +
 +----
 +
 +====== Étape 9 — Création ======
 +
 +<code>
 +src/modules/assets
 +
 +├── assets
 +
 +├── categories
 +
 +├── assignments
 +
 +├── lifecycle
 +
 +├── inventory
 +
 +├── tracking
 +
 +└── assets.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 10 — Services ======
 +
 +===== Créer =====
 +
 +<code>
 +AssetService
 +
 +AssetCategoryService
 +
 +AssetAssignmentService
 +
 +AssetLifecycleService
 +
 +AssetInventoryService
 +
 +AssetTrackingService
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.1-C ======
 +
 +===== Gestion des Actifs =====
 +
 +----
 +
 +====== Étape 11 — AssetService ======
 +
 +===== Créer =====
 +
 +<code>
 +asset.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createAsset()
 +
 +updateAsset()
 +
 +retireAsset()
 +
 +searchAssets()
 +
 +calculateCurrentValue()
 +</code>
 +
 +----
 +
 +====== Étape 12 — Types d'actifs ======
 +
 +===== Supporter =====
 +
 +<code>
 +Mobilier
 +
 +TV
 +
 +Climatisation
 +
 +Électroménager
 +
 +Literie
 +
 +Sécurité
 +
 +Équipements extérieurs
 +</code>
 +
 +----
 +
 +====== Étape 13 — Codes ======
 +
 +===== Générer =====
 +
 +<code>
 +AST-2027-000001
 +</code>
 +
 +pour chaque actif.
 +
 +----
 +
 +====== Sprint 6-B.1-D ======
 +
 +===== Affectation =====
 +
 +----
 +
 +====== Étape 14 — AssetAssignmentService ======
 +
 +===== Créer =====
 +
 +<code>
 +asset-assignment.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +assignAsset()
 +
 +moveAsset()
 +
 +unassignAsset()
 +
 +getAssetHistory()
 +</code>
 +
 +----
 +
 +====== Étape 15 — Historiser ======
 +
 +===== Conserver =====
 +
 +<code>
 +Date
 +
 +Property
 +
 +Utilisateur
 +
 +Action
 +</code>
 +
 +pour chaque mouvement.
 +
 +----
 +
 +====== Sprint 6-B.1-E ======
 +
 +===== Cycle de Vie =====
 +
 +----
 +
 +====== Étape 16 — AssetLifecycleService ======
 +
 +===== Créer =====
 +
 +<code>
 +asset-lifecycle.service.ts
 +</code>
 +
 +----
 +
 +===== Journaliser =====
 +
 +<code>
 +Achat
 +
 +Affectation
 +
 +Déplacement
 +
 +Réparation
 +
 +Retrait
 +</code>
 +
 +----
 +
 +====== Étape 17 — Méthodes ======
 +
 +<code ts>
 +recordEvent()
 +
 +getTimeline()
 +
 +calculateLifecycleCost()
 +</code>
 +
 +----
 +
 +====== Étape 18 — Finance ======
 +
 +===== Préparer =====
 +
 +<code>
 +Amortissement
 +
 +CAPEX
 +
 +OPEX
 +</code>
 +
 +pour Sprint 6-B.2.
 +
 +----
 +
 +====== Sprint 6-B.1-F ======
 +
 +===== Inventaire =====
 +
 +----
 +
 +====== Étape 19 — AssetInventoryService ======
 +
 +===== Créer =====
 +
 +<code>
 +asset-inventory.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createInventory()
 +
 +verifyAsset()
 +
 +closeInventory()
 +
 +generateVarianceReport()
 +</code>
 +
 +----
 +
 +====== Étape 20 — Contrôles ======
 +
 +===== Identifier =====
 +
 +<code>
 +Actifs présents
 +
 +Actifs manquants
 +
 +Actifs déplacés
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.1-G ======
 +
 +===== Tracking =====
 +
 +----
 +
 +====== Étape 21 — AssetTrackingService ======
 +
 +===== Créer =====
 +
 +<code>
 +asset-tracking.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +trackAsset()
 +
 +scanQrCode()
 +
 +scanBarcode()
 +
 +getLastLocation()
 +</code>
 +
 +----
 +
 +====== Étape 22 — Technologies ======
 +
 +===== Préparer =====
 +
 +<code>
 +QR Code
 +
 +Barcode
 +
 +RFID
 +
 +NFC
 +
 +IoT
 +</code>
 +
 +----
 +
 +====== Étape 23 — Temps réel ======
 +
 +===== Supporter =====
 +
 +<code>
 +Position
 +
 +Historique
 +
 +Mouvements
 +</code>
 +
 +des actifs.
 +
 +----
 +
 +====== Sprint 6-B.1-H ======
 +
 +===== API Asset Management =====
 +
 +----
 +
 +====== Étape 24 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET    /assets
 +
 +GET    /assets/{id}
 +
 +POST   /assets
 +
 +PUT    /assets/{id}
 +
 +DELETE /assets/{id}
 +
 +POST   /assets/{id}/assign
 +
 +POST   /assets/{id}/move
 +
 +GET    /assets/{id}/timeline
 +
 +GET    /assets/inventory
 +</code>
 +
 +----
 +
 +====== Étape 25 — Recherche ======
 +
 +===== Supporter =====
 +
 +<code>
 +Catégorie
 +
 +Statut
 +
 +Property
 +
 +Condition
 +
 +Valeur
 +</code>
 +
 +----
 +
 +====== Étape 26 — Export ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /assets/export
 +</code>
 +
 +Formats :
 +
 +<code>
 +CSV
 +
 +Excel
 +
 +PDF
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.1-I ======
 +
 +===== Sécurité =====
 +
 +----
 +
 +====== Étape 27 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +asset.read
 +
 +asset.create
 +
 +asset.update
 +
 +asset.assign
 +
 +asset.inventory
 +
 +asset.dispose
 +
 +asset.admin
 +</code>
 +
 +----
 +
 +====== Étape 28 — Multi-Propriété ======
 +
 +===== Filtrer =====
 +
 +par :
 +
 +<code>
 +Portfolio
 +
 +PropertyGroup
 +
 +Property
 +</code>
 +
 +sur toutes les requêtes.
 +
 +----
 +
 +====== Étape 29 — Audit ======
 +
 +===== Journaliser =====
 +
 +<code>
 +ASSET_CREATED
 +
 +ASSET_ASSIGNED
 +
 +ASSET_MOVED
 +
 +ASSET_RETIRED
 +
 +INVENTORY_COMPLETED
 +
 +TRACKING_SCAN
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.1-J ======
 +
 +===== Préparation Sprint 6-B.2 =====
 +
 +----
 +
 +====== Étape 30 — Compatible ======
 +
 +Préparer :
 +
 +<code>
 +Depreciation Engine
 +
 +Asset Valuation
 +
 +Capital Planning
 +
 +Lifecycle Forecasting
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-B.1 est terminé lorsque :
 +
 +<code>
 +✓ Asset créé
 +
 +✓ AssetCategory créé
 +
 +✓ AssetAssignment créé
 +
 +✓ AssetLifecycle créé
 +
 +✓ AssetInventory créé
 +
 +✓ AssetTracking créé
 +
 +✓ Audit intégré
 +
 +✓ Multi-Property Ready
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +Asset
 +
 +AssetCategory
 +
 +AssetAssignment
 +
 +AssetLifecycle
 +
 +AssetInventory
 +
 +AssetTracking
 +
 +AssetService
 +
 +AssetAssignmentService
 +
 +AssetLifecycleService
 +
 +AssetInventoryService
 +
 +AssetTrackingService
 +
 +Enterprise Asset Management Platform
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2 — Asset Intelligence & Lifecycle Management ======
 +
 +===== Objectif =====
 +
 +Transformer le registre d'actifs en plateforme patrimoniale Enterprise.
 +
 +Cette couche permet :
 +
 +<code>
 +Valorisation
 +
 +Amortissement
 +
 +Prévision de cycle de vie
 +
 +Planification CAPEX
 +
 +Optimisation maintenance
 +
 +Pilotage patrimonial
 +</code>
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Depreciation Engine
 +
 +✓ Asset Valuation
 +
 +✓ Lifecycle Forecasting
 +
 +✓ Replacement Planning
 +
 +✓ Maintenance Cost Analytics
 +
 +✓ Asset Health Score
 +
 +✓ Asset Intelligence Platform
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Assets
 +
 +
 +
 +Asset Intelligence Engine
 +
 +├── Depreciation Engine
 +├── Asset Valuation
 +├── Lifecycle Forecasting
 +├── Replacement Planning
 +├── Maintenance Analytics
 +├── Asset Health Scoring
 +└── AI Recommendations
 +
 +
 +
 +Portfolio Analytics
 +
 +
 +
 +Capital Planning
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — AssetDepreciation ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model AssetDepreciation {
 +
 +  assetId               String
 +                        @id
 +
 +  acquisitionValue      Decimal
 +                        @db.Decimal(14,2)
 +
 +  residualValue         Decimal
 +                        @db.Decimal(14,2)
 +
 +  usefulLifeYears       Int
 +
 +  annualDepreciation    Decimal
 +                        @db.Decimal(14,2)
 +
 +  accumulatedDepreciation Decimal
 +                        @db.Decimal(14,2)
 +
 +  bookValue             Decimal
 +                        @db.Decimal(14,2)
 +
 +  calculatedAt          DateTime
 +                        @updatedAt
 +
 +  asset                 Asset
 +                        @relation(
 +                          fields:[assetId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — AssetValuation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AssetValuation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  assetId               String
 +
 +  valuationDate         DateTime
 +
 +  estimatedValue        Decimal
 +                        @db.Decimal(14,2)
 +
 +  valuationMethod       AssetValuationMethod
 +
 +  confidenceScore       Float?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  asset                 Asset
 +                        @relation(
 +                          fields:[assetId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  @@index([assetId])
 +
 +  @@index([valuationDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — AssetForecast ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AssetForecast {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  assetId               String
 +
 +  forecastType          AssetForecastType
 +
 +  forecastDate          DateTime
 +
 +  predictedValue        Float
 +
 +  confidenceScore       Float?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([assetId])
 +
 +  @@index([forecastType])
 +
 +  @@index([forecastDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — AssetHealthScore ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AssetHealthScore {
 +
 +  assetId               String
 +                        @id
 +
 +  overallScore          Float
 +
 +  conditionScore        Float
 +
 +  maintenanceScore      Float
 +
 +  utilizationScore      Float
 +
 +  ageScore              Float
 +
 +  riskScore             Float
 +
 +  calculatedAt          DateTime
 +                        @updatedAt
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — AssetRecommendation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AssetRecommendation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  assetId               String
 +
 +  recommendationType    AssetRecommendationType
 +
 +  priority              RecommendationPriority
 +
 +  title                 String
 +
 +  description           String
 +
 +  estimatedCost         Decimal?
 +                        @db.Decimal(14,2)
 +
 +  estimatedSavings      Decimal?
 +                        @db.Decimal(14,2)
 +
 +  implemented           Boolean
 +                        @default(false)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([assetId])
 +
 +  @@index([recommendationType])
 +
 +  @@index([priority])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum AssetValuationMethod {
 +
 +  BOOK_VALUE
 +
 +  MARKET_VALUE
 +
 +  REPLACEMENT_COST
 +
 +  AI_ESTIMATION
 +}
 +
 +enum AssetForecastType {
 +
 +  REPLACEMENT
 +
 +  FAILURE_RISK
 +
 +  MAINTENANCE_COST
 +
 +  VALUE_EVOLUTION
 +}
 +
 +enum AssetRecommendationType {
 +
 +  REPAIR
 +
 +  REPLACE
 +
 +  UPGRADE
 +
 +  INSPECT
 +
 +  RETIRE
 +}
 +
 +enum RecommendationPriority {
 +
 +  LOW
 +
 +  MEDIUM
 +
 +  HIGH
 +
 +  CRITICAL
 +}
 +</code>
 +
 +----
 +
 +====== Étape 7 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name asset_intelligence
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-B ======
 +
 +===== Asset Intelligence Module =====
 +
 +----
 +
 +====== Étape 8 — Création ======
 +
 +<code>
 +src/modules/asset-intelligence
 +
 +├── depreciation
 +
 +├── valuation
 +
 +├── forecasting
 +
 +├── planning
 +
 +├── health
 +
 +├── recommendations
 +
 +└── asset-intelligence.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 9 — Services ======
 +
 +===== Créer =====
 +
 +<code>
 +DepreciationEngineService
 +
 +AssetValuationService
 +
 +LifecycleForecastService
 +
 +ReplacementPlanningService
 +
 +MaintenanceCostAnalyticsService
 +
 +AssetHealthScoreService
 +
 +AssetRecommendationService
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-C ======
 +
 +===== Depreciation Engine =====
 +
 +----
 +
 +====== Étape 10 — DepreciationEngineService ======
 +
 +===== Créer =====
 +
 +<code>
 +depreciation-engine.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +calculateStraightLine()
 +
 +calculateBookValue()
 +
 +calculateAccumulatedDepreciation()
 +
 +generateDepreciationSchedule()
 +</code>
 +
 +----
 +
 +====== Étape 11 — Méthodes comptables ======
 +
 +===== Supporter =====
 +
 +<code>
 +Linéaire
 +
 +Dégressif
 +
 +Personnalisé
 +</code>
 +
 +----
 +
 +====== Étape 12 — Exemple ======
 +
 +<code>
 +Actif
 +
 +10 000 €
 +
 +Durée
 +
 +5 ans
 +
 +
 +
 +2 000 €/an
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-D ======
 +
 +===== Asset Valuation =====
 +
 +----
 +
 +====== Étape 13 — AssetValuationService ======
 +
 +===== Créer =====
 +
 +<code>
 +asset-valuation.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +estimateCurrentValue()
 +
 +estimateReplacementCost()
 +
 +estimateResidualValue()
 +</code>
 +
 +----
 +
 +====== Étape 14 — Facteurs ======
 +
 +===== Utiliser =====
 +
 +<code>
 +Âge
 +
 +État
 +
 +Maintenance
 +
 +Utilisation
 +
 +Marché
 +</code>
 +
 +----
 +
 +====== Étape 15 — Valorisation ======
 +
 +===== Produire =====
 +
 +<code>
 +Valeur brute
 +
 +Valeur nette
 +
 +Valeur marché
 +
 +Valeur remplacement
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-E ======
 +
 +===== Lifecycle Forecasting =====
 +
 +----
 +
 +====== Étape 16 — LifecycleForecastService ======
 +
 +===== Créer =====
 +
 +<code>
 +lifecycle-forecast.service.ts
 +</code>
 +
 +----
 +
 +===== Prévoir =====
 +
 +<code>
 +Fin de vie
 +
 +Risque panne
 +
 +Coût futur
 +
 +Maintenance future
 +</code>
 +
 +----
 +
 +====== Étape 17 — Méthodes ======
 +
 +<code ts>
 +forecastReplacement()
 +
 +forecastFailureRisk()
 +
 +forecastMaintenanceCost()
 +</code>
 +
 +----
 +
 +====== Étape 18 — Exemple ======
 +
 +<code>
 +Climatisation
 +
 +Fin de vie estimée
 +
 +14 mois
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-F ======
 +
 +===== Replacement Planning =====
 +
 +----
 +
 +====== Étape 19 — ReplacementPlanningService ======
 +
 +===== Créer =====
 +
 +<code>
 +replacement-planning.service.ts
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code>
 +CAPEX Forecast
 +
 +Replacement Calendar
 +
 +Investment Plan
 +</code>
 +
 +----
 +
 +====== Étape 20 — Priorisation ======
 +
 +===== Classer =====
 +
 +selon :
 +
 +<code>
 +Health Score
 +
 +Coût maintenance
 +
 +Criticité
 +
 +ROI remplacement
 +</code>
 +
 +----
 +
 +====== Étape 21 — Exemple ======
 +
 +<code>
 +2028
 +
 +12 climatiseurs
 +
 +
 +
 +CAPEX 42 000 €
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-G ======
 +
 +===== Maintenance Cost Analytics =====
 +
 +----
 +
 +====== Étape 22 — MaintenanceCostAnalyticsService ======
 +
 +===== Créer =====
 +
 +<code>
 +maintenance-cost-analytics.service.ts
 +</code>
 +
 +----
 +
 +===== Analyser =====
 +
 +<code>
 +Coûts maintenance
 +
 +Coût possession
 +
 +Coût panne
 +
 +ROI réparation
 +</code>
 +
 +----
 +
 +====== Étape 23 — Sources ======
 +
 +===== Utiliser =====
 +
 +<code>
 +MaintenanceWorkOrder
 +
 +AssetLifecycle
 +
 +AssetValuation
 +</code>
 +
 +----
 +
 +====== Étape 24 — KPI ======
 +
 +===== Mesurer =====
 +
 +<code>
 +Maintenance Cost Ratio
 +
 +Cost Per Asset
 +
 +Failure Cost
 +
 +Replacement ROI
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-H ======
 +
 +===== Asset Health Score =====
 +
 +----
 +
 +====== Étape 25 — AssetHealthScoreService ======
 +
 +===== Créer =====
 +
 +<code>
 +asset-health-score.service.ts
 +</code>
 +
 +----
 +
 +===== Calcul =====
 +
 +<code>
 +Condition         30%
 +
 +Maintenance       25%
 +
 +Age               20%
 +
 +Utilization       15%
 +
 +Risk              10%
 +</code>
 +
 +----
 +
 +====== Étape 26 — Classification ======
 +
 +<code>
 +90-100 Excellent
 +
 +75-89 Healthy
 +
 +50-74 Warning
 +
 +0-49 Critical
 +</code>
 +
 +----
 +
 +====== Étape 27 — Exemple ======
 +
 +<code>
 +Asset Health
 +
 +92
 +
 +Excellent
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-I ======
 +
 +===== Recommandations IA =====
 +
 +----
 +
 +====== Étape 28 — AssetRecommendationService ======
 +
 +===== Créer =====
 +
 +<code>
 +asset-recommendation.service.ts
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code>
 +Remplacement
 +
 +Réparation
 +
 +Inspection
 +
 +Upgrade
 +
 +Retrait
 +</code>
 +
 +----
 +
 +====== Étape 29 — Exemple ======
 +
 +<code>
 +Climatisation
 +
 +Health Score 41
 +
 +
 +
 +Remplacement recommandé
 +</code>
 +
 +----
 +
 +====== Étape 30 — Exemple ======
 +
 +<code>
 +TV
 +
 +Health Score 82
 +
 +
 +
 +Maintenance préventive
 +</code>
 +
 +----
 +
 +====== Sprint 6-B.2-J ======
 +
 +===== Dashboard Intelligence =====
 +
 +----
 +
 +====== Étape 31 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /assets/intelligence
 +
 +GET /assets/{id}/health
 +
 +GET /assets/{id}/valuation
 +
 +GET /assets/{id}/forecast
 +
 +GET /assets/recommendations
 +
 +GET /assets/capex-plan
 +</code>
 +
 +----
 +
 +====== Étape 32 — Exemple ======
 +
 +===== Réponse =====
 +
 +<code json>
 +{
 +  "healthScore":92,
 +  "currentValue":8400,
 +  "replacementRisk":"LOW",
 +  "recommendations":[]
 +}
 +</code>
 +
 +----
 +
 +====== Étape 33 — Analytics ======
 +
 +===== Mesurer =====
 +
 +<code>
 +Forecast Accuracy
 +
 +Maintenance Savings
 +
 +Asset Lifespan
 +
 +CAPEX Accuracy
 +
 +Health Score Trends
 +</code>
 +
 +----
 +
 +====== Gouvernance ======
 +
 +----
 +
 +====== Étape 34 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +asset.intelligence.read
 +
 +asset.intelligence.forecast
 +
 +asset.intelligence.health
 +
 +asset.intelligence.capex
 +
 +asset.intelligence.admin
 +</code>
 +
 +----
 +
 +====== Étape 35 — Audit ======
 +
 +===== Journaliser =====
 +
 +<code>
 +ASSET_HEALTH_UPDATED
 +
 +ASSET_FORECAST_GENERATED
 +
 +ASSET_VALUATION_UPDATED
 +
 +ASSET_RECOMMENDATION_CREATED
 +
 +CAPEX_PLAN_GENERATED
 +</code>
 +
 +----
 +
 +====== Étape 36 — Jobs ======
 +
 +===== Ajouter =====
 +
 +<code>
 +Toutes les nuits
 +
 +Health Score Refresh
 +
 +Forecast Generation
 +
 +Valuation Refresh
 +
 +Recommendation Generation
 +</code>
 +
 +----
 +
 +====== Clôture Domaine Asset ======
 +
 +À la fin du Sprint 6-B.2 :
 +
 +<code>
 +✓ Asset Registry
 +
 +✓ Asset Tracking
 +
 +✓ Asset Lifecycle
 +
 +✓ Depreciation Engine
 +
 +✓ Asset Valuation
 +
 +✓ Forecasting
 +
 +✓ CAPEX Planning
 +
 +✓ Asset Intelligence
 +</code>
 +
 +sont entièrement opérationnels.
 +
 +----
 +
 +====== Sprint 6-C.1 — Portfolio Analytics & Multi-Site KPIs ======
 +
 +===== Objectif =====
 +
 +Construire le cockpit décisionnel consolidé du parc immobilier.
 +
 +Cette couche permet d'obtenir une vue globale :
 +
 +<code>
 +Portefeuilles
 +
 +Groupes
 +
 +Propriétés
 +
 +Revenus
 +
 +Occupation
 +
 +Performance
 +</code>
 +
 +afin de piloter des dizaines, centaines ou milliers de propriétés depuis une interface unique.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Portfolio Dashboard
 +
 +✓ Portfolio Revenue
 +
 +✓ Portfolio Occupancy
 +
 +✓ Portfolio Benchmarking
 +
 +✓ Multi-Site KPIs
 +
 +✓ Executive Reporting
 +
 +✓ Enterprise Portfolio Analytics
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Portfolio
 +
 +
 +
 +Portfolio Analytics Engine
 +
 +├── Revenue Analytics
 +├── Occupancy Analytics
 +├── Reservation Analytics
 +├── Property Performance
 +├── Benchmarking
 +├── Executive KPIs
 +└── Reporting
 +
 +
 +
 +Executive Dashboard
 +
 +
 +
 +Portfolio Intelligence
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — PortfolioAnalyticsSnapshot ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model PortfolioAnalyticsSnapshot {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  portfolioId           String
 +
 +  snapshotDate          DateTime
 +
 +  propertiesCount       Int
 +                        @default(0)
 +
 +  reservationsCount     Int
 +                        @default(0)
 +
 +  revenue               Decimal
 +                        @db.Decimal(14,2)
 +
 +  occupancyRate         Float?
 +
 +  averageRating         Float?
 +
 +  adr                   Decimal?
 +                        @db.Decimal(14,2)
 +
 +  revPar                Decimal?
 +                        @db.Decimal(14,2)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([portfolioId])
 +
 +  @@index([snapshotDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — PortfolioKPI ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioKPI {
 +
 +  portfolioId           String
 +                        @id
 +
 +  occupancyRate         Float?
 +
 +  adr                   Float?
 +
 +  revPar                Float?
 +
 +  revenueGrowth         Float?
 +
 +  reservationGrowth     Float?
 +
 +  guestSatisfaction     Float?
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — PortfolioBenchmark ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioBenchmark {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  portfolioId           String
 +
 +  metric                PortfolioBenchmarkMetric
 +
 +  portfolioValue        Float
 +
 +  benchmarkValue        Float
 +
 +  variancePercent       Float
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([portfolioId])
 +
 +  @@index([metric])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — ExecutiveReport ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model ExecutiveReport {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  portfolioId           String?
 +
 +  reportType            ExecutiveReportType
 +
 +  periodStart           DateTime
 +
 +  periodEnd             DateTime
 +
 +  generatedAt           DateTime
 +                        @default(now())
 +
 +  storagePath           String?
 +
 +  createdBy             String?
 +
 +  @@index([tenantId])
 +
 +  @@index([portfolioId])
 +
 +  @@index([reportType])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum PortfolioBenchmarkMetric {
 +
 +  REVENUE
 +
 +  OCCUPANCY
 +
 +  ADR
 +
 +  REVPAR
 +
 +  SATISFACTION
 +
 +  RESERVATIONS
 +}
 +
 +enum ExecutiveReportType {
 +
 +  DAILY
 +
 +  WEEKLY
 +
 +  MONTHLY
 +
 +  QUARTERLY
 +
 +  ANNUAL
 +
 +  CUSTOM
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name portfolio_analytics
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-B ======
 +
 +===== Portfolio Analytics Module =====
 +
 +----
 +
 +====== Étape 7 — Création ======
 +
 +<code>
 +src/modules/portfolio-analytics
 +
 +├── dashboard
 +
 +├── revenue
 +
 +├── occupancy
 +
 +├── benchmarking
 +
 +├── reporting
 +
 +├── kpis
 +
 +└── portfolio-analytics.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 8 — Services ======
 +
 +===== Créer =====
 +
 +<code>
 +PortfolioDashboardService
 +
 +PortfolioRevenueService
 +
 +PortfolioOccupancyService
 +
 +PortfolioBenchmarkingService
 +
 +ExecutiveReportingService
 +
 +PortfolioKPIService
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-C ======
 +
 +===== Revenue Analytics =====
 +
 +----
 +
 +====== Étape 9 — PortfolioRevenueService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-revenue.service.ts
 +</code>
 +
 +----
 +
 +===== Calculer =====
 +
 +<code>
 +Gross Revenue
 +
 +Net Revenue
 +
 +Revenue Growth
 +
 +Revenue By Property
 +
 +Revenue By Group
 +</code>
 +
 +----
 +
 +====== Étape 10 — Sources ======
 +
 +===== Utiliser =====
 +
 +<code>
 +Reservations
 +
 +Invoices
 +
 +Payments
 +
 +Refunds
 +</code>
 +
 +----
 +
 +====== Étape 11 — KPIs ======
 +
 +===== Produire =====
 +
 +<code>
 +ADR
 +
 +RevPAR
 +
 +Revenue Per Property
 +
 +Revenue Per Portfolio
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-D ======
 +
 +===== Occupancy Analytics =====
 +
 +----
 +
 +====== Étape 12 — PortfolioOccupancyService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-occupancy.service.ts
 +</code>
 +
 +----
 +
 +===== Mesurer =====
 +
 +<code>
 +Occupancy Rate
 +
 +Available Nights
 +
 +Booked Nights
 +
 +Lost Nights
 +
 +Capacity Usage
 +</code>
 +
 +----
 +
 +====== Étape 13 — Segmentation ======
 +
 +===== Analyser =====
 +
 +par :
 +
 +<code>
 +Portfolio
 +
 +Property Group
 +
 +Property
 +
 +Region
 +
 +Category
 +</code>
 +
 +----
 +
 +====== Étape 14 — KPIs ======
 +
 +===== Calculer =====
 +
 +<code>
 +Occupancy %
 +
 +Average Stay
 +
 +Booking Window
 +
 +Seasonality
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-E ======
 +
 +===== Multi-Site KPIs =====
 +
 +----
 +
 +====== Étape 15 — PortfolioKPIService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-kpi.service.ts
 +</code>
 +
 +----
 +
 +===== Agréger =====
 +
 +<code>
 +Revenue
 +
 +Occupancy
 +
 +Reservations
 +
 +Reviews
 +
 +Operations
 +
 +Assets
 +</code>
 +
 +----
 +
 +====== Étape 16 — Executive KPIs ======
 +
 +===== Calculer =====
 +
 +<code>
 +ADR
 +
 +RevPAR
 +
 +Occupancy
 +
 +Revenue Growth
 +
 +Guest Satisfaction
 +
 +Asset Utilization
 +</code>
 +
 +----
 +
 +====== Étape 17 — Score Global ======
 +
 +===== Construire =====
 +
 +<code>
 +Portfolio Health Score
 +</code>
 +
 +à partir de :
 +
 +<code>
 +Revenue
 +
 +Occupancy
 +
 +Reviews
 +
 +Operations
 +
 +Assets
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-F ======
 +
 +===== Benchmarking =====
 +
 +----
 +
 +====== Étape 18 — PortfolioBenchmarkingService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-benchmarking.service.ts
 +</code>
 +
 +----
 +
 +===== Comparer =====
 +
 +<code>
 +Portfolios
 +
 +Property Groups
 +
 +Properties
 +</code>
 +
 +----
 +
 +====== Étape 19 — Classements ======
 +
 +===== Identifier =====
 +
 +<code>
 +Top Revenue
 +
 +Top Occupancy
 +
 +Top Reviews
 +
 +Top Growth
 +</code>
 +
 +----
 +
 +====== Étape 20 — Variances ======
 +
 +===== Calculer =====
 +
 +<code>
 +Portfolio
 +
 +vs
 +
 +Average Portfolio
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-G ======
 +
 +===== Executive Reporting =====
 +
 +----
 +
 +====== Étape 21 — ExecutiveReportingService ======
 +
 +===== Créer =====
 +
 +<code>
 +executive-reporting.service.ts
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code>
 +Daily Report
 +
 +Weekly Report
 +
 +Monthly Report
 +
 +Board Report
 +</code>
 +
 +----
 +
 +====== Étape 22 — Formats ======
 +
 +===== Supporter =====
 +
 +<code>
 +PDF
 +
 +Excel
 +
 +CSV
 +</code>
 +
 +----
 +
 +====== Étape 23 — Contenu ======
 +
 +===== Inclure =====
 +
 +<code>
 +Revenue
 +
 +Occupancy
 +
 +Reservations
 +
 +Incidents
 +
 +Assets
 +
 +Forecasts
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-H ======
 +
 +===== Portfolio Dashboard =====
 +
 +----
 +
 +====== Étape 24 — PortfolioDashboardService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-dashboard.service.ts
 +</code>
 +
 +----
 +
 +===== Agréger =====
 +
 +<code>
 +Revenue
 +
 +Occupancy
 +
 +Reservations
 +
 +Properties
 +
 +Reviews
 +
 +Assets
 +</code>
 +
 +----
 +
 +====== Étape 25 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /portfolio/dashboard
 +
 +GET /portfolio/{id}/dashboard
 +</code>
 +
 +----
 +
 +====== Étape 26 — Exemple ======
 +
 +===== Réponse =====
 +
 +<code json>
 +{
 +  "properties":245,
 +  "occupancy":82.4,
 +  "revenue":8450000,
 +  "adr":142,
 +  "revpar":117,
 +  "portfolioHealth":91
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-I ======
 +
 +===== API Analytics =====
 +
 +----
 +
 +====== Étape 27 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /portfolio/analytics/revenue
 +
 +GET /portfolio/analytics/occupancy
 +
 +GET /portfolio/analytics/kpis
 +
 +GET /portfolio/analytics/benchmark
 +
 +GET /portfolio/reports
 +
 +POST /portfolio/reports
 +</code>
 +
 +----
 +
 +====== Étape 28 — Filtres ======
 +
 +===== Supporter =====
 +
 +<code>
 +Portfolio
 +
 +Property Group
 +
 +Property
 +
 +Date Range
 +
 +Region
 +
 +Category
 +</code>
 +
 +----
 +
 +====== Étape 29 — Export ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /portfolio/reports/{id}/download
 +</code>
 +
 +Formats :
 +
 +<code>
 +PDF
 +
 +Excel
 +
 +CSV
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.1-J ======
 +
 +===== Gouvernance =====
 +
 +----
 +
 +====== Étape 30 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +portfolio.analytics.read
 +
 +portfolio.analytics.export
 +
 +portfolio.analytics.benchmark
 +
 +portfolio.analytics.executive
 +
 +portfolio.analytics.admin
 +</code>
 +
 +----
 +
 +====== Étape 31 — Audit ======
 +
 +===== Journaliser =====
 +
 +<code>
 +PORTFOLIO_DASHBOARD_VIEWED
 +
 +PORTFOLIO_KPI_CALCULATED
 +
 +BENCHMARK_GENERATED
 +
 +EXECUTIVE_REPORT_CREATED
 +
 +REPORT_DOWNLOADED
 +</code>
 +
 +----
 +
 +====== Étape 32 — Jobs ======
 +
 +===== Ajouter =====
 +
 +<code>
 +Toutes les heures
 +
 +Portfolio KPI Refresh
 +
 +Toutes les nuits
 +
 +Analytics Snapshot
 +
 +Benchmark Refresh
 +
 +Executive Report Generation
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 6-C.2 ======
 +
 +Compatible avec :
 +
 +<code>
 +Forecasting
 +
 +Portfolio Intelligence
 +
 +Executive AI
 +
 +Investment Planning
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-C.1 est terminé lorsque :
 +
 +<code>
 +✓ Portfolio Dashboard créé
 +
 +✓ Revenue Analytics créé
 +
 +✓ Occupancy Analytics créé
 +
 +✓ Benchmarking créé
 +
 +✓ Executive Reporting créé
 +
 +✓ Multi-Site KPIs créés
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +PortfolioAnalyticsSnapshot
 +
 +PortfolioKPI
 +
 +PortfolioBenchmark
 +
 +ExecutiveReport
 +
 +PortfolioDashboardService
 +
 +PortfolioRevenueService
 +
 +PortfolioOccupancyService
 +
 +PortfolioBenchmarkingService
 +
 +ExecutiveReportingService
 +
 +Portfolio Analytics Platform
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2 — Portfolio Intelligence & Prévisions Multi-Sites ======
 +
 +===== Objectif =====
 +
 +Transformer les analytics consolidés en plateforme décisionnelle prédictive Enterprise.
 +
 +Cette couche permet :
 +
 +<code>
 +Prévisions
 +
 +Planification stratégique
 +
 +Détection d'opportunités
 +
 +Prévisions revenus
 +
 +Prévisions occupation
 +
 +Pilotage d'investissement
 +</code>
 +
 +sur l'ensemble du portefeuille immobilier.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Portfolio Forecasting
 +
 +✓ Revenue Forecast
 +
 +✓ Occupancy Forecast
 +
 +✓ Investment Insights
 +
 +✓ Portfolio Health Score
 +
 +✓ Executive AI Insights
 +
 +✓ Portfolio Intelligence Platform
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Portfolio Analytics
 +
 +
 +
 +Portfolio Intelligence Engine
 +
 +├── Revenue Forecast
 +├── Occupancy Forecast
 +├── Investment Insights
 +├── Risk Analysis
 +├── Portfolio Health Score
 +├── Executive AI Insights
 +└── Strategic Recommendations
 +
 +
 +
 +Executive Management
 +
 +
 +
 +Investment Planning
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — PortfolioForecast ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model PortfolioForecast {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  portfolioId           String
 +
 +  forecastType          PortfolioForecastType
 +
 +  forecastDate          DateTime
 +
 +  predictedValue        Float
 +
 +  confidenceScore       Float?
 +
 +  generatedAt           DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([portfolioId])
 +
 +  @@index([forecastType])
 +
 +  @@index([forecastDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — PortfolioInsight ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioInsight {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  portfolioId           String?
 +
 +  category              PortfolioInsightCategory
 +
 +  severity              InsightSeverity
 +
 +  title                 String
 +
 +  description           String
 +
 +  recommendation        String?
 +
 +  impactScore           Float?
 +
 +  implemented           Boolean
 +                        @default(false)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([portfolioId])
 +
 +  @@index([category])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — PortfolioHealthScore ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioHealthScore {
 +
 +  portfolioId           String
 +                        @id
 +
 +  overallScore          Float
 +
 +  revenueScore          Float
 +
 +  occupancyScore        Float
 +
 +  guestScore            Float
 +
 +  operationsScore       Float
 +
 +  assetScore            Float
 +
 +  growthScore           Float
 +
 +  calculatedAt          DateTime
 +                        @updatedAt
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — InvestmentRecommendation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model InvestmentRecommendation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  portfolioId           String
 +
 +  recommendationType    InvestmentRecommendationType
 +
 +  priority              RecommendationPriority
 +
 +  title                 String
 +
 +  description           String
 +
 +  estimatedInvestment   Decimal?
 +                        @db.Decimal(14,2)
 +
 +  estimatedReturn       Decimal?
 +                        @db.Decimal(14,2)
 +
 +  roiPercent            Float?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([portfolioId])
 +
 +  @@index([recommendationType])
 +
 +  @@index([priority])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum PortfolioForecastType {
 +
 +  REVENUE
 +
 +  OCCUPANCY
 +
 +  RESERVATIONS
 +
 +  REVPAR
 +
 +  ADR
 +}
 +
 +enum PortfolioInsightCategory {
 +
 +  REVENUE
 +
 +  OCCUPANCY
 +
 +  OPERATIONS
 +
 +  ASSETS
 +
 +  INVESTMENT
 +
 +  GROWTH
 +}
 +
 +enum InvestmentRecommendationType {
 +
 +  ACQUISITION
 +
 +  RENOVATION
 +
 +  REPLACEMENT
 +
 +  EXPANSION
 +
 +  OPTIMIZATION
 +
 +  DIVESTMENT
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name portfolio_intelligence
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-B ======
 +
 +===== Portfolio Intelligence Module =====
 +
 +----
 +
 +====== Étape 7 — Création ======
 +
 +<code>
 +src/modules/portfolio-intelligence
 +
 +├── forecasts
 +
 +├── revenue
 +
 +├── occupancy
 +
 +├── investments
 +
 +├── health
 +
 +├── insights
 +
 +└── portfolio-intelligence.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 8 — Services ======
 +
 +===== Créer =====
 +
 +<code>
 +PortfolioForecastService
 +
 +RevenueForecastService
 +
 +OccupancyForecastService
 +
 +InvestmentInsightService
 +
 +PortfolioHealthScoreService
 +
 +ExecutiveInsightService
 +
 +InvestmentRecommendationService
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-C ======
 +
 +===== Revenue Forecast =====
 +
 +----
 +
 +====== Étape 9 — RevenueForecastService ======
 +
 +===== Créer =====
 +
 +<code>
 +revenue-forecast.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +forecastRevenue()
 +
 +forecastADR()
 +
 +forecastRevPAR()
 +
 +forecastGrowth()
 +</code>
 +
 +----
 +
 +====== Étape 10 — Sources ======
 +
 +===== Utiliser =====
 +
 +<code>
 +Reservations
 +
 +Payments
 +
 +Invoices
 +
 +Portfolio Analytics
 +
 +Seasonality
 +</code>
 +
 +----
 +
 +====== Étape 11 — Prévisions ======
 +
 +===== Produire =====
 +
 +<code>
 +30 jours
 +
 +90 jours
 +
 +12 mois
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-D ======
 +
 +===== Occupancy Forecast =====
 +
 +----
 +
 +====== Étape 12 — OccupancyForecastService ======
 +
 +===== Créer =====
 +
 +<code>
 +occupancy-forecast.service.ts
 +</code>
 +
 +----
 +
 +===== Prévoir =====
 +
 +<code>
 +Occupancy
 +
 +Available Nights
 +
 +Demand
 +
 +Booking Pace
 +</code>
 +
 +----
 +
 +====== Étape 13 — Méthodes ======
 +
 +<code ts>
 +forecastOccupancy()
 +
 +forecastDemand()
 +
 +forecastSeasonality()
 +</code>
 +
 +----
 +
 +====== Étape 14 — Segmentation ======
 +
 +===== Calculer =====
 +
 +par :
 +
 +<code>
 +Portfolio
 +
 +Property Group
 +
 +Property
 +
 +Region
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-E ======
 +
 +===== Investment Insights =====
 +
 +----
 +
 +====== Étape 15 — InvestmentInsightService ======
 +
 +===== Créer =====
 +
 +<code>
 +investment-insight.service.ts
 +</code>
 +
 +----
 +
 +===== Identifier =====
 +
 +<code>
 +Expansion
 +
 +Renovation
 +
 +Asset Replacement
 +
 +Optimization
 +
 +Divestment
 +</code>
 +
 +----
 +
 +====== Étape 16 — Analyse ======
 +
 +===== Utiliser =====
 +
 +<code>
 +Revenue
 +
 +Occupancy
 +
 +Assets
 +
 +Maintenance
 +
 +Guest Satisfaction
 +</code>
 +
 +----
 +
 +====== Étape 17 — Exemple ======
 +
 +<code>
 +Property Group Paris
 +
 +ROI potentiel
 +
 +18%
 +
 +
 +
 +Rénovation recommandée
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-F ======
 +
 +===== Portfolio Health Score =====
 +
 +----
 +
 +====== Étape 18 — PortfolioHealthScoreService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-health-score.service.ts
 +</code>
 +
 +----
 +
 +===== Calcul =====
 +
 +<code>
 +Revenue           25%
 +
 +Occupancy         20%
 +
 +Guest Score       15%
 +
 +Operations        15%
 +
 +Assets            15%
 +
 +Growth            10%
 +</code>
 +
 +----
 +
 +====== Étape 19 — Classification ======
 +
 +<code>
 +90-100 Excellent
 +
 +75-89 Healthy
 +
 +50-74 Warning
 +
 +0-49 Critical
 +</code>
 +
 +----
 +
 +====== Étape 20 — Exemple ======
 +
 +<code>
 +Portfolio Health
 +
 +93
 +
 +Excellent
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-G ======
 +
 +===== Executive AI Insights =====
 +
 +----
 +
 +====== Étape 21 — ExecutiveInsightService ======
 +
 +===== Créer =====
 +
 +<code>
 +executive-insight.service.ts
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code>
 +Revenue Opportunities
 +
 +Occupancy Risks
 +
 +Growth Opportunities
 +
 +Asset Risks
 +
 +Investment Priorities
 +</code>
 +
 +----
 +
 +====== Étape 22 — Exemple ======
 +
 +<code>
 +Les propriétés côtières
 +
 +↑ 22%
 +
 +prévision revenus été
 +
 +
 +
 +Renforcer l'inventaire
 +</code>
 +
 +----
 +
 +====== Étape 23 — Exemple ======
 +
 +<code>
 +Le groupe Europe Nord
 +
 +
 +
 +Occupation en baisse
 +
 +-7%
 +
 +
 +
 +Action recommandée
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-H ======
 +
 +===== Recommandations d'Investissement =====
 +
 +----
 +
 +====== Étape 24 — InvestmentRecommendationService ======
 +
 +===== Créer =====
 +
 +<code>
 +investment-recommendation.service.ts
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code>
 +CAPEX
 +
 +Expansion
 +
 +Acquisition
 +
 +Renovation
 +
 +Cession
 +</code>
 +
 +----
 +
 +====== Étape 25 — Priorisation ======
 +
 +===== Utiliser =====
 +
 +<code>
 +ROI
 +
 +Health Score
 +
 +Forecast
 +
 +Asset Age
 +
 +Revenue Potential
 +</code>
 +
 +----
 +
 +====== Étape 26 — Exemple ======
 +
 +<code>
 +CAPEX
 +
 +250 000 €
 +
 +ROI estimé
 +
 +31%
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-I ======
 +
 +===== Dashboard Intelligence =====
 +
 +----
 +
 +====== Étape 27 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /portfolio/intelligence
 +
 +GET /portfolio/forecasts
 +
 +GET /portfolio/insights
 +
 +GET /portfolio/health
 +
 +GET /portfolio/investments
 +
 +GET /portfolio/recommendations
 +</code>
 +
 +----
 +
 +====== Étape 28 — Exemple ======
 +
 +===== Réponse =====
 +
 +<code json>
 +{
 +  "revenueForecast":12450000,
 +  "occupancyForecast":84.2,
 +  "portfolioHealth":93,
 +  "investmentOpportunities":12
 +}
 +</code>
 +
 +----
 +
 +====== Étape 29 — Analytics IA ======
 +
 +===== Mesurer =====
 +
 +<code>
 +Forecast Accuracy
 +
 +Investment ROI
 +
 +Health Score Trend
 +
 +Revenue Prediction Accuracy
 +
 +Recommendation Adoption
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-J ======
 +
 +===== Gouvernance =====
 +
 +----
 +
 +====== Étape 30 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +portfolio.intelligence.read
 +
 +portfolio.intelligence.forecast
 +
 +portfolio.intelligence.investment
 +
 +portfolio.intelligence.health
 +
 +portfolio.intelligence.executive
 +</code>
 +
 +----
 +
 +====== Étape 31 — Audit ======
 +
 +===== Journaliser =====
 +
 +<code>
 +PORTFOLIO_FORECAST_GENERATED
 +
 +PORTFOLIO_HEALTH_UPDATED
 +
 +EXECUTIVE_INSIGHT_CREATED
 +
 +INVESTMENT_RECOMMENDATION_CREATED
 +
 +INTELLIGENCE_DASHBOARD_VIEWED
 +</code>
 +
 +----
 +
 +====== Étape 32 — Jobs ======
 +
 +===== Ajouter =====
 +
 +<code>
 +Toutes les nuits
 +
 +Portfolio Forecast Refresh
 +
 +Portfolio Health Refresh
 +
 +Executive Insights Generation
 +
 +Investment Recommendation Refresh
 +</code>
 +
 +----
 +
 +====== Clôture Domaine Analytics ======
 +
 +À la fin du Sprint 6-C.2 :
 +
 +<code>
 +✓ Portfolio Analytics
 +
 +✓ Benchmarking
 +
 +✓ Forecasting
 +
 +✓ Executive Reporting
 +
 +✓ Portfolio Health Score
 +
 +✓ Investment Intelligence
 +
 +✓ Executive AI Insights
 +</code>
 +
 +sont entièrement opérationnels.
 +
 +----
 +
 +====== Préparation Sprint 6-D ======
 +
 +Compatible avec :
 +
 +<code>
 +Governance
 +
 +Delegation
 +
 +Approvals
 +
 +Compliance
 +
 +Enterprise Controls
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-C.2 est terminé lorsque :
 +
 +<code>
 +✓ Portfolio Forecasting créé
 +
 +✓ Revenue Forecast créé
 +
 +✓ Occupancy Forecast créé
 +
 +✓ Investment Insights créés
 +
 +✓ Portfolio Health Score créé
 +
 +✓ Executive AI Insights créés
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +PortfolioForecast
 +
 +PortfolioInsight
 +
 +PortfolioHealthScore
 +
 +InvestmentRecommendation
 +
 +PortfolioForecastService
 +
 +RevenueForecastService
 +
 +OccupancyForecastService
 +
 +InvestmentInsightService
 +
 +PortfolioHealthScoreService
 +
 +ExecutiveInsightService
 +
 +InvestmentRecommendationService
 +
 +Portfolio Intelligence Platform
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1 — Enterprise Governance & Multi-Site Security ======
 +
 +===== Objectif =====
 +
 +Mettre en place la couche de gouvernance Enterprise du parc immobilier.
 +
 +Cette couche permet de contrôler :
 +
 +<code>
 +Accès
 +
 +Délégations
 +
 +Validations
 +
 +Conformité
 +
 +Séparation des responsabilités
 +
 +Traçabilité
 +</code>
 +
 +sur l'ensemble des portefeuilles, groupes et propriétés.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Portfolio RBAC
 +
 +✓ Delegation
 +
 +✓ Approval Workflow
 +
 +✓ Compliance Controls
 +
 +✓ Multi-Site Permissions
 +
 +✓ Governance Dashboard
 +
 +✓ Enterprise Governance Platform
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Tenant
 +
 +
 +
 +Governance Layer
 +
 +├── RBAC
 +├── Delegation
 +├── Approval Workflow
 +├── Compliance
 +├── Audit
 +└── Governance Dashboard
 +
 +
 +
 +Portfolio
 +
 +
 +
 +Property Groups
 +
 +
 +
 +Properties
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — PortfolioRole ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model PortfolioRole {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  name                  String
 +
 +  code                  String
 +
 +  description           String?
 +
 +  systemRole            Boolean
 +                        @default(false)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  permissions           PortfolioPermission[]
 +
 +  assignments           PortfolioRoleAssignment[]
 +
 +  @@unique([tenantId, code])
 +
 +  @@index([tenantId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — PortfolioPermission ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioPermission {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  roleId                String
 +
 +  permission            String
 +
 +  role                  PortfolioRole
 +                        @relation(
 +                          fields:[roleId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  @@index([roleId])
 +
 +  @@index([permission])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — PortfolioRoleAssignment ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioRoleAssignment {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  userId                String
 +
 +  roleId                String
 +
 +  portfolioId           String?
 +
 +  propertyGroupId       String?
 +
 +  propertyId            String?
 +
 +  assignedAt            DateTime
 +                        @default(now())
 +
 +  expiresAt             DateTime?
 +
 +  role                  PortfolioRole
 +                        @relation(
 +                          fields:[roleId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([userId])
 +
 +  @@index([portfolioId])
 +
 +  @@index([propertyId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Delegation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model Delegation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  delegatorUserId       String
 +
 +  delegateUserId        String
 +
 +  portfolioId           String?
 +
 +  propertyGroupId       String?
 +
 +  propertyId            String?
 +
 +  startDate             DateTime
 +
 +  endDate               DateTime
 +
 +  active                Boolean
 +                        @default(true)
 +
 +  reason                String?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([delegatorUserId])
 +
 +  @@index([delegateUserId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — ApprovalRequest ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model ApprovalRequest {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  approvalType          ApprovalType
 +
 +  status                ApprovalStatus
 +
 +  entityType            String
 +
 +  entityId              String
 +
 +  requestedBy           String
 +
 +  approvedBy            String?
 +
 +  requestedAt           DateTime
 +                        @default(now())
 +
 +  approvedAt            DateTime?
 +
 +  comment               String?
 +
 +  @@index([tenantId])
 +
 +  @@index([status])
 +
 +  @@index([approvalType])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — ComplianceControl ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model ComplianceControl {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  code                  String
 +
 +  title                 String
 +
 +  category              ComplianceCategory
 +
 +  enabled               Boolean
 +                        @default(true)
 +
 +  severity              ComplianceSeverity
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([category])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 7 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum ApprovalType {
 +
 +  PROPERTY_CREATION
 +
 +  PROPERTY_UPDATE
 +
 +  OWNER_ASSIGNMENT
 +
 +  OPERATOR_ASSIGNMENT
 +
 +  CAPEX_REQUEST
 +
 +  CONTRACT_APPROVAL
 +}
 +
 +enum ApprovalStatus {
 +
 +  PENDING
 +
 +  APPROVED
 +
 +  REJECTED
 +
 +  CANCELLED
 +}
 +
 +enum ComplianceCategory {
 +
 +  SECURITY
 +
 +  FINANCIAL
 +
 +  LEGAL
 +
 +  GDPR
 +
 +  OPERATIONS
 +}
 +
 +enum ComplianceSeverity {
 +
 +  LOW
 +
 +  MEDIUM
 +
 +  HIGH
 +
 +  CRITICAL
 +}
 +</code>
 +
 +----
 +
 +====== Étape 8 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name governance_core
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-B ======
 +
 +===== Governance Module =====
 +
 +----
 +
 +====== Étape 9 — Création ======
 +
 +<code>
 +src/modules/governance
 +
 +├── roles
 +
 +├── permissions
 +
 +├── delegations
 +
 +├── approvals
 +
 +├── compliance
 +
 +├── dashboard
 +
 +└── governance.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 10 — Services ======
 +
 +===== Créer =====
 +
 +<code>
 +PortfolioRBACService
 +
 +DelegationService
 +
 +ApprovalWorkflowService
 +
 +ComplianceControlService
 +
 +GovernanceDashboardService
 +
 +PermissionResolverService
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-C ======
 +
 +===== Portfolio RBAC =====
 +
 +----
 +
 +====== Étape 11 — PortfolioRBACService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-rbac.service.ts
 +</code>
 +
 +----
 +
 +===== Rôles système =====
 +
 +<code>
 +PORTFOLIO_ADMIN
 +
 +PORTFOLIO_MANAGER
 +
 +GROUP_MANAGER
 +
 +PROPERTY_MANAGER
 +
 +OWNER_VIEWER
 +
 +AUDITOR
 +</code>
 +
 +----
 +
 +====== Étape 12 — Permissions ======
 +
 +===== Supporter =====
 +
 +<code>
 +Read
 +
 +Create
 +
 +Update
 +
 +Delete
 +
 +Approve
 +
 +Export
 +
 +Admin
 +</code>
 +
 +par scope.
 +
 +----
 +
 +====== Étape 13 — Scopes ======
 +
 +===== Appliquer =====
 +
 +<code>
 +Portfolio
 +
 +Property Group
 +
 +Property
 +</code>
 +
 +sur chaque permission.
 +
 +----
 +
 +====== Sprint 6-D.1-D ======
 +
 +===== Délégations =====
 +
 +----
 +
 +====== Étape 14 — DelegationService ======
 +
 +===== Créer =====
 +
 +<code>
 +delegation.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createDelegation()
 +
 +revokeDelegation()
 +
 +validateDelegation()
 +
 +getActiveDelegations()
 +</code>
 +
 +----
 +
 +====== Étape 15 — Cas d'usage ======
 +
 +===== Supporter =====
 +
 +<code>
 +Congés
 +
 +Remplacement
 +
 +Mission temporaire
 +
 +Support régional
 +</code>
 +
 +----
 +
 +====== Étape 16 — Expiration ======
 +
 +===== Désactiver =====
 +
 +automatiquement à :
 +
 +<code>
 +endDate
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-E ======
 +
 +===== Workflow d'Approbation =====
 +
 +----
 +
 +====== Étape 17 — ApprovalWorkflowService ======
 +
 +===== Créer =====
 +
 +<code>
 +approval-workflow.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +submitApproval()
 +
 +approve()
 +
 +reject()
 +
 +cancelApproval()
 +</code>
 +
 +----
 +
 +====== Étape 18 — Workflows ======
 +
 +===== Supporter =====
 +
 +<code>
 +Nouvelle propriété
 +
 +Changement propriétaire
 +
 +CAPEX
 +
 +Contrat
 +
 +Suppression actif
 +</code>
 +
 +----
 +
 +====== Étape 19 — Validation ======
 +
 +===== Exiger =====
 +
 +un approbateur différent du demandeur.
 +
 +----
 +
 +====== Sprint 6-D.1-F ======
 +
 +===== Contrôles de Conformité =====
 +
 +----
 +
 +====== Étape 20 — ComplianceControlService ======
 +
 +===== Créer =====
 +
 +<code>
 +compliance-control.service.ts
 +</code>
 +
 +----
 +
 +===== Vérifier =====
 +
 +<code>
 +RGPD
 +
 +Audit
 +
 +Sécurité
 +
 +Finance
 +
 +Exploitation
 +</code>
 +
 +----
 +
 +====== Étape 21 — Méthodes ======
 +
 +<code ts>
 +runControls()
 +
 +evaluateCompliance()
 +
 +createViolation()
 +
 +closeViolation()
 +</code>
 +
 +----
 +
 +====== Étape 22 — Scores ======
 +
 +===== Calculer =====
 +
 +<code>
 +Compliance Score
 +
 +Risk Score
 +
 +Violation Rate
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-G ======
 +
 +===== Dashboard Gouvernance =====
 +
 +----
 +
 +====== Étape 23 — GovernanceDashboardService ======
 +
 +===== Créer =====
 +
 +<code>
 +governance-dashboard.service.ts
 +</code>
 +
 +----
 +
 +===== Afficher =====
 +
 +<code>
 +Approvals Pending
 +
 +Active Delegations
 +
 +Compliance Score
 +
 +Open Violations
 +
 +Audit Events
 +</code>
 +
 +----
 +
 +====== Étape 24 — KPI ======
 +
 +===== Mesurer =====
 +
 +<code>
 +Approval Time
 +
 +Compliance Rate
 +
 +Policy Violations
 +
 +Delegation Usage
 +
 +Audit Coverage
 +</code>
 +
 +----
 +
 +====== Étape 25 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /governance/dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-H ======
 +
 +===== API Gouvernance =====
 +
 +----
 +
 +====== Étape 26 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET    /governance/roles
 +
 +POST   /governance/roles
 +
 +GET    /governance/delegations
 +
 +POST   /governance/delegations
 +
 +GET    /governance/approvals
 +
 +POST   /governance/approvals
 +
 +POST   /governance/approvals/{id}/approve
 +
 +POST   /governance/approvals/{id}/reject
 +
 +GET    /governance/compliance
 +</code>
 +
 +----
 +
 +====== Étape 27 — Exemple ======
 +
 +===== Approbation =====
 +
 +<code json>
 +{
 +  "approvalType":"CAPEX_REQUEST",
 +  "entityType":"Asset",
 +  "entityId":"ast_123"
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-I ======
 +
 +===== Sécurité Enterprise =====
 +
 +----
 +
 +====== Étape 28 — Permission Resolver ======
 +
 +===== Créer =====
 +
 +<code>
 +permission-resolver.service.ts
 +</code>
 +
 +----
 +
 +===== Résoudre =====
 +
 +dans l'ordre :
 +
 +<code>
 +Role
 +
 +
 +
 +Delegation
 +
 +
 +
 +Portfolio Scope
 +
 +
 +
 +Property Scope
 +</code>
 +
 +----
 +
 +====== Étape 29 — Middleware ======
 +
 +===== Ajouter =====
 +
 +<code ts>
 +@RequirePortfolioPermission()
 +
 +@RequireApproval()
 +</code>
 +
 +----
 +
 +====== Étape 30 — Audit ======
 +
 +===== Journaliser =====
 +
 +<code>
 +ROLE_ASSIGNED
 +
 +DELEGATION_CREATED
 +
 +APPROVAL_SUBMITTED
 +
 +APPROVAL_APPROVED
 +
 +COMPLIANCE_CHECK_EXECUTED
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-J ======
 +
 +===== Gouvernance Continue =====
 +
 +----
 +
 +====== Étape 31 — Jobs ======
 +
 +===== Ajouter =====
 +
 +<code>
 +Toutes les heures
 +
 +Delegation Expiration
 +
 +Toutes les nuits
 +
 +Compliance Scan
 +
 +Approval Escalation
 +
 +Governance KPI Refresh
 +</code>
 +
 +----
 +
 +====== Étape 32 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +governance.read
 +
 +governance.manage
 +
 +governance.approve
 +
 +governance.compliance
 +
 +governance.audit
 +
 +governance.admin
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 6-D.2 ======
 +
 +Compatible avec :
 +
 +<code>
 +Enterprise Policies
 +
 +Risk Management
 +
 +Internal Controls
 +
 +Governance Intelligence
 +
 +Audit Automation
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-D.1 est terminé lorsque :
 +
 +<code>
 +✓ Portfolio RBAC créé
 +
 +✓ Delegation créée
 +
 +✓ Approval Workflow créé
 +
 +✓ Compliance Controls créés
 +
 +✓ Multi-Site Permissions créées
 +
 +✓ Governance Dashboard créé
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +PortfolioRole
 +
 +PortfolioPermission
 +
 +PortfolioRoleAssignment
 +
 +Delegation
 +
 +ApprovalRequest
 +
 +ComplianceControl
 +
 +PortfolioRBACService
 +
 +DelegationService
 +
 +ApprovalWorkflowService
 +
 +ComplianceControlService
 +
 +GovernanceDashboardService
 +
 +Enterprise Governance Platform
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2 — Portfolio Intelligence & Prévisions Multi-Sites ======
 +
 +===== Objectif =====
 +
 +Transformer les analytics consolidés en plateforme décisionnelle prédictive Enterprise.
 +
 +Cette couche permet :
 +
 +<code>
 +Prévisions
 +
 +Planification stratégique
 +
 +Détection d'opportunités
 +
 +Prévisions revenus
 +
 +Prévisions occupation
 +
 +Pilotage d'investissement
 +</code>
 +
 +sur l'ensemble du portefeuille immobilier.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Portfolio Forecasting
 +
 +✓ Revenue Forecast
 +
 +✓ Occupancy Forecast
 +
 +✓ Investment Insights
 +
 +✓ Portfolio Health Score
 +
 +✓ Executive AI Insights
 +
 +✓ Portfolio Intelligence Platform
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Portfolio Analytics
 +
 +
 +
 +Portfolio Intelligence Engine
 +
 +├── Revenue Forecast
 +├── Occupancy Forecast
 +├── Investment Insights
 +├── Risk Analysis
 +├── Portfolio Health Score
 +├── Executive AI Insights
 +└── Strategic Recommendations
 +
 +
 +
 +Executive Management
 +
 +
 +
 +Investment Planning
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — PortfolioForecast ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model PortfolioForecast {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  portfolioId           String
 +
 +  forecastType          PortfolioForecastType
 +
 +  forecastDate          DateTime
 +
 +  predictedValue        Float
 +
 +  confidenceScore       Float?
 +
 +  generatedAt           DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([portfolioId])
 +
 +  @@index([forecastType])
 +
 +  @@index([forecastDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — PortfolioInsight ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioInsight {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  portfolioId           String?
 +
 +  category              PortfolioInsightCategory
 +
 +  severity              InsightSeverity
 +
 +  title                 String
 +
 +  description           String
 +
 +  recommendation        String?
 +
 +  impactScore           Float?
 +
 +  implemented           Boolean
 +                        @default(false)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([portfolioId])
 +
 +  @@index([category])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — PortfolioHealthScore ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioHealthScore {
 +
 +  portfolioId           String
 +                        @id
 +
 +  overallScore          Float
 +
 +  revenueScore          Float
 +
 +  occupancyScore        Float
 +
 +  guestScore            Float
 +
 +  operationsScore       Float
 +
 +  assetScore            Float
 +
 +  growthScore           Float
 +
 +  calculatedAt          DateTime
 +                        @updatedAt
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — InvestmentRecommendation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model InvestmentRecommendation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  portfolioId           String
 +
 +  recommendationType    InvestmentRecommendationType
 +
 +  priority              RecommendationPriority
 +
 +  title                 String
 +
 +  description           String
 +
 +  estimatedInvestment   Decimal?
 +                        @db.Decimal(14,2)
 +
 +  estimatedReturn       Decimal?
 +                        @db.Decimal(14,2)
 +
 +  roiPercent            Float?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([portfolioId])
 +
 +  @@index([recommendationType])
 +
 +  @@index([priority])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum PortfolioForecastType {
 +
 +  REVENUE
 +
 +  OCCUPANCY
 +
 +  RESERVATIONS
 +
 +  REVPAR
 +
 +  ADR
 +}
 +
 +enum PortfolioInsightCategory {
 +
 +  REVENUE
 +
 +  OCCUPANCY
 +
 +  OPERATIONS
 +
 +  ASSETS
 +
 +  INVESTMENT
 +
 +  GROWTH
 +}
 +
 +enum InvestmentRecommendationType {
 +
 +  ACQUISITION
 +
 +  RENOVATION
 +
 +  REPLACEMENT
 +
 +  EXPANSION
 +
 +  OPTIMIZATION
 +
 +  DIVESTMENT
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name portfolio_intelligence
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-B ======
 +
 +===== Portfolio Intelligence Module =====
 +
 +----
 +
 +====== Étape 7 — Création ======
 +
 +<code>
 +src/modules/portfolio-intelligence
 +
 +├── forecasts
 +
 +├── revenue
 +
 +├── occupancy
 +
 +├── investments
 +
 +├── health
 +
 +├── insights
 +
 +└── portfolio-intelligence.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 8 — Services ======
 +
 +===== Créer =====
 +
 +<code>
 +PortfolioForecastService
 +
 +RevenueForecastService
 +
 +OccupancyForecastService
 +
 +InvestmentInsightService
 +
 +PortfolioHealthScoreService
 +
 +ExecutiveInsightService
 +
 +InvestmentRecommendationService
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-C ======
 +
 +===== Revenue Forecast =====
 +
 +----
 +
 +====== Étape 9 — RevenueForecastService ======
 +
 +===== Créer =====
 +
 +<code>
 +revenue-forecast.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +forecastRevenue()
 +
 +forecastADR()
 +
 +forecastRevPAR()
 +
 +forecastGrowth()
 +</code>
 +
 +----
 +
 +====== Étape 10 — Sources ======
 +
 +===== Utiliser =====
 +
 +<code>
 +Reservations
 +
 +Payments
 +
 +Invoices
 +
 +Portfolio Analytics
 +
 +Seasonality
 +</code>
 +
 +----
 +
 +====== Étape 11 — Prévisions ======
 +
 +===== Produire =====
 +
 +<code>
 +30 jours
 +
 +90 jours
 +
 +12 mois
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-D ======
 +
 +===== Occupancy Forecast =====
 +
 +----
 +
 +====== Étape 12 — OccupancyForecastService ======
 +
 +===== Créer =====
 +
 +<code>
 +occupancy-forecast.service.ts
 +</code>
 +
 +----
 +
 +===== Prévoir =====
 +
 +<code>
 +Occupancy
 +
 +Available Nights
 +
 +Demand
 +
 +Booking Pace
 +</code>
 +
 +----
 +
 +====== Étape 13 — Méthodes ======
 +
 +<code ts>
 +forecastOccupancy()
 +
 +forecastDemand()
 +
 +forecastSeasonality()
 +</code>
 +
 +----
 +
 +====== Étape 14 — Segmentation ======
 +
 +===== Calculer =====
 +
 +par :
 +
 +<code>
 +Portfolio
 +
 +Property Group
 +
 +Property
 +
 +Region
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-E ======
 +
 +===== Investment Insights =====
 +
 +----
 +
 +====== Étape 15 — InvestmentInsightService ======
 +
 +===== Créer =====
 +
 +<code>
 +investment-insight.service.ts
 +</code>
 +
 +----
 +
 +===== Identifier =====
 +
 +<code>
 +Expansion
 +
 +Renovation
 +
 +Asset Replacement
 +
 +Optimization
 +
 +Divestment
 +</code>
 +
 +----
 +
 +====== Étape 16 — Analyse ======
 +
 +===== Utiliser =====
 +
 +<code>
 +Revenue
 +
 +Occupancy
 +
 +Assets
 +
 +Maintenance
 +
 +Guest Satisfaction
 +</code>
 +
 +----
 +
 +====== Étape 17 — Exemple ======
 +
 +<code>
 +Property Group Paris
 +
 +ROI potentiel
 +
 +18%
 +
 +
 +
 +Rénovation recommandée
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-F ======
 +
 +===== Portfolio Health Score =====
 +
 +----
 +
 +====== Étape 18 — PortfolioHealthScoreService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-health-score.service.ts
 +</code>
 +
 +----
 +
 +===== Calcul =====
 +
 +<code>
 +Revenue           25%
 +
 +Occupancy         20%
 +
 +Guest Score       15%
 +
 +Operations        15%
 +
 +Assets            15%
 +
 +Growth            10%
 +</code>
 +
 +----
 +
 +====== Étape 19 — Classification ======
 +
 +<code>
 +90-100 Excellent
 +
 +75-89 Healthy
 +
 +50-74 Warning
 +
 +0-49 Critical
 +</code>
 +
 +----
 +
 +====== Étape 20 — Exemple ======
 +
 +<code>
 +Portfolio Health
 +
 +93
 +
 +Excellent
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-G ======
 +
 +===== Executive AI Insights =====
 +
 +----
 +
 +====== Étape 21 — ExecutiveInsightService ======
 +
 +===== Créer =====
 +
 +<code>
 +executive-insight.service.ts
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code>
 +Revenue Opportunities
 +
 +Occupancy Risks
 +
 +Growth Opportunities
 +
 +Asset Risks
 +
 +Investment Priorities
 +</code>
 +
 +----
 +
 +====== Étape 22 — Exemple ======
 +
 +<code>
 +Les propriétés côtières
 +
 +↑ 22%
 +
 +prévision revenus été
 +
 +
 +
 +Renforcer l'inventaire
 +</code>
 +
 +----
 +
 +====== Étape 23 — Exemple ======
 +
 +<code>
 +Le groupe Europe Nord
 +
 +
 +
 +Occupation en baisse
 +
 +-7%
 +
 +
 +
 +Action recommandée
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-H ======
 +
 +===== Recommandations d'Investissement =====
 +
 +----
 +
 +====== Étape 24 — InvestmentRecommendationService ======
 +
 +===== Créer =====
 +
 +<code>
 +investment-recommendation.service.ts
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code>
 +CAPEX
 +
 +Expansion
 +
 +Acquisition
 +
 +Renovation
 +
 +Cession
 +</code>
 +
 +----
 +
 +====== Étape 25 — Priorisation ======
 +
 +===== Utiliser =====
 +
 +<code>
 +ROI
 +
 +Health Score
 +
 +Forecast
 +
 +Asset Age
 +
 +Revenue Potential
 +</code>
 +
 +----
 +
 +====== Étape 26 — Exemple ======
 +
 +<code>
 +CAPEX
 +
 +250 000 €
 +
 +ROI estimé
 +
 +31%
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-I ======
 +
 +===== Dashboard Intelligence =====
 +
 +----
 +
 +====== Étape 27 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /portfolio/intelligence
 +
 +GET /portfolio/forecasts
 +
 +GET /portfolio/insights
 +
 +GET /portfolio/health
 +
 +GET /portfolio/investments
 +
 +GET /portfolio/recommendations
 +</code>
 +
 +----
 +
 +====== Étape 28 — Exemple ======
 +
 +===== Réponse =====
 +
 +<code json>
 +{
 +  "revenueForecast":12450000,
 +  "occupancyForecast":84.2,
 +  "portfolioHealth":93,
 +  "investmentOpportunities":12
 +}
 +</code>
 +
 +----
 +
 +====== Étape 29 — Analytics IA ======
 +
 +===== Mesurer =====
 +
 +<code>
 +Forecast Accuracy
 +
 +Investment ROI
 +
 +Health Score Trend
 +
 +Revenue Prediction Accuracy
 +
 +Recommendation Adoption
 +</code>
 +
 +----
 +
 +====== Sprint 6-C.2-J ======
 +
 +===== Gouvernance =====
 +
 +----
 +
 +====== Étape 30 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +portfolio.intelligence.read
 +
 +portfolio.intelligence.forecast
 +
 +portfolio.intelligence.investment
 +
 +portfolio.intelligence.health
 +
 +portfolio.intelligence.executive
 +</code>
 +
 +----
 +
 +====== Étape 31 — Audit ======
 +
 +===== Journaliser =====
 +
 +<code>
 +PORTFOLIO_FORECAST_GENERATED
 +
 +PORTFOLIO_HEALTH_UPDATED
 +
 +EXECUTIVE_INSIGHT_CREATED
 +
 +INVESTMENT_RECOMMENDATION_CREATED
 +
 +INTELLIGENCE_DASHBOARD_VIEWED
 +</code>
 +
 +----
 +
 +====== Étape 32 — Jobs ======
 +
 +===== Ajouter =====
 +
 +<code>
 +Toutes les nuits
 +
 +Portfolio Forecast Refresh
 +
 +Portfolio Health Refresh
 +
 +Executive Insights Generation
 +
 +Investment Recommendation Refresh
 +</code>
 +
 +----
 +
 +====== Clôture Domaine Analytics ======
 +
 +À la fin du Sprint 6-C.2 :
 +
 +<code>
 +✓ Portfolio Analytics
 +
 +✓ Benchmarking
 +
 +✓ Forecasting
 +
 +✓ Executive Reporting
 +
 +✓ Portfolio Health Score
 +
 +✓ Investment Intelligence
 +
 +✓ Executive AI Insights
 +</code>
 +
 +sont entièrement opérationnels.
 +
 +----
 +
 +====== Préparation Sprint 6-D ======
 +
 +Compatible avec :
 +
 +<code>
 +Governance
 +
 +Delegation
 +
 +Approvals
 +
 +Compliance
 +
 +Enterprise Controls
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-C.2 est terminé lorsque :
 +
 +<code>
 +✓ Portfolio Forecasting créé
 +
 +✓ Revenue Forecast créé
 +
 +✓ Occupancy Forecast créé
 +
 +✓ Investment Insights créés
 +
 +✓ Portfolio Health Score créé
 +
 +✓ Executive AI Insights créés
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +PortfolioForecast
 +
 +PortfolioInsight
 +
 +PortfolioHealthScore
 +
 +InvestmentRecommendation
 +
 +PortfolioForecastService
 +
 +RevenueForecastService
 +
 +OccupancyForecastService
 +
 +InvestmentInsightService
 +
 +PortfolioHealthScoreService
 +
 +ExecutiveInsightService
 +
 +InvestmentRecommendationService
 +
 +Portfolio Intelligence Platform
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1 — Enterprise Governance & Multi-Site Security ======
 +
 +===== Objectif =====
 +
 +Mettre en place la couche de gouvernance Enterprise du parc immobilier.
 +
 +Cette couche permet de contrôler :
 +
 +<code>
 +Accès
 +
 +Délégations
 +
 +Validations
 +
 +Conformité
 +
 +Séparation des responsabilités
 +
 +Traçabilité
 +</code>
 +
 +sur l'ensemble des portefeuilles, groupes et propriétés.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Portfolio RBAC
 +
 +✓ Delegation
 +
 +✓ Approval Workflow
 +
 +✓ Compliance Controls
 +
 +✓ Multi-Site Permissions
 +
 +✓ Governance Dashboard
 +
 +✓ Enterprise Governance Platform
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Tenant
 +
 +
 +
 +Governance Layer
 +
 +├── RBAC
 +├── Delegation
 +├── Approval Workflow
 +├── Compliance
 +├── Audit
 +└── Governance Dashboard
 +
 +
 +
 +Portfolio
 +
 +
 +
 +Property Groups
 +
 +
 +
 +Properties
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — PortfolioRole ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model PortfolioRole {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  name                  String
 +
 +  code                  String
 +
 +  description           String?
 +
 +  systemRole            Boolean
 +                        @default(false)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  permissions           PortfolioPermission[]
 +
 +  assignments           PortfolioRoleAssignment[]
 +
 +  @@unique([tenantId, code])
 +
 +  @@index([tenantId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — PortfolioPermission ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioPermission {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  roleId                String
 +
 +  permission            String
 +
 +  role                  PortfolioRole
 +                        @relation(
 +                          fields:[roleId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  @@index([roleId])
 +
 +  @@index([permission])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — PortfolioRoleAssignment ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PortfolioRoleAssignment {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  userId                String
 +
 +  roleId                String
 +
 +  portfolioId           String?
 +
 +  propertyGroupId       String?
 +
 +  propertyId            String?
 +
 +  assignedAt            DateTime
 +                        @default(now())
 +
 +  expiresAt             DateTime?
 +
 +  role                  PortfolioRole
 +                        @relation(
 +                          fields:[roleId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([userId])
 +
 +  @@index([portfolioId])
 +
 +  @@index([propertyId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Delegation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model Delegation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  delegatorUserId       String
 +
 +  delegateUserId        String
 +
 +  portfolioId           String?
 +
 +  propertyGroupId       String?
 +
 +  propertyId            String?
 +
 +  startDate             DateTime
 +
 +  endDate               DateTime
 +
 +  active                Boolean
 +                        @default(true)
 +
 +  reason                String?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([delegatorUserId])
 +
 +  @@index([delegateUserId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — ApprovalRequest ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model ApprovalRequest {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  approvalType          ApprovalType
 +
 +  status                ApprovalStatus
 +
 +  entityType            String
 +
 +  entityId              String
 +
 +  requestedBy           String
 +
 +  approvedBy            String?
 +
 +  requestedAt           DateTime
 +                        @default(now())
 +
 +  approvedAt            DateTime?
 +
 +  comment               String?
 +
 +  @@index([tenantId])
 +
 +  @@index([status])
 +
 +  @@index([approvalType])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — ComplianceControl ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model ComplianceControl {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  code                  String
 +
 +  title                 String
 +
 +  category              ComplianceCategory
 +
 +  enabled               Boolean
 +                        @default(true)
 +
 +  severity              ComplianceSeverity
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([category])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 7 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum ApprovalType {
 +
 +  PROPERTY_CREATION
 +
 +  PROPERTY_UPDATE
 +
 +  OWNER_ASSIGNMENT
 +
 +  OPERATOR_ASSIGNMENT
 +
 +  CAPEX_REQUEST
 +
 +  CONTRACT_APPROVAL
 +}
 +
 +enum ApprovalStatus {
 +
 +  PENDING
 +
 +  APPROVED
 +
 +  REJECTED
 +
 +  CANCELLED
 +}
 +
 +enum ComplianceCategory {
 +
 +  SECURITY
 +
 +  FINANCIAL
 +
 +  LEGAL
 +
 +  GDPR
 +
 +  OPERATIONS
 +}
 +
 +enum ComplianceSeverity {
 +
 +  LOW
 +
 +  MEDIUM
 +
 +  HIGH
 +
 +  CRITICAL
 +}
 +</code>
 +
 +----
 +
 +====== Étape 8 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name governance_core
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-B ======
 +
 +===== Governance Module =====
 +
 +----
 +
 +====== Étape 9 — Création ======
 +
 +<code>
 +src/modules/governance
 +
 +├── roles
 +
 +├── permissions
 +
 +├── delegations
 +
 +├── approvals
 +
 +├── compliance
 +
 +├── dashboard
 +
 +└── governance.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 10 — Services ======
 +
 +===== Créer =====
 +
 +<code>
 +PortfolioRBACService
 +
 +DelegationService
 +
 +ApprovalWorkflowService
 +
 +ComplianceControlService
 +
 +GovernanceDashboardService
 +
 +PermissionResolverService
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-C ======
 +
 +===== Portfolio RBAC =====
 +
 +----
 +
 +====== Étape 11 — PortfolioRBACService ======
 +
 +===== Créer =====
 +
 +<code>
 +portfolio-rbac.service.ts
 +</code>
 +
 +----
 +
 +===== Rôles système =====
 +
 +<code>
 +PORTFOLIO_ADMIN
 +
 +PORTFOLIO_MANAGER
 +
 +GROUP_MANAGER
 +
 +PROPERTY_MANAGER
 +
 +OWNER_VIEWER
 +
 +AUDITOR
 +</code>
 +
 +----
 +
 +====== Étape 12 — Permissions ======
 +
 +===== Supporter =====
 +
 +<code>
 +Read
 +
 +Create
 +
 +Update
 +
 +Delete
 +
 +Approve
 +
 +Export
 +
 +Admin
 +</code>
 +
 +par scope.
 +
 +----
 +
 +====== Étape 13 — Scopes ======
 +
 +===== Appliquer =====
 +
 +<code>
 +Portfolio
 +
 +Property Group
 +
 +Property
 +</code>
 +
 +sur chaque permission.
 +
 +----
 +
 +====== Sprint 6-D.1-D ======
 +
 +===== Délégations =====
 +
 +----
 +
 +====== Étape 14 — DelegationService ======
 +
 +===== Créer =====
 +
 +<code>
 +delegation.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createDelegation()
 +
 +revokeDelegation()
 +
 +validateDelegation()
 +
 +getActiveDelegations()
 +</code>
 +
 +----
 +
 +====== Étape 15 — Cas d'usage ======
 +
 +===== Supporter =====
 +
 +<code>
 +Congés
 +
 +Remplacement
 +
 +Mission temporaire
 +
 +Support régional
 +</code>
 +
 +----
 +
 +====== Étape 16 — Expiration ======
 +
 +===== Désactiver =====
 +
 +automatiquement à :
 +
 +<code>
 +endDate
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-E ======
 +
 +===== Workflow d'Approbation =====
 +
 +----
 +
 +====== Étape 17 — ApprovalWorkflowService ======
 +
 +===== Créer =====
 +
 +<code>
 +approval-workflow.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +submitApproval()
 +
 +approve()
 +
 +reject()
 +
 +cancelApproval()
 +</code>
 +
 +----
 +
 +====== Étape 18 — Workflows ======
 +
 +===== Supporter =====
 +
 +<code>
 +Nouvelle propriété
 +
 +Changement propriétaire
 +
 +CAPEX
 +
 +Contrat
 +
 +Suppression actif
 +</code>
 +
 +----
 +
 +====== Étape 19 — Validation ======
 +
 +===== Exiger =====
 +
 +un approbateur différent du demandeur.
 +
 +----
 +
 +====== Sprint 6-D.1-F ======
 +
 +===== Contrôles de Conformité =====
 +
 +----
 +
 +====== Étape 20 — ComplianceControlService ======
 +
 +===== Créer =====
 +
 +<code>
 +compliance-control.service.ts
 +</code>
 +
 +----
 +
 +===== Vérifier =====
 +
 +<code>
 +RGPD
 +
 +Audit
 +
 +Sécurité
 +
 +Finance
 +
 +Exploitation
 +</code>
 +
 +----
 +
 +====== Étape 21 — Méthodes ======
 +
 +<code ts>
 +runControls()
 +
 +evaluateCompliance()
 +
 +createViolation()
 +
 +closeViolation()
 +</code>
 +
 +----
 +
 +====== Étape 22 — Scores ======
 +
 +===== Calculer =====
 +
 +<code>
 +Compliance Score
 +
 +Risk Score
 +
 +Violation Rate
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-G ======
 +
 +===== Dashboard Gouvernance =====
 +
 +----
 +
 +====== Étape 23 — GovernanceDashboardService ======
 +
 +===== Créer =====
 +
 +<code>
 +governance-dashboard.service.ts
 +</code>
 +
 +----
 +
 +===== Afficher =====
 +
 +<code>
 +Approvals Pending
 +
 +Active Delegations
 +
 +Compliance Score
 +
 +Open Violations
 +
 +Audit Events
 +</code>
 +
 +----
 +
 +====== Étape 24 — KPI ======
 +
 +===== Mesurer =====
 +
 +<code>
 +Approval Time
 +
 +Compliance Rate
 +
 +Policy Violations
 +
 +Delegation Usage
 +
 +Audit Coverage
 +</code>
 +
 +----
 +
 +====== Étape 25 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /governance/dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-H ======
 +
 +===== API Gouvernance =====
 +
 +----
 +
 +====== Étape 26 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET    /governance/roles
 +
 +POST   /governance/roles
 +
 +GET    /governance/delegations
 +
 +POST   /governance/delegations
 +
 +GET    /governance/approvals
 +
 +POST   /governance/approvals
 +
 +POST   /governance/approvals/{id}/approve
 +
 +POST   /governance/approvals/{id}/reject
 +
 +GET    /governance/compliance
 +</code>
 +
 +----
 +
 +====== Étape 27 — Exemple ======
 +
 +===== Approbation =====
 +
 +<code json>
 +{
 +  "approvalType":"CAPEX_REQUEST",
 +  "entityType":"Asset",
 +  "entityId":"ast_123"
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-I ======
 +
 +===== Sécurité Enterprise =====
 +
 +----
 +
 +====== Étape 28 — Permission Resolver ======
 +
 +===== Créer =====
 +
 +<code>
 +permission-resolver.service.ts
 +</code>
 +
 +----
 +
 +===== Résoudre =====
 +
 +dans l'ordre :
 +
 +<code>
 +Role
 +
 +
 +
 +Delegation
 +
 +
 +
 +Portfolio Scope
 +
 +
 +
 +Property Scope
 +</code>
 +
 +----
 +
 +====== Étape 29 — Middleware ======
 +
 +===== Ajouter =====
 +
 +<code ts>
 +@RequirePortfolioPermission()
 +
 +@RequireApproval()
 +</code>
 +
 +----
 +
 +====== Étape 30 — Audit ======
 +
 +===== Journaliser =====
 +
 +<code>
 +ROLE_ASSIGNED
 +
 +DELEGATION_CREATED
 +
 +APPROVAL_SUBMITTED
 +
 +APPROVAL_APPROVED
 +
 +COMPLIANCE_CHECK_EXECUTED
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.1-J ======
 +
 +===== Gouvernance Continue =====
 +
 +----
 +
 +====== Étape 31 — Jobs ======
 +
 +===== Ajouter =====
 +
 +<code>
 +Toutes les heures
 +
 +Delegation Expiration
 +
 +Toutes les nuits
 +
 +Compliance Scan
 +
 +Approval Escalation
 +
 +Governance KPI Refresh
 +</code>
 +
 +----
 +
 +====== Étape 32 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +governance.read
 +
 +governance.manage
 +
 +governance.approve
 +
 +governance.compliance
 +
 +governance.audit
 +
 +governance.admin
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 6-D.2 ======
 +
 +Compatible avec :
 +
 +<code>
 +Enterprise Policies
 +
 +Risk Management
 +
 +Internal Controls
 +
 +Governance Intelligence
 +
 +Audit Automation
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-D.1 est terminé lorsque :
 +
 +<code>
 +✓ Portfolio RBAC créé
 +
 +✓ Delegation créée
 +
 +✓ Approval Workflow créé
 +
 +✓ Compliance Controls créés
 +
 +✓ Multi-Site Permissions créées
 +
 +✓ Governance Dashboard créé
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +PortfolioRole
 +
 +PortfolioPermission
 +
 +PortfolioRoleAssignment
 +
 +Delegation
 +
 +ApprovalRequest
 +
 +ComplianceControl
 +
 +PortfolioRBACService
 +
 +DelegationService
 +
 +ApprovalWorkflowService
 +
 +ComplianceControlService
 +
 +GovernanceDashboardService
 +
 +Enterprise Governance Platform
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2 — Governance Intelligence & Risk Management ======
 +
 +===== Objectif =====
 +
 +Transformer la gouvernance opérationnelle en plateforme de pilotage des risques Enterprise.
 +
 +Cette couche permet :
 +
 +<code>
 +Gestion des risques
 +
 +Politiques Enterprise
 +
 +Contrôles internes
 +
 +Prévision conformité
 +
 +Analyse d'audit
 +
 +Pilotage exécutif
 +</code>
 +
 +sur l'ensemble des portefeuilles, groupes et propriétés.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Risk Engine
 +
 +✓ Policy Engine
 +
 +✓ Segregation of Duties
 +
 +✓ Audit Intelligence
 +
 +✓ Compliance Forecasting
 +
 +✓ Governance Score
 +
 +✓ Governance Intelligence Platform
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Governance Layer
 +
 +
 +
 +Governance Intelligence Engine
 +
 +├── Risk Engine
 +├── Policy Engine
 +├── SoD Engine
 +├── Audit Intelligence
 +├── Compliance Forecasting
 +├── Governance Score
 +└── Executive Recommendations
 +
 +
 +
 +Executive Governance
 +
 +
 +
 +Enterprise Controls
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — GovernanceRisk ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model GovernanceRisk {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  portfolioId           String?
 +
 +  propertyGroupId       String?
 +
 +  propertyId            String?
 +
 +  category              RiskCategory
 +
 +  severity              RiskSeverity
 +
 +  title                 String
 +
 +  description           String
 +
 +  riskScore             Float
 +
 +  likelihood            Float?
 +
 +  impact                Float?
 +
 +  mitigationPlan        String?
 +
 +  ownerUserId           String?
 +
 +  status                RiskStatus
 +
 +  detectedAt            DateTime
 +                        @default(now())
 +
 +  resolvedAt            DateTime?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +  @@index([category])
 +  @@index([severity])
 +  @@index([status])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — GovernancePolicy ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model GovernancePolicy {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  code                  String
 +
 +  title                 String
 +
 +  description           String?
 +
 +  category              PolicyCategory
 +
 +  active                Boolean
 +                        @default(true)
 +
 +  version               String
 +
 +  effectiveDate         DateTime?
 +
 +  reviewDate            DateTime?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  @@unique([tenantId, code])
 +
 +  @@index([tenantId])
 +  @@index([category])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — SoDViolation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model SoDViolation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  userId                String
 +
 +  ruleCode              String
 +
 +  conflictDescription   String
 +
 +  severity              RiskSeverity
 +
 +  resolved              Boolean
 +                        @default(false)
 +
 +  detectedAt            DateTime
 +                        @default(now())
 +
 +  resolvedAt            DateTime?
 +
 +  @@index([tenantId])
 +  @@index([userId])
 +  @@index([resolved])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — GovernanceForecast ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model GovernanceForecast {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  forecastType          GovernanceForecastType
 +
 +  forecastDate          DateTime
 +
 +  predictedValue        Float
 +
 +  confidenceScore       Float?
 +
 +  generatedAt           DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +  @@index([forecastType])
 +  @@index([forecastDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — GovernanceScore ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model GovernanceScore {
 +
 +  tenantId              String
 +                        @id
 +
 +  overallScore          Float
 +
 +  complianceScore       Float
 +
 +  auditScore            Float
 +
 +  riskScore             Float
 +
 +  controlsScore         Float
 +
 +  segregationScore      Float
 +
 +  calculatedAt          DateTime
 +                        @updatedAt
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum RiskCategory {
 +
 +  SECURITY
 +
 +  FINANCIAL
 +
 +  OPERATIONAL
 +
 +  COMPLIANCE
 +
 +  LEGAL
 +
 +  GOVERNANCE
 +}
 +
 +enum RiskSeverity {
 +
 +  LOW
 +
 +  MEDIUM
 +
 +  HIGH
 +
 +  CRITICAL
 +}
 +
 +enum RiskStatus {
 +
 +  OPEN
 +
 +  MITIGATING
 +
 +  ACCEPTED
 +
 +  RESOLVED
 +}
 +
 +enum PolicyCategory {
 +
 +  ACCESS
 +
 +  SECURITY
 +
 +  FINANCE
 +
 +  OPERATIONS
 +
 +  GDPR
 +
 +  AUDIT
 +}
 +
 +enum GovernanceForecastType {
 +
 +  COMPLIANCE_SCORE
 +
 +  RISK_EXPOSURE
 +
 +  AUDIT_FINDINGS
 +
 +  POLICY_VIOLATIONS
 +}
 +</code>
 +
 +----
 +
 +====== Étape 7 — Migration ======
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name governance_intelligence
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-B ======
 +
 +===== Governance Intelligence Module =====
 +
 +----
 +
 +====== Étape 8 — Structure ======
 +
 +<code>
 +src/modules/governance-intelligence
 +
 +├── risk
 +├── policy
 +├── sod
 +├── audit
 +├── forecasting
 +├── scoring
 +├── recommendations
 +└── governance-intelligence.module.ts
 +</code>
 +
 +----
 +
 +====== Étape 9 — Services ======
 +
 +<code>
 +RiskEngineService
 +
 +PolicyEngineService
 +
 +SegregationOfDutiesService
 +
 +AuditIntelligenceService
 +
 +ComplianceForecastingService
 +
 +GovernanceScoreService
 +
 +GovernanceRecommendationService
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-C ======
 +
 +===== Risk Engine =====
 +
 +----
 +
 +====== Étape 10 — RiskEngineService ======
 +
 +===== Créer =====
 +
 +<code>
 +risk-engine.service.ts
 +</code>
 +
 +----
 +
 +===== Capacités =====
 +
 +<code>
 +Risk Registry
 +
 +Risk Scoring
 +
 +Risk Classification
 +
 +Risk Mitigation
 +
 +Risk Monitoring
 +</code>
 +
 +----
 +
 +====== Étape 11 — Détecter ======
 +
 +<code>
 +Accès excessifs
 +
 +Violations politiques
 +
 +Fraudes potentielles
 +
 +Conflits SoD
 +
 +Défauts conformité
 +
 +Anomalies d'audit
 +</code>
 +
 +----
 +
 +====== Étape 12 — Méthodes ======
 +
 +<code ts>
 +detectRisks()
 +
 +calculateRiskScore()
 +
 +classifyRisk()
 +
 +createMitigationPlan()
 +
 +resolveRisk()
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-D ======
 +
 +===== Policy Engine =====
 +
 +----
 +
 +====== Étape 13 — PolicyEngineService ======
 +
 +===== Créer =====
 +
 +<code>
 +policy-engine.service.ts
 +</code>
 +
 +----
 +
 +===== Supporter =====
 +
 +<code>
 +Policies
 +
 +Rules
 +
 +Exceptions
 +
 +Escalations
 +
 +Approvals
 +</code>
 +
 +----
 +
 +====== Étape 14 — Méthodes ======
 +
 +<code ts>
 +evaluatePolicy()
 +
 +registerException()
 +
 +validateAction()
 +
 +triggerEscalation()
 +
 +auditExecution()
 +</code>
 +
 +----
 +
 +====== Étape 15 — Exemples ======
 +
 +<code>
 +CAPEX > 50 000 €
 +
 +
 +
 +Double approbation
 +</code>
 +
 +----
 +
 +<code>
 +Suppression propriété
 +
 +
 +
 +Validation exécutive
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-E ======
 +
 +===== Segregation of Duties =====
 +
 +----
 +
 +====== Étape 16 — SegregationOfDutiesService ======
 +
 +===== Créer =====
 +
 +<code>
 +segregation-of-duties.service.ts
 +</code>
 +
 +----
 +
 +===== Contrôler =====
 +
 +<code>
 +Création
 +
 +Validation
 +
 +Paiement
 +
 +Audit
 +
 +Administration
 +</code>
 +
 +----
 +
 +====== Étape 17 — Détection ======
 +
 +===== Identifier =====
 +
 +<code>
 +Demandeur + Approbateur
 +
 +Créateur + Auditeur
 +
 +Administrateur + Contrôleur
 +</code>
 +
 +----
 +
 +====== Étape 18 — Méthodes ======
 +
 +<code ts>
 +detectConflict()
 +
 +validateRoleAssignment()
 +
 +createViolation()
 +
 +resolveViolation()
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-F ======
 +
 +===== Audit Intelligence =====
 +
 +----
 +
 +====== Étape 19 — AuditIntelligenceService ======
 +
 +===== Créer =====
 +
 +<code>
 +audit-intelligence.service.ts
 +</code>
 +
 +----
 +
 +===== Analyser =====
 +
 +<code>
 +Audit Logs
 +
 +Approvals
 +
 +Permissions
 +
 +Violations
 +
 +Incidents
 +</code>
 +
 +----
 +
 +====== Étape 20 — Détecter ======
 +
 +<code>
 +Anomalies
 +
 +Patterns
 +
 +Abus potentiels
 +
 +Contrôles manquants
 +
 +Zones à risque
 +</code>
 +
 +----
 +
 +====== Étape 21 — Méthodes ======
 +
 +<code ts>
 +analyzeAuditLogs()
 +
 +detectAnomalies()
 +
 +generateFindings()
 +
 +identifyControlGaps()
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-G ======
 +
 +===== Compliance Forecasting =====
 +
 +----
 +
 +====== Étape 22 — ComplianceForecastingService ======
 +
 +===== Créer =====
 +
 +<code>
 +compliance-forecasting.service.ts
 +</code>
 +
 +----
 +
 +===== Prévoir =====
 +
 +<code>
 +Violations
 +
 +Audit Findings
 +
 +Risk Exposure
 +
 +Compliance Trend
 +</code>
 +
 +----
 +
 +====== Étape 23 — Sources ======
 +
 +<code>
 +Compliance Controls
 +
 +Audit Logs
 +
 +Governance Risks
 +
 +SoD Violations
 +</code>
 +
 +----
 +
 +====== Étape 24 — Méthodes ======
 +
 +<code ts>
 +forecastCompliance()
 +
 +forecastRiskExposure()
 +
 +forecastAuditFindings()
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-H ======
 +
 +===== Governance Score =====
 +
 +----
 +
 +====== Étape 25 — GovernanceScoreService ======
 +
 +===== Créer =====
 +
 +<code>
 +governance-score.service.ts
 +</code>
 +
 +----
 +
 +===== Pondération =====
 +
 +<code>
 +Compliance        25%
 +
 +Risk              25%
 +
 +Audit             20%
 +
 +Controls          15%
 +
 +SoD               15%
 +</code>
 +
 +----
 +
 +====== Étape 26 — Classification ======
 +
 +<code>
 +90-100  Excellent
 +
 +75-89   Healthy
 +
 +50-74   Warning
 +
 +0-49    Critical
 +</code>
 +
 +----
 +
 +====== Étape 27 — Exemple ======
 +
 +<code>
 +Governance Score
 +
 +94
 +
 +Excellent
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-I ======
 +
 +===== Executive Intelligence =====
 +
 +----
 +
 +====== Étape 28 — GovernanceRecommendationService ======
 +
 +===== Créer =====
 +
 +<code>
 +governance-recommendation.service.ts
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code>
 +Réduction risques
 +
 +Renforcement contrôles
 +
 +Corrections conformité
 +
 +Optimisation processus
 +
 +Actions audit
 +</code>
 +
 +----
 +
 +====== Étape 29 — Exemples ======
 +
 +<code>
 +18 violations SoD
 +
 +
 +
 +Séparer les rôles Finance
 +</code>
 +
 +----
 +
 +<code>
 +Risque conformité en hausse
 +
 +
 +
 +Audit ciblé recommandé
 +</code>
 +
 +----
 +
 +====== Sprint 6-D.2-J ======
 +
 +===== Dashboard Intelligence =====
 +
 +----
 +
 +====== Étape 30 — Endpoints ======
 +
 +<code http>
 +GET /governance/intelligence
 +
 +GET /governance/risks
 +
 +GET /governance/policies
 +
 +GET /governance/score
 +
 +GET /governance/forecasts
 +
 +GET /governance/recommendations
 +
 +GET /governance/sod
 +</code>
 +
 +----
 +
 +====== Étape 31 — Exemple ======
 +
 +<code json>
 +{
 +  "governanceScore":94,
 +  "openRisks":7,
 +  "criticalRisks":1,
 +  "sodViolations":3,
 +  "complianceForecast":91
 +}
 +</code>
 +
 +----
 +
 +====== Étape 32 — Permissions ======
 +
 +<code>
 +governance.intelligence.read
 +
 +governance.risk.manage
 +
 +governance.policy.manage
 +
 +governance.audit.intelligence
 +
 +governance.executive
 +</code>
 +
 +----
 +
 +====== Étape 33 — Audit ======
 +
 +<code>
 +RISK_DETECTED
 +
 +POLICY_VIOLATION
 +
 +SOD_VIOLATION_CREATED
 +
 +FORECAST_GENERATED
 +
 +GOVERNANCE_SCORE_UPDATED
 +
 +EXECUTIVE_RECOMMENDATION_CREATED
 +</code>
 +
 +----
 +
 +====== Étape 34 — Jobs ======
 +
 +<code>
 +Toutes les heures
 +
 +Risk Detection
 +
 +Toutes les nuits
 +
 +Compliance Forecast Refresh
 +
 +Governance Score Refresh
 +
 +Audit Intelligence Refresh
 +
 +Recommendation Generation
 +</code>
 +
 +----
 +
 +====== Clôture Sprint 6 ======
 +
 +À la fin du Sprint 6 :
 +
 +<code>
 +✓ Portfolio Management
 +
 +✓ Asset Management
 +
 +✓ Portfolio Analytics
 +
 +✓ Portfolio Intelligence
 +
 +✓ Enterprise Governance
 +
 +✓ Risk Management
 +
 +✓ Executive Controls
 +</code>
 +
 +sont entièrement opérationnels.
 +
 +----
 +
 +====== Préparation Sprint 7 ======
 +
 +Compatible avec :
 +
 +<code>
 +Marketplace
 +
 +OTA
 +
 +Distribution
 +
 +Partners
 +
 +Channels
 +
 +Revenue Sharing
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 6-D.2 est terminé lorsque :
 +
 +<code>
 +✓ Risk Engine créé
 +
 +✓ Policy Engine créé
 +
 +✓ Segregation of Duties créée
 +
 +✓ Audit Intelligence créée
 +
 +✓ Compliance Forecasting créé
 +
 +✓ Governance Score créé
 +
 +✓ Executive Intelligence créée
 +
 +✓ Gouvernance Enterprise finalisée
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +GovernanceRisk
 +
 +GovernancePolicy
 +
 +SoDViolation
 +
 +GovernanceForecast
 +
 +GovernanceScore
 +
 +RiskEngineService
 +
 +PolicyEngineService
 +
 +SegregationOfDutiesService
 +
 +AuditIntelligenceService
 +
 +ComplianceForecastingService
 +
 +GovernanceScoreService
 +
 +GovernanceRecommendationService
 +
 +Governance Intelligence Platform
 +</code>
 +
 +----
 +
 +
ujusum/3-codage/2-sprints/6-sprint-6.1781108200.txt.gz · Dernière modification : 2026/06/10 18:16 de 83.202.252.200

DokuWiki Appliance - Powered by TurnKey Linux