From e1f46225b424cd7dc7d9d2af618eef8a404813ac Mon Sep 17 00:00:00 2001 From: Davide Colleoni <103409906+dcolleoni@users.noreply.github.com> Date: Wed, 28 Sep 2022 15:45:46 +0200 Subject: [PATCH 01/43] Merge pull request #29 from Systemorph/importCeProject Migrate Base code --- Constants/Consts.ipynb | 386 +++ Constants/Enums.ipynb | 269 ++ Constants/Validations.ipynb | 200 ++ DataModel/DataStructure.ipynb | 2139 ++++++++++++ Database/.gitignore | 1 + Database/Configure.ipynb | 131 + Database/Schema Delete.ipynb | 87 + Export/MapTemplate.ipynb | 338 ++ Files/300.ReportingNodes/ReportingNodes.csv | 10 + .../DataNodeParameters_CH_2020_12.csv | 22 + .../DataNodeStates_CH_2020_12.csv | 19 + Files/700.DataNodes/DataNodes_CH.csv | 36 + Files/800.Parameters/CreditDefaultRate.csv | 23 + Files/800.Parameters/ExchangeRate.csv | 14 + Files/800.Parameters/PartnerRating.csv | 4 + Files/800.Parameters/YieldCurve.csv | 11 + .../Actuals_CH_2020_12.csv | 33 + .../Actuals_CH_2021_3.csv | 62 + .../NominalCashflows_CH_2020_12.csv | 85 + .../NominalCashflows_CH_2021_3.csv | 158 + .../Openings_CH_2020_12.csv | 8 + Files/DimensionsAndPartitions.csv | 259 ++ Images/ActualFormat.png | Bin 0 -> 25544 bytes Images/CashflowFormat.png | Bin 0 -> 66204 bytes Images/OpeningFormat.png | Bin 0 -> 19729 bytes Images/SpecificationsCSM.PNG | Bin 0 -> 40913 bytes Images/SpecificationsImportActuals.PNG | Bin 0 -> 12211 bytes Images/SpecificationsImportCashflows.PNG | Bin 0 -> 38471 bytes Images/SpecificationsPL.PNG | Bin 0 -> 79272 bytes Images/Systemorph_logo.png | Bin 0 -> 17061 bytes Import/ImportResultPreview.ipynb | 344 ++ Import/ImportScopeCalculation.ipynb | 2296 +++++++++++++ Import/ImportStorage.ipynb | 387 +++ Import/Importers.ipynb | 1199 +++++++ .../InitSystemorphBaseToMemory.ipynb | 268 ++ Initialization/InitSystemorphToDatabase.ipynb | 314 ++ Initialization/InitSystemorphToMemory.ipynb | 147 + InputFormatDescription.ipynb | 113 + OverviewCalculationEngine.ipynb | 258 ++ Report/ReportConfigurationAndUtils.ipynb | 148 + Report/ReportScopes.ipynb | 1038 ++++++ Report/ReportStorage.ipynb | 241 ++ Report/Reports.ipynb | 516 +++ Test/AocStructureTest.ipynb | 704 ++++ Test/Data/CashflowComplex.csv | 9 + Test/Data/DataNodeParameter_Duplicate.csv | 13 + .../DataNodeParameter_InvalidDataNode.csv | 14 + .../DataNodeParameter_InvalidReinsCov.csv | 12 + .../BM_CH_2020_12_A.csv | 34 + .../BM_CH_2020_12_AA.csv | 8 + .../BM_CH_2020_12_APA.csv | 11 + .../BM_CH_2020_12_BE.csv | 181 + .../BM_CH_2020_12_BEPA.csv | 11 + .../BM_CH_2020_12_C.csv | 40 + .../BM_CH_2020_12_DA.csv | 21 + .../BM_CH_2020_12_F.csv | 17 + .../BM_CH_2020_12_OA.csv | 8 + .../BM_CH_2020_12_RA.csv | 94 + .../IfrsVariableBenchmarks/BM_CH_2021_3_A.csv | 39 + .../BM_CH_2021_3_AA.csv | 26 + .../BM_CH_2021_3_AAPA.csv | 11 + .../BM_CH_2021_3_APA.csv | 11 + .../BM_CH_2021_3_BE.csv | 471 +++ .../BM_CH_2021_3_BEPA.csv | 16 + .../IfrsVariableBenchmarks/BM_CH_2021_3_C.csv | 55 + .../BM_CH_2021_3_DA.csv | 25 + .../IfrsVariableBenchmarks/BM_CH_2021_3_F.csv | 17 + .../IfrsVariableBenchmarks/BM_CH_2021_3_L.csv | 22 + .../BM_CH_2021_3_LR.csv | 13 + .../BM_CH_2021_3_OA.csv | 26 + .../BM_CH_2021_3_OAPA.csv | 11 + .../BM_CH_2021_3_RA.csv | 215 ++ ...ableBenchmarks_2020_12_CH__Contractual.csv | 537 +++ ...iableBenchmarks_2021_3_CH__Contractual.csv | 1113 +++++++ Test/ExportIfrsVariable.ipynb | 124 + Test/ExportReportVariables.ipynb | 186 ++ Test/IfrsVariablesTest.ipynb | 327 ++ Test/ImportStorageTest.ipynb | 707 ++++ Test/MapTemplateAndImportTest.ipynb | 564 ++++ Test/QueriesTest.ipynb | 535 +++ Test/ReportStorageTest.ipynb | 127 + Test/ReportVariablesTest.ipynb | 256 ++ Test/ReportVariablesTestBase.ipynb | 161 + Test/SpecificationsFinancialPerformance.ipynb | 1692 ++++++++++ Test/SpecificationsImportActuals.ipynb | 705 ++++ Test/SpecificationsImportCashflows.ipynb | 2906 +++++++++++++++++ Test/SpecificationsSetup.ipynb | 137 + Test/SpecificationsTechnicalMargin.ipynb | 2576 +++++++++++++++ Test/TechnicalMarginTest.ipynb | 305 ++ Test/Tests.ipynb | 183 ++ Utils/ApplicationMessage.ipynb | 149 + Utils/UtilityMethods.ipynb | 1155 +++++++ 92 files changed, 28144 insertions(+) create mode 100644 Constants/Consts.ipynb create mode 100644 Constants/Enums.ipynb create mode 100644 Constants/Validations.ipynb create mode 100644 DataModel/DataStructure.ipynb create mode 100644 Database/.gitignore create mode 100644 Database/Configure.ipynb create mode 100644 Database/Schema Delete.ipynb create mode 100644 Export/MapTemplate.ipynb create mode 100644 Files/300.ReportingNodes/ReportingNodes.csv create mode 100644 Files/700.DataNodes/DataNodeParameters_CH_2020_12.csv create mode 100644 Files/700.DataNodes/DataNodeStates_CH_2020_12.csv create mode 100644 Files/700.DataNodes/DataNodes_CH.csv create mode 100644 Files/800.Parameters/CreditDefaultRate.csv create mode 100644 Files/800.Parameters/ExchangeRate.csv create mode 100644 Files/800.Parameters/PartnerRating.csv create mode 100644 Files/800.Parameters/YieldCurve.csv create mode 100644 Files/900.TransactionalData/Actuals_CH_2020_12.csv create mode 100644 Files/900.TransactionalData/Actuals_CH_2021_3.csv create mode 100644 Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv create mode 100644 Files/900.TransactionalData/NominalCashflows_CH_2021_3.csv create mode 100644 Files/900.TransactionalData/Openings_CH_2020_12.csv create mode 100644 Files/DimensionsAndPartitions.csv create mode 100644 Images/ActualFormat.png create mode 100644 Images/CashflowFormat.png create mode 100644 Images/OpeningFormat.png create mode 100644 Images/SpecificationsCSM.PNG create mode 100644 Images/SpecificationsImportActuals.PNG create mode 100644 Images/SpecificationsImportCashflows.PNG create mode 100644 Images/SpecificationsPL.PNG create mode 100644 Images/Systemorph_logo.png create mode 100644 Import/ImportResultPreview.ipynb create mode 100644 Import/ImportScopeCalculation.ipynb create mode 100644 Import/ImportStorage.ipynb create mode 100644 Import/Importers.ipynb create mode 100644 Initialization/InitSystemorphBaseToMemory.ipynb create mode 100644 Initialization/InitSystemorphToDatabase.ipynb create mode 100644 Initialization/InitSystemorphToMemory.ipynb create mode 100644 InputFormatDescription.ipynb create mode 100644 OverviewCalculationEngine.ipynb create mode 100644 Report/ReportConfigurationAndUtils.ipynb create mode 100644 Report/ReportScopes.ipynb create mode 100644 Report/ReportStorage.ipynb create mode 100644 Report/Reports.ipynb create mode 100644 Test/AocStructureTest.ipynb create mode 100644 Test/Data/CashflowComplex.csv create mode 100644 Test/Data/DataNodeParameter_Duplicate.csv create mode 100644 Test/Data/DataNodeParameter_InvalidDataNode.csv create mode 100644 Test/Data/DataNodeParameter_InvalidReinsCov.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_A.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_AA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_APA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BE.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_BEPA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_C.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_DA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_F.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_OA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_RA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_A.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_AA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_AAPA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_APA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_BE.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_BEPA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_C.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_DA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_F.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_L.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_LR.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_OA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_OAPA.csv create mode 100644 Test/Data/IfrsVariableBenchmarks/BM_CH_2021_3_RA.csv create mode 100644 Test/Data/ReportVariableBenchmarks/ReportVariableBenchmarks_2020_12_CH__Contractual.csv create mode 100644 Test/Data/ReportVariableBenchmarks/ReportVariableBenchmarks_2021_3_CH__Contractual.csv create mode 100644 Test/ExportIfrsVariable.ipynb create mode 100644 Test/ExportReportVariables.ipynb create mode 100644 Test/IfrsVariablesTest.ipynb create mode 100644 Test/ImportStorageTest.ipynb create mode 100644 Test/MapTemplateAndImportTest.ipynb create mode 100644 Test/QueriesTest.ipynb create mode 100644 Test/ReportStorageTest.ipynb create mode 100644 Test/ReportVariablesTest.ipynb create mode 100644 Test/ReportVariablesTestBase.ipynb create mode 100644 Test/SpecificationsFinancialPerformance.ipynb create mode 100644 Test/SpecificationsImportActuals.ipynb create mode 100644 Test/SpecificationsImportCashflows.ipynb create mode 100644 Test/SpecificationsSetup.ipynb create mode 100644 Test/SpecificationsTechnicalMargin.ipynb create mode 100644 Test/TechnicalMarginTest.ipynb create mode 100644 Test/Tests.ipynb create mode 100644 Utils/ApplicationMessage.ipynb create mode 100644 Utils/UtilityMethods.ipynb diff --git a/Constants/Consts.ipynb b/Constants/Consts.ipynb new file mode 100644 index 00000000..21850a86 --- /dev/null +++ b/Constants/Consts.ipynb @@ -0,0 +1,386 @@ +{ + "metadata": { + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "toc-autonumbering": "True", + "toc-showcode": "False", + "toc-showmarkdowntxt": "False", + "authors": [], + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "id": "2kYu9e9ygUipdOuqA9Hk6A", + "cell_type": "markdown", + "source": [ + "
Consts
" + ], + "metadata": {} + }, + { + "id": "DmUpa-myfk6s7tnBoktcyw", + "cell_type": "markdown", + "source": [ + "# Numerical Precision" + ], + "metadata": {} + }, + { + "id": "KG3zmL2K_kGTNzWA2eQJvg", + "cell_type": "code", + "source": [ + "public const double Precision = 1E-5;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "gMPLPUb7kUiJnLQWtEkkFA", + "cell_type": "code", + "source": [ + "public const double ProjectionPrecision = 1E-3;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "gv0HnKTwuU--7Xo8e6UU2w", + "cell_type": "code", + "source": [ + "public const double BenchmarkPrecision = 1E-4;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "gbuDd5t2Ike1Jq-lnVVIqg", + "cell_type": "markdown", + "source": [ + "# Time Period" + ], + "metadata": {} + }, + { + "id": "oX6yOw75DE-NwrYkdYTmzg", + "cell_type": "code", + "source": [ + "public const int CurrentPeriod = 0; " + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "2XFjLebnDEWBoNCyq6lKgg", + "cell_type": "code", + "source": [ + "public const int PreviousPeriod = -1; " + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "5ydvfd1abEm-CSTH-csz-g", + "cell_type": "code", + "source": [ + "public const int MonthInAYear = 12;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "yhpv5BPDJUGKucF6Y_AVeQ", + "cell_type": "markdown", + "source": [ + "# Defaults" + ], + "metadata": {} + }, + { + "id": "uOfb6nvi8USI3mPOH8YvwQ", + "cell_type": "code", + "source": [ + "public const int DefaultDataNodeActivationMonth = 1;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "ZU5IN71RqEmHfRQSSCUvnw", + "cell_type": "code", + "source": [ + "public const double DefaultPremiumExperienceAdjustmentFactor = 1.0;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "KNUzhe58B0GBnCuZD1ATOg", + "cell_type": "markdown", + "source": [ + "# Names" + ], + "metadata": {} + }, + { + "id": "hZGPPDopiECnoXlB48cB2Q", + "cell_type": "code", + "source": [ + "public const string Main = nameof(Main);" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "w5Zs2AGjxkWgRQfAGs8BIA", + "cell_type": "code", + "source": [ + "public const string Default = nameof(Default);" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "jAyhudwOJkmsPwMaZM1P4g", + "cell_type": "code", + "source": [ + "public const string ValueType = nameof(ValueType);" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "Aj_qnZxiqUeFHk088tNruA", + "cell_type": "markdown", + "source": [ + "GroupCurrency defines the SystemName (from Currency Dimension) to be used as the Group Currency." + ], + "metadata": {} + }, + { + "id": "pvlhKSXdW0Wt3dns45SWfQ", + "cell_type": "code", + "source": [ + "public const string GroupCurrency = \"CHF\";" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "9SCJFj6zcUK_5Uczpicjjw", + "cell_type": "markdown", + "source": [ + "# Import Formats" + ], + "metadata": {} + }, + { + "id": "xEDrrk_AxUicpKHTSr6acA", + "cell_type": "code", + "source": [ + "public static class ImportFormats{", + "\n public const string Cashflow = nameof(Cashflow);", + "\n public const string Actual = nameof(Actual);", + "\n public const string DataNodeParameter = nameof(DataNodeParameter);", + "\n public const string SimpleValue = nameof(SimpleValue);", + "\n public const string Opening = nameof(Opening);", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "DQHpY4V8xUOGR8L84B7DTg", + "cell_type": "markdown", + "source": [ + "# IFRS specific" + ], + "metadata": {} + }, + { + "id": "YjgOf6OCyUuxcwR9IhoZvA", + "cell_type": "code", + "source": [ + "public static class ValuationApproaches{", + "\n public const string BBA = nameof(BBA); //Building Block Approach", + "\n public const string VFA = nameof(VFA); //Variable Fee Approach", + "\n public const string PAA = nameof(PAA); //Premium Allocation Approach", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "pMhVfzvrjkyXcNpx0Tn4wA", + "cell_type": "code", + "source": [ + "public static class LiabilityTypes{", + "\n public const string LRC = nameof(LRC); //Liability for Remaining Coverage", + "\n public const string LIC = nameof(LIC); //Liability Incurred Claims", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "1eDEjgoZmEOfPbRzZthlTQ", + "cell_type": "code", + "source": [ + "public static class CalculationTypes{", + "\n public const string BE = nameof(BE); //Best Estimate", + "\n public const string CU = nameof(CU); //Coverage Units", + "\n public const string RA = nameof(RA); //Risk Adjustment", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "b6cmqzNyQ0q0McHf-Rf5lw", + "cell_type": "code", + "source": [ + "public static class EstimateTypes{", + "\n public const string BE = nameof(BE); //Best Estimate", + "\n public const string RA = nameof(RA); //Risk Adjustment", + "\n public const string A = nameof(A); //Actuals", + "\n public const string AA = nameof(AA); //Advance Actuals", + "\n public const string OA = nameof(OA); //Overdue Actuals", + "\n public const string DA = nameof(DA); //Deferrable Actuals", + "\n public const string C = nameof(C); //Contractual Service Margin", + "\n public const string L = nameof(L); //Loss Component", + "\n public const string LR = nameof(LR); //Loss Recovery", + "\n public const string F = nameof(F); //factors", + "\n public const string FCF = nameof(FCF); //Fulfilment Cash flows", + "\n public const string BEPA = nameof(BEPA); //Experience Adjusted BE Premium to Csm", + "\n public const string APA = nameof(APA); //Experience Adjusted Written Actual Premium to Csm", + "\n public const string AAPA = nameof(AAPA); //Experience Adjusted Advance Actual Premium to Csm", + "\n public const string OAPA = nameof(OAPA); //Experience Adjusted Overdue Actual Premium to Csm", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "vCJNvDF6D02HPepD8ay2pA", + "cell_type": "code", + "source": [ + "public static class AocTypes{", + "\n public const string BOP = nameof(BOP);", + "\n public const string MC = nameof(MC);", + "\n public const string RCU = nameof(RCU);", + "\n public const string CF = nameof(CF);", + "\n public const string IA = nameof(IA);", + "\n public const string YCU = nameof(YCU);", + "\n public const string CRU = nameof(CRU);", + "\n public const string WO = nameof(WO);", + "\n public const string EV = nameof(EV);", + "\n public const string CL = nameof(CL);", + "\n public const string EA = nameof(EA);", + "\n public const string AM = nameof(AM);", + "\n public const string FX = nameof(FX);", + "\n public const string EOP = nameof(EOP);", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "OE45Je2KUk6WlHo9upd5fA", + "cell_type": "code", + "source": [ + "public static class Novelties{", + "\n public const string I = nameof(I); //In-Force", + "\n public const string N = nameof(N); //New Business", + "\n public const string C = nameof(C); //All Novelties Combined", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "BUPmJSTjdkuP8nR7MJyQiw", + "cell_type": "code", + "source": [ + "public static class EconomicBases{", + "\n public const string L = nameof(L); //Locked Interest Rates", + "\n public const string C = nameof(C); //Current Interest Rates", + "\n public const string N = nameof(N); //Nominal Interest Rates", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "-cRhXT5tKE-834Umpyaudw", + "cell_type": "code", + "source": [ + "public static class AmountTypes{", + "\n public const string ACA = nameof(ACA); //Attributable Commissions Acquisition", + "\n public const string AEA = nameof(AEA); //Attributable Expenses Acquisition", + "\n public const string CDR = nameof(CDR); //Credit Default Risk", + "\n public const string CL = nameof(CL); //Claims", + "\n public const string PR = nameof(PR); //Premiums", + "\n public const string NIC = nameof(NIC); //Claims Non-Investment component", + "\n public const string ICO = nameof(ICO); //Claims Investment component", + "\n public const string NE = nameof(NE); //Non Attributable Expenses", + "\n public const string ACM = nameof(ACM); //Attributable Commissions Maintenance", + "\n public const string AEM = nameof(AEM); //Attributable Expenses Maintenance", + "\n public const string AC = nameof(AC); //Attributable Commissions", + "\n public const string AE = nameof(AE); //Attributable Expenses", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "e33hFwGm9kmVNOsShmvn4w", + "cell_type": "markdown", + "source": [ + "# Insurance specific" + ], + "metadata": {} + }, + { + "id": "9n2de6iCUEKECrkoUtSuiw", + "cell_type": "code", + "source": [ + "public static class LineOfBusinesses{", + "\n public const string LI = nameof(LI); //Life", + "\n public const string NL = nameof(NL); //Non-Life", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/Constants/Enums.ipynb b/Constants/Enums.ipynb new file mode 100644 index 00000000..5700a892 --- /dev/null +++ b/Constants/Enums.ipynb @@ -0,0 +1,269 @@ +{ + "metadata": { + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "toc-autonumbering": "True", + "toc-showcode": "False", + "toc-showmarkdowntxt": "False", + "authors": [], + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "id": "HUFgBXkmYU6rV0daYBo-nQ", + "cell_type": "markdown", + "source": [ + "# Enumerables", + "\n", + "\nIn the case of data which is not expected to change over time, it is convenient to introduce such data as variables of type \"enumerable\"." + ], + "metadata": {} + }, + { + "id": "ALWeaAkPh0uiwQ9SYb9Y-w", + "cell_type": "markdown", + "source": [ + "## Exchange Rates", + "\n", + "\nFor exchange rates, we set the type for which the rates apply:" + ], + "metadata": {} + }, + { + "id": "W6x_0Pa3_kOAd3N9CBgcgQ", + "cell_type": "code", + "source": [ + "public enum FxType { Spot, Average }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "r50zPe2AP0KrCOR-fgpccg", + "cell_type": "code", + "source": [ + "public enum FxPeriod { NotApplicable, BeginningOfPeriod, Average, EndOfPeriod }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "YCF3tVHQB0eUa0yWpiRD0g", + "cell_type": "markdown", + "source": [ + "## Currency Types" + ], + "metadata": {} + }, + { + "id": "cF0fRptcGE64Vr1b058rqg", + "cell_type": "markdown", + "source": [ + "Currency Types define which currency is used as standard at different aggregation levels (in the Data Level hierarchy).", + "\n- Functional: this is the standard Currency Type at Reporting Node level", + "\n- Group: this is the standard Currency Type at Group level", + "\n- Contractual: this is the standard Currency Type at Data Node level", + "\n- Transactional: this is the standard Currency Type at Transactional level (used typically for Actuals)" + ], + "metadata": {} + }, + { + "id": "zj07LR0PT0CesH4nRl1Sig", + "cell_type": "code", + "source": [ + "public enum CurrencyType { Functional, Group, Contractual, Transactional }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "wL17I9jyQ0eaeXrSdlvJyA", + "cell_type": "markdown", + "source": [ + "## Period Type" + ], + "metadata": {} + }, + { + "id": "3e3wVNw-rECnTHBTkVOfCQ", + "cell_type": "code", + "source": [ + "public enum PeriodType { NotApplicable, BeginningOfPeriod, EndOfPeriod }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "Expd7Urm102om6-y2Skz4w", + "cell_type": "markdown", + "source": [ + "## Valuation Period" + ], + "metadata": {} + }, + { + "id": "dsJwHWIQPkOB29dEUCLHGg", + "cell_type": "code", + "source": [ + "public enum ValuationPeriod { NotApplicable, BeginningOfPeriod, MidOfPeriod, Delta, EndOfPeriod }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "iejG0G0VJ0q_tAg2HGHuOw", + "cell_type": "markdown", + "source": [ + "## Portfolio View" + ], + "metadata": {} + }, + { + "id": "0Pdzxbnsx0SOaIiUb_X1YQ", + "cell_type": "code", + "source": [ + "[Flags] public enum PortfolioView { Gross = 1, Reinsurance = 2, Net = Gross | Reinsurance }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "v7NVqB0p1Ei4vilTCiErFg", + "cell_type": "markdown", + "source": [ + "## Structure Type" + ], + "metadata": {} + }, + { + "id": "Kge1fD31n0S7BW0EiClT0g", + "cell_type": "code", + "source": [ + "public enum StructureType { None, AoC }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "S49a3Gcz_0S7apcSmQy3JA", + "cell_type": "markdown", + "source": [ + "## State" + ], + "metadata": {} + }, + { + "id": "mJADknA9Q0KQjmTmf03Blw", + "cell_type": "markdown", + "source": [ + "State describes the state in which a Data Node can be - There are two types of states:", + "\n- Active: visible in reports and queries", + "\n- Inactive: not visible in reports and queries" + ], + "metadata": {} + }, + { + "id": "lsRYxseYzUaLMcAn7JB2Qw", + "cell_type": "code", + "source": [ + "public enum State { Active, Inactive }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "kgMLZfJ4PkCFRU4kLKSGcw", + "cell_type": "markdown", + "source": [ + "## Periodicity" + ], + "metadata": {} + }, + { + "id": "iV_fcqBE2E6B12CgJq2ybg", + "cell_type": "code", + "source": [ + "public enum Periodicity { Monthly, Quarterly, Yearly }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "ndV2D2lQL0icIY9VirJweQ", + "cell_type": "markdown", + "source": [ + "## Input Source" + ], + "metadata": {} + }, + { + "id": "z6t0m-civUGAcBEAW0C3Nw", + "cell_type": "code", + "source": [ + "[Flags]", + "\npublic enum InputSource {NotApplicable = 0, Opening = 1, Actual = 2, Cashflow = 4} ", + "\n//Opening + Actual = 3,", + "\n//Opening + Cashflow = 5", + "\n//Actual + Cashflow = 6", + "\n//Opening + Actual + Cashflow = 7" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "aEqUAtvxPESgt-FHx2e7yA", + "cell_type": "markdown", + "source": [ + "## Data Type" + ], + "metadata": {} + }, + { + "id": "LR7R7DUA0k6Ywl5WjSrEvg", + "cell_type": "code", + "source": [ + "public enum DataType { Optional, Mandatory, Calculated, CalculatedTelescopic }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "euBhm6zy1Uib521-G3w3eQ", + "cell_type": "markdown", + "source": [ + "## Import Scope" + ], + "metadata": {} + }, + { + "id": "4PP7M-Sv9k6_6MsJWS1bUg", + "cell_type": "code", + "source": [ + "public enum ImportScope { Primary, Secondary }" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/Constants/Validations.ipynb b/Constants/Validations.ipynb new file mode 100644 index 00000000..f58110a8 --- /dev/null +++ b/Constants/Validations.ipynb @@ -0,0 +1,200 @@ +{ + "metadata": { + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "toc-autonumbering": "True", + "toc-showcode": "False", + "toc-showmarkdowntxt": "False", + "authors": [], + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "id": "LgEd-jVnbEGK9QI-QWcVQw", + "cell_type": "markdown", + "source": [ + "Errors and Warnings
" + ], + "metadata": {} + }, + { + "id": "-scbNYag2kmx_38hEmkBgA", + "cell_type": "code", + "source": [ + "#!import \"Enums\"", + "\n#!import \"Consts\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "8xjDwqEVm0WjJuTlC2QERA", + "cell_type": "markdown", + "source": [ + "# Codes" + ], + "metadata": {} + }, + { + "id": "9CPbuC0YV0aSt5wA3uOxnw", + "cell_type": "code", + "source": [ + "public enum Warning {", + "\n // Import", + "\n ActiveDataNodeWithCashflowBOPI,", + "\n // Default", + "\n Generic", + "\n}; " + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "QWAQV2xUcEigl3eydHTJaA", + "cell_type": "code", + "source": [ + "public enum Error { ", + "\n // Import", + "\n NoMainTab, IncompleteMainTab, ParsingScientificNotation, ValueTypeNotFound, ValueTypeNotValid, AocTypeNotValid,", + "\n // Partition", + "\n PartitionNotFound, ParsedPartitionNotFound, PartititionNameNotFound, PartitionTypeNotFound,", + "\n // Dimensions", + "\n AmountTypeNotFound, EstimateTypeNotFound,CalculationTypeNotFound, ReportingNodeNotFound, AocTypeMapNotFound, AocTypeNotFound, PortfolioGicNotFound, PortfolioGricNotFound, ", + "\n InvalidAmountTypeEstimateType, MultipleTechnicalMarginOpening,", + "\n // Exchange Rate", + "\n ExchangeRateNotFound, ExchangeRateCurrency,", + "\n // Data Note State", + "\n ChangeDataNodeState, InactiveDataNodeState,", + "\n // Parameters", + "\n ReinsuranceCoverageDataNode, DuplicateInterDataNode, DuplicateSingleDataNode, InvalidDataNode, ", + "\n // Storage", + "\n DataNodeNotFound, PartnerNotFound, RatingNotFound, CreditDefaultRateNotFound, MissingPremiumAllocation, ReinsuranceCoverage, ", + "\n YieldCurveNotFound, YieldCurvePeriodNotApplicable, EconomicBasisNotFound, AccountingVariableTypeNotFound,", + "\n // Scopes", + "\n NotSupportedAocStepReference, MultipleEoP,", + "\n // Data completeness", + "\n MissingDataAtPosting, MissingCombinedLiability, MissingCoverageUnit, ", + "\n // Default", + "\n Generic", + "\n};" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "ThPESGETMUm31fuq-qS4_w", + "cell_type": "markdown", + "source": [ + "# Messages" + ], + "metadata": {} + }, + { + "id": "x3UlljewwEut3M0NRlUDDg", + "cell_type": "code", + "source": [ + "public static string Get (Error e, params string[] s) => (e, s.Length) switch ", + "\n{", + "\n // Import", + "\n (Error.NoMainTab , _) => $\"No Main tab in the parsed file.\",", + "\n (Error.IncompleteMainTab , _) => $\"Incomplete Main tab in the parsed file.\",", + "\n (Error.ParsingScientificNotation , 1) => $\"While parsing found real number in scientific notation: {s[0]}.\",", + "\n (Error.ValueTypeNotFound , _) => $\"Value Type not found.\",", + "\n (Error.ValueTypeNotValid , 1) => $\"The Value Type {s[0]} is invalid.\",", + "\n (Error.AocTypeNotValid , 1) => $\"The parsed AocType {s[0]} is invalid.\",", + "\n // Partition", + "\n (Error.PartitionNotFound , _) => $\"Partition do not found.\",", + "\n (Error.ParsedPartitionNotFound , 1) => $\"Parsed partition not available: ReportingNode {s[0]}.\",", + "\n (Error.ParsedPartitionNotFound , 4) => $\"Parsed partition not available: ReportingNode {s[0]}, Year {s[1]}, Month {s[2]}, Scenario {s[3]}.\",", + "\n (Error.PartitionTypeNotFound , 1) => $\"Partition type not found: {s[0]}.\",", + "\n // Dimensions", + "\n (Error.AmountTypeNotFound , 1) => $\"AmountType {s[0]} not found.\",", + "\n (Error.EstimateTypeNotFound , 1) => $\"EstimateType {s[0]} not found.\",", + "\n (Error.CalculationTypeNotFound , 1) => $\"CalculationType {s[0]} not found.\",", + "\n (Error.ReportingNodeNotFound , 1) => $\"Reporting Node {s[0]} not found.\",", + "\n (Error.AocTypeNotFound , 1) => $\"AocType {s[0]} not found.\",", + "\n (Error.AocTypeMapNotFound , 2) => $\"AocType {s[0]} and Novelty {s[1]} combination not defined in the mapping.\",", + "\n (Error.PortfolioGicNotFound , 2) => $\"Portfolio {s[0]} assigned to Group of Insurance Contract {s[1]} does not exist.\",", + "\n (Error.PortfolioGricNotFound , 2) => $\"Portfolio {s[0]} assigned to Group of Reinsurance Contract {s[1]} does not exist.\",", + "\n (Error.InvalidAmountTypeEstimateType , 2) => $\"Invalid combination of EstimateType {s[0]} and AmountType {s[1]}.\",", + "\n (Error.MultipleTechnicalMarginOpening , 1) => $\"Multiple opening for techincal margin are not allowed for DataNode {s[0]}.\",", + "\n // Exchange Rate", + "\n (Error.ExchangeRateNotFound , 2) => $\"Exchange Rate for {s[0]} {s[1]} is not present.\",", + "\n (Error.ExchangeRateCurrency , 1) => $\"{s[0]} does not have any Exchange Rate defined.\", ", + "\n // Data Node State", + "\n (Error.ChangeDataNodeState , 0) => $\"Data Node State can not change from Inactive state into Active state.\",", + "\n (Error.ChangeDataNodeState , 1) => $\"Data Node State for {s[0]} can not change from Inactive state into Active state.\",", + "\n (Error.ChangeDataNodeState , 3) => $\"Data Node State for {s[0]} can not change from {s[1]} state into {s[2]} state.\",", + "\n (Error.InactiveDataNodeState , 1) => $\"Data imported for inactive Data Node {s[0]}.\",", + "\n //Parameters", + "\n (Error.ReinsuranceCoverageDataNode , 2) => $\"Invalid Reinsurance Coverage parameter does not link a GroupOfReinsuranceContract to a GroupOfInsuranceContract. Provided GroupOfContracts are: {s[0]}, {s[1]}.\",", + "\n (Error.DuplicateInterDataNode , 2) => $\"Duplicated Inter-DataNode parameter for {s[0]}-{s[1]} is found.\",", + "\n (Error.DuplicateSingleDataNode , 1) => $\"Duplicated Single-DataNode parameter for {s[0]} is found.\",", + "\n (Error.InvalidDataNode , 1) => $\"Data imported for invalid Data Node {s[0]}.\",", + "\n // Storage", + "\n (Error.DataNodeNotFound , 1) => $\"DataNode {s[0]} not found.\",", + "\n (Error.PartnerNotFound , 1) => $\"Partner not found for DataNode {s[0]}.\",", + "\n (Error.RatingNotFound , 1) => $\"Rating not found for Partner {s[0]}.\",", + "\n (Error.CreditDefaultRateNotFound , 1) => $\"Credit Default Rate not found for rating {s[0]}.\",", + "\n (Error.MissingPremiumAllocation , 1) => $\"Premium Allocation Rate not found for Group of Contract {s[0]}.\", // TODO: this is now a warning to be produced by a validation in the importers (default is 1)", + "\n (Error.ReinsuranceCoverage , 1) => $\"Reinsurance Allocation Rate not found for Group of Insurance Contract {s[0]}.\",", + "\n (Error.YieldCurveNotFound , 3) => $\"Yield Curve not found for currency {s[0]}, year {s[1]}, and month {s[2]}.\",", + "\n (Error.YieldCurvePeriodNotApplicable , 2) => $\"YieldCurve period NotApplicable not valid for AocStep with AocType {s[0]} and Novelty {s[1]}.\",", + "\n (Error.EconomicBasisNotFound , 1) => $\"EconomicBasis not valid for DataNode {s[0]}.\",", + "\n (Error.AccountingVariableTypeNotFound , 1) => $\"AccountingVariableType {s[0]} not found.\",", + "\n // Scopes", + "\n (Error.NotSupportedAocStepReference , 1) => $\"Unsupported reference Aoc Step for Aoc Type {s[0]}.\",", + "\n (Error.MultipleEoP , 0) => $\"Closing Balance for both Csm and Lc are computed.\",", + "\n // Data Completeness", + "\n (Error.MissingDataAtPosting , 1) => $\"Missing imported data for {s[0]} DataNode.\",", + "\n (Error.MissingCombinedLiability , 2) => $\"Missing Combined Liability Aoc Type for DataNode {s[0]} and AmountType {s[1]}.\",", + "\n (Error.MissingCoverageUnit , 1) => $\"Missing Coverage Unit cash flow for {s[0]} DataNode.\",", + "\n // Default", + "\n (Error.Generic , _) => $\"{s[0]}\",", + "\n (_ , _) => $\"Error not found.\"", + "\n};" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "PnguuqruSkaTERChlORdKw", + "cell_type": "code", + "source": [ + "public static string Get (Warning w, params string[] s) => (w, s.Length) switch {", + "\n // Import", + "\n (Warning.ActiveDataNodeWithCashflowBOPI , _) => $\"Cashflows for active DataNode has been parsed with AocType {AocTypes.BOP} and Novelty {Novelties.I} \",", + "\n // Default", + "\n (Warning.Generic , _) => $\"{s[0]}\",", + "\n (_ , _) => $\"Warning not found.\"", + "\n};" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "COxOqdqYwUqx0ozqRQof0w", + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/DataModel/DataStructure.ipynb b/DataModel/DataStructure.ipynb new file mode 100644 index 00000000..1e65f8b1 --- /dev/null +++ b/DataModel/DataStructure.ipynb @@ -0,0 +1,2139 @@ +{ + "metadata": { + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "toc-autonumbering": "True", + "toc-showcode": "False", + "toc-showmarkdowntxt": "False", + "authors": [], + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "id": "E3XGdKdQXkSFZwQ0OR8f9Q", + "cell_type": "markdown", + "source": [ + "", + "\nData Model
", + "\n", + "\nThis notebook has the main structures used to hold data - This is usually called the **data model**." + ], + "metadata": {} + }, + { + "id": "wIRyXTP_f0aojedzQ_2yaw", + "cell_type": "markdown", + "source": [ + "# References", + "\nThis section initializes libraries and code from other notebooks, which will be used here, as well as information needed for querying data from the database." + ], + "metadata": {} + }, + { + "id": "_ldA06bDKEyrEr1rDJpRng", + "cell_type": "markdown", + "source": [ + "## Libraries" + ], + "metadata": {} + }, + { + "id": "iVjxSwqCvkCRk9OnawoClw", + "cell_type": "code", + "source": [ + "#r \"nuget:Systemorph.Workspace,1.2.0\"", + "\n#r \"nuget:Systemorph.Scopes,1.2.4\"", + "\n#r \"nuget:Systemorph.Import,1.3.0\"", + "\n#r \"nuget:Systemorph.Test,1.2.4\"", + "\n#r \"nuget:Systemorph.Export,1.3.0\"", + "\n#r \"nuget:Systemorph.DataSetReader,1.3.0\"", + "\n#r \"nuget:Systemorph.DataSource,1.2.0\"", + "\n#r \"nuget:Systemorph.DataSource.Conversions,1.2.0\"", + "\n#r \"nuget:Systemorph.Reporting,1.2.4\"", + "\n#r \"nuget:Systemorph.DomainDesigner,1.3.0\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "tVqfp6kjPEWcWTsE7nmIJQ", + "cell_type": "markdown", + "source": [ + "## Usings" + ], + "metadata": {} + }, + { + "id": "H4cEfQ5jnE-pcrbgue7FNA", + "cell_type": "code", + "source": [ + "using System.ComponentModel.DataAnnotations;", + "\nusing System.ComponentModel.DataAnnotations.Schema;", + "\nusing Systemorph.Vertex.Grid.Model;", + "\nusing static Systemorph.Vertex.Arithmetics.ArithmeticOperations;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "r7mAcZwhpEOp8xf82HvdyQ", + "cell_type": "markdown", + "source": [ + "## Notebooks" + ], + "metadata": {} + }, + { + "id": "wkcyVZzJ5kqKCJm_siKkNQ", + "cell_type": "code", + "source": [ + "#!import \"../Constants/Enums\"", + "\n#!import \"../Constants/Consts\"", + "\n#!import \"../Constants/Validations\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "HTeT_yYbpUCPrWtjwe9fdQ", + "cell_type": "markdown", + "source": [ + "# Data Infrastructure" + ], + "metadata": {} + }, + { + "id": "HrfAYsLiM0SFRqKe6IIlxA", + "cell_type": "markdown", + "source": [ + "", + "\n## Base Interfaces", + "\nThe following interfaces are used to define the granularity at which data is stored.", + "\n", + "\nFor instance, the IKeyed interface corresponds to the lowest granularity which is simply a unique identifier for a certain generic piece of data:" + ], + "metadata": {} + }, + { + "id": "-JHURlI5Z0mY6_UxQ7gfGA", + "cell_type": "code", + "source": [ + "public interface IKeyed", + "\n{ ", + "\n public Guid Id { get; init; }", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "TLXXKZET0E-dDwCIcdZXBg", + "cell_type": "markdown", + "source": [ + "The interface IPartition identifies the partitions in the system." + ], + "metadata": {} + }, + { + "id": "A-Onlfa3vkqOVvHu6-JMQg", + "cell_type": "code", + "source": [ + "public interface IPartition : IKeyed {}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "iF7QiEQqBE2pxD1M85J2Sw", + "cell_type": "markdown", + "source": [ + "The interface IPartitioned simply assigns a unique identifier for elements of a data partition - The exact definition of such elements can be found in the [partition](#partition) section below." + ], + "metadata": {} + }, + { + "id": "UI71Ps6BF0K27AoG-9UkDw", + "cell_type": "code", + "source": [ + "public interface IPartitioned", + "\n{", + "\n public Guid Partition { get; init; }", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "mwvvs9R7IE6s7-QzaQ44Iw", + "cell_type": "markdown", + "source": [ + "The interface IHierarchy is used for modelling dimensions which have an hierarchical structure, such as [Amount Type](#amount-type)." + ], + "metadata": {} + }, + { + "id": "udn_BFvLkE-kpOBDTNrOzg", + "cell_type": "code", + "source": [ + "public interface IHierarchy", + "\n{", + "\n [Display(Order = 10)]", + "\n public string Name { get; init; }", + "\n ", + "\n [Display(Order = 20)]", + "\n public string Parent { get; init; }", + "\n ", + "\n [Display(Order = 30)]", + "\n public string Child { get; init; }", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "qlvXHTn5VUmrP2f97WrtTw", + "cell_type": "markdown", + "source": [ + "The interface IWithYearAndMonth allows to speficy to which year and month a certain piece of data applies to:" + ], + "metadata": {} + }, + { + "id": "jD1t0fnTnUGMALFqTwsLHA", + "cell_type": "code", + "source": [ + "public interface IWithYearAndMonth", + "\n{", + "\n public int Year { get; init; }", + "\n ", + "\n public int Month { get; init; }", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "WbhV6bUsy0ukIAm920fzwg", + "cell_type": "markdown", + "source": [ + "", + "\n## Abstract Classes", + "\nThese classes are not reflected in the database, i.e. are not persisted." + ], + "metadata": {} + }, + { + "id": "EVd9ytkY40OTYvjWp5aziA", + "cell_type": "code", + "source": [ + "public abstract record KeyedRecord : IKeyed {", + "\n [Key]", + "\n [NotVisible] ", + "\n public Guid Id { get; init; }", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "h-P8iuN2zUqCz2F1HgnXjQ", + "cell_type": "code", + "source": [ + "public abstract record KeyedDimension : INamed {", + "\n [Key]", + "\n [IdentityProperty]", + "\n [StringLength(16)]", + "\n [Display(Order = 1)]", + "\n public string SystemName { get; init; }", + "\n ", + "\n [Display(Order = 2)]", + "\n [NotVisible]", + "\n public string DisplayName { get; init; }", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "q1r9nxY4cEudsXAFS_0LOA", + "cell_type": "code", + "source": [ + "public abstract record KeyedOrderedDimension : KeyedDimension, IOrdered {", + "\n [NotVisible]", + "\n public int Order { get; init; }", + "\n}" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "V0ZEujrm8EeHPz95bLGLOA", + "cell_type": "code", + "source": [ + "public abstract record KeyedOrderedDimensionWithExternalId : KeyedOrderedDimension {", + "\n [Display(Order = 100)]", + "\n [Conversion(typeof(JsonConverterExternalId."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "ffEXk8fDRUSuFc1EOOWVXA",
+ "cell_type": "code",
+ "source": [
+ "public record AmountType : KeyedOrderedDimensionWithExternalId, IHierarchicalDimension",
+ "\n{",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(AmountType))]",
+ "\n public string Parent { get; init; }",
+ "\n ",
+ "\n [Display(Order = 20)]",
+ "\n [Dimension(typeof(PeriodType))]",
+ "\n public PeriodType PeriodType { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "xY7Lv0cnPk2ZqR7zMUKVAQ",
+ "cell_type": "markdown",
+ "source": [
+ "We distinguish between amount types used for cashflows and actuals (**Present Value Amount Types**), and amount types used for deferrable values (**Deferrable Amount Types**). In particular, deferrable amount types are for costs and expenses that can be deferred to the future. These amounts are treated separately from the Present Value Amount Types because they are not considered for the calculation of Contractual Service Margin and Loss Component."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "u1zwrsAl_06VNVKVjqY52g",
+ "cell_type": "code",
+ "source": [
+ "public record PvAmountType : AmountType {} //TODO Rename ",
+ "\n",
+ "\npublic record DeferrableAmountType : AmountType {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "uCEMSSPR00Oh87NXjPpxaQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Calculation Type",
+ "\nThis dimension is used to distinguish between e.g. **Best Estimate** values and **Risk Adjustment** values:"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "ZNlHEPmkHky4j1HvhgN88A",
+ "cell_type": "code",
+ "source": [
+ "public record CalculationType : KeyedOrderedDimension {",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(PeriodType))]",
+ "\n public PeriodType PeriodType { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "vKJfcG-udU2bWMy_nL8WSQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Risk Driver",
+ "\n",
+ "\nRisk drivers are used to distinguish between the different Risk Adjustment numbers. For instance: Mortality, Disability, Longevity, etc.",
+ "\n",
+ "\nWhen only total risk adjustment values are used, then there is no need to use risk drivers."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "fa88nNjOdk6ESB_dqpM35w",
+ "cell_type": "code",
+ "source": [
+ "public record RiskDriver : KeyedOrderedDimension, IHierarchicalDimension",
+ "\n{",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(RiskDriver))]",
+ "\n public string Parent { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "VkCT-HB9TkyWJJyAcX42QQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Estimate Type",
+ "\n",
+ "\nEstimate Type is a Scenario record holds the various scenarios for which calculations should also be performed."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "WKR88bI5G0qwjmpDyGZTsw",
+ "cell_type": "code",
+ "source": [
+ "public record Scenario : KeyedDimension {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "c-cppckU8UeROzwpBdL44A",
+ "cell_type": "markdown",
+ "source": [
+ " The 'neutral' Scenario (i.e. the default one, with no-stress situations applied) is designated as 'Best Estimate'."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "ysCBY_ONbUmbRFL_KEXoXg",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Line Of Business"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "XPrjV3N-LE-TKVM80pV5yQ",
+ "cell_type": "markdown",
+ "source": [
+ "Line Of Business is a dimension used to identity insurance business according to usual business classifications (usually a market or company-specific business classification representing a convolution of risk covered, 1st party / 3rd party cover type, product type, etc...)",
+ "\nTypical examples of Line of Business are Motor, Property, Endowment, etc... This is a hierarchical dimension."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "VxLXh8klyEi6UhXPn1ZKKw",
+ "cell_type": "code",
+ "source": [
+ "public record LineOfBusiness : KeyedOrderedDimension, IHierarchicalDimension",
+ "\n{",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(LineOfBusiness))]",
+ "\n public string Parent { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "pnCYzQI05UWCUkXGHAB9QA",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Currency"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "PZEeN2QhsEGXT0BQ4Rjlag",
+ "cell_type": "markdown",
+ "source": [
+ "Currency is a dimension used to identity the currency.",
+ "\nTypical examples of Currency are EUR, CHF, USD, etc..."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "TUEcu5Y_ZE6Nv_pUG-_COQ",
+ "cell_type": "code",
+ "source": [
+ "public record Currency : KeyedDimension {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "TUfMA1ybakuqVJ73ERA3ZQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Economic Basis",
+ "\n",
+ "\nThe Economic Basis defines the discount type which is used in calculations. Examples are: Nominal, Current and Locked."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "rt_ieWyHpU29K0fpiBXLcQ",
+ "cell_type": "code",
+ "source": [
+ "public record EconomicBasis : KeyedDimension {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "CJjymwgpJEiBZhPYBoZV-w",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Valuation Approach",
+ "\nThis dimension holds the various methodologies used in the calculations: BBA, VFA and PAA."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "oPjqx6DSTkyk2Pi5v9Bgww",
+ "cell_type": "code",
+ "source": [
+ "public record ValuationApproach : KeyedDimension {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "v5-cD3t8RkaWxWs7t5oTxg",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Liability Type",
+ "\nThe Liability Type distinguishes betweeen e.g. liabilities for incurred claims and liabilities for remaining coverage."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "zZBD3LVJqUSlsfat1_eEDw",
+ "cell_type": "code",
+ "source": [
+ "public record LiabilityType : KeyedDimension, IHierarchicalDimension",
+ "\n{",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(LiabilityType))]",
+ "\n public string Parent { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "JkEN-M0lnUaJ5FsC0QM6JQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## OCI Type",
+ "\nOther Comprehensive Income (OCI) Type describes how the financial contributions to the IFRS17 Financial Performance is apportioned between the P&L and the OCI sections."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "pAjz1mAaPUGhHNTdyP54gw",
+ "cell_type": "code",
+ "source": [
+ "public record OciType : KeyedDimension {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "ZvvcNAbtHki9DK9rkMj5PQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Profitability"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "SpHNgrkn70WBckuZf-9rtA",
+ "cell_type": "markdown",
+ "source": [
+ "Profitability is a dimension used in IFRS 17 to describe the profitability of a Group of Contracts (GIC/GRIC).",
+ "\nTypical examples of Profitability are Profitable, Non-Profitable, etc.."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "rJS1Lqw9gUyBmW8LzFRIAw",
+ "cell_type": "code",
+ "source": [
+ "public record Profitability : KeyedDimension {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "5nzILMYUw06HnJmXUyLYgg",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Partner",
+ "\nPartner is the counterparty of a reinsurance contract."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "_vf2ckZDHkiTBUqDESRY7A",
+ "cell_type": "code",
+ "source": [
+ "public record Partner : KeyedDimension {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "K48oHe7Yw0GIy27KBHbDtQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Credit Risk Rating",
+ "\nThis holds the credit risk rating of each Partner."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "faZdNRqxWkqUXYnGZQNNLQ",
+ "cell_type": "code",
+ "source": [
+ "public record CreditRiskRating : KeyedDimension {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "LrcDCmrTYkiEFks8X5d5qQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Reporting Node",
+ "\nA Reporting Node is an element in the reporting structure of the company. It has a hierarchical structure and the end nodes is the level at which data is imported."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "yfIk7Ocnc0SkfFXciN5yfQ",
+ "cell_type": "code",
+ "source": [
+ "public record ReportingNode : KeyedDimension, IHierarchicalDimension ",
+ "\n{",
+ "\n [Display(Order = 20)]",
+ "\n [Dimension(typeof(ReportingNode))]",
+ "\n public string Parent { get; init; }",
+ "\n ",
+ "\n [Required]",
+ "\n [Display(Order = 40)]",
+ "\n [Dimension(typeof(Currency))]",
+ "\n public virtual string Currency { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "dgSDvMwORkWAHKNhcKsOsQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Projection Configuration"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "SXiQr9uXpEOar1SWj1NbHQ",
+ "cell_type": "markdown",
+ "source": [
+ "Projections are configured by defining the following 2 parameters:",
+ "\n",
+ "\n- Shift defines how many months are in the cashflow file before the first value of the period in interest.DataType identifies between Calculated aoc steps and Optional inputs or Mandatory inputs.",
+ "\n- InputSource identifies whether an aoc step is relevant for Actuals, Cashflow or both calculations.",
+ "\n- FxPeriod identifies which fx rate should be used.",
+ "\n- YcPeriod identifies which Yield Curve should be used (from current or previous period).",
+ "\n- CdrPeriod identifies which Credit Default Rate should be used (from current or previous period).",
+ "\n- ValuationPeriod identifies which value from the Cashflow corresponds to the Present Value.",
+ "\n- RcPeriod identifies which Reinsurance Coverage should be used (from current or previous period).",
+ "\n",
+ "\nYear. The last value is considered valid also for the following years (for which no value has been provided). ",
+ "\n",
+ "\nThe latest Credit Default Rate available in the system with Year and Month earlier or equal to Year and Month of the closing period will be used as the current value during calculation."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "dGtfTrO3iUaqdptZ0yybYw",
+ "cell_type": "code",
+ "source": [
+ "public record CreditDefaultRate : KeyedRecord, IWithYearAndMonth",
+ "\n{ ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(CreditRiskRating))]",
+ "\n public string CreditRiskRating { get; init; }",
+ "\n",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Year))]",
+ "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n [Display(Order = 20)]",
+ "\n public int Year { get; init; }",
+ "\n ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Month))]",
+ "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n [Display(Order = 30)]",
+ "\n public int Month { get; init; }",
+ "\n ",
+ "\n [Conversion(typeof(PrimitiveArrayConverter))]",
+ "\n [Display(Order = 40)]",
+ "\n public double[] Values { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "9_ycC9yzPkG8EqR3gTj3PA",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Yield Curve",
+ "\nThe record below holds the Yield Curves across time for each [Currency](#currency) and [Scenario](#scenario).",
+ "\nYield curves can be updated every month as part of the close preparation. In general, the last month of the reporting period should be use to import the new data for the period. ",
+ "\n",
+ "\nThe Yield Curve values must be entered with **yearly** granularity, i.e. every value corresponds to the rate of the whole year starting from the year entered in column Year. The last value is considered valid also for the following years (for which no value has been provided). ",
+ "\n",
+ "\nWhen the current Yield Curve must be used in the calculation, the latest Yield Curve available in the system with Year and Month earlier or equal to Year and Month of the closing period will be used."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "3TbdMYHKKk2Wan-Egtuetg",
+ "cell_type": "code",
+ "source": [
+ "public record YieldCurve : KeyedRecord, IWithYearAndMonth",
+ "\n{ ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(Currency))]",
+ "\n public string Currency { get; init; }",
+ "\n",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Year))]",
+ "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n [Display(Order = 20)]",
+ "\n public int Year { get; init; }",
+ "\n ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Month))]",
+ "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n [Display(Order = 30)]",
+ "\n public int Month { get; init; }",
+ "\n",
+ "\n [IdentityProperty]",
+ "\n [Display(Order = 35)]",
+ "\n public string Scenario { get; init; }",
+ "\n",
+ "\n [Conversion(typeof(PrimitiveArrayConverter))]",
+ "\n [Display(Order = 40)]",
+ "\n public double[] Values { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "kR4nqN3MwkqRBS8Yeb4bOA",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Partner Rating",
+ "\nThe record below holds the [Credit Risk Rating](#credit-risk-partner) for each [Partner](#partner) across time. Partner Rating can be updated every month as part of the close preparation. In general, the last month of the reporting period should be use to import the new data for the period. "
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "-yzxBGiz7U62zp3niNtqEA",
+ "cell_type": "code",
+ "source": [
+ "public record PartnerRating : KeyedRecord, IWithYearAndMonth",
+ "\n{ ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(Partner))]",
+ "\n public string Partner { get; init; }",
+ "\n",
+ "\n [Required]",
+ "\n [Display(Order = 20)]",
+ "\n [Dimension(typeof(CreditRiskRating))]",
+ "\n public string CreditRiskRating { get; init; }",
+ "\n",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Year))]",
+ "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n [Display(Order = 30)]",
+ "\n public int Year { get; init; }",
+ "\n ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Month))]",
+ "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n [Display(Order = 40)]",
+ "\n public int Month { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "4bFzr4BUxECkAZN1KK83Kg",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n# Partitions",
+ "\nThe notion of Partition is used to define small but meaningful sets of data, called partitions. Partitions are then used to optimize the extraction of data from the database, i.e. only the data for a certain partition is retrieved."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "lfo6j69S00S5MmeGEgWhWA",
+ "cell_type": "code",
+ "source": [
+ "public abstract record IfrsPartition : IPartition {",
+ "\n [Key]",
+ "\n [PartitionId]",
+ "\n public Guid Id { get; init; }",
+ "\n",
+ "\n [Required]",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(ReportingNode))]",
+ "\n [IdentityProperty]",
+ "\n public string ReportingNode { get; init; }",
+ "\n",
+ "\n [Display(Order = 50)]",
+ "\n [Dimension(typeof(Scenario))]",
+ "\n [IdentityProperty]",
+ "\n public string Scenario { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "Oy6PSvNeAkOrHXzbWi144g",
+ "cell_type": "markdown",
+ "source": [
+ "For instance, the data pertaining to a certain [Reporting Node](#reporting-node) for a certain [Scenario](#scenario) is called an IfrsPartition and assigned a unique identifier:"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "YQl5TqjBQUui3Ao3FsgiUw",
+ "cell_type": "code",
+ "source": [
+ "public record PartitionByReportingNode : IfrsPartition {}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "M8p4dGJQHkC7dFwqXU4RXQ",
+ "cell_type": "markdown",
+ "source": [
+ "The partition PartitionByReportingNodeAndPeriod is a further partition of the IfrsPartition sets - In particular, it defines sets for the data pertaining to a certain [Reporting Node](#reporting-node), [Scenario](#scenario), year and month. The value of the Month is the last month of the reporting period to which the data belongs to. "
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "a7nDH2imYUeP23B6WT5yZw",
+ "cell_type": "code",
+ "source": [
+ "public record PartitionByReportingNodeAndPeriod : IfrsPartition {",
+ "\n [Display(Order = 30)]",
+ "\n [Dimension(typeof(int), nameof(Year))]",
+ "\n [IdentityProperty]",
+ "\n public int Year { get; init; }",
+ "\n",
+ "\n [Display(Order = 40)]",
+ "\n [Dimension(typeof(int), nameof(Month))]",
+ "\n [IdentityProperty]",
+ "\n public int Month { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "TZvDAkF0M02LQtQKCZLJRA",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n# Policy-related Data Structures",
+ "\n",
+ "\nThe data structures below are the pieces of the data model where policy-related data is held."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "kjn-7dhJgEa7EDS2jG2CbA",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Data Node",
+ "\n",
+ "\nA data node is basically a set of labels which identify data according to its:",
+ "\n- Reporting Node",
+ "\n- Scenario",
+ "\n- Contractual Currency",
+ "\n- FunctionalCurrency",
+ "\n- LineOfBusiness",
+ "\n- ValuationApproach",
+ "\n- OCI Type"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "7I3_uOSDzkuHhcVJMukGlA",
+ "cell_type": "markdown",
+ "source": [
+ "TODOs:",
+ "\nPremiumAllocation : defines the weight of Premium to be included in the Experience Adjustement AocType of the Technical Margin and is valid only for Group of Insurance Contract with LiabilityType : Liability for Remaining Coverage.",
+ "\nReinsuranceCoverage : defines the weight of the underlying gross business to be considered in the computation of the allocation of the Technical Margin in a Reinsurance case.",
+ "\n",
+ "\nThe latest Data Node Parameters available in the system with Year and Month earlier or equal to Year and Month of the closing period will be used as the current value during calculation."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "Y9V4hdUwV0WlDgxhiVJ0lg",
+ "cell_type": "code",
+ "source": [
+ "public record DataNodeParameter : KeyedRecord, IPartitioned, IWithYearAndMonth",
+ "\n{",
+ "\n [NotVisible]",
+ "\n [PartitionKey(typeof(PartitionByReportingNode))]",
+ "\n public Guid Partition { get; init; }",
+ "\n ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Year))]",
+ "\n [Range(1900, 2100, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n [Display(Order = 20)]",
+ "\n public int Year { get; init; }",
+ "\n ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Month))]",
+ "\n [Range(1, 12, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n [Display(Order = 30)]",
+ "\n [DefaultValue(DefaultDataNodeActivationMonth)]",
+ "\n public int Month { get; init; } = DefaultDataNodeActivationMonth;",
+ "\n ",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [Display(Order = 10)]",
+ "\n [Dimension(typeof(GroupOfContract))]",
+ "\n public string DataNode { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "Cnr2el8xg0OjF0x79bM9lQ",
+ "cell_type": "code",
+ "source": [
+ "public record SingleDataNodeParameter : DataNodeParameter {",
+ "\n [DefaultValue(DefaultPremiumExperienceAdjustmentFactor)]",
+ "\n [Range(0, 1, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n public double PremiumAllocation { get; init; } = DefaultPremiumExperienceAdjustmentFactor;",
+ "\n}",
+ "\n",
+ "\npublic record InterDataNodeParameter : DataNodeParameter {",
+ "\n [Required]",
+ "\n [IdentityProperty]",
+ "\n [Display(Order = 20)]",
+ "\n [Dimension(typeof(GroupOfContract))]",
+ "\n public string LinkedDataNode { get; init; }",
+ "\n ",
+ "\n [Range(0, 1, ErrorMessage = \"Value for {0} must be between {1} and {2}.\")]",
+ "\n public double ReinsuranceCoverage { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "WCZyCC4Qlkm0FjxSRHM0xw",
+ "cell_type": "markdown",
+ "source": [
+ "## DataNodeData PocoType",
+ "\nThe DataNodeData type is not persisted (i.e. not stored in the database) and is used in order to hold Data Node data during data manipulations."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "koNxFi27ZkuU4_2cCG2GMA",
+ "cell_type": "code",
+ "source": [
+ "public record DataNodeData {",
+ "\n public string DataNode { get; init; }",
+ "\n ",
+ "\n //Portfolio",
+ "\n public string ContractualCurrency { get; init; }",
+ "\n public string FunctionalCurrency { get; init; }",
+ "\n public string LineOfBusiness { get; init; }",
+ "\n public string ValuationApproach { get; init; }",
+ "\n public string OciType { get; init; }",
+ "\n ",
+ "\n //GroupOfContract",
+ "\n public string Portfolio { get; init; }",
+ "\n public int AnnualCohort { get; init; }",
+ "\n public string LiabilityType { get; init; }",
+ "\n public string Profitability { get; init; }",
+ "\n public string Partner { get; init; }",
+ "\n ",
+ "\n //DataNodeState",
+ "\n public int Year { get; init; }",
+ "\n public int Month { get; init; }",
+ "\n public State State { get; init; }",
+ "\n public State PreviousState { get; init; }",
+ "\n ",
+ "\n public bool IsReinsurance { get; init; }",
+ "\n ",
+ "\n public DataNodeData(){}",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "9zeoLgvZ8EKhCCDbihId8w",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Raw Variables (Cashflows)",
+ "\n",
+ "\nRaw Variables are used to store **cashflows** on the database during import, i.e. *after* mappings are applied and *before* calculations are applied.",
+ "\n",
+ "\nThey are stored on the database for both audit and re-calculation purposes."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "vy4oWvNmmUGJTicrwsX63Q",
+ "cell_type": "code",
+ "source": [
+ "public abstract record BaseVariableIdentity {",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(GroupOfContract))]",
+ "\n [IdentityProperty]",
+ "\n public string DataNode { get; init; }",
+ "\n ",
+ "\n [NotVisible] ",
+ "\n [Dimension(typeof(AocType))]",
+ "\n [IdentityProperty]",
+ "\n public string AocType { get; init; }",
+ "\n ",
+ "\n [NotVisible] ",
+ "\n [Dimension(typeof(Novelty))]",
+ "\n [IdentityProperty]",
+ "\n public string Novelty { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "_bTxTL4-o0efG6zNvhuDjg",
+ "cell_type": "code",
+ "source": [
+ "public abstract record BaseDataRecord : BaseVariableIdentity, IKeyed, IPartitioned {",
+ "\n [Key]",
+ "\n [NotVisible] ",
+ "\n public Guid Id { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [PartitionKey(typeof(PartitionByReportingNodeAndPeriod))]",
+ "\n public Guid Partition { get; init; }",
+ "\n ",
+ "\n [NotVisible] ",
+ "\n [Dimension(typeof(AmountType))]",
+ "\n [IdentityProperty]",
+ "\n public string AmountType { get; init; }",
+ "\n ",
+ "\n [NotVisible] ",
+ "\n [Dimension(typeof(int),nameof(AccidentYear))]",
+ "\n [IdentityProperty]",
+ "\n public int? AccidentYear { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "X688yB4HTEm3riHh8lTrug",
+ "cell_type": "markdown",
+ "source": [
+ "Basically, RawVariable is defined for a certain Reporting Node, Scenario, Year, Month, Amount Type and Calculation Type:"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "kfbf0LwJSEGaxyUuPFnsKg",
+ "cell_type": "code",
+ "source": [
+ "public record RawVariable : BaseDataRecord",
+ "\n{",
+ "\n [Conversion(typeof(PrimitiveArrayConverter))]",
+ "\n public double[] Values { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(CalculationType))]",
+ "\n [IdentityProperty]",
+ "\n public string CalculationType { get; init; }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "IeCO6PmNPEioYptDRrzHTA",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Ifrs Variable",
+ "\n",
+ "\nIfrs Variables are used to store:",
+ "\n",
+ "\n- **Actual Values**",
+ "\n- **Present Values**",
+ "\n",
+ "\nPresent Values are calculated from the [raw variables](#raw-variables) during the import of cashflows.",
+ "\n",
+ "\nIfrs Variables are stored on the database, i.e. they are 'persisted', for performance purposes."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "H9N-c0drk0GPoWh-VfRXzA",
+ "cell_type": "code",
+ "source": [
+ "public record IfrsVariable : BaseDataRecord",
+ "\n{",
+ "\n public double Value { get; init; }",
+ "\n ",
+ "\n [NotVisible] ",
+ "\n [Dimension(typeof(EstimateType))]",
+ "\n [IdentityProperty]",
+ "\n public string EstimateType { get; init; }",
+ "\n ",
+ "\n [NotVisible] ",
+ "\n [Dimension(typeof(EconomicBasis))]",
+ "\n [IdentityProperty]",
+ "\n public string EconomicBasis { get; init; }",
+ "\n ",
+ "\n public IfrsVariable (){}",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "MCh8EtPVKUyEIcixf6Q_1Q",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n## Import Identity",
+ "\nThe Import Identity contains the data elements used to determine the data sets which are used when performing data manipulations, e.g. during a [data import](./Import/ImportScopeCalculation) - In particular, an Import Identity is defined by: DataNode, AocType, Novelty, and whether it's reinsurance data or not:"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "w5SSaFTyYE-3Xj0yy0eobw",
+ "cell_type": "code",
+ "source": [
+ "public record ImportIdentity : BaseVariableIdentity {",
+ "\n ",
+ "\n [NotVisible]",
+ "\n public bool IsReinsurance { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n public string ValuationApproach { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n public int ProjectionPeriod { get; init; }",
+ "\n ",
+ "\n public (string, string) AocStep => (AocType, Novelty);",
+ "\n ",
+ "\n public ImportScope ImportScope { get; init; }",
+ "\n ",
+ "\n public ImportIdentity(RawVariable rv){",
+ "\n DataNode = rv.DataNode;",
+ "\n AocType = rv.AocType;",
+ "\n Novelty = rv.Novelty;",
+ "\n }",
+ "\n ",
+ "\n public ImportIdentity(IfrsVariable iv){",
+ "\n DataNode = iv.DataNode;",
+ "\n AocType = iv.AocType;",
+ "\n Novelty = iv.Novelty;",
+ "\n }",
+ "\n",
+ "\n public ImportIdentity(){}",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "31-e-C4gwESKBN8E0Rr6gQ",
+ "cell_type": "markdown",
+ "source": [
+ "",
+ "\n# Report Variable",
+ "\n",
+ "\nReport Variables are used to hold data after data manipulations and before being outputed in the form of a report. They are not persisted, i.e. they are not saved on the database."
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "2yvEMKViYE6wZPnuy7AClg",
+ "cell_type": "code",
+ "source": [
+ "public record ReportVariable {",
+ "\n",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(ReportingNode))]",
+ "\n [IdentityProperty]",
+ "\n public string ReportingNode { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(Scenario))]",
+ "\n [IdentityProperty]",
+ "\n public string Scenario { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(Currency), nameof(FunctionalCurrency))]",
+ "\n [IdentityProperty]",
+ "\n //[AggregateBy]",
+ "\n public string FunctionalCurrency { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(Currency), nameof(ContractualCurrency))]",
+ "\n [IdentityProperty]",
+ "\n //[AggregateBy]",
+ "\n public string ContractualCurrency { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(GroupOfContract))]",
+ "\n [IdentityProperty]",
+ "\n public string GroupOfContract { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(Portfolio))]",
+ "\n [IdentityProperty]",
+ "\n public string Portfolio { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(LineOfBusiness))]",
+ "\n [IdentityProperty]",
+ "\n public string LineOfBusiness { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(LiabilityType))]",
+ "\n [IdentityProperty]",
+ "\n public string LiabilityType { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(Profitability), nameof(InitialProfitability))]",
+ "\n [IdentityProperty]",
+ "\n public string InitialProfitability { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(ValuationApproach))]",
+ "\n [IdentityProperty]",
+ "\n public string ValuationApproach { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(AnnualCohort))]",
+ "\n [IdentityProperty]",
+ "\n public int AnnualCohort { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(OciType))]",
+ "\n [IdentityProperty]",
+ "\n public string OciType { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(Partner))]",
+ "\n [IdentityProperty]",
+ "\n public string Partner { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [IdentityProperty]",
+ "\n public bool IsReinsurance { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(AccidentYear))]",
+ "\n [IdentityProperty]",
+ "\n public int AccidentYear { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [NoArithmetics(ArithmeticOperation.Scale)]",
+ "\n [Dimension(typeof(int), nameof(Projection))]",
+ "\n [IdentityProperty]",
+ "\n //[AggregateBy]",
+ "\n public int Projection { get; init;}",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(VariableType))]",
+ "\n [IdentityProperty]",
+ "\n public string VariableType { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(Novelty))]",
+ "\n [IdentityProperty]",
+ "\n public string Novelty { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(AmountType))]",
+ "\n [IdentityProperty]",
+ "\n public string AmountType { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(EstimateType))]",
+ "\n [IdentityProperty]",
+ "\n public string EstimateType { get; init; }",
+ "\n ",
+ "\n [NotVisible]",
+ "\n [Dimension(typeof(EconomicBasis))]",
+ "\n [IdentityProperty]",
+ "\n //[AggregateBy]",
+ "\n public string EconomicBasis { get; init; }",
+ "\n ",
+ "\n public double Value { get; init; }",
+ "\n ",
+ "\n public ReportVariable(){}",
+ "\n public ReportVariable(ReportVariable rv){",
+ "\n ReportingNode = rv.ReportingNode;",
+ "\n Scenario = rv.Scenario;",
+ "\n FunctionalCurrency = rv.FunctionalCurrency;",
+ "\n ContractualCurrency = rv.ContractualCurrency;",
+ "\n GroupOfContract = rv.GroupOfContract;",
+ "\n Portfolio = rv.Portfolio;",
+ "\n LineOfBusiness = rv.LineOfBusiness;",
+ "\n LiabilityType = rv.LiabilityType;",
+ "\n InitialProfitability = rv.InitialProfitability;",
+ "\n ValuationApproach = rv.ValuationApproach;",
+ "\n AnnualCohort = rv.AnnualCohort;",
+ "\n OciType = rv.OciType;",
+ "\n Partner = rv.Partner;",
+ "\n IsReinsurance = rv.IsReinsurance;",
+ "\n AccidentYear = rv.AccidentYear;",
+ "\n Projection = rv.Projection;",
+ "\n VariableType = rv.VariableType;",
+ "\n Novelty = rv.Novelty;",
+ "\n AmountType = rv.AmountType;",
+ "\n EstimateType = rv.EstimateType;",
+ "\n EconomicBasis = rv.EconomicBasis;",
+ "\n Value = rv.Value;",
+ "\n }",
+ "\n public ReportVariable(DataNodeData dn, IfrsVariable iv){",
+ "\n FunctionalCurrency = dn.FunctionalCurrency;",
+ "\n ContractualCurrency = dn.ContractualCurrency;",
+ "\n GroupOfContract = dn.DataNode;",
+ "\n Portfolio = dn.Portfolio;",
+ "\n LineOfBusiness = dn.LineOfBusiness;",
+ "\n LiabilityType = dn.LiabilityType;",
+ "\n InitialProfitability = dn.Profitability;",
+ "\n ValuationApproach = dn.ValuationApproach;",
+ "\n AnnualCohort = dn.AnnualCohort;",
+ "\n OciType = dn.OciType;",
+ "\n Partner = dn.Partner;",
+ "\n IsReinsurance = dn.IsReinsurance;",
+ "\n AccidentYear = iv.AccidentYear ?? default;",
+ "\n VariableType = iv.AocType;",
+ "\n Novelty = iv.Novelty;",
+ "\n AmountType = iv.AmountType;",
+ "\n EstimateType = iv.EstimateType;",
+ "\n EconomicBasis = iv.EconomicBasis;",
+ "\n Value = iv.Value;",
+ "\n }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "WtIFU8efQE2aUaVim03Iog",
+ "cell_type": "markdown",
+ "source": [
+ "# Args"
+ ],
+ "metadata": {}
+ },
+ {
+ "id": "i8WBwS3IuUqLxaV5XGKWsg",
+ "cell_type": "code",
+ "source": [
+ "public record Args(string ReportingNode, int Year, int Month, Periodicity Periodicity, string Scenario){}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "6FcgQqQpzE2yPeqwZNRfiQ",
+ "cell_type": "code",
+ "source": [
+ "public record ImportArgs : Args",
+ "\n{",
+ "\n public string ImportFormat { get; init; }",
+ "\n ",
+ "\n public ImportArgs(string reportingNode, int year, int month, Periodicity periodicity, string scenario, string importFormat)",
+ "\n : base(reportingNode, year, month, periodicity, scenario)",
+ "\n {",
+ "\n ImportFormat = importFormat;",
+ "\n }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "id": "mJUZ9khq1k-jUZcG-qZniQ",
+ "cell_type": "code",
+ "source": [
+ "public record ReportArgs : Args",
+ "\n{",
+ "\n public string HierarchyName { get; init; }",
+ "\n ",
+ "\n public CurrencyType CurrencyType { get; init; }",
+ "\n ",
+ "\n public string ReportName { get; init; } // this is the key to which data to load (like loading behavior). If null, loads everything",
+ "\n ",
+ "\n public ReportArgs(string reportingNode, int year, int month, Periodicity periodicity, string scenario, string hierarchyName, CurrencyType currencyType)",
+ "\n : base(reportingNode, year, month, periodicity, scenario)",
+ "\n {",
+ "\n CurrencyType = currencyType;",
+ "\n HierarchyName = hierarchyName;",
+ "\n }",
+ "\n}"
+ ],
+ "metadata": {},
+ "execution_count": 1,
+ "outputs": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Database/.gitignore b/Database/.gitignore
new file mode 100644
index 00000000..34be061b
--- /dev/null
+++ b/Database/.gitignore
@@ -0,0 +1 @@
+PersonalConnection.ipynb
\ No newline at end of file
diff --git a/Database/Configure.ipynb b/Database/Configure.ipynb
new file mode 100644
index 00000000..2819a9af
--- /dev/null
+++ b/Database/Configure.ipynb
@@ -0,0 +1,131 @@
+{
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Formula Framework",
+ "language": "C#",
+ "name": "C#"
+ },
+ "toc-autonumbering": "True",
+ "toc-showcode": "False",
+ "toc-showmarkdowntxt": "False",
+ "authors": [],
+ "language_info": {
+ "file_extension": ".cs",
+ "mimetype": "text/plain",
+ "name": "C#"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5,
+ "cells": [
+ {
+ "id": "vWKQtrDv20CeZFovAj82Vw",
+ "cell_type": "markdown",
+ "source": [
+ "DataSource Configuration
" + ], + "metadata": {} + }, + { + "id": "ekOMREP2YkKF0vgtOn6cyQ", + "cell_type": "code", + "source": [ + "#!import \"../DataModel/DataStructure\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "eEI7AS2fc0-CFjAR_WzdHg", + "cell_type": "code", + "source": [ + "#!import \"PersonalConnection\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "ZoHg5nndvEWdxnUy6nU0aQ", + "cell_type": "code", + "source": [ + "using System.Reflection;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "V3sPPe7bkEOIAjZHtM5oTw", + "cell_type": "markdown", + "source": [ + "# Database Configure" + ], + "metadata": {} + }, + { + "id": "ZxIo5q84i02LBlbq4AQnNA", + "cell_type": "code", + "source": [ + "var allTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes())", + "\n .Where(t => (t.IsAssignableTo(typeof(IKeyed)) || t.IsAssignableTo(typeof(KeyedDimension)))", + "\n && !t.IsInterface", + "\n && !t.IsAbstract", + "\n ).ToArray();" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "Wi93Z_KSukSEMiLoOfsKXA", + "cell_type": "code", + "source": [ + "await DataSource.Configure().UseMsSql(opt => opt.WithConnectionString(connectionStringMsSql)", + "\n .WithTypes(allTypes)) .ConnectAsync();" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "4jSr3apQzEm6bXs7ot9uJQ", + "cell_type": "code", + "source": [ + "await DataSource.CommitAsync();" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "SUiuO25f-0S6Uv5at0MehA", + "cell_type": "markdown", + "source": [ + "# Reset Workspace" + ], + "metadata": {} + }, + { + "id": "T0pNd11nrkuDwN6S0YgItg", + "cell_type": "code", + "source": [ + "Workspace.Reset(x => x.ResetInitializationRules());" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "sAYMeiwmiUWC-T3QYXi7aw", + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/Database/Schema Delete.ipynb b/Database/Schema Delete.ipynb new file mode 100644 index 00000000..49792b90 --- /dev/null +++ b/Database/Schema Delete.ipynb @@ -0,0 +1,87 @@ +{ + "metadata": { + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "authors": [], + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + }, + "documentInfo": "{\r\n \"authors\": [\r\n \"Peter Kunszt\"\r\n ],\r\n \"contributors\": [],\r\n \"tags\": [\r\n \"storage\",\r\n \"database\",\r\n \"persistence\",\r\n \"dependency\"\r\n ],\r\n \"title\": \"Multiple Storages with Persistence\",\r\n \"description\": \"Demo the usage of database backend to resolve a data dependency.\",\r\n \"createdDate\": \"Jan. 2022\",\r\n \"publishedDate\": \"Jan. 2022\",\r\n \"changelog\": [\r\n {\r\n \"version\": \"1.0\",\r\n \"description\": \"Initial Notebook\"\r\n }\r\n ]\r\n }" + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "id": "XekEwxVoCk6YtMSTaBi_6A", + "cell_type": "code", + "source": [ + "#!import \"PersonalConnection\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "aMGWTiny-EO8ZtyaiC0M2A", + "cell_type": "code", + "source": [ + "#r \"nuget:SqlConnection,1.0.4\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "dKBE6yQHq0CZbS4Oq7ZXag", + "cell_type": "code", + "source": [ + "string[] split = connectionStringMsSql.Split(new char[] { '=', ':', ',', ';' });", + "\n", + "\nstring serverName = split[2];", + "\nstring database = split[5];", + "\nstring userID = split[9];", + "\nstring password = split[11];" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "BBbDUGWgHUywoxk289vQ2A", + "cell_type": "code", + "source": [ + "using SQLConnection;", + "\nusing System;", + "\nusing System.Data.SqlClient;" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "S-_OArgE70qFUpEbX12H3Q", + "cell_type": "code", + "source": [ + "string query = \"DECLARE @sql NVARCHAR(max)='' SELECT @sql += ' Drop table ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; 'FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' Exec Sp_executesql @sql\";" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "oeQryPr0l0uflGqNrUvmLw", + "cell_type": "code", + "source": [ + "int rowAffect = SqlServer.AzureSqlConnection(serverName, database, userID, password, query);" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/Export/MapTemplate.ipynb b/Export/MapTemplate.ipynb new file mode 100644 index 00000000..c1fb9d01 --- /dev/null +++ b/Export/MapTemplate.ipynb @@ -0,0 +1,338 @@ +{ + "metadata": { + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "toc-autonumbering": "True", + "toc-showcode": "False", + "authors": [], + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "id": "J7Lk0NfjhkC9DBXVAnd4ag", + "cell_type": "markdown", + "source": [ + "Map Template
" + ], + "metadata": {} + }, + { + "id": "nJozo1XeSkeGCLiQXUPlzA", + "cell_type": "markdown", + "source": [ + "This Notebook exports the Data nodes, states, and parameters for the target partition to a spreadsheet file which can be read, modified, and is ready to be re-imported." + ], + "metadata": {} + }, + { + "id": "T4LYGKNFjke1IDEPU8E44Q", + "cell_type": "markdown", + "source": [ + "After setting the desired target Partition, the Data present in the workspace is ready to be exported. " + ], + "metadata": {} + }, + { + "id": "J3Om4qznT0qnFdizsJg6gA", + "cell_type": "markdown", + "source": [ + "# Import dependencies" + ], + "metadata": {} + }, + { + "id": "jz0ZzjaNNkyPlNjH7p_9CQ", + "cell_type": "code", + "source": [ + "#!import \"../Utils/UtilityMethods\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "4kGmVeM2F0y1LR3iEJJAaA", + "cell_type": "markdown", + "source": [ + "# Select Initialization" + ], + "metadata": {} + }, + { + "id": "nVFGNWhtb0iw49kOFNKpUQ", + "cell_type": "markdown", + "source": [ + "Choose to run the Map Template either with the set of Systemorph data in memory or with the data present in the Database. Uncomment the desired option." + ], + "metadata": {} + }, + { + "id": "MbQiJg5acUurtMhQFZOPtw", + "cell_type": "code", + "source": [ + "/* The DataSource is configured and connected to real database */", + "\n//#!eval-notebook \"Database/Configure\"", + "\n/* The Systemorph set of dimensions + mockdata are dispatched to the unconfigured in-memory DataSource */", + "\n#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "Ma-JBoxkmUqAb81Pb2v8EA", + "cell_type": "markdown", + "source": [ + "# Workspace Initialization " + ], + "metadata": {} + }, + { + "id": "zaO0K3_d3UOftmtrwhqrFg", + "cell_type": "markdown", + "source": [ + "Firstly, the Workspace is initialized with basic dimensions and with Data Nodes. For a list of the dimensions please refer to the DataModel/DataStructure notebook." + ], + "metadata": {} + }, + { + "id": "BP4HG8krfkul6dXSvdGHnw", + "cell_type": "code", + "source": [ + "Workspace.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "CirOR3dQA0iqxXipYfNcFQ", + "cell_type": "markdown", + "source": [ + "# Map Template: Data Node" + ], + "metadata": {} + }, + { + "id": "z1pGwBuU20ywRLjN6Gj5eg", + "cell_type": "markdown", + "source": [ + "## Set Partition" + ], + "metadata": {} + }, + { + "id": "8y9ezk2H7EetGACPthoNUw", + "cell_type": "code", + "source": [ + "static var partition = new PartitionByReportingNode() { ReportingNode = \"CH\" };" + ], + "metadata": {}, + "execution_count": 1, + "outputs": [] + }, + { + "id": "XFPlV7vwiUCUY7llRpEeEQ", + "cell_type": "code", + "source": [ + "await Workspace.Partition.SetAsyncnhsi>$ZDJikBv2k&69o}Vd
zadB~Sa?;b&laZ0(;NWm`bJNh!ynXwYnwpxFl=S7xmuP5cuV25Wpr9ZiAi&4RM?pb(
z@!|y`A>p%U&wwoeTvKNMC;}h1E^12Zfbjo+^a8D=Kj{Xh0mDI7#~B2A(f;>F>9WrU
zw1$z6+=urX9)<_0V6SX>{JaU9P?3rk6u%Q#%PBNlGjzG^m-__|NrKk}f5}HnJ>0k8
zn(E`t>E!%F+ik}7cZ&c2>;J_waP=7X_@tGwoR|hACTm_M3KCUt@8V2$wqxrvHOIGj
zK_KpcSDZo<-;)ya6?K|TA7o29)F*7zFU03e%^Z&(j*s@z=bJQUh5$YK+MTru=(mhG
ziqD&ppU7|D(SV|-1g*qh93OZX{FkY@)j*Co$8jIgu5?vEb7;)}Tap2SzbpnlCUv2e
zC$3on&4$xqE`LM4QY%OGVP)_?_(Hgh^&9iJ>^;g;%FHO#A2{y~F*N elE>SFU*FkzE`Pz7elQy&5=qV*d+bWE*)cx(-eDB3
zN^_0l){A;P(R*;dqN~Tdlf~Kv1cF!*H;v)heQu@5LV>u8hx{6kvW6vVBXn13CPY84Q1F~~@s
zi&?z+B*6VE>Xo2F+XIg_%9o*G36wv*yEWYEAdaKu1#VT49wSS=#-m<2>eKYh@2Jzg
zwC~s^9+UF0s5Jet|MMb%ws587gV@&i9Sf2-&c}njt75x^Y#a&n82w8K;y+{Z{H-B!aQtxe1fO?<@%NoSR}VfV
z;%R&rWtrsE$yj(@D&-wpM00YW4#k0K%8{Dy4#Ljm)pddQ>9{8v<(Fo_Ee;d_qpXuk
zx&TJP`BlUwb2_`fP}oP3&y2lm;>5AB`aylYJh?Ehfs~^UulPJy^MAT8al7~8*Y2SH
z05AW2ImJ%(XwsNo)3Y(!A)FA4usO>52diR}@x*K$EN)^)>09`s_WnD!xnL|FP5))d
zlw44_PeI;3!p^9!tV|78`2>}$Y|U(aYsL~~op}|@09y;~*asHRtt<4?w;|X6f2V3#
zlSxBzGVSrtuuB&Bqsi8gxG7q9gd2iIP5Gt~ly)-ZS`6Ct2>Xn=j1jR#U5;v#P(>h)
zK%Z8=c+>5ahdNzynt1l1NYqmBUIB85vg?q@mG+O
y=4dQ5}AAk{v^_yyzm2I%Lji!Q@@YKe-an%!Qu&n&n4J^J3WHQv64J)$UYjjY_J3
zFO-(ms)d@55jY~o2i@+ee?{xe({K|zE&y$|XM2fOxcmcQB{6A;&NjI3w#t^j^8?u>
z6ir*uEHHcY%%Eq$ZQIFGJu#s{J>BJ98@#m|nc+y`6`;+wt{o>E7zQ0_%Bc?bVbTjh
z^=g%F;W4w+kVyQ<5J%_xXB+}h@;G*KZ+3jUn{fwCON8nJs4s@Zq7hp(dU~y;{>A@#
zx|tS!sL7#6f5D^ALEZ@Hx3d-%ib%?QDm+Q02wtyoH`i!qE*|@^Nzd7%Mo%p~dU8@e
zt$vD&-
>#uX54k?
z9TWy-R;oc5XG9YVrhZrvF*9eC(%?xj74~9|_FzUy6+
vr`)lluzpq$4
zC$jtqz#W*u935gUpw<*{>J1=+L@c;xHSNLTG{ZY(>h|vD|1Kx|KiT&EXWrs}aPIrh
zG&uOeuLw8$@32&$SX`)``ES|lKm6cXo5El0;9#0wSwd7_T?~%z