using System; namespace FrenchExDev.Net.State.Economy.Dsl; /// /// Opération économique au sens SEC 2010 / SCN 2008 (codes P, D, F, K). /// Chaque type d'opération est un phantom type — la classification d'un flux /// devient une contrainte générique compile-time et alimente la table /// de compatibilité opération × secteur scannée par l'analyzer ECO003. /// public interface IEconomicOperation { /// Code SEC 2010 (ex : "P1", "B1g", "D62", "P51g"). string Code { get; } } /// P1 — Production (valeur des biens et services produits). public sealed class P1_Output : IEconomicOperation { public string Code => "P1"; public static readonly P1_Output Instance = new(); private P1_Output() { } } /// P2 — Consommation intermédiaire (biens transformés). public sealed class P2_IntermediateConsumption : IEconomicOperation { public string Code => "P2"; public static readonly P2_IntermediateConsumption Instance = new(); private P2_IntermediateConsumption() { } } /// B1g — Valeur ajoutée brute (P1 − P2). Solde caractéristique des unités productrices. public sealed class B1g_GrossValueAdded : IEconomicOperation { public string Code => "B1g"; public static readonly B1g_GrossValueAdded Instance = new(); private B1g_GrossValueAdded() { } } /// D — Opérations de répartition (impôts, subventions, prestations). Famille ouverte : D2, D5, D6, D7… public sealed class D_DistributiveTransactions : IEconomicOperation { public string Code => "D"; public static readonly D_DistributiveTransactions Instance = new(); private D_DistributiveTransactions() { } } /// P51g — Formation brute de capital fixe (investissement productif). public sealed class P51g_GrossFixedCapitalFormation : IEconomicOperation { public string Code => "P51g"; public static readonly P51g_GrossFixedCapitalFormation Instance = new(); private P51g_GrossFixedCapitalFormation() { } } /// /// Table de compatibilité opération × secteur Eurostat (simplifiée). /// Source : Manuel SEC 2010 — Annexe A, section 1.57 et suivantes. /// L'analyzer ECO003 lit cette table pour émettre un diagnostic quand /// une opération est attribuée à un secteur incompatible (ex : B1g sur S14). /// public static class SectorOperationCompatibility { public static bool IsCompatible(Type sector, Type operation) { if (sector is null) throw new ArgumentNullException(nameof(sector)); if (operation is null) throw new ArgumentNullException(nameof(operation)); // B1g (valeur ajoutée brute) : producteurs uniquement — S11, S12, S13, S15. // Les ménages S14 ne dégagent pas de B1g en tant que secteur // (sauf entrepreneurs individuels traités comme quasi-sociétés dans S11). if (operation == typeof(B1g_GrossValueAdded)) { return sector == typeof(S11_NonFinancialCorporations) || sector == typeof(S12_FinancialCorporations) || sector == typeof(S13_GeneralGovernment) || sector == typeof(S1311_CentralGovernment) || sector == typeof(S1313_LocalGovernment) || sector == typeof(S1314_SocialSecurityFunds) || sector == typeof(S15_NPISH); } // P51g (FBCF) : tous secteurs résidents investissent — pas S2 (reste du monde). if (operation == typeof(P51g_GrossFixedCapitalFormation)) { return sector != typeof(S2_RestOfWorld); } // P1, P2, D : tous secteurs acceptés — la discipline fine (D62 prestations // sociales exclusivement S13/S14 par ex.) est laissée à une table // plus détaillée dans les instances nationales. return true; } }