{
  "version": "1.0.0",
  "generated_at": "2026-07-30T00:00:00Z",
  "cible_rbac_roles": 50,
  "portails_business": ["ventes", "construction", "achat", "compta", "direction"],
  "roles": [
    {
      "id": "direction-president-waf",
      "nom_fr": "Président · WAF (Holding)",
      "famille": "direction",
      "portail": "direction",
      "entite_principale": "WAF",
      "niveau": 5,
      "erpnext_role_name": "OTO Direction Président",
      "scope_donnees": "groupe",
      "description": "Vue consolidée toutes entités ; approbations stratégiques et plafonds haut niveau. Lecture large, écriture limitée aux validations.",
      "modules": ["Accounts", "CRM", "Selling", "Buying", "Projects", "OTOV7 Faisabilité"],
      "permissions_cibles": [
        { "doctype": "Sales Invoice", "actions": ["read", "report", "print", "export"] },
        { "doctype": "Purchase Invoice", "actions": ["read", "report", "export"] },
        { "doctype": "Opportunity", "actions": ["read", "report"] },
        { "doctype": "Faisabilité", "custom": true, "actions": ["read", "report"] }
      ]
    },
    {
      "id": "direction-dg",
      "nom_fr": "Directeur Général",
      "famille": "direction",
      "portail": "direction",
      "entite_principale": "Groupe",
      "niveau": 5,
      "erpnext_role_name": "OTO Direction Générale",
      "scope_donnees": "groupe",
      "description": "Pilotage opérationnel du groupe ; approbation devis/commandes au-delà des plafonds directeurs.",
      "modules": ["Accounts", "CRM", "Selling", "Buying", "Projects", "HR"],
      "permissions_cibles": [
        { "doctype": "Quotation", "actions": ["read", "write", "submit", "cancel", "report"] },
        { "doctype": "Sales Order", "actions": ["read", "write", "submit", "cancel", "report"] },
        { "doctype": "Purchase Order", "actions": ["read", "write", "submit", "cancel", "report"] },
        { "doctype": "Project", "actions": ["read", "write", "report"] }
      ]
    },
    {
      "id": "direction-cfo",
      "nom_fr": "Directeur Financier (CFO)",
      "famille": "finance",
      "portail": "direction",
      "entite_principale": "Groupe",
      "niveau": 5,
      "erpnext_role_name": "OTO Direction Financière",
      "scope_donnees": "groupe",
      "description": "Responsable comptabilité/trésorerie consolidées ; validation des écritures et des paiements.",
      "modules": ["Accounts", "Buying", "Selling", "Report"],
      "permissions_cibles": [
        { "doctype": "Journal Entry", "actions": ["read", "write", "create", "submit", "cancel", "report"] },
        { "doctype": "Payment Entry", "actions": ["read", "write", "submit", "cancel", "report"] },
        { "doctype": "Sales Invoice", "actions": ["read", "write", "submit", "cancel", "report", "export"] },
        { "doctype": "Purchase Invoice", "actions": ["read", "write", "submit", "cancel", "report", "export"] }
      ]
    },
    {
      "id": "direction-coo",
      "nom_fr": "Directeur des Opérations (COO)",
      "famille": "direction",
      "portail": "direction",
      "entite_principale": "Groupe",
      "niveau": 4,
      "erpnext_role_name": "OTO Direction Opérations",
      "scope_donnees": "groupe",
      "description": "Coordination construction/achat/logistique multi-projets ; supervision des jalons.",
      "modules": ["Projects", "Buying", "Stock", "Report"],
      "permissions_cibles": [
        { "doctype": "Project", "actions": ["read", "write", "create", "report"] },
        { "doctype": "Task", "actions": ["read", "write", "create", "report"] },
        { "doctype": "Purchase Order", "actions": ["read", "report"] }
      ]
    },
    {
      "id": "direction-cco",
      "nom_fr": "Directeur Commercial (CCO)",
      "famille": "direction",
      "portail": "direction",
      "entite_principale": "Groupe",
      "niveau": 4,
      "erpnext_role_name": "OTO Direction Commerciale",
      "scope_donnees": "groupe",
      "description": "Stratégie commerciale groupe ; supervision pipeline et marketing.",
      "modules": ["CRM", "Selling", "Website", "Report"],
      "permissions_cibles": [
        { "doctype": "Opportunity", "actions": ["read", "write", "report", "export"] },
        { "doctype": "Quotation", "actions": ["read", "write", "report"] },
        { "doctype": "Lead", "actions": ["read", "report"] }
      ]
    },
    {
      "id": "direction-board",
      "nom_fr": "Conseil d'Administration (lecture consolidée)",
      "famille": "direction",
      "portail": "direction",
      "entite_principale": "Groupe",
      "niveau": 5,
      "erpnext_role_name": "OTO Conseil Administration",
      "scope_donnees": "groupe",
      "description": "Accès strictement lecture aux tableaux de bord consolidés et rapports 4Big (aucune écriture).",
      "modules": ["Accounts", "Report", "OTOV7 Faisabilité"],
      "permissions_cibles": [
        { "doctype": "Sales Invoice", "actions": ["read", "report"] },
        { "doctype": "Faisabilité", "custom": true, "actions": ["read", "report"] }
      ]
    },

    {
      "id": "ventes-directeur",
      "nom_fr": "Directeur des Ventes",
      "famille": "ventes",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 4,
      "erpnext_role_name": "OTO Ventes Directeur",
      "scope_donnees": "entite",
      "description": "Pilote le pipeline Helios RD ; approuve devis et remises ; assigne les leads aux équipes.",
      "modules": ["CRM", "Selling", "Report"],
      "permissions_cibles": [
        { "doctype": "Lead", "actions": ["read", "write", "create", "share", "report"] },
        { "doctype": "Opportunity", "actions": ["read", "write", "create", "report", "export"] },
        { "doctype": "Quotation", "actions": ["read", "write", "create", "submit", "cancel", "report"] },
        { "doctype": "Sales Order", "actions": ["read", "write", "submit", "report"] }
      ]
    },
    {
      "id": "ventes-chef-equipe",
      "nom_fr": "Chef d'Équipe Ventes",
      "famille": "ventes",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 3,
      "erpnext_role_name": "OTO Ventes Chef Équipe",
      "scope_donnees": "equipe",
      "description": "Supervise les conseillers de son équipe ; réaffecte leads et suit les objectifs.",
      "modules": ["CRM", "Selling"],
      "permissions_cibles": [
        { "doctype": "Lead", "actions": ["read", "write", "create", "report"] },
        { "doctype": "Opportunity", "actions": ["read", "write", "create", "report"] },
        { "doctype": "Quotation", "actions": ["read", "write", "create", "submit"] }
      ]
    },
    {
      "id": "ventes-conseiller",
      "nom_fr": "Conseiller Ventes",
      "famille": "ventes",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 2,
      "erpnext_role_name": "OTO Ventes Conseiller",
      "scope_donnees": "own",
      "description": "Gère ses propres leads/opportunités et produit des devis (soumis à approbation).",
      "modules": ["CRM", "Selling"],
      "permissions_cibles": [
        { "doctype": "Lead", "actions": ["read", "write", "create"] },
        { "doctype": "Opportunity", "actions": ["read", "write", "create"] },
        { "doctype": "Quotation", "actions": ["read", "write", "create", "print", "email"] }
      ]
    },
    {
      "id": "ventes-courtier-externe",
      "nom_fr": "Agent Externe / Courtier",
      "famille": "ventes",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 1,
      "erpnext_role_name": "OTO Ventes Courtier Externe",
      "scope_donnees": "own",
      "description": "Partenaire externe : soumet des leads et suit ses propres réservations/commissions, sans accès aux données internes.",
      "modules": ["CRM"],
      "permissions_cibles": [
        { "doctype": "Lead", "actions": ["read", "create"] },
        { "doctype": "Opportunity", "actions": ["read"] }
      ]
    },
    {
      "id": "ventes-reservations",
      "nom_fr": "Coordinateur Réservations",
      "famille": "ventes",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 2,
      "erpnext_role_name": "OTO Ventes Réservations",
      "scope_donnees": "entite",
      "description": "Enregistre les réservations/dépôts, gère la disponibilité des unités et l'agenda des visites.",
      "modules": ["Selling", "CRM"],
      "permissions_cibles": [
        { "doctype": "Sales Order", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Payment Entry", "actions": ["read", "create"] }
      ]
    },
    {
      "id": "ventes-contrats",
      "nom_fr": "Gestionnaire Contrats de Vente",
      "famille": "ventes",
      "portail": "ventes",
      "entite_principale": "WA SRL",
      "niveau": 3,
      "erpnext_role_name": "OTO Ventes Contrats",
      "scope_donnees": "entite",
      "description": "Établit et suit les contrats (promesse → contrat définitif) ; assure la cohérence avec le devis validé.",
      "modules": ["Selling", "Accounts"],
      "permissions_cibles": [
        { "doctype": "Sales Order", "actions": ["read", "write", "submit", "print", "email"] },
        { "doctype": "Sales Invoice", "actions": ["read", "create", "print"] }
      ]
    },
    {
      "id": "ventes-confotur",
      "nom_fr": "Coordinateur CONFOTUR (Ventes)",
      "famille": "ventes",
      "portail": "ventes",
      "entite_principale": "WA SRL",
      "niveau": 3,
      "erpnext_role_name": "OTO Ventes CONFOTUR",
      "scope_donnees": "entite",
      "description": "Monte les dossiers d'incitation CONFOTUR côté vente (pièces client, éligibilité) ; liaison avec l'agent ONAPI/Legal.",
      "modules": ["Selling", "OTOV7 CONFOTUR"],
      "permissions_cibles": [
        { "doctype": "CONFOTUR Application", "custom": true, "actions": ["read", "write", "create", "print"] },
        { "doctype": "Customer", "actions": ["read"] }
      ]
    },
    {
      "id": "ventes-apres-vente",
      "nom_fr": "Support Après-Vente",
      "famille": "ventes",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 2,
      "erpnext_role_name": "OTO Ventes Après-Vente",
      "scope_donnees": "entite",
      "description": "Traite les demandes clients post-signature (livraison, garanties) via les tickets et les tâches.",
      "modules": ["CRM", "Support", "Projects"],
      "permissions_cibles": [
        { "doctype": "Issue", "actions": ["read", "write", "create"] },
        { "doctype": "Customer", "actions": ["read"] }
      ]
    },

    {
      "id": "marketing-directeur",
      "nom_fr": "Directeur Marketing",
      "famille": "marketing",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 4,
      "erpnext_role_name": "OTO Marketing Directeur",
      "scope_donnees": "entite",
      "description": "Pilote la marque publique Helios RD, les campagnes et la validation du contenu du site vente.otov7.com.",
      "modules": ["CRM", "Website", "Report"],
      "permissions_cibles": [
        { "doctype": "Web Page", "actions": ["read", "write", "create"] },
        { "doctype": "Publiciste Log", "custom": true, "actions": ["read", "report"] }
      ]
    },
    {
      "id": "marketing-publiciste",
      "nom_fr": "Éditeur Contenu / Publiciste",
      "famille": "marketing",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 2,
      "erpnext_role_name": "OTO Marketing Publiciste",
      "scope_donnees": "entite",
      "description": "Compte applicatif de l'agent Publiciste : publie le site public à partir des faisabilités validées (jamais d'invention de prix — CLAUDE.md #6).",
      "modules": ["Website", "OTOV7 Publiciste"],
      "permissions_cibles": [
        { "doctype": "Web Page", "actions": ["read", "write", "create"] },
        { "doctype": "Publiciste Log", "custom": true, "actions": ["read", "write", "create"] }
      ]
    },
    {
      "id": "marketing-seo",
      "nom_fr": "Spécialiste SEO",
      "famille": "marketing",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 2,
      "erpnext_role_name": "OTO Marketing SEO",
      "scope_donnees": "entite",
      "description": "Optimise l'indexation trilingue FR/EN/ES (hreflang, schema.org) ; suit Google Search Console.",
      "modules": ["Website", "Report"],
      "permissions_cibles": [
        { "doctype": "Web Page", "actions": ["read", "write"] }
      ]
    },
    {
      "id": "marketing-social",
      "nom_fr": "Community / Réseaux Sociaux",
      "famille": "marketing",
      "portail": "ventes",
      "entite_principale": "Helios RD",
      "niveau": 1,
      "erpnext_role_name": "OTO Marketing Social",
      "scope_donnees": "entite",
      "description": "Gère les publications réseaux sociaux et remonte les leads sociaux dans le CRM.",
      "modules": ["CRM", "Website"],
      "permissions_cibles": [
        { "doctype": "Lead", "actions": ["read", "create"] }
      ]
    },

    {
      "id": "construction-directeur",
      "nom_fr": "Directeur Construction",
      "famille": "construction",
      "portail": "construction",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 4,
      "erpnext_role_name": "OTO Construction Directeur",
      "scope_donnees": "entite",
      "description": "Dirige AC Arias Cuevas ; approuve les projets, budgets travaux et jalons de chantier.",
      "modules": ["Projects", "Buying", "Stock", "Report"],
      "permissions_cibles": [
        { "doctype": "Project", "actions": ["read", "write", "create", "submit", "report"] },
        { "doctype": "Task", "actions": ["read", "write", "create", "report"] },
        { "doctype": "Purchase Order", "actions": ["read", "write", "submit"] }
      ]
    },
    {
      "id": "construction-chef-projet",
      "nom_fr": "Chef de Projet Construction",
      "famille": "construction",
      "portail": "construction",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 3,
      "erpnext_role_name": "OTO Construction Chef Projet",
      "scope_donnees": "equipe",
      "description": "Pilote un projet : planning, tâches, avancement et demandes d'achat de chantier.",
      "modules": ["Projects", "Buying"],
      "permissions_cibles": [
        { "doctype": "Project", "actions": ["read", "write", "report"] },
        { "doctype": "Task", "actions": ["read", "write", "create"] },
        { "doctype": "Material Request", "actions": ["read", "write", "create", "submit"] }
      ]
    },
    {
      "id": "construction-ingenieur",
      "nom_fr": "Ingénieur de Chantier",
      "famille": "construction",
      "portail": "construction",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 2,
      "erpnext_role_name": "OTO Construction Ingénieur",
      "scope_donnees": "equipe",
      "description": "Suit l'exécution technique sur site ; met à jour l'avancement des tâches et les feuilles de temps.",
      "modules": ["Projects"],
      "permissions_cibles": [
        { "doctype": "Task", "actions": ["read", "write"] },
        { "doctype": "Timesheet", "actions": ["read", "write", "create"] }
      ]
    },
    {
      "id": "construction-architecte",
      "nom_fr": "Architecte",
      "famille": "construction",
      "portail": "construction",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 3,
      "erpnext_role_name": "OTO Construction Architecte",
      "scope_donnees": "entite",
      "description": "Produit le volet Architecture des faisabilités ; valide les plans et les modèles IFC.",
      "modules": ["Projects", "OTOV7 Faisabilité"],
      "permissions_cibles": [
        { "doctype": "Faisabilité", "custom": true, "actions": ["read", "write", "create"] },
        { "doctype": "Project", "actions": ["read"] }
      ]
    },
    {
      "id": "construction-qaqc",
      "nom_fr": "Contrôleur Qualité Chantier (QA/QC)",
      "famille": "construction",
      "portail": "construction",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 2,
      "erpnext_role_name": "OTO Construction QAQC",
      "scope_donnees": "entite",
      "description": "Contrôle la conformité qualité du chantier ; consigne inspections et non-conformités.",
      "modules": ["Projects", "Quality"],
      "permissions_cibles": [
        { "doctype": "Quality Inspection", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Task", "actions": ["read"] }
      ]
    },
    {
      "id": "construction-bim",
      "nom_fr": "Coordinateur BIM",
      "famille": "construction",
      "portail": "construction",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 3,
      "erpnext_role_name": "OTO Construction BIM",
      "scope_donnees": "entite",
      "description": "Coordonne les maquettes BIM (Blender/Bonsai/IFC/Speckle) ; publie les modèles vers bim-cloud.otov7.com.",
      "modules": ["Projects", "OTOV7 Faisabilité"],
      "permissions_cibles": [
        { "doctype": "Faisabilité", "custom": true, "actions": ["read", "write"] },
        { "doctype": "File", "actions": ["read", "write", "create"] }
      ]
    },
    {
      "id": "construction-sous-traitants",
      "nom_fr": "Superviseur Sous-traitants",
      "famille": "construction",
      "portail": "construction",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 2,
      "erpnext_role_name": "OTO Construction Sous-traitants",
      "scope_donnees": "equipe",
      "description": "Suit les sous-traitants et leurs livrables ; valide l'avancement pour paiement.",
      "modules": ["Projects", "Buying"],
      "permissions_cibles": [
        { "doctype": "Purchase Order", "actions": ["read", "report"] },
        { "doctype": "Task", "actions": ["read", "write"] }
      ]
    },

    {
      "id": "achat-directeur",
      "nom_fr": "Directeur des Achats",
      "famille": "achat",
      "portail": "achat",
      "entite_principale": "WA SRL",
      "niveau": 4,
      "erpnext_role_name": "OTO Achat Directeur",
      "scope_donnees": "entite",
      "description": "Pilote la fonction achats ; approuve commandes fournisseurs au-delà des plafonds acheteurs.",
      "modules": ["Buying", "Stock", "Accounts", "Report"],
      "permissions_cibles": [
        { "doctype": "Purchase Order", "actions": ["read", "write", "create", "submit", "cancel", "report"] },
        { "doctype": "Supplier", "actions": ["read", "write", "create"] },
        { "doctype": "Material Request", "actions": ["read", "write", "submit"] }
      ]
    },
    {
      "id": "achat-acheteur",
      "nom_fr": "Acheteur / Approvisionneur",
      "famille": "achat",
      "portail": "achat",
      "entite_principale": "WA SRL",
      "niveau": 2,
      "erpnext_role_name": "OTO Achat Acheteur",
      "scope_donnees": "entite",
      "description": "Émet demandes de prix et commandes fournisseurs (soumises à approbation) ; suit les délais.",
      "modules": ["Buying", "Stock"],
      "permissions_cibles": [
        { "doctype": "Material Request", "actions": ["read", "write", "create"] },
        { "doctype": "Request for Quotation", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Purchase Order", "actions": ["read", "write", "create"] }
      ]
    },
    {
      "id": "achat-fournisseurs",
      "nom_fr": "Gestionnaire Fournisseurs",
      "famille": "achat",
      "portail": "achat",
      "entite_principale": "WA SRL",
      "niveau": 2,
      "erpnext_role_name": "OTO Achat Fournisseurs",
      "scope_donnees": "entite",
      "description": "Tient à jour la base fournisseurs, les conditions et la conformité documentaire.",
      "modules": ["Buying"],
      "permissions_cibles": [
        { "doctype": "Supplier", "actions": ["read", "write", "create"] },
        { "doctype": "Contact", "actions": ["read", "write", "create"] }
      ]
    },
    {
      "id": "achat-magasinier",
      "nom_fr": "Magasinier / Inventaire",
      "famille": "achat",
      "portail": "achat",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 2,
      "erpnext_role_name": "OTO Achat Magasinier",
      "scope_donnees": "entite",
      "description": "Gère les stocks de chantier/dépôt : entrées, sorties et inventaires.",
      "modules": ["Stock"],
      "permissions_cibles": [
        { "doctype": "Stock Entry", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Item", "actions": ["read"] }
      ]
    },
    {
      "id": "achat-reception",
      "nom_fr": "Contrôleur Réception Matériaux",
      "famille": "achat",
      "portail": "achat",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 2,
      "erpnext_role_name": "OTO Achat Réception",
      "scope_donnees": "entite",
      "description": "Réceptionne et contrôle les livraisons ; établit les bons de réception.",
      "modules": ["Stock", "Buying"],
      "permissions_cibles": [
        { "doctype": "Purchase Receipt", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Purchase Order", "actions": ["read"] }
      ]
    },

    {
      "id": "compta-controleur-gestion",
      "nom_fr": "Contrôleur de Gestion",
      "famille": "finance",
      "portail": "compta",
      "entite_principale": "Groupe",
      "niveau": 4,
      "erpnext_role_name": "OTO Compta Contrôle Gestion",
      "scope_donnees": "groupe",
      "description": "Suit budgets, marges et point d'équilibre (52% pré-vente) ; produit les rapports de gestion consolidés.",
      "modules": ["Accounts", "Report"],
      "permissions_cibles": [
        { "doctype": "Budget", "actions": ["read", "write", "create", "report"] },
        { "doctype": "GL Entry", "actions": ["read", "report", "export"] },
        { "doctype": "Cost Center", "actions": ["read", "report"] }
      ]
    },
    {
      "id": "compta-comptable-general",
      "nom_fr": "Comptable Général",
      "famille": "finance",
      "portail": "compta",
      "entite_principale": "WA SRL",
      "niveau": 3,
      "erpnext_role_name": "OTO Compta Général",
      "scope_donnees": "entite",
      "description": "Tient la comptabilité générale de l'entité ; saisit et rapproche les écritures.",
      "modules": ["Accounts"],
      "permissions_cibles": [
        { "doctype": "Journal Entry", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Account", "actions": ["read"] }
      ]
    },
    {
      "id": "compta-fournisseurs-ap",
      "nom_fr": "Comptable Fournisseurs (AP)",
      "famille": "finance",
      "portail": "compta",
      "entite_principale": "WA SRL",
      "niveau": 2,
      "erpnext_role_name": "OTO Compta Fournisseurs AP",
      "scope_donnees": "entite",
      "description": "Traite les factures fournisseurs et prépare les paiements (soumis à approbation trésorier/CFO).",
      "modules": ["Accounts", "Buying"],
      "permissions_cibles": [
        { "doctype": "Purchase Invoice", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Payment Entry", "actions": ["read", "create"] }
      ]
    },
    {
      "id": "compta-clients-ar",
      "nom_fr": "Comptable Clients (AR)",
      "famille": "finance",
      "portail": "compta",
      "entite_principale": "Helios RD",
      "niveau": 2,
      "erpnext_role_name": "OTO Compta Clients AR",
      "scope_donnees": "entite",
      "description": "Émet les factures clients et suit les encaissements (Cardnet · USD/DOP) et relances.",
      "modules": ["Accounts", "Selling"],
      "permissions_cibles": [
        { "doctype": "Sales Invoice", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Payment Entry", "actions": ["read", "create"] }
      ]
    },
    {
      "id": "compta-tresorier",
      "nom_fr": "Trésorier · Ploutos",
      "famille": "finance",
      "portail": "compta",
      "entite_principale": "Ploutos",
      "niveau": 3,
      "erpnext_role_name": "OTO Compta Trésorier",
      "scope_donnees": "entite",
      "description": "Gère la trésorerie et le patrimoine monétaire (Ploutos) ; valide les décaissements.",
      "modules": ["Accounts"],
      "permissions_cibles": [
        { "doctype": "Payment Entry", "actions": ["read", "write", "submit", "cancel"] },
        { "doctype": "Bank Transaction", "actions": ["read", "write", "submit"] }
      ]
    },
    {
      "id": "compta-paie",
      "nom_fr": "Gestionnaire Paie · Consortium ECR DR",
      "famille": "finance",
      "portail": "compta",
      "entite_principale": "Consortium ECR DR",
      "niveau": 3,
      "erpnext_role_name": "OTO Compta Paie",
      "scope_donnees": "entite",
      "description": "Traite la paie (paymaster RH Consortium ECR DR) ; établit et soumet les bulletins.",
      "modules": ["Payroll", "HR"],
      "permissions_cibles": [
        { "doctype": "Salary Slip", "actions": ["read", "write", "create", "submit"] },
        { "doctype": "Employee", "actions": ["read"] }
      ]
    },
    {
      "id": "compta-fiscaliste-ecf",
      "nom_fr": "Fiscaliste / e-CF DGII",
      "famille": "finance",
      "portail": "compta",
      "entite_principale": "WA SRL",
      "niveau": 3,
      "erpnext_role_name": "OTO Compta Fiscaliste eCF",
      "scope_donnees": "entite",
      "description": "Gère la facturation électronique e-CF (Compupar/DGII) et la conformité fiscale RD.",
      "modules": ["Accounts", "Report"],
      "permissions_cibles": [
        { "doctype": "Sales Invoice", "actions": ["read", "write", "submit", "export"] },
        { "doctype": "Purchase Invoice", "actions": ["read", "export"] }
      ]
    },
    {
      "id": "compta-audit-uaf",
      "nom_fr": "Auditeur Interne / Conformité UAF",
      "famille": "finance",
      "portail": "compta",
      "entite_principale": "Groupe",
      "niveau": 4,
      "erpnext_role_name": "OTO Compta Audit UAF",
      "scope_donnees": "groupe",
      "description": "Audit interne et conformité anti-blanchiment (UAF) ; accès lecture/rapport étendu, aucune écriture comptable.",
      "modules": ["Accounts", "Report"],
      "permissions_cibles": [
        { "doctype": "GL Entry", "actions": ["read", "report", "export"] },
        { "doctype": "Payment Entry", "actions": ["read", "report"] },
        { "doctype": "Sales Invoice", "actions": ["read", "report"] }
      ]
    },

    {
      "id": "faisabilite-analyste",
      "nom_fr": "Analyste Faisabilité",
      "famille": "faisabilite",
      "portail": "direction",
      "entite_principale": "WA SRL",
      "niveau": 3,
      "erpnext_role_name": "OTO Faisabilité Analyste",
      "scope_donnees": "entite",
      "description": "Produit les faisabilités 4 volets (Masterplan/Architecture/Paysage/Ingénierie) niveau 4Big ; versionne et score.",
      "modules": ["OTOV7 Faisabilité", "Projects", "Report"],
      "permissions_cibles": [
        { "doctype": "Faisabilité", "custom": true, "actions": ["read", "write", "create", "submit", "report"] },
        { "doctype": "Project", "actions": ["read"] }
      ]
    },
    {
      "id": "faisabilite-rendu-3d",
      "nom_fr": "Spécialiste Rendu 3D",
      "famille": "faisabilite",
      "portail": "construction",
      "entite_principale": "WA SRL",
      "niveau": 2,
      "erpnext_role_name": "OTO Faisabilité Rendu 3D",
      "scope_donnees": "entite",
      "description": "Génère les rendus Flux liés au projet réel (❌ IA générique interdite — CLAUDE.md) ; 6 vues/projet.",
      "modules": ["OTOV7 Faisabilité"],
      "permissions_cibles": [
        { "doctype": "File", "actions": ["read", "write", "create"] },
        { "doctype": "Faisabilité", "custom": true, "actions": ["read"] }
      ]
    },
    {
      "id": "faisabilite-ifc-speckle",
      "nom_fr": "Gestionnaire IFC / Speckle",
      "famille": "faisabilite",
      "portail": "construction",
      "entite_principale": "WA SRL",
      "niveau": 2,
      "erpnext_role_name": "OTO Faisabilité IFC Speckle",
      "scope_donnees": "entite",
      "description": "Exporte IFC→GLB et publie les modèles sur bim-cloud.otov7.com pour le viewer console.",
      "modules": ["OTOV7 Faisabilité"],
      "permissions_cibles": [
        { "doctype": "File", "actions": ["read", "write", "create"] },
        { "doctype": "Faisabilité", "custom": true, "actions": ["read", "write"] }
      ]
    },
    {
      "id": "faisabilite-economiste",
      "nom_fr": "Économiste de la Construction (métrés)",
      "famille": "faisabilite",
      "portail": "construction",
      "entite_principale": "AC Arias Cuevas",
      "niveau": 3,
      "erpnext_role_name": "OTO Faisabilité Économiste",
      "scope_donnees": "entite",
      "description": "Produit métrés et quantitatifs (BIM compras) pour le volet Ingénierie ; chiffre les coûts travaux.",
      "modules": ["OTOV7 Faisabilité", "Buying", "Stock"],
      "permissions_cibles": [
        { "doctype": "Faisabilité", "custom": true, "actions": ["read", "write"] },
        { "doctype": "Item", "actions": ["read"] }
      ]
    },

    {
      "id": "legal-directeur",
      "nom_fr": "Directeur Juridique",
      "famille": "legal",
      "portail": "direction",
      "entite_principale": "WAF",
      "niveau": 4,
      "erpnext_role_name": "OTO Legal Directeur",
      "scope_donnees": "groupe",
      "description": "Supervise les contrats, la conformité et les dépôts légaux du groupe ; valide les documents à portée juridique.",
      "modules": ["OTOV7 CONFOTUR", "Accounts", "Report"],
      "permissions_cibles": [
        { "doctype": "CONFOTUR Application", "custom": true, "actions": ["read", "write", "submit", "report"] },
        { "doctype": "Contract", "actions": ["read", "write", "create", "submit"] }
      ]
    },
    {
      "id": "legal-onapi",
      "nom_fr": "Agent ONAPI / Propriété Intellectuelle",
      "famille": "legal",
      "portail": "direction",
      "entite_principale": "WAF",
      "niveau": 2,
      "erpnext_role_name": "OTO Legal ONAPI",
      "scope_donnees": "groupe",
      "description": "Prépare et suit les dépôts ONAPI (marques, Classes 36/37/43) et les dossiers CONFOTUR (P05/P07).",
      "modules": ["OTOV7 CONFOTUR"],
      "permissions_cibles": [
        { "doctype": "CONFOTUR Application", "custom": true, "actions": ["read", "write", "create"] }
      ]
    },

    {
      "id": "plateforme-devops",
      "nom_fr": "Administrateur Système (DevOps)",
      "famille": "plateforme",
      "portail": "plateforme",
      "entite_principale": "9060 QC",
      "niveau": 5,
      "erpnext_role_name": "OTO Plateforme DevOps",
      "scope_donnees": "groupe",
      "description": "Administre l'infrastructure (Docker, Gitea, systemd, nginx) et les déploiements. Aucune plateforme git hors Gitea (CLAUDE.md #2).",
      "modules": ["Core", "Website", "Report"],
      "permissions_cibles": [
        { "doctype": "Scheduled Job Type", "actions": ["read", "write"] },
        { "doctype": "Server Script", "actions": ["read", "write", "create"] }
      ]
    },
    {
      "id": "plateforme-rbac-admin",
      "nom_fr": "Administrateur RBAC / Sécurité",
      "famille": "plateforme",
      "portail": "plateforme",
      "entite_principale": "9060 QC",
      "niveau": 5,
      "erpnext_role_name": "OTO Plateforme RBAC Admin",
      "scope_donnees": "groupe",
      "description": "Gère utilisateurs, rôles et User Permissions ; seul habilité à modifier les habilitations (séparation des pouvoirs).",
      "modules": ["Users and Permissions", "Core"],
      "permissions_cibles": [
        { "doctype": "User", "actions": ["read", "write", "create", "set_user_permissions"] },
        { "doctype": "Role", "actions": ["read", "write", "create"] },
        { "doctype": "Role Profile", "actions": ["read", "write", "create"] },
        { "doctype": "User Permission", "actions": ["read", "write", "create", "delete"] }
      ]
    },
    {
      "id": "plateforme-qa",
      "nom_fr": "Ingénieur QA Plateforme",
      "famille": "plateforme",
      "portail": "plateforme",
      "entite_principale": "9060 QC",
      "niveau": 3,
      "erpnext_role_name": "OTO Plateforme QA",
      "scope_donnees": "groupe",
      "description": "Exécute les audits qualité 4Big (Playwright, night-audit) ; accès lecture large + rapports, aucune écriture métier.",
      "modules": ["Report", "Core"],
      "permissions_cibles": [
        { "doctype": "Report", "actions": ["read", "report", "export"] },
        { "doctype": "Error Log", "actions": ["read"] }
      ]
    },
    {
      "id": "plateforme-otoia",
      "nom_fr": "Orchestrateur OTOIA (compte système)",
      "famille": "plateforme",
      "portail": "plateforme",
      "entite_principale": "9060 QC",
      "niveau": 4,
      "erpnext_role_name": "OTO Plateforme OTOIA",
      "scope_donnees": "groupe",
      "description": "Compte de service de l'agent OTOIA (AEC + RAG + prompt engine). Écrit faisabilités et logs via API ; périmètre limité aux DocTypes DTP.",
      "modules": ["OTOV7 Faisabilité", "OTOV7 Publiciste", "Core"],
      "permissions_cibles": [
        { "doctype": "Faisabilité", "custom": true, "actions": ["read", "write", "create"] },
        { "doctype": "Publiciste Log", "custom": true, "actions": ["read", "write", "create"] }
      ]
    },
    {
      "id": "plateforme-mobile",
      "nom_fr": "Développeur Mobile",
      "famille": "plateforme",
      "portail": "plateforme",
      "entite_principale": "9060 QC",
      "niveau": 2,
      "erpnext_role_name": "OTO Plateforme Mobile",
      "scope_donnees": "groupe",
      "description": "Maintient l'app Expo/React Native et l'API mobile ; gère les builds EAS et les soumissions stores.",
      "modules": ["Core", "Website"],
      "permissions_cibles": [
        { "doctype": "API Access", "custom": true, "actions": ["read", "write"] }
      ]
    },
    {
      "id": "plateforme-bi",
      "nom_fr": "Analyste Données / BI",
      "famille": "plateforme",
      "portail": "plateforme",
      "entite_principale": "Groupe",
      "niveau": 3,
      "erpnext_role_name": "OTO Plateforme BI",
      "scope_donnees": "groupe",
      "description": "Construit tableaux de bord et rapports consolidés (lecture seule) pour la direction ; aucune écriture transactionnelle.",
      "modules": ["Report", "Accounts", "CRM"],
      "permissions_cibles": [
        { "doctype": "Dashboard", "actions": ["read", "write", "create"] },
        { "doctype": "Report", "actions": ["read", "write", "create", "export"] }
      ]
    }
  ]
}
