diff --git a/PresentValueSeries/InitializeData.ipynb b/PresentValueSeries/InitializeData.ipynb index eacf5385..a7dc504d 100644 --- a/PresentValueSeries/InitializeData.ipynb +++ b/PresentValueSeries/InitializeData.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "HSWSJivQ9Uq-k7P9Ky6MAg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,14 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False", - "toc-showtags": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -108,4 +105,4 @@ "outputs": [] } ] -} +} \ No newline at end of file diff --git a/PresentValueSeries/PresentValue - Episode 2.ipynb b/PresentValueSeries/PresentValue - Episode 2.ipynb index 70a4c51a..2a33a1c7 100644 --- a/PresentValueSeries/PresentValue - Episode 2.ipynb +++ b/PresentValueSeries/PresentValue - Episode 2.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "HmaHGel-LEeFl0jOhE9pPw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,14 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False", - "toc-showtags": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/PresentValueSeries/PresentValue - Episode 3.ipynb b/PresentValueSeries/PresentValue - Episode 3.ipynb index 0c3d4211..a8b09155 100644 --- a/PresentValueSeries/PresentValue - Episode 3.ipynb +++ b/PresentValueSeries/PresentValue - Episode 3.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "UQV1FkirrkmGCOCfpHVsEA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,14 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False", - "toc-showtags": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/PresentValueSeries/Test.ipynb b/PresentValueSeries/Test.ipynb index 25430e56..049a72e7 100644 --- a/PresentValueSeries/Test.ipynb +++ b/PresentValueSeries/Test.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "t7h_PHrvb0GNmLCXuxb1kg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17-template/Constants/CalculationEngine.ipynb b/ifrs17-template/Constants/CalculationEngine.ipynb index 4ce89cf3..c3f4e015 100644 --- a/ifrs17-template/Constants/CalculationEngine.ipynb +++ b/ifrs17-template/Constants/CalculationEngine.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "ORrEbLR_T0C1aoQoVcXCpA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,13 +14,13 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "code", "source": [ "var projectName = \"ifrs17\";", - "\nvar environmentName = \"v1.1.1\";", + "\nvar environmentName = \"v1.2.0\";", "\nvar notebookName = \"CalculationEngine\";", "\nvar calculationEngine = $\"#!import \\\"//{projectName}/{environmentName}/{notebookName}\\\"\";" ], diff --git a/ifrs17-template/Database/Configure.ipynb b/ifrs17-template/Database/Configure.ipynb index c536ff36..2ff22d3b 100644 --- a/ifrs17-template/Database/Configure.ipynb +++ b/ifrs17-template/Database/Configure.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "NKif7XZ_00aa5ksgQlE6_g", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,13 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -81,7 +79,10 @@ "cell_type": "code", "source": [ "await DataSource.Configure().UseMsSql(opt => opt.WithConnectionString(connectionStringMsSql)", - "\n .WithTypes(allTypes)) .ConnectAsync();" + "\n .WithTypes(allTypes)", + "\n // .WithMigration() // uncomment if run with migration", + "\n ) ", + "\n .ConnectAsync();" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Database/MigrationAndScaffolding/Initial.ipynb b/ifrs17-template/Database/MigrationAndScaffolding/Initial.ipynb new file mode 100644 index 00000000..223e80bd --- /dev/null +++ b/ifrs17-template/Database/MigrationAndScaffolding/Initial.ipynb @@ -0,0 +1,729 @@ +{ + "metadata": { + "authors": [], + "id": "vjKyjbrTjk-dDxMZiTA1Mg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

The Initial Migration Code

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This copy contains the copy of the initial migration code. It is a necessary input to execute the first migration flow. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[Migration(\"20230208105811_InitialTypes\")]", + "\npublic class InitialTypes : Migration", + "\n{", + "\n protected override void Up(MigrationBuilder migrationBuilder)", + "\n {", + "\n migrationBuilder.CreateTable(", + "\n name: \"AmountType\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n Parent = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n PeriodType = table.Column(type: \"int\", nullable: false),", + "\n Discriminator = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Order = table.Column(type: \"int\", nullable: false),", + "\n ExternalId = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_AmountType\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"AocConfiguration\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n AocType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Novelty = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n DataType = table.Column(type: \"int\", nullable: false),", + "\n InputSource = table.Column(type: \"int\", nullable: false),", + "\n FxPeriod = table.Column(type: \"int\", nullable: false),", + "\n YcPeriod = table.Column(type: \"int\", nullable: false),", + "\n CdrPeriod = table.Column(type: \"int\", nullable: false),", + "\n ValuationPeriod = table.Column(type: \"int\", nullable: false),", + "\n RcPeriod = table.Column(type: \"int\", nullable: false),", + "\n Order = table.Column(type: \"int\", nullable: false)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_AocConfiguration\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"CreditDefaultRate\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n CreditRiskRating = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n Values = table.Column(type: \"varbinary(max)\", nullable: true),", + "\n Scenario = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_CreditDefaultRate\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"CreditRiskRating\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_CreditRiskRating\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"Currency\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_Currency\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"DataNode\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n Partition = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n ContractualCurrency = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n FunctionalCurrency = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n LineOfBusiness = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n ValuationApproach = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n OciType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Discriminator = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n AnnualCohort = table.Column(type: \"int\", nullable: true),", + "\n LiabilityType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Profitability = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Portfolio = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n YieldCurveName = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Partner = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_DataNode\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"DataNodeParameter\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Partition = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n DataNode = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n Scenario = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Discriminator = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n LinkedDataNode = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n ReinsuranceCoverage = table.Column(type: \"float\", nullable: true),", + "\n PremiumAllocation = table.Column(type: \"float\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_DataNodeParameter\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"DataNodeState\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Partition = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n DataNode = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n State = table.Column(type: \"int\", nullable: false),", + "\n Scenario = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_DataNodeState\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"EconomicBasis\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_EconomicBasis\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"EstimateType\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n InputSource = table.Column(type: \"int\", nullable: false),", + "\n StructureType = table.Column(type: \"int\", nullable: false),", + "\n PeriodType = table.Column(type: \"int\", nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Order = table.Column(type: \"int\", nullable: false),", + "\n ExternalId = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_EstimateType\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ExchangeRate\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Currency = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n FxType = table.Column(type: \"int\", nullable: false),", + "\n FxToGroupCurrency = table.Column(type: \"float\", nullable: false),", + "\n Scenario = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ExchangeRate\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ExportFile\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Name = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n ContentType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n CreationTime = table.Column(type: \"datetime2\", nullable: false),", + "\n SerializedContent = table.Column(type: \"varbinary(max)\", nullable: true),", + "\n Length = table.Column(type: \"bigint\", nullable: true),", + "\n Format = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ExportFile\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"IfrsVariable\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Value = table.Column(type: \"float\", nullable: false),", + "\n EstimateType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n EconomicBasis = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n DataNode = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n AocType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Novelty = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Partition = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n AmountType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n AccidentYear = table.Column(type: \"int\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_IfrsVariable\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ImportDataSet\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n CreationTime = table.Column(type: \"datetime2\", nullable: false),", + "\n SerializedContent = table.Column(type: \"varbinary(max)\", nullable: true),", + "\n Length = table.Column(type: \"bigint\", nullable: true),", + "\n Format = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ImportDataSet\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ImportExportActivity\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Username = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n StartDateTime = table.Column(type: \"datetime2\", nullable: false),", + "\n EndDateTime = table.Column(type: \"datetime2\", nullable: false),", + "\n Status = table.Column(type: \"int\", nullable: false),", + "\n Category = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n ExceptionMessage = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n ErrorMessages = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n WarningMessages = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n InfoMessages = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n SourceId = table.Column(type: \"uniqueidentifier\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ImportExportActivity\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ImportFile\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Name = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Directory = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n ContentType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Partition = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Source = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n CreationTime = table.Column(type: \"datetime2\", nullable: false),", + "\n SerializedContent = table.Column(type: \"varbinary(max)\", nullable: true),", + "\n Length = table.Column(type: \"bigint\", nullable: true),", + "\n Format = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ImportFile\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ImportStream\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n CreationTime = table.Column(type: \"datetime2\", nullable: false),", + "\n SerializedContent = table.Column(type: \"varbinary(max)\", nullable: true),", + "\n Length = table.Column(type: \"bigint\", nullable: true),", + "\n Format = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ImportStream\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ImportString\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Content = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n CreationTime = table.Column(type: \"datetime2\", nullable: false),", + "\n SerializedContent = table.Column(type: \"varbinary(max)\", nullable: true),", + "\n Length = table.Column(type: \"bigint\", nullable: true),", + "\n Format = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ImportString\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"LiabilityType\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n Parent = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_LiabilityType\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"LineOfBusiness\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n Parent = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Order = table.Column(type: \"int\", nullable: false)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_LineOfBusiness\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"Novelty\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Order = table.Column(type: \"int\", nullable: false)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_Novelty\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"OciType\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_OciType\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"PartitionByReportingNode\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n ReportingNode = table.Column(type: \"nvarchar(max)\", nullable: false)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_PartitionByReportingNode\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"PartitionByReportingNodeAndPeriod\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n Scenario = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n ReportingNode = table.Column(type: \"nvarchar(max)\", nullable: false)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_PartitionByReportingNodeAndPeriod\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"Partner\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_Partner\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"PartnerRating\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Partner = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n CreditRiskRating = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n Scenario = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_PartnerRating\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"Profitability\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_Profitability\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ProjectionConfiguration\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n Shift = table.Column(type: \"int\", nullable: false),", + "\n TimeStep = table.Column(type: \"int\", nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ProjectionConfiguration\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"RawVariable\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Values = table.Column(type: \"varbinary(max)\", nullable: true),", + "\n EstimateType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n DataNode = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n AocType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Novelty = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Partition = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n AmountType = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n AccidentYear = table.Column(type: \"int\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_RawVariable\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ReportingNode\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n Parent = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Currency = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ReportingNode\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"RiskDriver\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n Parent = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Order = table.Column(type: \"int\", nullable: false)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_RiskDriver\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"Scenario\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_Scenario\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"ValuationApproach\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_ValuationApproach\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"VariableType\",", + "\n columns: table => new", + "\n {", + "\n SystemName = table.Column(type: \"nvarchar(16)\", maxLength: 16, nullable: false),", + "\n Parent = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Discriminator = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n DisplayName = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Order = table.Column(type: \"int\", nullable: false)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_VariableType\", x => x.SystemName);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"YieldCurve\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Currency = table.Column(type: \"nvarchar(max)\", nullable: false),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n Scenario = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Name = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Values = table.Column(type: \"varbinary(max)\", nullable: true)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_YieldCurve\", x => x.Id);", + "\n });", + "\n", + "\n migrationBuilder.CreateTable(", + "\n name: \"YieldCurveReport\",", + "\n columns: table => new", + "\n {", + "\n Id = table.Column(type: \"uniqueidentifier\", nullable: false),", + "\n Currency = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Year = table.Column(type: \"int\", nullable: false),", + "\n Month = table.Column(type: \"int\", nullable: false),", + "\n Scenario = table.Column(type: \"nvarchar(max)\", nullable: true),", + "\n Index = table.Column(type: \"int\", nullable: false),", + "\n Value = table.Column(type: \"float\", nullable: false)", + "\n },", + "\n constraints: table =>", + "\n {", + "\n table.PrimaryKey(\"PK_YieldCurveReport\", x => x.Id);", + "\n });", + "\n }", + "\n", + "\n protected override void Down(MigrationBuilder migrationBuilder)", + "\n {", + "\n migrationBuilder.DropTable(", + "\n name: \"AmountType\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"AocConfiguration\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"CreditDefaultRate\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"CreditRiskRating\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"Currency\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"DataNode\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"DataNodeParameter\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"DataNodeState\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"EconomicBasis\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"EstimateType\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ExchangeRate\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ExportFile\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"IfrsVariable\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ImportDataSet\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ImportExportActivity\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ImportFile\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ImportStream\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ImportString\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"LiabilityType\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"LineOfBusiness\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"Novelty\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"OciType\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"PartitionByReportingNode\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"PartitionByReportingNodeAndPeriod\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"Partner\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"PartnerRating\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"Profitability\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ProjectionConfiguration\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"RawVariable\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ReportingNode\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"RiskDriver\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"Scenario\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"ValuationApproach\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"VariableType\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"YieldCurve\");", + "\n", + "\n migrationBuilder.DropTable(", + "\n name: \"YieldCurveReport\");", + "\n }", + "\n}", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Database/MigrationAndScaffolding/MigrationFlow.ipynb b/ifrs17-template/Database/MigrationAndScaffolding/MigrationFlow.ipynb new file mode 100644 index 00000000..d7bbb00c --- /dev/null +++ b/ifrs17-template/Database/MigrationAndScaffolding/MigrationFlow.ipynb @@ -0,0 +1,87 @@ +{ + "metadata": { + "authors": [], + "id": "oPiKSNUZMki5wrdUJlHjPQ", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Migration Flow

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#r \"nuget:Systemorph.SchemaMigrations,1.6.3\"", + "\n#!import \"../PersonalConnectionExample\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "For the initial migration one needs a migration code from the Initial notebook, so we import it here. For any subsequent migrations please change the next cell to import the notebook, where your stored the relevant migration code." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"Initial\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Here is the migration of the data base. For all subsequent migrations, please replace the InitialTypes in the second row with the name, that you gave to your migration. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await SchemaMigrations", + "\n .Apply() // Change the class in <> for future migrations", + "\n .ToMsSql(connectionStringMsSql)", + "\n .MigrateAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Database/MigrationAndScaffolding/ReadMe.ipynb b/ifrs17-template/Database/MigrationAndScaffolding/ReadMe.ipynb new file mode 100644 index 00000000..3863c81d --- /dev/null +++ b/ifrs17-template/Database/MigrationAndScaffolding/ReadMe.ipynb @@ -0,0 +1,127 @@ +{ + "metadata": { + "authors": [], + "id": "bq9bMSDFR02hhSb_XpjkBQ", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Explanation of Migration and Scaffolding

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Brief Explanation of Migration" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Migration is a powerful tool that allows us to keep the same Database (DB) during the whole lifetime of the project, without any need to remove it if one needs to modify the DB, e.g. via addition or removing certain tables or columns. With the migration, if modification of the DB is needed, we do not remove the old DB, but rather migrate it incrementally. Note, however, that running a project with migration is a choice rather than a default option. If you are OK with removing the DB each time when some change in the tables structure is needed, migration is not necessary. ", + "\n", + "\nAt the first step we perform the [scaffolding](Scaffold). The scaffolding procedure naturally outputs the migration code and the model snapshot. The migration code is the code that we should run in order to change the DB according to our new requirements, or, alternatively, if we start from scratch, to create the DB. The snapshot contains all the information about the structure of the DB after the migration. It is necessary to have the snapshot, in order for us not to start from scratch at the next migration, but rather only *implement the changes*. Each time when the DB has to be changed, we should scaffold the new model, taking into account the snapshot of the previous step. The snapshot of the new scaffold should be copied manually without changes into the [Snapshot notebook](Snapshot). We have done it already for the initial migration, please do not forget to change the [Snapshot notebook](Snapshot) for any subsequent migration.", + "\n", + "\nAt the next step the migration code should be copied into a new notebook. The first one was copied into the [Initial notebook](Initial). Of course, it would make a lot of sense to add each new incremental migration into a new notebook inside this folder. ", + "\n", + "\nFinally, in order to update or initiate the DB, one should run the [Migration flow notebook](MigrationFlow) where we feed all the necessary information from the [personal connection](../PersonalConnectionExample) and the notebook that includes the migration code, which is the [Initial notebook](Initial) for the first migration. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# A Handful of Comments on Migration" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Do Not Delete " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Since the logic migration includes incremental changes, while adding or removing something from the DB, one should not delete the schema anymore. Therefore, the [schema deletion notebook](../SchemaDelete) must not be used. ", + "\n", + "\nSince migration is not a default mode, we are still leaving this notebook in the folder. However, note that now using it would contradict the logic of migration, so please do not do it light-headedly. Stick to migration if this is your choice." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Configure" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Before you execute the [Configure notebook](../Configure), please uncomment the row, that specifies that the Configuration is run with migration. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Initialize" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Note, that when the schema is created, it is not filled automatically via running the [Configure](../Configure) notebook. Therefore there is a need to initaliaze the DB manually via [this](../../Initialization/InitSystemorphToDatabase) notebook. Otherwise you will get a correctly structured, but completely empty DB " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Database/MigrationAndScaffolding/Scaffold.ipynb b/ifrs17-template/Database/MigrationAndScaffolding/Scaffold.ipynb new file mode 100644 index 00000000..435abf39 --- /dev/null +++ b/ifrs17-template/Database/MigrationAndScaffolding/Scaffold.ipynb @@ -0,0 +1,131 @@ +{ + "metadata": { + "authors": [], + "id": "6wyTMSMvdEK_4OlFd8bqJA", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Scaffolding

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"../../Constants/CalculationEngine\"", + "\n#!eval calculationEngine" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "At the first stage we generate an array of classes that we are about to scaffold. Here we scuffold old the suitable classes that have keys (we want to have a unique identifier of each object in the DB) and are not interfaces or abstract classes, because in general we are not going to have instance of such abstract objects like interface or abstract class. You personal choice might be even narrower than that, in this case just mofify the code in the cell below. Note that the array of types that you are going to scaffold must have no repetitions. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "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": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Start from the scaffolding of the initial types. Please make sure that you run this code *only at the first you create the DB*. For any subsequent changes, please comment this cell out and never use it again. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var migration = SchemaMigrations", + "\n .ConfigureScaffolder(allTypes)", + "\n .ForMsSql()", + "\n .Scaffold(\"InitialTypes\");" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "In order to perform any subsequent change in the DB, there is no need to erase the DB and create a new from the scratch. It is sufficient to erase the cell above and uncomment the following cell. Please do not forget to insert a proper array of classes that you'd like to scaffold in the third row, as well as to give your own unique name to this migration in the 5th line. This is exactly the name that are going to use in the migration flow. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "//#!import \"Snapshot\"", + "\n//var migration = SchemaMigrations", + "\n// .ConfigureScaffolder({your array of types here}, new DbModelSnapshot())", + "\n// .ForMsSql()", + "\n// .Scaffold({Your unique name here}); " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "migration.MigrationCode" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "migration.SnapshotCode" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Database/MigrationAndScaffolding/Snapshot.ipynb b/ifrs17-template/Database/MigrationAndScaffolding/Snapshot.ipynb new file mode 100644 index 00000000..532ff740 --- /dev/null +++ b/ifrs17-template/Database/MigrationAndScaffolding/Snapshot.ipynb @@ -0,0 +1,1081 @@ +{ + "metadata": { + "authors": [], + "id": "JQaVP3MiNEiUST8hRneHpQ", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

The Current Snapshot

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Each time you produce a new migration, please copy and paste the snapshot code directly here. This must be the copy of the *most recent* migration snapshot. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "using Microsoft.EntityFrameworkCore;", + "\nusing Microsoft.EntityFrameworkCore.Infrastructure;", + "\nusing Microsoft.EntityFrameworkCore.Metadata;", + "\n", + "\npublic class DbModelSnapshot : ModelSnapshot", + "\n{", + "\n protected override void BuildModel(ModelBuilder modelBuilder)", + "\n {", + "\n modelBuilder", + "\n .HasAnnotation(\"ProductVersion\", \"6.0.1\")", + "\n .HasAnnotation(\"Relational:MaxIdentifierLength\", 128);", + "\n", + "\n SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);", + "\n", + "\n modelBuilder.Entity(\"Submission_151+YieldCurveReport\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Currency\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Index\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Scenario\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Value\")", + "\n .HasColumnType(\"float\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"YieldCurveReport\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_287+ImportExportActivity\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Category\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"EndDateTime\")", + "\n .HasColumnType(\"datetime2\");", + "\n", + "\n b.Property(\"ErrorMessages\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"ExceptionMessage\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"InfoMessages\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"SourceId\")", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"StartDateTime\")", + "\n .HasColumnType(\"datetime2\");", + "\n", + "\n b.Property(\"Status\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Username\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"WarningMessages\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"ImportExportActivity\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_289+ExportFile\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"ContentType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"CreationTime\")", + "\n .HasColumnType(\"datetime2\");", + "\n", + "\n b.Property(\"Format\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Length\")", + "\n .HasColumnType(\"bigint\");", + "\n", + "\n b.Property(\"Name\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"SerializedContent\")", + "\n .HasColumnType(\"varbinary(max)\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"ExportFile\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_291+ImportFile\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"ContentType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"CreationTime\")", + "\n .HasColumnType(\"datetime2\");", + "\n", + "\n b.Property(\"Directory\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Format\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Length\")", + "\n .HasColumnType(\"bigint\");", + "\n", + "\n b.Property(\"Name\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Partition\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"SerializedContent\")", + "\n .HasColumnType(\"varbinary(max)\");", + "\n", + "\n b.Property(\"Source\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"ImportFile\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_292+ImportString\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Content\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"CreationTime\")", + "\n .HasColumnType(\"datetime2\");", + "\n", + "\n b.Property(\"Format\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Length\")", + "\n .HasColumnType(\"bigint\");", + "\n", + "\n b.Property(\"SerializedContent\")", + "\n .HasColumnType(\"varbinary(max)\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"ImportString\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_293+ImportDataSet\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"CreationTime\")", + "\n .HasColumnType(\"datetime2\");", + "\n", + "\n b.Property(\"Format\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Length\")", + "\n .HasColumnType(\"bigint\");", + "\n", + "\n b.Property(\"SerializedContent\")", + "\n .HasColumnType(\"varbinary(max)\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"ImportDataSet\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_294+ImportStream\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"CreationTime\")", + "\n .HasColumnType(\"datetime2\");", + "\n", + "\n b.Property(\"Format\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Length\")", + "\n .HasColumnType(\"bigint\");", + "\n", + "\n b.Property(\"SerializedContent\")", + "\n .HasColumnType(\"varbinary(max)\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"ImportStream\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_57+AmountType\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"Discriminator\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"ExternalId\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Order\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Parent\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"PeriodType\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"AmountType\");", + "\n", + "\n b.HasDiscriminator(\"Discriminator\").HasValue(\"AmountType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_59+RiskDriver\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Order\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Parent\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"RiskDriver\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_60+EstimateType\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"ExternalId\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"InputSource\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Order\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"PeriodType\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"StructureType\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"EstimateType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_61+Novelty\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Order\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"Novelty\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_62+VariableType\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"Discriminator\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Order\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Parent\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"VariableType\");", + "\n", + "\n b.HasDiscriminator(\"Discriminator\").HasValue(\"VariableType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_68+Scenario\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"Scenario\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_69+LineOfBusiness\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Order\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Parent\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"LineOfBusiness\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_70+Currency\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"Currency\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_71+EconomicBasis\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"EconomicBasis\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_72+ValuationApproach\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"ValuationApproach\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_73+LiabilityType\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Parent\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"LiabilityType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_74+OciType\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"OciType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_75+Profitability\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"Profitability\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_76+Partner\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"Partner\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_77+CreditRiskRating\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"CreditRiskRating\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_78+ReportingNode\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"Currency\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Parent\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"ReportingNode\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_79+ProjectionConfiguration\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Shift\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"TimeStep\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"ProjectionConfiguration\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_80+AocConfiguration\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"AocType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"CdrPeriod\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"DataType\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"FxPeriod\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"InputSource\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Novelty\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Order\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"RcPeriod\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"ValuationPeriod\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"YcPeriod\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"AocConfiguration\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_81+ExchangeRate\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Currency\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"FxToGroupCurrency\")", + "\n .HasColumnType(\"float\");", + "\n", + "\n b.Property(\"FxType\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Scenario\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"ExchangeRate\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_82+CreditDefaultRate\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"CreditRiskRating\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Scenario\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Values\")", + "\n .HasColumnType(\"varbinary(max)\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"CreditDefaultRate\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_83+YieldCurve\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Currency\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Name\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Scenario\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Values\")", + "\n .HasColumnType(\"varbinary(max)\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"YieldCurve\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_84+PartnerRating\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"CreditRiskRating\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Partner\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Scenario\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"PartnerRating\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_86+PartitionByReportingNode\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"ReportingNode\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"PartitionByReportingNode\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_87+PartitionByReportingNodeAndPeriod\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"ReportingNode\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Scenario\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"PartitionByReportingNodeAndPeriod\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_88+DataNode\", b =>", + "\n {", + "\n b.Property(\"SystemName\")", + "\n .HasMaxLength(16)", + "\n .HasColumnType(\"nvarchar(16)\");", + "\n", + "\n b.Property(\"ContractualCurrency\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Discriminator\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"DisplayName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"FunctionalCurrency\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"LineOfBusiness\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"OciType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Partition\")", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"ValuationApproach\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasKey(\"SystemName\");", + "\n", + "\n b.ToTable(\"DataNode\");", + "\n", + "\n b.HasDiscriminator(\"Discriminator\").HasValue(\"DataNode\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_92+DataNodeState\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"DataNode\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Partition\")", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Scenario\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"State\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"DataNodeState\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_93+DataNodeParameter\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"DataNode\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Discriminator\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Month\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"Partition\")", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Scenario\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Year\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"DataNodeParameter\");", + "\n", + "\n b.HasDiscriminator(\"Discriminator\").HasValue(\"DataNodeParameter\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_98+RawVariable\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"AccidentYear\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"AmountType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"AocType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"DataNode\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"EstimateType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Novelty\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Partition\")", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Values\")", + "\n .HasColumnType(\"varbinary(max)\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"RawVariable\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_99+IfrsVariable\", b =>", + "\n {", + "\n b.Property(\"Id\")", + "\n .ValueGeneratedOnAdd()", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"AccidentYear\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"AmountType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"AocType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"DataNode\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"EconomicBasis\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"EstimateType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Novelty\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Partition\")", + "\n .HasColumnType(\"uniqueidentifier\");", + "\n", + "\n b.Property(\"Value\")", + "\n .HasColumnType(\"float\");", + "\n", + "\n b.HasKey(\"Id\");", + "\n", + "\n b.ToTable(\"IfrsVariable\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_58+DeferrableAmountType\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_57+AmountType\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"DeferrableAmountType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_63+AocType\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_62+VariableType\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"AocType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_65+PnlVariableType\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_62+VariableType\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"PnlVariableType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_66+BsVariableType\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_62+VariableType\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"BsVariableType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_67+AccountingVariableType\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_62+VariableType\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"AccountingVariableType\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_89+Portfolio\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_88+DataNode\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"Portfolio\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_90+GroupOfContract\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_88+DataNode\");", + "\n", + "\n b.Property(\"AnnualCohort\")", + "\n .HasColumnType(\"int\");", + "\n", + "\n b.Property(\"LiabilityType\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Partner\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Portfolio\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"Profitability\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"YieldCurveName\")", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"GroupOfContract\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_94+InterDataNodeParameter\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_93+DataNodeParameter\");", + "\n", + "\n b.Property(\"LinkedDataNode\")", + "\n .IsRequired()", + "\n .HasColumnType(\"nvarchar(max)\");", + "\n", + "\n b.Property(\"ReinsuranceCoverage\")", + "\n .HasColumnType(\"float\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"InterDataNodeParameter\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_94+SingleDataNodeParameter\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_93+DataNodeParameter\");", + "\n", + "\n b.Property(\"PremiumAllocation\")", + "\n .HasColumnType(\"float\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"SingleDataNodeParameter\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_89+InsurancePortfolio\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_89+Portfolio\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"InsurancePortfolio\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_89+ReinsurancePortfolio\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_89+Portfolio\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"ReinsurancePortfolio\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_91+GroupOfInsuranceContract\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_90+GroupOfContract\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"GroupOfInsuranceContract\");", + "\n });", + "\n", + "\n modelBuilder.Entity(\"Submission_91+GroupOfReinsuranceContract\", b =>", + "\n {", + "\n b.HasBaseType(\"Submission_90+GroupOfContract\");", + "\n", + "\n b.HasDiscriminator().HasValue(\"GroupOfReinsuranceContract\");", + "\n });", + "\n }", + "\n}", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Database/PersonalConnectionExample.ipynb b/ifrs17-template/Database/PersonalConnectionExample.ipynb index 58813866..203c0cd1 100644 --- a/ifrs17-template/Database/PersonalConnectionExample.ipynb +++ b/ifrs17-template/Database/PersonalConnectionExample.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "iMY-rLl2BUa8lkYs0sDLqg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "code", diff --git a/ifrs17-template/Database/Schema Delete.ipynb b/ifrs17-template/Database/Schema Delete.ipynb index 68be7e2c..9695bf66 100644 --- a/ifrs17-template/Database/Schema Delete.ipynb +++ b/ifrs17-template/Database/Schema Delete.ipynb @@ -1,7 +1,7 @@ { "metadata": { "authors": [], - "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 }", + "id": "5eRSY38YIEezOQrFaki93g", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -14,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "code", diff --git a/ifrs17-template/Export/MapTemplate.ipynb b/ifrs17-template/Export/MapTemplate.ipynb index f7801ae7..a4538e72 100644 --- a/ifrs17-template/Export/MapTemplate.ipynb +++ b/ifrs17-template/Export/MapTemplate.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "45_kgGyWikmokx6bcLybBA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -111,7 +110,7 @@ "source": [ "# Map Template: Data Node", "\n", - "\n[DataNodes](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#data-node) defines the properties of [Portfolios](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#portfolios) and [Group of Contracts](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#group-of-contracts)." + "\n[DataNodes](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#data-node) defines the properties of [Portfolios](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#portfolios) and [Group of Contracts](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#group-of-contracts)." ], "metadata": {}, "execution_count": 0, @@ -155,7 +154,7 @@ "\n .GroupofContractConfiguration(typeof(ReinsurancePortfolio))", "\n .GroupofContractConfiguration(typeof(InsurancePortfolio))", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -167,7 +166,7 @@ "source": [ "# Map Template: Data Node State", "\n", - "\n[Data Node State](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#data-node-state) defines whether the instance is active (used in import/output) or inactive (present in the DataSource but not used in input/output operations)." + "\n[Data Node State](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#data-node-state) defines whether the instance is active (used in import/output) or inactive (present in the DataSource but not used in input/output operations)." ], "metadata": {}, "execution_count": 0, @@ -241,7 +240,7 @@ "\n .StateEnumConfiguration() ", "\n .DataNodeStateConfiguration(dataNodeStates)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -253,7 +252,7 @@ "source": [ "# Map Template: Data Node Parameter", "\n", - "\n[Data Node Parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#data-node-parameters) are defined at the Group of Contract level and are used during the import calculation. " + "\n[Data Node Parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#data-node-parameters) are defined at the Group of Contract level and are used during the import calculation. " ], "metadata": {}, "execution_count": 0, @@ -328,7 +327,7 @@ "\n .WithSource(Workspace)", "\n .DataNodeParameterConfiguration(dataNodeParameters)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Images/QuotaShareReinsurance.png b/ifrs17-template/Images/QuotaShareReinsurance.png new file mode 100644 index 00000000..242ca134 Binary files /dev/null and b/ifrs17-template/Images/QuotaShareReinsurance.png differ diff --git a/ifrs17-template/Images/QuotaShareReinsurance2.png b/ifrs17-template/Images/QuotaShareReinsurance2.png new file mode 100644 index 00000000..5e504624 Binary files /dev/null and b/ifrs17-template/Images/QuotaShareReinsurance2.png differ diff --git a/ifrs17-template/Import/CloseImportTemplate.ipynb b/ifrs17-template/Import/CloseImportTemplate.ipynb index 3f96d4b5..9662ac57 100644 --- a/ifrs17-template/Import/CloseImportTemplate.ipynb +++ b/ifrs17-template/Import/CloseImportTemplate.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "yMtBIgY0skapo5-0Kg-V1w", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -38,7 +39,7 @@ "source": [ "All imports are triggered via the Import command. Several options can be fluently appended to customize the import action:", "\n- FromFile() : accepts a string as input (eg. \"../Files/TransactionalData/Openings_CH_2020_12.csv\"). It corresponds the file to be imported complete with the path", - "\n- WithFormat() : accepts a string as input (eg. \"Cashflow\" or \"Actual\"). It is used to trigger the desired import logic for the current file. Full list of avalaible ImportFormats can be found [here](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Constants/Consts#import-formats)", + "\n- WithFormat() : accepts a string as input (eg. \"Cashflow\" or \"Actual\"). It is used to trigger the desired import logic for the current file. Full list of avalaible ImportFormats can be found [here](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Constants/Consts#import-formats)", "\n- WithFileStorage() : defined the drive from where the input files is retrieved. In this example we use the project file storage (new files have to be uploaded into the project), other options are SharePoint and OneDrive. ", "\n- WithTarget() : target drive where the results are stored. In this example we use our in-memory set up", "\n" @@ -88,9 +89,9 @@ "\nNew Data Nodes and Parameters are imported here.", "\n
To easily generate these files, please refer to the **Map Template** files exported [here](../Export/MapTemplate). Edit them at your wish and import them back into the solution through the following cells. ", "\n
For the **ImportFormat**, the following options are expected:", - "\n- ImportFormats.DataNode : [Portfolios](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#portfolios) and [Group of Contracts](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#group-of-contracts)", - "\n- ImportFormats.DataNodeState : the [state of a data node](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#data-node-state) can be either active or inactive.", - "\n- ImportFormats.DataNodeParameter : parameters are described [here](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#data-node-parameters). For **Group of Insurance Contracts** a default [Premium Allocation factor](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Import/ImportScopeCalculation#experience-adjustment-on-premium) of 1 is applied if the parameter is not imported.", + "\n- ImportFormats.DataNode : [Portfolios](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#portfolios) and [Group of Contracts](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#group-of-contracts)", + "\n- ImportFormats.DataNodeState : the [state of a data node](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#data-node-state) can be either active or inactive.", + "\n- ImportFormats.DataNodeParameter : parameters are described [here](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#data-node-parameters). For **Group of Insurance Contracts** a default [Premium Allocation factor](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Import/ImportScopeCalculation#experience-adjustment-on-premium) of 1 is applied if the parameter is not imported.", "\n" ], "metadata": {}, @@ -121,7 +122,7 @@ "await Import.FromFile(pathToFile)", "\n .WithFormat(format)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -170,7 +171,7 @@ "await Import.FromFile(pathToFile)", "\n .WithFormat(format)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb b/ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb index 412f644a..59a4f805 100644 --- a/ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb +++ b/ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "y9xL_svpDUiNzR7LMSA2BA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -80,7 +79,7 @@ "await Import.FromFile(\"../Files/DataNodes/DataNodes_CH.csv\")", "\n .WithFormat(ImportFormats.DataNode)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -93,7 +92,7 @@ "await Import.FromFile(\"../Files/DataNodes/DataNodeStates_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.DataNodeState)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -106,7 +105,7 @@ "await Import.FromFile(\"../Files/DataNodes/DataNodeParameters_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.DataNodeParameter)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Initialization/InitSystemorphRefDataToMemory.ipynb b/ifrs17-template/Initialization/InitSystemorphRefDataToMemory.ipynb index d406a80d..9ee80c7a 100644 --- a/ifrs17-template/Initialization/InitSystemorphRefDataToMemory.ipynb +++ b/ifrs17-template/Initialization/InitSystemorphRefDataToMemory.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "VJIatQORbkmmRr7eJSpAjg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -118,7 +117,7 @@ "\n .WithType()", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -131,7 +130,7 @@ "await Import.FromFile(\"../Files/Dimensions.csv\")", "\n .WithFormat(ImportFormats.AocConfiguration)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -144,7 +143,7 @@ "await Import.FromFile(\"../Files/ReportingNodes/ReportingNodes.csv\")", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -166,42 +165,42 @@ "var log = await Import.FromFile(\"../Files/Parameters/YieldCurve_2019_12.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2020_1.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2020_3.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2020_12.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2021_3.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2021_6.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2021_12.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync());", "\nlog" ], @@ -215,7 +214,7 @@ "await Import.FromFile(\"../Files/Parameters/ExchangeRate.csv\")", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -228,7 +227,7 @@ "await Import.FromFile(\"../Files/Parameters/PartnerRating.csv\")", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -241,7 +240,7 @@ "await Import.FromFile(\"../Files/Parameters/CreditDefaultRate.csv\")", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb b/ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb index ecb29f00..fae6f837 100644 --- a/ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb +++ b/ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "QCMDxyUBBEyl3M18wFrgDA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -96,7 +95,7 @@ "\n .WithType()", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -109,7 +108,7 @@ "await Import.FromFile(\"../Files/ReportingNodes/ReportingNodes.csv\")", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -131,42 +130,42 @@ "var log = await Import.FromFile(\"../Files/Parameters/YieldCurve_2019_12.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2020_1.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2020_3.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2020_12.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2021_3.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2021_6.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog.Merge(await Import.FromFile(\"../Files/Parameters/YieldCurve_2021_12.csv\")", "\n .WithFormat(ImportFormats.YieldCurve)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()", "\n );", "\nlog" @@ -181,7 +180,7 @@ "await Import.FromFile(\"../Files/Parameters/ExchangeRate.csv\")", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -194,7 +193,7 @@ "await Import.FromFile(\"../Files/Parameters/PartnerRating.csv\")", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -207,7 +206,7 @@ "await Import.FromFile(\"../Files/Parameters/CreditDefaultRate.csv\")", "\n .WithType()", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -229,7 +228,7 @@ "await Import.FromFile(\"../Files/DataNodes/DataNodes_CH.csv\")", "\n .WithFormat(ImportFormats.DataNode)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -242,7 +241,7 @@ "await Import.FromFile(\"../Files/DataNodes/DataNodeStates_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.DataNodeState)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -255,7 +254,7 @@ "await Import.FromFile(\"../Files/DataNodes/DataNodeParameters_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.DataNodeParameter)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -277,7 +276,7 @@ "await Import.FromFile(\"../Files/TransactionalData/Openings_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Opening)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -290,7 +289,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -303,7 +302,7 @@ "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -316,7 +315,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2021_3.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -329,7 +328,7 @@ "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2021_3.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -342,7 +341,7 @@ "await Import.FromFile(\"../Files/TransactionalData/SimpleValue_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.SimpleValue )", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -355,7 +354,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12_MTUP10pct.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Initialization/InitSystemorphToMemory.ipynb b/ifrs17-template/Initialization/InitSystemorphToMemory.ipynb index f5a7d4bc..b196f3e8 100644 --- a/ifrs17-template/Initialization/InitSystemorphToMemory.ipynb +++ b/ifrs17-template/Initialization/InitSystemorphToMemory.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "6vRP2T2AiEq5rmfljOKoSQ", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -70,7 +69,7 @@ "await Import.FromFile(\"../Files/TransactionalData/Openings_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Opening)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -83,7 +82,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -96,7 +95,7 @@ "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -109,7 +108,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2021_3.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -122,7 +121,7 @@ "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2021_3.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -135,7 +134,7 @@ "await Import.FromFile(\"../Files/TransactionalData/SimpleValue_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.SimpleValue )", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -148,7 +147,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12_MTUP10pct.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/InputFormatDescription.ipynb b/ifrs17-template/InputFormatDescription.ipynb index c0eb846c..79563031 100644 --- a/ifrs17-template/InputFormatDescription.ipynb +++ b/ifrs17-template/InputFormatDescription.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "jHYsC7bG1kWZ1KUpb2B2nw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -39,17 +38,17 @@ "source": [ "A cash flow file is named **NominalCashflows** *\\_* *\\_* *\\_* and is composed of two sections: **Main** and **Cashflow**.", "\n", - "\nThe **Main** section contains information such as: Reporting Node, Year, Month and Scenario for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#partitions) to which the data belongs.", + "\nThe **Main** section contains information such as: Reporting Node, Year, Month and Scenario for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#partitions) to which the data belongs.", "\n", "\nThe **Cashflow** section contains the cash flow data. Several pieces of information are required to characterize a cash flow correctly:", - "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", - "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#amount-type) : entered with its SystemName,", - "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#estimate-type) : entered with its SystemName,", - "\n- [AocType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#aoc-type) : entered with its SystemName,", - "\n- [Novelty](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#novelty) : entered with its SystemName,", + "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", + "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", + "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", + "\n- [AocType](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#aoc-type) : entered with its SystemName,", + "\n- [Novelty](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#novelty) : entered with its SystemName,", "\n- AccidentYear : relevant for Data Node with Liability Type: Liability for Incurred Claims.", "\n", - "\nAll valid combinations of AocType and Novelty can be found in [AocConfiguration](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#aoc-configuration) with DataType Optional or Mandatory.", + "\nAll valid combinations of AocType and Novelty can be found in [AocConfiguration](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#aoc-configuration) with DataType Optional or Mandatory.", "\n
The cash flow is entered in the columns named ValuesN where N goes from 0 to the length of cash flow. The Value0 corresponds to January of the Year entered in the **Main** section for every combination of AocType and Novelty. " ], "metadata": {}, @@ -74,13 +73,13 @@ "source": [ "An Actuals file is named **Actuals** *\\_* *\\_* *\\_* and is composed of two sections: **Main** and **Actual**.", "\n", - "\nThe **Main** section contains information such as: Reporting Node, Year, Month for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#partition) to which the data belong.", + "\nThe **Main** section contains information such as: Reporting Node, Year, Month for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#partition) to which the data belong.", "\n", "\nThe **Actual** section contains the actuals data. Several pieces of information are required to to characterize an Actuals amount correctly:", - "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", - "\n- [AocType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#aoc-type) : entered with its SystemName,", - "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#amount-type) : entered with its SystemName,", - "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#estimate-type) : entered with its SystemName,", + "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", + "\n- [AocType](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#aoc-type) : entered with its SystemName,", + "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", + "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", "\n- AccidentYear : relevant for Data Node with Liability Type: Liability for Incurred Claims." ], "metadata": {}, @@ -105,12 +104,12 @@ "source": [ "An Openings file is named **Openings** *\\_* *\\_* *\\_* and is composed of two sections: **Main** and **Opening**. In an AoC for one period, we only need one file with the year/month combination of the beginning of the period. Some GICs do not need any entries in Openings.", "\n", - "\nThe **Main** section contains information such as: Reporting Node, Year, Month for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#partition) to which the data belong.", + "\nThe **Main** section contains information such as: Reporting Node, Year, Month for which the data is being imported. This information is used to define the [partition](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#partition) to which the data belong.", "\n", "\nThe **Opening** section contains values at opening of an analysis. Several pieces of information are required to to characterize an Opening amount correctly:", - "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", - "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#amount-type) : entered with its SystemName,", - "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#estimate-type) : entered with its SystemName,", + "\n- [DataNode](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#group-of-contracts) : lowest granularity of the Data Node, it is entered with its SystemName,", + "\n- [AmountType](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#amount-type) : entered with its SystemName,", + "\n- [EstimateType](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#estimate-type) : entered with its SystemName,", "\n- AccidentYear : relevant for Data Node with Liability Type: Liability for Incurred Claims." ], "metadata": {}, diff --git a/ifrs17-template/OverviewIFRS17Template.ipynb b/ifrs17-template/OverviewIFRS17Template.ipynb index 95a010d7..5bb78de2 100644 --- a/ifrs17-template/OverviewIFRS17Template.ipynb +++ b/ifrs17-template/OverviewIFRS17Template.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "x4yyGM3xMkujl6CbUMKyng", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseDataImport.ipynb b/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseDataImport.ipynb index f3066174..87fd4e02 100644 --- a/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseDataImport.ipynb +++ b/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseDataImport.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "B0gzeyIBW0-tm7A4o9ykGw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -77,7 +76,7 @@ "await Import.FromFile(\"DataNodes_ActualsCase_CH.csv\")", "\n .WithFormat(ImportFormats.DataNode)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -90,7 +89,7 @@ "await Import.FromFile(\"DataNodeStates_ActualsCase_CH_2020_1.csv\")", "\n .WithFormat(ImportFormats.DataNodeState)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -103,7 +102,7 @@ "await Import.FromFile(\"DataNodeParameters_ActualsCase_CH_2020_1.csv\")", "\n .WithFormat(ImportFormats.DataNodeParameter)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -134,7 +133,7 @@ "await Import.FromFile(\"NominalCashflows_ActualsCase_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -147,7 +146,7 @@ "await Import.FromFile(\"Actuals_ActualsCase_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -169,7 +168,7 @@ "await Import.FromFile(\"NominalCashflows_ActualsCase_CH_2021_6.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -182,7 +181,7 @@ "await Import.FromFile(\"Actuals_ActualsCase_CH_2021_6.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -204,7 +203,7 @@ "await Import.FromFile(\"NominalCashflows_ActualsCase_CH_2021_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -217,7 +216,7 @@ "await Import.FromFile(\"Actuals_ActualsCase_CH_2021_12.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports.ipynb b/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports.ipynb index 133580d4..6c493cd4 100644 --- a/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports.ipynb +++ b/ifrs17-template/PracticalUseCases/ActualsOutsideThePeriod/ActualsUseCaseReports.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "Z8P8Xunhp0ynikLIE1omWQ", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_BE.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_BE.csv new file mode 100644 index 00000000..14f9777c --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_BE.csv @@ -0,0 +1,11 @@ +@@Main,,,,, +ReportingNode,Year,Month,,, +CH,2020,12,,, +@@Actual,,,,, +DataNode,AocType,AmountType,EstimateType,AccidentYear,Value +RP1.1,CF,PR,A,,1000 +RP1.1,CF,NIC,A,,-600 +RP1.1,CF,AEM,A,,-300 +RPR1.1,CF,PR,A,,-300 +RPR1.1,CF,NIC,A,,180 +RPR1.1,CF,AC,A,,105 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_ELR60A70.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_ELR60A70.csv new file mode 100644 index 00000000..68943f13 --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_ELR60A70.csv @@ -0,0 +1,11 @@ +@@Main,,,,, +ReportingNode,Year,Month,Scenario,, +CH,2020,12,ELR60A70,, +@@Actual,,,,, +DataNode,AocType,AmountType,EstimateType,AccidentYear,Value +RP1.1,CF,PR,A,,1000 +RP1.1,CF,NIC,A,,-700 +RP1.1,CF,AEM,A,,-300 +RPR1.1,CF,PR,A,,-300 +RPR1.1,CF,NIC,A,,210 +RPR1.1,CF,AC,A,,105 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_ELR60A80.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_ELR60A80.csv new file mode 100644 index 00000000..e58f9304 --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_ELR60A80.csv @@ -0,0 +1,11 @@ +@@Main,,,,, +ReportingNode,Year,Month,Scenario,, +CH,2020,12,ELR60A80,, +@@Actual,,,,, +DataNode,AocType,AmountType,EstimateType,AccidentYear,Value +RP1.1,CF,PR,A,,1000 +RP1.1,CF,NIC,A,,-800 +RP1.1,CF,AEM,A,,-300 +RPR1.1,CF,PR,A,,-300 +RPR1.1,CF,NIC,A,,240 +RPR1.1,CF,AC,A,,105 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_LR70.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_LR70.csv new file mode 100644 index 00000000..025df1ea --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_LR70.csv @@ -0,0 +1,11 @@ +@@Main,,,,, +ReportingNode,Year,Month,Scenario,, +CH,2020,12,LR70,, +@@Actual,,,,, +DataNode,AocType,AmountType,EstimateType,AccidentYear,Value +RP1.1,CF,PR,A,,1000 +RP1.1,CF,NIC,A,,-700 +RP1.1,CF,AEM,A,,-300 +RPR1.1,CF,PR,A,,-300 +RPR1.1,CF,NIC,A,,210 +RPR1.1,CF,AC,A,,105 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_LR80.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_LR80.csv new file mode 100644 index 00000000..38aba505 --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Actual_CH_2020_12_LR80.csv @@ -0,0 +1,11 @@ +@@Main,,,,, +ReportingNode,Year,Month,Scenario,, +CH,2020,12,LR80,, +@@Actual,,,,, +DataNode,AocType,AmountType,EstimateType,AccidentYear,Value +RP1.1,CF,PR,A,,1000 +RP1.1,CF,NIC,A,,-800 +RP1.1,CF,AEM,A,,-300 +RPR1.1,CF,PR,A,,-300 +RPR1.1,CF,NIC,A,,240 +RPR1.1,CF,AC,A,,105 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataImport.ipynb b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataImport.ipynb new file mode 100644 index 00000000..fe076312 --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataImport.ipynb @@ -0,0 +1,283 @@ +{ + "metadata": { + "authors": [], + "id": "YGWMnwRniU64QZaE2oBrFw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Contractual Service Margin and Loss Component Switch Data Import

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This is the Data Import notebook for the Contractual Service Margin and Loss Component Switch case.", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Set up and data import" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reference Data and Parameters" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"../../Initialization/InitSystemorphRefDataToMemory\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Scenarios" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"Scenarios.csv\").WithType().WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Data Nodes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"DataNodes_CH.csv\").WithFormat(ImportFormats.DataNode).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"DataNodeStates_CH_2020_12.csv\").WithFormat(ImportFormats.DataNodeState).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"DataNodeParameters_CH_2020_12.csv\").WithFormat(ImportFormats.DataNodeParameter).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Best Estimate - Loss Ratio 60%" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### importing first GIC: 2020 12 for fully retrospective calculation and 2021 3 for the current calculation" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"Actual_CH_2020_12_BE.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"NominalCashflows_CH_2020_12_BE.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Import Scenarios" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Loss Ratio 70%" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"Actual_CH_2020_12_LR70.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"NominalCashflows_CH_2020_12_LR70.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Loss Ratio 80%" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"Actual_CH_2020_12_LR80.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"NominalCashflows_CH_2020_12_LR80.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Expected Loss Ratio 60% (BE) Actual 70%" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"Actual_CH_2020_12_ELR60A70.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Expected Loss Ratio 60% (BE) Actual 80%" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"Actual_CH_2020_12_ELR60A80.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).WithActivityLog().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Initialize Workspace" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nWorkspace.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodeParameters_CH_2020_12.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodeParameters_CH_2020_12.csv new file mode 100644 index 00000000..bb53a8a8 --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodeParameters_CH_2020_12.csv @@ -0,0 +1,11 @@ +@@Main,, +ReportingNode,Year,Month,Scenario +CH,2020,12 +,, +@@SingleDataNodeParameter,, +DataNode,PremiumAllocation, +RP1.1,0.0 +,, +@@InterDataNodeParameter,, +DataNode,LinkedDataNode,ReinsuranceCoverage +RP1.1,RPR1.1,0.3 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodeStates_CH_2020_12.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodeStates_CH_2020_12.csv new file mode 100644 index 00000000..576d5bd0 --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodeStates_CH_2020_12.csv @@ -0,0 +1,8 @@ +@@Main +ReportingNode,Year,Month,Scenario +CH,2020,12, + +@@DataNodeState,, +DataNode,State, +RP1.1,Active, +RPR1.1,Active, diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodes_CH.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodes_CH.csv new file mode 100644 index 00000000..ca3696e5 --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/DataNodes_CH.csv @@ -0,0 +1,15 @@ +@@Main +ReportingNode +CH +@@InsurancePortfolio +SystemName,DisplayName,ContractualCurrency,LineOfBusiness,ValuationApproach,OciType, +RP1,Insurance Portfolio,USD,ANN,BBA,Default, +@@GroupOfInsuranceContract +SystemName,DisplayName,InsurancePortfolio,AnnualCohort,LiabilityType,Profitability, +RP1.1,Gross Business Reinsured,RP1,2020,LRC,O, +@@ReinsurancePortfolio +SystemName,DisplayName,ContractualCurrency,LineOfBusiness,ValuationApproach,OciType, +RPR1,Reinsurance Portfolio,USD,ANN,BBA,Default, +@@GroupOfReinsuranceContract +SystemName,DisplayName,ReinsurancePortfolio,AnnualCohort,LiabilityType,Profitability,Partner +RPR1.1,Reinsurance Contract,RPR1,2020,LRC,P,PT1 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_BE.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_BE.csv new file mode 100644 index 00000000..11b389f9 --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_BE.csv @@ -0,0 +1,19 @@ +@@Main,,,,,,,,,,,,,,,,, +ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,, +CH,2020,12,,,,,,,,,,,,,,, +@@Cashflow,,,,,,,,,,,,,,,,, +DataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11 +RP1.1,,CU,CL,C,,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333 +RPR1.1,,CU,CL,C,,50,50,50,50,50,50,50,50,50,50,50,50 +RP1.1,PR,BE,BOP,N,,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333 +RP1.1,PR,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RP1.1,NIC,BE,BOP,N,,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50 +RP1.1,NIC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RP1.1,AEM,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25 +RP1.1,AEM,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,PR,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25 +RPR1.1,PR,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,NIC,BE,BOP,N,,15,15,15,15,15,15,15,15,15,15,15,15 +RPR1.1,NIC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,AC,BE,BOP,N,,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75 +RPR1.1,AC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_LR70.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_LR70.csv new file mode 100644 index 00000000..c0bd388a --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_LR70.csv @@ -0,0 +1,19 @@ +@@Main,,,,,,,,,,,,,,,,, +ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,, +CH,2020,12,LR70,,,,,,,,,,,,,, +@@Cashflow,,,,,,,,,,,,,,,,, +DataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11 +RP1.1,,CU,CL,C,,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333 +RPR1.1,,CU,CL,C,,58.33333333,58.33333333,58.33333333,58.33333333,58.33333333,58.33333333,58.33333333,58.33333333,58.33333333,58.33333333,58.33333333,58.33333333 +RP1.1,PR,BE,BOP,N,,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333 +RP1.1,PR,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RP1.1,NIC,BE,BOP,N,,-58.33333333,-58.33333333,-58.33333333,-58.33333333,-58.33333333,-58.33333333,-58.33333333,-58.33333333,-58.33333333,-58.33333333,-58.33333333,-58.33333333 +RP1.1,NIC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RP1.1,AEM,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25 +RP1.1,AEM,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,PR,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25 +RPR1.1,PR,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,NIC,BE,BOP,N,,17.5,17.5,17.5,17.5,17.5,17.5,17.5,17.5,17.5,17.5,17.5,17.5 +RPR1.1,NIC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,AC,BE,BOP,N,,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75 +RPR1.1,AC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_LR80.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_LR80.csv new file mode 100644 index 00000000..6f1d5cdb --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/NominalCashflows_CH_2020_12_LR80.csv @@ -0,0 +1,19 @@ +@@Main,,,,,,,,,,,,,,,,, +ReportingNode,Year,Month,Scenario,,,,,,,,,,,,,, +CH,2020,12,LR80,,,,,,,,,,,,,, +@@Cashflow,,,,,,,,,,,,,,,,, +DataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11 +RP1.1,,CU,CL,C,,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333 +RPR1.1,,CU,CL,C,,66.66666667,66.66666667,66.66666667,66.66666667,66.66666667,66.66666667,66.66666667,66.66666667,66.66666667,66.66666667,66.66666667,66.66666667 +RP1.1,PR,BE,BOP,N,,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333,83.33333333 +RP1.1,PR,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RP1.1,NIC,BE,BOP,N,,-66.66666667,-66.66666667,-66.66666667,-66.66666667,-66.66666667,-66.66666667,-66.66666667,-66.66666667,-66.66666667,-66.66666667,-66.66666667,-66.66666667 +RP1.1,NIC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RP1.1,AEM,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25 +RP1.1,AEM,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,PR,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25 +RPR1.1,PR,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,NIC,BE,BOP,N,,20,20,20,20,20,20,20,20,20,20,20,20 +RPR1.1,NIC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 +RPR1.1,AC,BE,BOP,N,,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75,8.75 +RPR1.1,AC,BE,CL,C,,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Reports.ipynb b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Reports.ipynb new file mode 100644 index 00000000..209e4d2d --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Reports.ipynb @@ -0,0 +1,471 @@ +{ + "metadata": { + "authors": [], + "id": "fSGCg42oXUOYruTUQPiNXg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Quota Share Reinsurance

", + "\n", + "\n

Loss Ratio analysis

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Case Study", + "\n", + "\n## Modelling Cash-flow inputs", + "\n", + "\nA simple Group of Insurance Contract with New Business and End Of Period runs is modeled over one year period with an expected Loss Ratio (LR) of 60%. We modeled the cashflows evenly distributed over time for both premium (1000 USD total), Claims, and Expenses (estimated to be 30% of Premiums). A Reinsurance Contract covers the above mentioned Insurance Contract. A Quota Share of 30% is considered and a Reinsurance Commission of 35% on the Reinsurance Premiums is modeled. Actual values entered matching the expected values. ", + "\n", + "\nAll these parameters are summarized in the following tables: ", + "\n

", + "\n| Insurance Contract | ||| Reinsurance Contract | |", + "\n|-----------------------|------|-|-----------------------|------|", + "\n| Total Premium (USD) | 1000 ||| Cession Share | 30% |", + "\n| Internal Expense | 30% ||| Commission | 35% |", + "\n
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenarios ", + "\n", + "\nThe inputs descibed in [Modelling Cash-flow inputs](#modelling-cash-flow-inputs) defines the so called \"Best Estimate\" Scenario. This corresponds to what is expected to happen in reality. A scenario analysis is required by IFRS 17 Standards and it can be useful in many cases to analyse risks and take decisions on the future. For example one can easily study how the profit of the Insurance and Reinsuance Contracts modelled with the above mentioned parameter would perform under different values of Loss Ratio. ", + "\n

", + "\n
", + "\n", + "\n", + "\n


", + "\n
", + "\nIn the best estimate scenario (Loss Ratio 60%) we expect the net result of the Insurance and Reinsurance Group Contracts to be profitable, but the costs of having a Reinsurance Contract lower the total profit of the Insurance Group of Contract stand alone. At Loss Ratio of 70% the Group of Insurance Contracts is very close to zero margin and raising futher the Loss Ratio to 80% a Loss making scenario is obtained, where the effect of the Reinsurance contract clearly mitigates the losses as shown by the Net view. ", + "\n

", + "\nIn the current use case, we analyse the impact of the Loss Ratio on the relevant figures computed under IFRS 17 using our standard solution implementation.", + "\nFor simplicity, we consider the contribution of Risk Adjustment to be zero and locked-in and current yield curves are the same. ", + "\nWe have defined four scenarios in addition to the best estimate. We considered variations to the Loss Ratio up to 70% and 80%. In addition, we also studied the cases of having modelled the input cash flow assuming a Loss Ratio of 60% but the incurred actual cash flow producing a Loss Ratio of 70% and 80%. ", + "\n

", + "\n", + "\n| Scenario | Expected Loss Ratio | Actual Loss Ratio |", + "\n|------------------------------|---------------------|--------------------|", + "\n| Best Estimate | 60% | as expected |", + "\n| Loss Ratio 70 | 70% | as expected |", + "\n| Loss Ratio 80 | 80% | as expected |", + "\n| Expected LR 60 Actual LR 70 | 60% | 70% |", + "\n| Expected LR 60 Actual LR 80 | 60% | 80% |", + "\n", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Data Import" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"DataImport\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17 = new Ifrs17(Workspace, Scopes, Report, Export);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var reportingYear = 2020; ", + "\nvar reportingMonth = 12;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Best Estimate", + "\n", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var pv = ifrs17.PresentValues;", + "\npv.ReportingNode = \"CH\";", + "\npv.ReportingPeriod = (reportingYear, reportingMonth);", + "\npv.CurrencyType = CurrencyType.Contractual;", + "\npv.ColumnSlices = new string[]{\"Scenario\",\"GroupOfContract\", \"AmountType\"};", + "\npv.DataFilter = new [] {(\"EconomicBasis\", \"L\")};//,(\"Scenario\",\"!ELR60A70\"),(\"Scenario\",\"!ELR60A80\")};", + "\npv.Scenario = \"All\";// null;//\"LR70\";//\"All\";", + "\n(await pv.ToReportAsync)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Written Actuals" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var writtenActual = ifrs17.WrittenActuals;", + "\nwrittenActual.ReportingNode = \"CH\";", + "\nwrittenActual.ReportingPeriod = (reportingYear, reportingMonth);", + "\nwrittenActual.ColumnSlices = new string[]{\"Scenario\", \"GroupOfContract\"};", + "\nwrittenActual.DataFilter = null;", + "\nwrittenActual.Scenario = \"All\";", + "\n(await writtenActual.ToReportAsync) with { GroupDefaultExpanded = 0}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Actuarial Experience Adjustment" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var experienceAdjustments = ifrs17.ExperienceAdjustments;", + "\nexperienceAdjustments.ReportingNode = \"CH\";", + "\nexperienceAdjustments.ReportingPeriod = (reportingYear, reportingMonth);", + "\nexperienceAdjustments.ColumnSlices = new string[]{\"Scenario\",\"GroupOfContract\"};//\"GroupOfContract\", \"AmountType\"", + "\nexperienceAdjustments.RowSlices = new string[]{\"AmountType\",\"EstimateType\"};//\"GroupOfContract\", \"AmountType\"", + "\nexperienceAdjustments.DataFilter = null; //new [] {(\"Scenario\", \"!LR70\"),(\"Scenario\", \"!LR80\")};", + "\nexperienceAdjustments.Scenario = \"All\";", + "\n(await experienceAdjustments.ToReportAsync) with { GroupDefaultExpanded = 0}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Contractual Service Margin / Loss Component" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var allocatedTechnicalMargins = ifrs17.AllocatedTechnicalMargins;", + "\nallocatedTechnicalMargins.ReportingNode = \"CH\";", + "\nallocatedTechnicalMargins.ReportingPeriod = (reportingYear, reportingMonth);", + "\nallocatedTechnicalMargins.ColumnSlices = new string[]{\"Scenario\", \"GroupOfContract\", \"EstimateType\"};", + "\nallocatedTechnicalMargins.DataFilter = new [] {(\"Scenario\",\"!ELR60A70\"),(\"Scenario\",\"!ELR60A80\")}; //new [] {(\"Scenario\", \"!LR70\"),(\"Scenario\", \"!LR80\")};", + "\n//allocatedTechnicalMargins.Scenario = null;", + "\nallocatedTechnicalMargins.Scenario = \"All\";", + "\n(await allocatedTechnicalMargins.ToReportAsync) with {Height = 700}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# LRC Actuarial", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var actuarialLrc = ifrs17.ActuarialLrc;", + "\nactuarialLrc.ReportingNode = \"CH\";", + "\nactuarialLrc.ReportingPeriod = (reportingYear, reportingMonth);", + "\nactuarialLrc.ColumnSlices = new string[]{\"Scenario\",\"GroupOfContract\",\"EstimateType\"};", + "\nactuarialLrc.DataFilter = new [] {(\"Scenario\",\"!ELR60A70\"),(\"Scenario\",\"!ELR60A80\")};", + "\nactuarialLrc.Scenario = \"All\";", + "\n(await actuarialLrc.ToReportAsync) with {Height = 750}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Financial Performance", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var financialPerformance = ifrs17.FinancialPerformance;", + "\nfinancialPerformance.ReportingNode = \"CH\";", + "\nfinancialPerformance.ReportingPeriod = (reportingYear, reportingMonth);", + "\nfinancialPerformance.ColumnSlices = new string[]{\"Scenario\", \"GroupOfContract\"};", + "\nfinancialPerformance.RowSlices = new string[]{\"AmountType\"};", + "\nfinancialPerformance.DataFilter = null; //new []{(\"Scenario\",\"!LR70\"),(\"Scenario\",\"!ELR60A70\")};//new []{(\"Scenario\",\"!ELR60A70\"),(\"Scenario\",\"!ELR60A80\")};", + "\nfinancialPerformance.Scenario = \"All\";", + "\n(await financialPerformance.ToReportAsync) with { Height = 900, GroupDefaultExpanded = 3}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Key Performance Indicators (KPIs)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Contractual Service Margine : value creation" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### New Business" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var csmNb = allocatedTechnicalMargins.GetDataCube().Where(x => x.VariableType == \"BOP\")", + "\n .Select(x => x.Scenario == null ? x with {Scenario = \"Best Estimate\"} : x);", + "\n // .Select(x => x.Scenario == null ? x with {Scenario = \"Best Estimate\", ", + "\n // Value = x.EstimateType == \"C\" ? -x.Value : x.Value} : x with {Value = x.EstimateType == \"C\" ? -x.Value : x.Value});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Report.ForDataCube(csmNb.ToDataCube()).WithQuerySource(Workspace)", + "\n .SliceRowsBy(\"VariableType\",\"GroupOfContract\")", + "\n .SliceColumnsBy(new[]{\"Currency\",\"Scenario\"})", + "\n .ReportGridOptions().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Amortization" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var csmAM = allocatedTechnicalMargins.GetDataCube().Where(x => x.VariableType == \"AM\" && Math.Abs(x.Value) > 10E-5)", + "\n .Select(x => x.Scenario == null ? x with {Scenario = \"Best Estimate\", ", + "\n Value = x.EstimateType == \"C\" ? -x.Value : x.Value} : x with {Value = x.EstimateType == \"C\" ? -x.Value : x.Value});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Report.ForDataCube(csmAM.ToDataCube()).WithQuerySource(Workspace)", + "\n .SliceRowsBy(\"VariableType\",\"GroupOfContract\")", + "\n .SliceColumnsBy(new[]{\"Currency\",\"Scenario\",\"EstimateType\"})", + "\n .ReportGridOptions(headerColumnWidth: 300).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Financial Performance" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Total Comprehensive Income : profitability", + "\nIn absence of the Other Comprehensive Income (OCI) this corresponds to the Profit and Loss as locked-in and current yield curves are the same. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var tci = financialPerformance.GetDataCube().Select(x => x.Scenario == null ? x with {Scenario = \"Best Estimate\"} : x);", + "\nvar hierarchicalDimension = Workspace.ToHierarchicalDimensionCache();", + "\nawait hierarchicalDimension.InitializeAsync(); ", + "\nvar pnl = tci.Where(x => hierarchicalDimension.Get().Ancestors(x.VariableType, includeSelf: true).Any(x => x.SystemName == \"PNL\"));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Report.ForDataCube(pnl.ToDataCube()).WithQuerySource(Workspace)", + "\n .SliceRowsBy(\"Scenario\")", + "\n .SliceColumnsBy(new[]{\"Currency\",\"GroupOfContract\"}) //\"GroupOfContract\"", + "\n .ReportGridOptions().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Insurance Revenue : business growth" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var insRev = tci.Where(x => hierarchicalDimension.Get().Ancestors(x.VariableType, includeSelf: true).Any(x => x.SystemName == \"IR\"));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Report.ForDataCube(insRev.ToDataCube()).WithQuerySource(Workspace)", + "\n .SliceRowsBy(\"Scenario\")", + "\n .SliceColumnsBy(new[]{\"Currency\",\"GroupOfContract\"})", + "\n .ReportGridOptions().ExecuteAsync() " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Experience Variance : business strategy", + "\nThis indicator represent how well the expected values match the actual. It is not a financial key performance indicator rather a modelling key performance indicator, indicating how well the company expectations are met by the actual figures." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "experienceAdjustments.DataFilter = null;", + "\nvar expAdj = experienceAdjustments.GetDataCube().Where(x => x.VariableType == \"CF\" && Math.Abs(x.Value) > 10E-5).Select(x => x.Scenario == null ? x with {Scenario = \"Best Estimate\"} : x);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Report.ForDataCube(expAdj.ToDataCube()).WithQuerySource(Workspace)", + "\n .SliceRowsBy(\"Scenario\")", + "\n .SliceColumnsBy(new[]{\"Currency\",\"GroupOfContract\"})", + "\n .ReportGridOptions().ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Scenarios.csv b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Scenarios.csv new file mode 100644 index 00000000..ad34991d --- /dev/null +++ b/ifrs17-template/PracticalUseCases/CompareReinsuranceContracts/Scenarios.csv @@ -0,0 +1,22 @@ +@@Scenario,,,,,,,,,,, +SystemName,DisplayName,,,,,,,,,, +LR70,Loss Ratio 70, +LR80,Loss Ratio 80, +ELR60A70,Expected Loss Ratio 60 Actual 70, +ELR60A80,Expected Loss Ratio 60 Actual 80, +YCUP1.0pct,Yield Curve Up 1.0pct,,,,,,,,,, +YCDW1.0pct,Yield Curve Down 1.0pct,,,,,,,,,, +SRUP1.0pct,Spread Rate Up 1.0pct,,,,,,,,,, +SRDW1.0pct,Spread Rate Down 1.0pct,,,,,,,,,, +EUP1.0pct,Equity Up 1.0pct,,,,,,,,,, +EDW1.0pct,Equity Down 1.0pct,,,,,,,,,, +FXUP1.0pct,Exchange Rate Up 1.0pct,,,,,,,,,, +FXDW1.0pct,Exchange Rate Down 1.0pct,,,,,,,,,, +MTUP10pct,Mortality Up 10pct,,,,,,,,,, +MTDW10pct,Mortality Down 10pct,,,,,,,,,, +LUP10pct,Longevity Up 10pct,,,,,,,,,, +LDW10pct,Longevity Down 10pct,,,,,,,,,, +DUP10pct,Disability Up 10pct,,,,,,,,,, +DDW10pct,Disability Down 10pct,,,,,,,,,, +LICUP10pct,Lic Up 10pct,,,,,,,,,, +LICDW10pct,Lic Down 10pct,,,,,,,,,, diff --git a/ifrs17-template/PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchDataImport.ipynb b/ifrs17-template/PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchDataImport.ipynb index a0d0556a..74524f7c 100644 --- a/ifrs17-template/PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchDataImport.ipynb +++ b/ifrs17-template/PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchDataImport.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "YGWMnwRniU64QZaE1oBrFw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -76,7 +77,7 @@ "await Import.FromFile(\"DataNodes_CsmSwitch_CH.csv\")", "\n .WithFormat(ImportFormats.DataNode)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -89,7 +90,7 @@ "await Import.FromFile(\"DataNodeStates_CsmSwitch_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.DataNodeState)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -102,7 +103,7 @@ "await Import.FromFile(\"DataNodeParameters_CsmSwitch_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.DataNodeParameter)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -133,7 +134,7 @@ "await Import.FromFile(\"NominalCashflows_CsmSwitch_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -146,7 +147,7 @@ "await Import.FromFile(\"Actuals_CsmSwitch_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -159,7 +160,7 @@ "await Import.FromFile(\"NominalCashflows_CsmSwitch_CH_2021_3.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -172,7 +173,7 @@ "await Import.FromFile(\"Actuals_CsmSwitch_CH_2021_3.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -194,7 +195,7 @@ "await Import.FromFile(\"SimpleValue_CsmSwitch_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.SimpleValue)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -207,7 +208,7 @@ "await Import.FromFile(\"SimpleValue_CsmSwitch_CH_2021_3.csv\")", "\n .WithFormat(ImportFormats.SimpleValue)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -217,7 +218,7 @@ { "cell_type": "markdown", "source": [ - "# Reset Workspace" + "# Initialize Workspace" ], "metadata": {}, "execution_count": 0, @@ -226,17 +227,8 @@ { "cell_type": "code", "source": [ - "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17.Reset(Workspace)" + "Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nWorkspace.InitializeFrom(DataSource);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchReports.ipynb b/ifrs17-template/PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchReports.ipynb index 2805affe..51ab27b4 100644 --- a/ifrs17-template/PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchReports.ipynb +++ b/ifrs17-template/PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchReports.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "fSGCg4loXUOYruTUQPiNXg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -95,6 +94,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "ifrs17 = new Ifrs17(Workspace, Scopes, Report, Export);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/README.md b/ifrs17-template/README.md index e6033e6a..34d33c99 100644 --- a/ifrs17-template/README.md +++ b/ifrs17-template/README.md @@ -63,7 +63,7 @@ For more information on our IFRS 17 initiative check out our [IFRS 17 page](http Interact with our IFRS 17 practical use cases. Analyze your data and create new use cases. -
+
@@ -78,6 +78,13 @@ Compare use-cases of [actuals](./PracticalUseCases/ActualsOutsideThePeriod/Actua Compare the effects of modelling the [CSM - LC switch](./PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchReports) with a single vs multiple switch logic. +
+
+ +### Scenario analysis for re-insured contracts + +Compare Net results under IFRS 17 obtained for different [loss ratio](./PracticalUseCases/CompareReinsuranceContracts/Reports). +
diff --git a/ifrs17-template/Report/InteractiveParameterReport.ipynb b/ifrs17-template/Report/InteractiveParameterReport.ipynb new file mode 100644 index 00000000..d0a57990 --- /dev/null +++ b/ifrs17-template/Report/InteractiveParameterReport.ipynb @@ -0,0 +1,106 @@ +{ + "metadata": { + "authors": [], + "id": "SB2KH3IeJ0ayzI-af7eReA", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "", + "\n

Interactive Parameter Reports

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This notebook is the interactive version of [Parameter Reports](./ParameterReports). For demonstration purposes we import here data for some *Group of Insurance Contract* (GIC) and *Group of Reinsurance Contract* (GRIC) - the import is triggered in the [Set up data and configuration](#set-up-data-and-configuration) section.", + "\n
The imported data set consists of cash flows, actuals, and parameters.", + "\n
Input files can be found in the **File** directory. You are invited to change them or upload your own or add new data in the [CloseImportTemplate](../Import/CloseImportTemplate) notebook. ", + "\n", + "\nIn this notebook we show the parameters (provided to the calculation engine as inputs) used to performe the calculation of the reports shown in [Reports](Reports) notebook.", + "\n", + "\nSelect from the dropdown which *Report Type* you are interested in and the report adjust to the desired selection. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Set up data and configuration", + "\n", + "\nChoose to run the Reports notebook either with the set of Systemorph data in memory or with the data present in the Database: ", + "\n- #!eval-notebook \"../Database/Configure\" : connects to a physical Database", + "\n- #!eval-notebook \"../Import/CloseImportTemplate\" : uses the in-memory set up", + "\n", + "\nWe use here the in-memory set up." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../Import/CloseImportTemplate\"", + "\nWorkspace.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parameterInteractive.Reset(Workspace);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive view" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parameterInteractive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parameterInteractive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/Accruals.ipynb b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb new file mode 100644 index 00000000..75dc7156 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "oKYWmrRFfU2e9YTd1Vj9iw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Accruals

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"Accruals\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb new file mode 100644 index 00000000..79e91b5d --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "YfxenPHy6ky0dq9nEONroA", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Contractual Service Margin / Loss Component / Loss Recovery Component

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"CsmLcLorecoReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb new file mode 100644 index 00000000..ca2df7be --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "T4bL4ggXtUu8qf7OrBY7lg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Deferrals

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"DeferralsReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb new file mode 100644 index 00000000..deb117cf --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "AXPivUdMuE-lUwK-q-qUPg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Experience Adjustment

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"ExpAdjReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb new file mode 100644 index 00000000..a9362ec3 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "AmrSZNq9YUqkLnbEjLUpkw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Financial Performance

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"FpReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb new file mode 100644 index 00000000..1d236eb3 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "SJ5ZNXF0EkSstU_pWIG2Kg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Fulfilment Cash flow

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"FcfReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/LIC.ipynb b/ifrs17-template/Report/InteractiveReports/LIC.ipynb new file mode 100644 index 00000000..47a75c64 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/LIC.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "qorXFtJ_gE2BGWjTnWDHAg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

LIC

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"LicReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/LRC.ipynb b/ifrs17-template/Report/InteractiveReports/LRC.ipynb new file mode 100644 index 00000000..8af13994 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/LRC.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "e-MbqoKGUEaq_uBz7npwPQ", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

LRC

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"LrcReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb new file mode 100644 index 00000000..51b14119 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "dVthm2DPB0qGOEC02sxPsA", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

LIC Actuarial

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"LicActualReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/LoadData.ipynb b/ifrs17-template/Report/InteractiveReports/LoadData.ipynb new file mode 100644 index 00000000..bd3666a6 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/LoadData.ipynb @@ -0,0 +1,65 @@ +{ + "metadata": { + "authors": [], + "id": "HX-3ABD14UaeXjlLLekeNw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Set up and configurations

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Choose to run the Report notebooks either with the set of Systemorph data in memory or with the data present in the Database:", + "\n", + "\n- #!eval-notebook \"../Database/Configure\" : connects to a physical Database", + "\n- #!eval-notebook \"../Import/CloseImportTemplate\" : uses the in-memory set up", + "\n", + "\nWe use here the in-memory set up.", + "\n", + "\nThe current notebook is used by all interactive reports and any change made here is going to affect all interactive reports.", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"../../Import/CloseImportTemplate\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb new file mode 100644 index 00000000..c265e2d7 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "6W4aDEXW4kGr7_GR8uVx6g", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

LRC Actuarial

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"LrcActualReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb new file mode 100644 index 00000000..121c4e1b --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "PTEWug2t60Cim-6iwrIVGg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Present Value of Best Estimate

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"PvReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb new file mode 100644 index 00000000..0d434716 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "BBEqtQSGT0CHl8YpJC18hw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Risk Adjustment

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"RiskAdjReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb new file mode 100644 index 00000000..f6457dcf --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "c9ui1BTJv0-wnUoEiBU1pw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Technical Margin

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"TmReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb new file mode 100644 index 00000000..2de89a90 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb @@ -0,0 +1,92 @@ +{ + "metadata": { + "authors": [], + "id": "WzfGMeugkEGQTanwpQJcTg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Written Actuarial

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"WrittenReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/ParameterReports.ipynb b/ifrs17-template/Report/ParameterReports.ipynb index 3e23a6bb..b46257ee 100644 --- a/ifrs17-template/Report/ParameterReports.ipynb +++ b/ifrs17-template/Report/ParameterReports.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "owrOOpusB0qEDMpG2Uj9hg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -101,7 +102,7 @@ "# Retrieve data ", "\n", "\nThe parameters used for calculation of the provided period are here retrieved through queries.", - "\nThe queries and the data model of the reported objects can be foud in the [ParameterReportQueries](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ParameterReportsQueries#queries)" + "\nThe queries and the data model of the reported objects can be foud in the [ParameterReportQueries](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ParameterReportsQueries#queries)" ], "metadata": {}, "execution_count": 0, @@ -183,7 +184,7 @@ "cell_type": "markdown", "source": [ "## Data node", - "\nProperties of the Group of Contracts and corresponding Portfolios are merged to provide a full description of the [Data Node](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructureDataStructure#data-node)" + "\nProperties of the Group of Contracts and corresponding Portfolios are merged to provide a full description of the [Data Node](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructureDataStructure#data-node)" ], "metadata": {}, "execution_count": 0, @@ -207,7 +208,7 @@ "source": [ "## Data node state", "\n", - "\nCurrent and previous period [data node state](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#data-node-state)." + "\nCurrent and previous period [data node state](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#data-node-state)." ], "metadata": {}, "execution_count": 0, @@ -232,7 +233,7 @@ "cell_type": "markdown", "source": [ "## Yield curve", - "\n[Yield Curve](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#yield-curve) used for locked-in discounting and current rating discouning (curret period and previous period) are shown." + "\n[Yield Curve](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#yield-curve) used for locked-in discounting and current rating discouning (curret period and previous period) are shown." ], "metadata": {}, "execution_count": 0, @@ -256,7 +257,7 @@ "cell_type": "markdown", "source": [ "## Single data node parameter", - "\n[Single data node parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#data-node-parameters) for current and previous period. " + "\n[Single data node parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#data-node-parameters) for current and previous period. " ], "metadata": {}, "execution_count": 0, @@ -280,7 +281,7 @@ "cell_type": "markdown", "source": [ "## Inter data node parameter", - "\n[Inter data node parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#data-node-parameters) for current and previous period. " + "\n[Inter data node parameters](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#data-node-parameters) for current and previous period. " ], "metadata": {}, "execution_count": 0, @@ -304,7 +305,7 @@ "cell_type": "markdown", "source": [ "## Partner ratings", - "\n[Partner ratings](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#partner-rating) for current and previous period." + "\n[Partner ratings](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#partner-rating) for current and previous period." ], "metadata": {}, "execution_count": 0, @@ -328,7 +329,7 @@ "cell_type": "markdown", "source": [ "## Partner default rates", - "\n[Partner default rates](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/DataModel/DataStructure#credit-default-rate) for current and previous period." + "\n[Partner default rates](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/DataModel/DataStructure#credit-default-rate) for current and previous period." ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/Reports.ipynb b/ifrs17-template/Report/Reports.ipynb index 3eaadc9e..1b9facff 100644 --- a/ifrs17-template/Report/Reports.ipynb +++ b/ifrs17-template/Report/Reports.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "DCgii_7-fECfGgqIf40f0w", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -80,7 +79,7 @@ "source": [ "# Best Estimate", "\n", - "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#best-estimate) future cash flows are shown here in an Analysis of Change report.", + "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#best-estimate) future cash flows are shown here in an Analysis of Change report.", "\n", "\nThe granularity of the reported figures can be modified by changing the Column Slices options.", "\nFor example one can add \"GroupOfContract\" to separate the contributions of the individual Group of Contracts.", @@ -100,7 +99,7 @@ "\npv.CurrencyType = CurrencyType.Contractual;", "\npv.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", "\npv.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.2\"),(\"LiabilityType\", \"LIC\") };", - "\n(await pv.ToReportAsync) with {Height = 720}" + "\n(await pv.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -111,7 +110,7 @@ "source": [ "# Risk Adjustment", "\n", - "\nPresent values of the [risk adjustment](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#risk-adjustment) future cash flows are shown here.", + "\nPresent values of the [risk adjustment](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#risk-adjustment) future cash flows are shown here.", "\n", "\nThe additional ColumnSlices are added to the view as the inner column. This can dicrease the readability of the report. For example, adding the slice by \"GroupOfContract\" leaves the lock-in and current rate contributions far apart and difficult to compare. The re-order of default slices with custom slices is achieved by esplicitly add the default slice among the custom slices. In our case, you can try entering both \"GroupOfContract\" and \"EconomicBasis\" separated by a comma in the ColumnSlices." ], @@ -127,7 +126,7 @@ "\nra.ReportingPeriod = (2021, 3);", "\nra.ColumnSlices = new string[]{};//\"GroupOfContract\", \"EconomicBasis\"", "\nra.DataFilter = null;//new [] {(\"GroupOfContract\", \"DT1.2\")};", - "\n(await ra.ToReportAsync) with {Height = 800}" + "\n(await ra.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -138,7 +137,7 @@ "source": [ "# Written Actuals", "\n", - "\n[Written Actuals](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#written-accrual-deferral) are shown here. ", + "\n[Written Actuals](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#written-accrual-deferral) are shown here. ", "\n", "\nIn this case, the analysis of change view is replaced with a default slice by the **AmountTypes**. Only the amount type with non zero value are displayed. ", "\n
Filters can be applied to reports in order to isolate a sub-set of the data. They are specified by the name of the dimension to filter and the system name of the desired value. For example, to investigate the contribution of a single Group of Contract the following filter can be applied: new [] {(\"GroupOfContract\", \"DT1.1\")}." @@ -155,7 +154,7 @@ "\nwrittenActual.ReportingPeriod = (2021, 3);", "\nwrittenActual.ColumnSlices = new string[]{};//\"GroupOfContract\"", "\nwrittenActual.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await writtenActual.ToReportAsync) with {Height = 400}" + "\n(await writtenActual.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -166,8 +165,8 @@ "source": [ "## Advance, Overdue Actuals", "\n", - "\nActuals payed in [Advance](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#written-accrual-deferral)", - "\nor [Overdue](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#written-accrual-deferral) are shown here together in a simplified Analysis of Change. ", + "\nActuals payed in [Advance](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#written-accrual-deferral)", + "\nor [Overdue](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#written-accrual-deferral) are shown here together in a simplified Analysis of Change. ", "\n", "\nCombining Filters and ColumnSlices facilitate the report analysis. For example, you can select \"GroupOfContract\" as column slices with a Filter on EstimateType \"AA\" to analyse the Advance Actuals for all Group of Contract. " ], @@ -183,7 +182,7 @@ "\naccrualActual.ReportingPeriod = (2021, 3);", "\naccrualActual.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", "\naccrualActual.DataFilter = null; //new [] {(\"EstimateType\", \"AA\")};", - "\n(await accrualActual.ToReportAsync) with {Height = 400}" + "\n(await accrualActual.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -194,7 +193,7 @@ "source": [ "## Deferrable Actuals", "\n", - "\n[Deferrable Actuals](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#written-accrual-deferral) are shown here. Amortization of the deferrable amount is computed using the Coverage Unit pattern. " + "\n[Deferrable Actuals](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#written-accrual-deferral) are shown here. Amortization of the deferrable amount is computed using the Coverage Unit pattern. " ], "metadata": {}, "execution_count": 0, @@ -208,7 +207,7 @@ "\ndeferrableActual.ReportingPeriod = (2021, 3);", "\ndeferrableActual.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", "\ndeferrableActual.DataFilter = null;//new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await deferrableActual.ToReportAsync) with {Height = 400}" + "\n(await deferrableActual.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -219,7 +218,7 @@ "source": [ "# Fulfilment Cash flow", "\n", - "\nPresent Value of the [Fulfilment Cash flow](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#fulfillment-cash-flows) are shown here. ", + "\nPresent Value of the [Fulfilment Cash flow](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#fulfillment-cash-flows) are shown here. ", "\n
The individual contributions from Best Estimate and Risk Adjustment can be visualized slicing by **EstimateType**.", "\n", "\nFilters can be applied to report to isolate a sub-set of the data. For example you can Filter by a specific Group of Contract using its system name using : new [] {(\"GroupOfContract\", \"DT1.1\")}.", @@ -237,7 +236,7 @@ "\nfulfillmentCashflows.ReportingPeriod = (2021, 3);", "\nfulfillmentCashflows.ColumnSlices = new string[]{};//\"EstimateType\"", "\nfulfillmentCashflows.DataFilter = null;// new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await fulfillmentCashflows.ToReportAsync) with {Height = 750}" + "\n(await fulfillmentCashflows.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -248,7 +247,7 @@ "source": [ "# Actuarial Experience Adjustment", "\n", - "\nA comparison between [Written Actual](#written-actual) and the Releases of the [Best Estimate](#present-value) is reported in the [Actuarial Experience Adjustment](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#experience-adjustment)." + "\nA comparison between [Written Actual](#written-actual) and the Releases of the [Best Estimate](#present-value) is reported in the [Actuarial Experience Adjustment](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#experience-adjustment)." ], "metadata": {}, "execution_count": 0, @@ -262,7 +261,7 @@ "\nexperienceAdjustments.ReportingPeriod = (2021, 3);", "\nexperienceAdjustments.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", "\nexperienceAdjustments.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await experienceAdjustments.ToReportAsync) with {Height = 300}" + "\n(await experienceAdjustments.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -273,7 +272,7 @@ "source": [ "# LRC Technical Margin", "\n", - "\nIn the [Technical Margin](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#technical-margin) report we present a unified view on the figures that are allocated to either Contractual Service Margin or to Loss Component. ", + "\nIn the [Technical Margin](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#technical-margin) report we present a unified view on the figures that are allocated to either Contractual Service Margin or to Loss Component. ", "\n
The Analysis of Change is expanded with few more steps such as **Experience Adjustment** and **Amortization**." ], "metadata": {}, @@ -288,7 +287,7 @@ "\ntechnicalMargins.ReportingPeriod = (2021, 3);", "\ntechnicalMargins.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", "\ntechnicalMargins.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await technicalMargins.ToReportAsync) with {Height = 600}" + "\n(await technicalMargins.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -299,7 +298,7 @@ "source": [ "# Contractual Service Margin / Loss Component / Loss Recovery Component", "\n", - "\nThe Contractual Service Margin (CSM) / Loss Component (LC) / Loss Recovery Component (LR) [report](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#technical-margin) are here shown side by side as the allocation to profit or loss is done at each step of the Analysis of Change. ", + "\nThe Contractual Service Margin (CSM) / Loss Component (LC) / Loss Recovery Component (LR) [report](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#technical-margin) are here shown side by side as the allocation to profit or loss is done at each step of the Analysis of Change. ", "\n", "\nA default slice by EstimateType - which distinguish between CSM, LC and LR contributions - is automatically enforced. " ], @@ -315,7 +314,7 @@ "\nallocatedTechnicalMargins.ReportingPeriod = (2021, 3);", "\nallocatedTechnicalMargins.ColumnSlices = new string[]{};//\"GroupOfContract\", \"EstimateType\"", "\nallocatedTechnicalMargins.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await allocatedTechnicalMargins.ToReportAsync) with {Height = 700}" + "\n(await allocatedTechnicalMargins.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -326,7 +325,7 @@ "source": [ "# LRC Actuarial", "\n", - "\nThe [Actuarial Liability for Remaining Coverage](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#lrc-actuarial-actuarial-liability-for-remaining-coverage) report shows figures from Fulfilment Cash flow discounted with current yield curve, and the allocated techinical margin. " + "\nThe [Actuarial Liability for Remaining Coverage](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#lrc-actuarial-actuarial-liability-for-remaining-coverage) report shows figures from Fulfilment Cash flow discounted with current yield curve, and the allocated techinical margin. " ], "metadata": {}, "execution_count": 0, @@ -340,7 +339,7 @@ "\nactuarialLrc.ReportingPeriod = (2021, 3);", "\nactuarialLrc.ColumnSlices = new string[]{};//\"GroupOfContract\"", "\nactuarialLrc.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await actuarialLrc.ToReportAsync) with {Height = 750}" + "\n(await actuarialLrc.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -351,7 +350,7 @@ "source": [ "# LRC", "\n", - "\nThe [Liability for Remaining Coverage](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#lrc-liability-for-remaining-coverage) report adds to the [Actuarial Liability for Remaining Coverage](#lrc-actuarial) the contribution of and accrual actuals. A simplified AoC Chain is used to allow comparison of the balance change between Actuals and Present Values. " + "\nThe [Liability for Remaining Coverage](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#lrc-liability-for-remaining-coverage) report adds to the [Actuarial Liability for Remaining Coverage](#lrc-actuarial) the contribution of and accrual actuals. A simplified AoC Chain is used to allow comparison of the balance change between Actuals and Present Values. " ], "metadata": {}, "execution_count": 0, @@ -365,7 +364,7 @@ "\nlrc.ReportingPeriod = (2021, 3);", "\nlrc.ColumnSlices = new string[]{};//\"GroupOfContract\",", "\nlrc.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await lrc.ToReportAsync) with {Height = 250}" + "\n(await lrc.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -376,7 +375,7 @@ "source": [ "# LIC Actuarial", "\n", - "\nThe [Actuarial Liability of Incurred Claims](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#lic-actuarial-actuarial-liability-for-incurred-claims) report shows figures from Fulfilment Cash flow discounted with current yield curve. " + "\nThe [Actuarial Liability of Incurred Claims](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#lic-actuarial-actuarial-liability-for-incurred-claims) report shows figures from Fulfilment Cash flow discounted with current yield curve. " ], "metadata": {}, "execution_count": 0, @@ -390,7 +389,7 @@ "\nactuarialLic.ReportingPeriod = (2021, 3);", "\nactuarialLic.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", "\nactuarialLic.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await actuarialLic.ToReportAsync) with {Height = 750}" + "\n(await actuarialLic.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -401,7 +400,7 @@ "source": [ "# LIC", "\n", - "\nThe [Liability for Incurred Claims](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#lic-liability-for-incurred-claims) adds to the [Actuarial Liability for Incurred Claims](#lic-actuarial) the contribution of and accrual actuals." + "\nThe [Liability for Incurred Claims](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#lic-liability-for-incurred-claims) adds to the [Actuarial Liability for Incurred Claims](#lic-actuarial) the contribution of and accrual actuals." ], "metadata": {}, "execution_count": 0, @@ -415,7 +414,7 @@ "\nlic.ReportingPeriod = (2021, 3);", "\nlic.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", "\nlic.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await lic.ToReportAsync) with {Height = 250}" + "\n(await lic.ToReportAsync)" ], "metadata": {}, "execution_count": 0, @@ -426,7 +425,7 @@ "source": [ "# Financial Performance", "\n", - "\nThe [Financial Performance](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.1/Report/ReportScopes#ifrs-17-financial-performance) report discloses the Change in Estimate of the IFRS 17 balance sheet items ([LRC](#lrc) and [LIC](#lic)) and the relevant incurred cash flows (Premiums, Claims, Expenses, etc...) for the given period.", + "\nThe [Financial Performance](https://portal.systemorph.cloud/project/ifrs17/env/v1.2.0/Report/ReportScopes#ifrs-17-financial-performance) report discloses the Change in Estimate of the IFRS 17 balance sheet items ([LRC](#lrc) and [LIC](#lic)) and the relevant incurred cash flows (Premiums, Claims, Expenses, etc...) for the given period.", "\n", "\nUse the expand and collapse buttons in the report rows to change the granularity of the figures displayed." ], @@ -442,7 +441,7 @@ "\nfinancialPerformance.ReportingPeriod = (2021, 3);", "\nfinancialPerformance.ColumnSlices = new string[]{};//\"GroupOfContract\"", "\nfinancialPerformance.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", - "\n(await financialPerformance.ToReportAsync) with { Height = 900, GroupDefaultExpanded = 3}" + "\n(await financialPerformance.ToReportAsync) with {GroupDefaultExpanded = 3}" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/Data/ExportIfrsVariable.ipynb b/ifrs17-template/Test/Data/ExportIfrsVariable.ipynb index f855a567..024579cd 100644 --- a/ifrs17-template/Test/Data/ExportIfrsVariable.ipynb +++ b/ifrs17-template/Test/Data/ExportIfrsVariable.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "zqa5Gis-qkCUXLkhzzM-LA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -47,8 +46,8 @@ { "cell_type": "code", "source": [ - "//#!eval-notebook \"InitSystemorphToMemoryForTesting\"", - "\n#!eval-notebook \"../../PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchDataImport\"" + "#!eval-notebook \"InitSystemorphToMemoryForTesting\"", + "\n//#!eval-notebook \"../../PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchDataImport\"" ], "metadata": {}, "execution_count": 0, @@ -104,7 +103,8 @@ "source": [ "var exportScope = new ImportArgs[]{", "\n new ImportArgs (\"CH\", 2020, 12, (Periodicity)default, null, null),", - "\n new ImportArgs (\"CH\", 2021, 3, (Periodicity)default, null, null)", + "\n new ImportArgs (\"CH\", 2021, 3, (Periodicity)default, null, null),", + "\n new ImportArgs (\"CH\", 2020, 12, (Periodicity)default, \"MTUP10pct\", null)", "\n };" ], "metadata": {}, @@ -123,7 +123,7 @@ { "cell_type": "code", "source": [ - "var args = exportScope[0];", + "var args = exportScope[2];", "\nargs" ], "metadata": {}, @@ -216,7 +216,7 @@ { "cell_type": "code", "source": [ - "var estimateType = \"BE\";" + "var estimateType = \"RA\";" ], "metadata": {}, "execution_count": 0, @@ -245,6 +245,15 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17-template/Test/Data/ExportReportVariables.ipynb b/ifrs17-template/Test/Data/ExportReportVariables.ipynb index bf06f205..b02953c4 100644 --- a/ifrs17-template/Test/Data/ExportReportVariables.ipynb +++ b/ifrs17-template/Test/Data/ExportReportVariables.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "mQuQKO3zWUmlFaU6pRflbA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -144,8 +143,7 @@ "\n ((2020, 12), \"CH\", null, CurrencyType.Group), ", "\n ((2021, 3), \"CH\", null, CurrencyType.Contractual),", "\n ((2021, 3), \"CH\", null, CurrencyType.Functional),", - "\n ((2021, 3), \"CH\", null, CurrencyType.Group),", - "\n ((2020, 12), \"CH\", nameof(Scenarios.MTUP10pct), CurrencyType.Contractual)", + "\n ((2021, 3), \"CH\", null, CurrencyType.Group)", "\n};" ], "metadata": {}, diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv index b950aba6..016b5edf 100644 --- a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_A.csv @@ -4,21 +4,9 @@ Month,ReportingNode,Scenario,Year @@A AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value ,NIC,CF,DT1.1,,A,C,-310 -,PR,CF,DT1.1,,A,C,400 -,ACA,CF,DT1.1,,A,C,-10 -,AEA,CF,DT1.1,,A,C,-5 2020,NIC,CF,DT1.2,,A,C,-310 -,NIC,CF,DT2.1,,A,C,-310 -,PR,CF,DT2.1,,A,C,400 -,ACA,CF,DT2.1,,A,C,-10 -,AEA,CF,DT2.1,,A,C,-5 ,NIC,CF,DT1.3,,A,C,-310 -,PR,CF,DT1.3,,A,C,400 -,ACA,CF,DT1.3,,A,C,-10 -,AEA,CF,DT1.3,,A,C,-5 +,NIC,CF,DT2.1,,A,C,-310 2020,NIC,CF,DT2.2,,A,C,-310 ,NIC,CF,DTR1.1,,A,C,170 -,PR,CF,DTR1.1,,A,C,-200 -2020,NIC,CF,DTR1.2,,A,C,170 -,PR,CF,DTR2.1,,A,C,-200 -,NIC,CF,DTR2.1,,A,C,140 \ No newline at end of file +2020,NIC,CF,DTR1.2,,A,C,170 \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_AA.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_AA.csv new file mode 100644 index 00000000..da193d4d --- /dev/null +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_AA.csv @@ -0,0 +1,5 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@AA +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_APA.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_APA.csv index 98071041..fcfb044a 100644 --- a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_APA.csv +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_APA.csv @@ -2,7 +2,4 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@APA -AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,PR,CF,DT1.1,,APA,C,320 -,PR,CF,DT2.1,,APA,C,320 -,PR,CF,DT1.3,,APA,C,400 \ No newline at end of file +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BE.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BE.csv index 97f1efee..c40053de 100644 --- a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BE.csv +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BE.csv @@ -3,67 +3,60 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@BE AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,NIC,BOP,DT1.1,L,BE,N,658.62824 -,PR,BOP,DT1.1,L,BE,N,-798.53673 -,NIC,BOP,DT1.1,C,BE,N,658.62824 -,PR,BOP,DT1.1,C,BE,N,-798.53673 -,NIC,EOP,DT1.1,L,BE,C,329.6431 -,PR,EOP,DT1.1,L,BE,C,-399.63393 ,NIC,EOP,DT1.1,C,BE,C,329.6431 -,PR,EOP,DT1.1,C,BE,C,-399.63393 -,NIC,IA,DT1.1,L,BE,N,1.01487 -,PR,IA,DT1.1,L,BE,N,-1.0972 +,NIC,BOP,DT1.1,C,BE,N,658.62824 +,NIC,CF,DT1.1,C,BE,N,-330 ,NIC,IA,DT1.1,C,BE,N,1.01487 -,PR,IA,DT1.1,C,BE,N,-1.0972 +,NIC,EOP,DT1.1,L,BE,C,329.6431 +,NIC,BOP,DT1.1,L,BE,N,658.62824 ,NIC,CF,DT1.1,L,BE,N,-330 -,PR,CF,DT1.1,L,BE,N,400 -,NIC,CF,DT1.1,C,BE,N,-330 -,PR,CF,DT1.1,C,BE,N,400 -2020,NIC,BOP,DT1.2,L,BE,N,658.62824 -2020,NIC,BOP,DT1.2,C,BE,N,658.62824 -2020,NIC,EOP,DT1.2,L,BE,C,329.6431 +,NIC,IA,DT1.1,L,BE,N,1.01487 2020,NIC,EOP,DT1.2,C,BE,C,329.6431 -2020,NIC,IA,DT1.2,L,BE,N,1.01487 +2020,NIC,BOP,DT1.2,C,BE,N,658.62824 +2020,NIC,CF,DT1.2,C,BE,N,-330 2020,NIC,IA,DT1.2,C,BE,N,1.01487 +2020,NIC,EOP,DT1.2,L,BE,C,329.6431 +2020,NIC,BOP,DT1.2,L,BE,N,658.62824 2020,NIC,CF,DT1.2,L,BE,N,-330 -2020,NIC,CF,DT1.2,C,BE,N,-330 -,NIC,BOP,DTR1.1,L,BE,N,-329.31412 -,PR,BOP,DTR1.1,L,BE,N,399.26837 -,CDR,BOP,DTR1.1,L,BE,N,0.52925 -,NIC,BOP,DTR1.1,C,BE,N,-329.31412 -,PR,BOP,DTR1.1,C,BE,N,399.26837 +2020,NIC,IA,DT1.2,L,BE,N,1.01487 +,CDR,EOP,DTR1.1,C,BE,C,0.1268 ,CDR,BOP,DTR1.1,C,BE,N,0.52925 -,NIC,EOP,DTR1.1,L,BE,C,-164.82155 -,PR,EOP,DTR1.1,L,BE,C,199.81696 -,CDR,EOP,DTR1.1,L,BE,C,0.1268 +,CDR,CF,DTR1.1,C,BE,N,-0.40374 +,CDR,IA,DTR1.1,C,BE,N,0.00129 ,NIC,EOP,DTR1.1,C,BE,C,-164.82155 -,PR,EOP,DTR1.1,C,BE,C,199.81696 -,CDR,EOP,DTR1.1,C,BE,C,0.1268 -,NIC,IA,DTR1.1,L,BE,N,-0.50743 -,PR,IA,DTR1.1,L,BE,N,0.5486 -,CDR,IA,DTR1.1,L,BE,N,0.00129 +,NIC,BOP,DTR1.1,C,BE,N,-329.31412 +,NIC,CF,DTR1.1,C,BE,N,165 ,NIC,IA,DTR1.1,C,BE,N,-0.50743 -,PR,IA,DTR1.1,C,BE,N,0.5486 -,CDR,IA,DTR1.1,C,BE,N,0.00129 -,NIC,CF,DTR1.1,L,BE,N,165 -,PR,CF,DTR1.1,L,BE,N,-200 +,CDR,EOP,DTR1.1,L,BE,C,0.1268 +,CDR,BOP,DTR1.1,L,BE,N,0.52925 ,CDR,CF,DTR1.1,L,BE,N,-0.40374 -,NIC,CF,DTR1.1,C,BE,N,165 -,PR,CF,DTR1.1,C,BE,N,-200 -,CDR,CF,DTR1.1,C,BE,N,-0.40374 -2020,NIC,BOP,DTR1.2,L,BE,N,-329.31412 -2020,CDR,BOP,DTR1.2,L,BE,N,0.52925 -2020,NIC,BOP,DTR1.2,C,BE,N,-329.31412 +,CDR,IA,DTR1.1,L,BE,N,0.00129 +,NIC,EOP,DTR1.1,L,BE,C,-164.82155 +,NIC,BOP,DTR1.1,L,BE,N,-329.31412 +,NIC,CF,DTR1.1,L,BE,N,165 +,NIC,IA,DTR1.1,L,BE,N,-0.50743 +2020,CDR,EOP,DTR1.2,C,BE,C,0.1268 2020,CDR,BOP,DTR1.2,C,BE,N,0.52925 -2020,NIC,EOP,DTR1.2,L,BE,C,-164.82155 -2020,CDR,EOP,DTR1.2,L,BE,C,0.1268 +2020,CDR,CF,DTR1.2,C,BE,N,-0.40374 +2020,CDR,IA,DTR1.2,C,BE,N,0.00129 2020,NIC,EOP,DTR1.2,C,BE,C,-164.82155 -2020,CDR,EOP,DTR1.2,C,BE,C,0.1268 -2020,NIC,IA,DTR1.2,L,BE,N,-0.50743 -2020,CDR,IA,DTR1.2,L,BE,N,0.00129 +2020,NIC,BOP,DTR1.2,C,BE,N,-329.31412 +2020,NIC,CF,DTR1.2,C,BE,N,165 2020,NIC,IA,DTR1.2,C,BE,N,-0.50743 -2020,CDR,IA,DTR1.2,C,BE,N,0.00129 -2020,NIC,CF,DTR1.2,L,BE,N,165 +2020,CDR,EOP,DTR1.2,L,BE,C,0.1268 +2020,CDR,BOP,DTR1.2,L,BE,N,0.52925 2020,CDR,CF,DTR1.2,L,BE,N,-0.40374 -2020,NIC,CF,DTR1.2,C,BE,N,165 -2020,CDR,CF,DTR1.2,C,BE,N,-0.40374 \ No newline at end of file +2020,CDR,IA,DTR1.2,L,BE,N,0.00129 +2020,NIC,EOP,DTR1.2,L,BE,C,-164.82155 +2020,NIC,BOP,DTR1.2,L,BE,N,-329.31412 +2020,NIC,CF,DTR1.2,L,BE,N,165 +2020,NIC,IA,DTR1.2,L,BE,N,-0.50743,N,165 +2020,NIC,IA,DTR1.2,C,BE,N,-0.5074328025652143 +2020,CDR,EOP,DTR1.2,L,BE,C,0.12679876434718015 +2020,CDR,BOP,DTR1.2,L,BE,N,0.5292475300191577 +2020,CDR,CF,DTR1.2,L,BE,N,-0.40373597582193455 +2020,CDR,IA,DTR1.2,L,BE,N,0.001287210150087148 +2020,NIC,EOP,DTR1.2,L,BE,C,-164.8215523318298 +2020,NIC,BOP,DTR1.2,L,BE,N,-329.3141195292647 +2020,NIC,CF,DTR1.2,L,BE,N,165 +2020,NIC,IA,DTR1.2,L,BE,N,-0.5074328025652143 \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BEPA.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BEPA.csv index 4674e6db..afd6e7c6 100644 --- a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BEPA.csv +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_BEPA.csv @@ -2,5 +2,4 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@BEPA -AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,PR,CF,DT1.1,L,BEPA,N,320 \ No newline at end of file +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv index dcfc1f10..b9f6ed7f 100644 --- a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_C.csv @@ -3,26 +3,13 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@C AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,,BOP,DT1.1,,C,N,80.0332 -,,EOP,DT1.1,,C,C,22.35306 ,,AM,DT1.1,,C,C,-42.67021 -,,EA,DT1.1,,C,C,-15 +,,EOP,DT1.1,,C,C,22.35306 +,,BOP,DT1.1,,C,N,80.0332 ,,IA,DT1.1,,C,N,-0.00993 -,,EA,DT2.1,,C,C,-15 -,,AM,DT2.1,,C,C,-82.02271 -,,EOP,DT2.1,,C,C,42.96811 -,,BOP,DT2.1,,C,N,139.90849 -,,IA,DT2.1,,C,N,0.08233 -,,EA,DT1.3,,C,C,-15 -,,AM,DT1.3,,C,C,-82.02271 -,,EOP,DT1.3,,C,C,42.96811 -,,BOP,DT1.3,,C,N,139.90849 -,,IA,DT1.3,,C,N,0.08233 ,,AM,DTR1.1,,C,C,26.60498 ,,EOP,DTR1.1,,C,C,-13.93719 ,,BOP,DTR1.1,,C,N,-40.54585 -,,IA,DTR1.1,,C,N,0.00368 -,,AM,DTR2.1,,C,C,46.24958 -,,EOP,DTR2.1,,C,C,-24.22813 -,,BOP,DTR2.1,,C,N,-70.43538 -,,IA,DTR2.1,,C,N,-0.04234 \ No newline at end of file +,,IA,DTR1.1,,C,N,0.0036888043 +,,BOP,DTR1.1,,C,N,-40.545846351508814 +,,IA,DTR1.1,,C,N,0.003676678453477744 \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_DA.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_DA.csv index 4ad94e50..60cc80c2 100644 --- a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_DA.csv +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_DA.csv @@ -2,13 +2,4 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@DA -AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,,EOP,DT1.1,,DA,C,-5.15655 -,,AM,DT1.1,,DA,C,9.84345 -,,CF,DT1.1,,DA,C,-15 -,,CF,DT2.1,,DA,C,-15 -,,AM,DT2.1,,DA,C,9.84345 -,,EOP,DT2.1,,DA,C,-5.15655 -,,CF,DT1.3,,DA,C,-15 -,,AM,DT1.3,,DA,C,9.84345 -,,EOP,DT1.3,,DA,C,-5.15655 \ No newline at end of file +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_F.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_F.csv index 20a47c21..ffe034ac 100644 --- a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_F.csv +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_F.csv @@ -2,8 +2,4 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@F -AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,,AM,DT1.1,L,F,C,0.65623 -,,AM,DT1.2,L,F,C,1 -,,AM,DTR1.1,L,F,C,0.65623 -,,AM,DTR1.2,L,F,C,1 \ No newline at end of file +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_OA.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_OA.csv new file mode 100644 index 00000000..6ebb2b89 --- /dev/null +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_OA.csv @@ -0,0 +1,5 @@ +@@Main +Month,ReportingNode,Scenario,Year +12,CH,MTUP10pct,2020 +@@OA +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value \ No newline at end of file diff --git a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_RA.csv b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_RA.csv index 9b1cb78e..cf55d925 100644 --- a/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_RA.csv +++ b/ifrs17-template/Test/Data/IfrsVariableBenchmarks/BM_CH_2020_12_MTUP10pct_RA.csv @@ -2,36 +2,4 @@ Month,ReportingNode,Scenario,Year 12,CH,MTUP10pct,2020 @@RA -AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value -,,BOP,DT1.1,C,RA,N,59.87529 -,,BOP,DT1.1,L,RA,N,59.87529 -,,EOP,DT1.1,C,RA,C,29.96755 -,,EOP,DT1.1,L,RA,C,29.96755 -,,IA,DT1.1,C,RA,N,0.09226 -,,IA,DT1.1,L,RA,N,0.09226 -,,CF,DT1.1,C,RA,N,-30 -,,CF,DT1.1,L,RA,N,-30 -2020,,BOP,DT1.2,C,RA,N,59.87529 -2020,,BOP,DT1.2,L,RA,N,59.87529 -2020,,EOP,DT1.2,C,RA,C,29.96755 -2020,,EOP,DT1.2,L,RA,C,29.96755 -2020,,IA,DT1.2,C,RA,N,0.09226 -2020,,IA,DT1.2,L,RA,N,0.09226 -2020,,CF,DT1.2,C,RA,N,-30 -2020,,CF,DT1.2,L,RA,N,-30 -,,BOP,DTR1.1,C,RA,N,-29.93765 -,,BOP,DTR1.1,L,RA,N,-29.93765 -,,EOP,DTR1.1,C,RA,C,-14.98378 -,,EOP,DTR1.1,L,RA,C,-14.98378 -,,IA,DTR1.1,C,RA,N,-0.04613 -,,IA,DTR1.1,L,RA,N,-0.04613 -,,CF,DTR1.1,C,RA,N,15 -,,CF,DTR1.1,L,RA,N,15 -2020,,BOP,DTR1.2,C,RA,N,-29.93765 -2020,,BOP,DTR1.2,L,RA,N,-29.93765 -2020,,EOP,DTR1.2,C,RA,C,-14.98378 -2020,,EOP,DTR1.2,L,RA,C,-14.98378 -2020,,IA,DTR1.2,C,RA,N,-0.04613 -2020,,IA,DTR1.2,L,RA,N,-0.04613 -2020,,CF,DTR1.2,C,RA,N,15 -2020,,CF,DTR1.2,L,RA,N,15 \ No newline at end of file +AccidentYear,AmountType,AocType,DataNode,EconomicBasis,EstimateType,Novelty,Value \ No newline at end of file diff --git a/ifrs17-template/Test/Data/InitSystemorphToMemoryForTesting.ipynb b/ifrs17-template/Test/Data/InitSystemorphToMemoryForTesting.ipynb index 36b1ed2a..44c43288 100644 --- a/ifrs17-template/Test/Data/InitSystemorphToMemoryForTesting.ipynb +++ b/ifrs17-template/Test/Data/InitSystemorphToMemoryForTesting.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "bSinnaybPkGIZ8Km0b0H0Q", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "code", @@ -30,7 +31,7 @@ "await Import.FromFile(\"Actuals_CH_2020_12_MTUP10pct.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Test/IfrsVariablesTest.ipynb b/ifrs17-template/Test/IfrsVariablesTest.ipynb index 860c13ee..851ae200 100644 --- a/ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "L-jO5zRc-0WHi8WTFkhcWQ", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -272,7 +271,7 @@ "\n //Get the computed Data", "\n var computedVariables = computedVariablesByEstimateType.TryGetValue(bmTableName, out var ret) ? ret : Enumerable.Empty();", "\n", - "\n if(!computedVariables.Any())", + "\n if(!computedVariables.Any() && bmVariables.Any())", "\n errorList.Add(new BenchmarkTestResult(\"No variables are computed for EstimateType: \" + bmTableName, 0, 0));", "\n //CompareAgainstBm", "\n if (bmVariables.Any() && computedVariables.Any()) //TODO we are adding duplicates here", @@ -292,6 +291,15 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb index 39134932..99938caa 100644 --- a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "P6NgZqj6e0-iv6Td2_aRaQ", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -166,7 +165,7 @@ "\n .GroupofContractConfiguration(typeof(ReinsurancePortfolio))", "\n .GroupofContractConfiguration(typeof(InsurancePortfolio))", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -185,7 +184,7 @@ "\n .GroupofContractConfiguration(typeof(ReinsurancePortfolio))", "\n .GroupofContractConfiguration(typeof(InsurancePortfolio))", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -267,7 +266,7 @@ "\n .StateEnumConfiguration() ", "\n .DataNodeStateConfiguration(dataNodeStates)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -284,7 +283,7 @@ "\n .StateEnumConfiguration() ", "\n .DataNodeStateConfiguration(dataNodeStates)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -361,7 +360,7 @@ "\n .WithSource(Workspace)", "\n .DataNodeParameterConfiguration(dataNodeParameters)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -377,7 +376,7 @@ "\n .WithSource(Workspace)", "\n .DataNodeParameterConfiguration(dataNodeParameters)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -543,11 +542,10 @@ { "cell_type": "code", "source": [ - "public async Task CheckErrors(string inputFileName, List errorBms)", + "public async Task CheckErrors(string inputFileName, List errorBms, IWorkspace workspace)", "\n{", "\n Activity.Start();", - "\n var log = await Import.FromFile(inputFileName).WithFormat(ImportFormats.DataNodeParameter).WithTarget(Workspace).ExecuteAsync();", - "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\n var log = await Import.FromFile(inputFileName).WithFormat(ImportFormats.DataNodeParameter).WithTarget(workspace).ExecuteAsync();", "\n errorBms.Intersect(log.Errors.Select(x => x.ToString().Substring(0,x.ToString().Length-2).Substring(40)).ToArray()).Count().Should().Be(errorBms.Count());", "\n return Activity.Finish();", "\n}" @@ -556,6 +554,16 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var ws1 = Workspace.CreateNew();", + "\nws1.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -563,32 +571,52 @@ "\nvar errorsBm = new List(){Get(Error.InvalidDataNode, \"DataNodeInvalid0\"),", "\n Get(Error.InvalidDataNode, \"DataNodeInvalid1\"),", "\n Get(Error.InvalidDataNode, \"DataNodeInvalid2\")};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws1);", "\nactivity" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var ws2 = Workspace.CreateNew();", + "\nws2.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ "var inputFileName = \"Data/DataNodeParameter_Duplicate.csv\";", "\nvar errorsBm = new List(){Get(Error.DuplicateSingleDataNode, \"DT1.1\"),", "\n Get(Error.DuplicateInterDataNode, \"DT1.1\",\"DTR1.1\"),};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws2);", "\nactivity" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var ws3 = Workspace.CreateNew();", + "\nws3.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ "var inputFileName = \"Data/DataNodeParameter_InvalidReinsCov.csv\";", "\nvar errorsBm = new List(){Get(Error.ReinsuranceCoverageDataNode, \"DT1.1\",\"DT1.1\")};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws3);", "\nactivity" ], "metadata": {}, diff --git a/ifrs17-template/Test/PracticalCasesTest.ipynb b/ifrs17-template/Test/PracticalCase-CSMSwitchTest.ipynb similarity index 98% rename from ifrs17-template/Test/PracticalCasesTest.ipynb rename to ifrs17-template/Test/PracticalCase-CSMSwitchTest.ipynb index 52e24619..7b64a176 100644 --- a/ifrs17-template/Test/PracticalCasesTest.ipynb +++ b/ifrs17-template/Test/PracticalCase-CSMSwitchTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "bZ9mwrWya0Ox8CXAyFRn2Q", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -36,7 +37,7 @@ { "cell_type": "code", "source": [ - "#!import \"../PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchReports\"" + "#!eval-notebook \"../PracticalUseCases/SingleVsMultipleCsmSwitch/CsmSwitchReports\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/PracticalCase-CompareReinsuranceTest.ipynb b/ifrs17-template/Test/PracticalCase-CompareReinsuranceTest.ipynb new file mode 100644 index 00000000..a8bd925f --- /dev/null +++ b/ifrs17-template/Test/PracticalCase-CompareReinsuranceTest.ipynb @@ -0,0 +1,355 @@ +{ + "metadata": { + "authors": [], + "id": "cZ9mwrWya0Ox8CXAyFRn2Q", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Test Practical Cases

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Compare Reinsurance Contracts" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../PracticalUseCases/CompareReinsuranceContracts/Reports\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "using FluentAssertions;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var grossBusinessReinsured = \"RP1.1\";", + "\nvar reinsuranceContract = \"RPR1.1\";", + "\nvar groupsOfContracts = new[] {grossBusinessReinsured, reinsuranceContract};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Best Estimate" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var bops = pv.GetDataCube().Where(x => x.Novelty==\"N\" && x.VariableType==\"BOP\");" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==grossBusinessReinsured && x.Scenario==null).Sum(x=>x.Value).Should().BeApproximately(-100.00828, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==grossBusinessReinsured && x.Scenario==\"LR70\").Sum(x=>x.Value).Should().BeApproximately(-0.11643, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==grossBusinessReinsured && x.Scenario==\"LR80\").Sum(x=>x.Value).Should().BeApproximately(99.77541, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==grossBusinessReinsured && x.Scenario==\"ELR60A70\").Sum(x=>x.Value).Should().BeApproximately(-100.00828, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==grossBusinessReinsured && x.Scenario==\"ELR60A80\").Sum(x=>x.Value).Should().BeApproximately(-100.00828, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==reinsuranceContract && x.Scenario==null).Sum(x=>x.Value).Should().BeApproximately(15.15453, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==reinsuranceContract && x.Scenario==\"LR70\").Sum(x=>x.Value).Should().BeApproximately(-14.78996, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==reinsuranceContract && x.Scenario==\"LR80\").Sum(x=>x.Value).Should().BeApproximately(-44.73446, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==reinsuranceContract && x.Scenario==\"ELR60A70\").Sum(x=>x.Value).Should().BeApproximately(15.15453, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "bops.Where(x => x.GroupOfContract==reinsuranceContract && x.Scenario==\"ELR60A80\").Sum(x=>x.Value).Should().BeApproximately(15.15453, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Experience Adjustments" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var eAs = experienceAdjustments.GetDataCube().Where(x => groupsOfContracts.Contains(x.GroupOfContract));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "eAs.Where(x => x.Scenario == null).Sum(x => x.Value).Should().BeApproximately(0, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "eAs.Where(x => x.Scenario == \"LR70\").Sum(x => x.Value).Should().BeApproximately(0, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "eAs.Where(x => x.Scenario == \"LR80\").Sum(x => x.Value).Should().BeApproximately(0, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "eAs.Where(x => x.Scenario == \"ELR60A70\").Sum(x => x.Value).Should().BeApproximately(-70, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "eAs.Where(x => x.Scenario == \"ELR60A80\").Sum(x => x.Value).Should().BeApproximately(-140, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Csm/Loss Component" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var csmAM = allocatedTechnicalMargins.GetDataCube().Where(x => groupsOfContracts.Contains(x.GroupOfContract) && x.VariableType == \"AM\" && Math.Abs(x.Value) > Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "csmAM.Where(x => x.Scenario == null).Sum(x => x.Value).Should().BeApproximately(-84.86029, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "csmAM.Where(x => x.Scenario == \"LR70\").Sum(x => x.Value).Should().BeApproximately(-14.83859, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "csmAM.Where(x => x.Scenario == \"LR80\").Sum(x => x.Value).Should().BeApproximately(-55.18393, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Financial Performance" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pnl = pnl.Where(x => groupsOfContracts.Contains(x.GroupOfContract));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pnl.Where(x => x.Scenario == \"Best Estimate\").Sum(x => x.Value).Should().BeApproximately(84.99882, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pnl.Where(x => x.Scenario == \"LR70\").Sum(x => x.Value).Should().BeApproximately(15.00020, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pnl.Where(x => x.Scenario == \"LR80\").Sum(x => x.Value).Should().BeApproximately(-55.00076, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pnl.Where(x => x.Scenario == \"ELR60A70\").Sum(x => x.Value).Should().BeApproximately(14.99882, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "pnl.Where(x => x.Scenario == \"ELR60A80\").Sum(x => x.Value).Should().BeApproximately(-55.00117, Precision);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb b/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb index 7e911369..a51633ec 100644 --- a/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb +++ b/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "MW1tEAQXFUyIZF05Nm_9sw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -50,7 +51,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -85,7 +86,7 @@ "await Import.FromFile(\"Data/NominalCashflows_CH_2020_12_DT1.1NoPrem.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Test/ReportVariablesTest.ipynb b/ifrs17-template/Test/ReportVariablesTest.ipynb index d68c8116..be2c38f9 100644 --- a/ifrs17-template/Test/ReportVariablesTest.ipynb +++ b/ifrs17-template/Test/ReportVariablesTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "KQxwaFlDd0-4GXgvftROHA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -92,7 +91,7 @@ { "cell_type": "code", "source": [ - "var reportStorage = new ReportStorage(Workspace, Report);", + "var reportStorage = new ReportStorage(Workspace, Report, Export);", "\nawait reportStorage.InitializeReportIndependentCacheAsync();" ], "metadata": {}, diff --git a/ifrs17-template/Test/ReportVariablesTestBase.ipynb b/ifrs17-template/Test/ReportVariablesTestBase.ipynb index a41671c0..70fb899d 100644 --- a/ifrs17-template/Test/ReportVariablesTestBase.ipynb +++ b/ifrs17-template/Test/ReportVariablesTestBase.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "5CKjRei0rkqYmm9zIKqElw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17-template/Test/ScenarioDataImportTest.ipynb b/ifrs17-template/Test/ScenarioDataImportTest.ipynb index e6603fef..5b5e8e52 100644 --- a/ifrs17-template/Test/ScenarioDataImportTest.ipynb +++ b/ifrs17-template/Test/ScenarioDataImportTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "RTdwhhLYx0Oqt3uP2hPqzg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -54,8 +55,7 @@ { "cell_type": "code", "source": [ - "var ws = Workspace.CreateNew();", - "\nws.InitializeFrom(DataSource);" + "var EnableScenarioBackup = Scenarios.EnableScenario;" ], "metadata": {}, "execution_count": 0, @@ -64,8 +64,7 @@ { "cell_type": "code", "source": [ - "var argsBestEstimate = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Cashflow);", - "\nvar argsScenario = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"Test\", ImportFormats.Cashflow);" + "Scenarios.EnableScenario = true;" ], "metadata": {}, "execution_count": 0, @@ -74,8 +73,8 @@ { "cell_type": "code", "source": [ - "var initStorage = new ImportStorage(argsBestEstimate, DataSource, ws);", - "\nawait initStorage.InitializeAsync();" + "var argsBestEstimate = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Cashflow);", + "\nvar argsScenario = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"Test\", ImportFormats.Cashflow);" ], "metadata": {}, "execution_count": 0, @@ -84,11 +83,12 @@ { "cell_type": "code", "source": [ - "var actualETs = initStorage.EstimateTypesByImportFormat[ImportFormats.Actual];", - "\nvar cashflowETs = initStorage.EstimateTypesByImportFormat[ImportFormats.Cashflow];", - "\nvar actualOrCashflowETs = actualETs.Intersect(cashflowETs);", - "\nvar onlyActualETs = actualETs.Except(cashflowETs);", - "\nvar onlyCashflowETs = cashflowETs.Except(actualETs);" + "var estimateTypes = (await DataSource.Query().ToArrayAsync());", + "\nvar actualEstimateTypes = estimateTypes.Where(et => et.InputSource.Contains(InputSource.Actual)).Select(x => x.SystemName);", + "\nvar cashflowEstimateTypes = estimateTypes.Where(et => et.InputSource.Contains(InputSource.Cashflow)).Select(x => x.SystemName);", + "\nvar actualAndCashflowEstimateTypes = actualEstimateTypes.Intersect(cashflowEstimateTypes);", + "\nvar onlyActualEstimateTypes = actualEstimateTypes.Except(cashflowEstimateTypes);", + "\nvar onlyCashflowEstimateTypes = cashflowEstimateTypes.Except(actualEstimateTypes);" ], "metadata": {}, "execution_count": 0, @@ -214,9 +214,9 @@ "await DataSource.Partition.SetAsync(argsScenario);", "\nvar ivsScenarioInitCashFlows = await DataSource.Query().ToArrayAsync();", "\nvar diffs = ivsScenarioInitCashFlows.Except(ivsBestEstimateInit, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();", - "\nvar actualOrCashflowVars = diffs.Where(x => actualOrCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar actualAndCashflowVars = diffs.Where(x => actualAndCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -225,11 +225,9 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n actualVars.Length.Should().Be(0);", - "\n cashflowVars.Length.Should().NotBe(0);", - "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", - "\n}" + "actualVars.Length.Should().Be(0);", + "\ncashflowVars.Length.Should().NotBe(0);", + "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualAndCashflowVars)).ToArray().Length.Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -274,9 +272,9 @@ "await DataSource.Partition.SetAsync(argsScenario);", "\nvar ivsScenarioInitActuals = DataSource.Query().ToArray();", "\nvar diffs = ivsScenarioInitActuals.Except(ivsScenarioInitCashFlows, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();", - "\nvar actualOrCashflowVars = diffs.Where(x => actualOrCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar actualAndCashflowVars = diffs.Where(x => actualAndCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -285,11 +283,9 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n actualVars.Length.Should().NotBe(0);", - "\n cashflowVars.Length.Should().Be(0);", - "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", - "\n}" + "actualVars.Length.Should().NotBe(0);", + "\ncashflowVars.Length.Should().Be(0);", + "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualAndCashflowVars)).ToArray().Length.Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -343,9 +339,9 @@ "await DataSource.Partition.SetAsync(argsScenario);", "\nvar ivsScenarioCashflowUpdateCU = await DataSource.Query().ToArrayAsync();", "\nvar diffs = ivsScenarioCashflowUpdateCU.Except(ivsScenarioInitActuals, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();", - "\nvar actualOrCashflowVars = diffs.Where(x => actualOrCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar actualAndCashflowVars = diffs.Where(x => actualAndCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -354,11 +350,11 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n actualVars.Length.Should().Be(0);", - "\n cashflowVars.Length.Should().NotBe(0);", - "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", - "\n}" + "actualVars.Length.Should().Be(0);", + "\ncashflowVars.Where(x => x.EstimateType == EstimateTypes.F).Count().Should().NotBe(0);", + "\ndiffs.Where(x => x.EstimateType == EstimateTypes.C).Count().Should().NotBe(0);", + "\ndiffs.Where(x => x.EstimateType == EstimateTypes.DA).Count().Should().NotBe(0);", + "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualAndCashflowVars)).ToArray().Length.Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -404,9 +400,9 @@ "await DataSource.Partition.SetAsync(argsScenario);", "\nvar ivsScenarioActualUpdateACAAEA = await DataSource.Query().ToArrayAsync();", "\nvar diffs = ivsScenarioActualUpdateACAAEA.Except(ivsScenarioCashflowUpdateCU, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();", - "\nvar actualOrCashflowVars = diffs.Where(x => actualOrCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar actualAndCashflowVars = diffs.Where(x => actualAndCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -415,11 +411,10 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n diffs.Where(x => x.EstimateType == EstimateTypes.DA).ToArray().Length.Should().NotBe(0);", - "\n diffs.Where(x => x.EstimateType == EstimateTypes.F).ToArray().Length.Should().Be(0);", - "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", - "\n}" + "cashflowVars.Count().Should().Be(0);", + "\ndiffs.Where(x => x.EstimateType == EstimateTypes.DA).ToArray().Length.Should().NotBe(0);", + "\ndiffs.Where(x => x.EstimateType == EstimateTypes.F).ToArray().Length.Should().Be(0);", + "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualAndCashflowVars)).ToArray().Length.Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -482,11 +477,9 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n diffs.Where(x => x.EstimateType == EstimateTypes.DA).ToArray().Length.Should().NotBe(0);", - "\n ivsScenarioActualNoACAAEA.Where(x => x.EstimateType == EstimateTypes.F).Count().Should().NotBe(0);", - "\n ivsScenarioActualNoACAAEA.Where(x => x.EstimateType == EstimateTypes.DA && Math.Abs(x.Value) > Precision).Count().Should().Be(0);", - "\n}" + "diffs.Where(x => x.EstimateType == EstimateTypes.DA).ToArray().Length.Should().NotBe(0);", + "\nivsScenarioActualNoACAAEA.Where(x => x.EstimateType == EstimateTypes.F).Count().Should().NotBe(0);", + "\nivsScenarioActualNoACAAEA.Where(x => x.EstimateType == EstimateTypes.DA && Math.Abs(x.Value) > Precision).Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -495,7 +488,7 @@ { "cell_type": "markdown", "source": [ - "# Robustness: back to Best Estimate" + "# Robustness: scenario back to Best Estimate" ], "metadata": {}, "execution_count": 0, @@ -568,7 +561,7 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) diffs.Count().Should().Be(0);" + "ivsScenarioReimportEqualToBestEstimate.Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -627,11 +620,11 @@ "cell_type": "code", "source": [ "await DataSource.Partition.SetAsync(argsBestEstimate);", - "\nvar ivsBestEstimateReimportCashFlows = await DataSource.Query().ToArrayAsync();", - "\nvar diffs = ivsBestEstimateReimportCashFlows.Except(ivsBestEstimateInit, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();", - "\nvar actualOrCashflowVars = diffs.Where(x => actualOrCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar ivsBestEstimateReimportCashFlowsNoImpactScenario = await DataSource.Query().ToArrayAsync();", + "\nvar diffs = ivsBestEstimateReimportCashFlowsNoImpactScenario.Except(ivsBestEstimateInit, IfrsVariableComparer.Instance());", + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar actualAndCashflowVars = diffs.Where(x => actualAndCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -642,7 +635,7 @@ "source": [ "diffs.Where(x => x.EstimateType == EstimateTypes.DA).Count().Should().NotBe(0);", "\nactualVars.Length.Should().Be(0);", - "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);" + "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualAndCashflowVars)).ToArray().Length.Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -652,8 +645,8 @@ "cell_type": "code", "source": [ "await DataSource.Partition.SetAsync(argsScenario);", - "\nvar ivsScenarioReimportCashFlows = await DataSource.Query().ToArrayAsync();", - "\nvar diffs = ivsScenarioReimportCashFlows.Except(ivsBestEstimateInit, IfrsVariableComparer.Instance());" + "\nvar ivsScenarioReimportCashFlowsNoImpactScenario = await DataSource.Query().ToArrayAsync();", + "\nvar diffs = ivsScenarioReimportCashFlowsNoImpactScenario.Except(ivsBestEstimateInit, IfrsVariableComparer.Instance());" ], "metadata": {}, "execution_count": 0, @@ -662,10 +655,8 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType) && x.EstimateType != EstimateTypes.F && Math.Abs(x.Value) > Precision).Count().Should().Be(0);", - "\n diffs.Where(x => onlyActualETs.Contains(x.EstimateType) && Math.Abs(x.Value) > Precision).Count().Should().Be(0);", - "\n}" + "diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType) && x.EstimateType != EstimateTypes.F && Math.Abs(x.Value) > Precision).Count().Should().Be(0);", + "\ndiffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType) && Math.Abs(x.Value) > Precision).Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -674,7 +665,7 @@ { "cell_type": "markdown", "source": [ - "# Reimport of Best Estimate Cashflow: impact on Scenario" + "# Reimport of Best Estimate Cashflow" ], "metadata": {}, "execution_count": 0, @@ -708,15 +699,35 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsBestEstimate);", + "\nvar ivsBestEstimateReimportCashFlows = await DataSource.Query().ToArrayAsync();", + "\nvar diffs = ivsBestEstimateReimportCashFlows.Except(ivsBestEstimateReimportCashFlowsNoImpactScenario, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ "await DataSource.Partition.SetAsync(argsScenario);", - "\nvar ivsScenarioReimportCashFlowsImpact = await DataSource.Query().ToArrayAsync();", - "\nvar diffs = ivsScenarioReimportCashFlowsImpact.Except(ivsScenarioReimportCashFlows, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();", - "\nvar actualOrCashflowVars = diffs.Where(x => actualOrCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar ivsScenarioReimportCashFlows = await DataSource.Query().ToArrayAsync();", + "\nvar diffs = ivsScenarioReimportCashFlows.Except(ivsScenarioReimportCashFlowsNoImpactScenario, IfrsVariableComparer.Instance());", + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar actualAndCashflowVars = diffs.Where(x => actualAndCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -725,11 +736,9 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n cashflowVars.Length.Should().NotBe(0);", - "\n actualVars.Length.Should().Be(0);", - "\n diffs.Except(actualVars.Union(cashflowVars).Union(actualOrCashflowVars)).ToArray().Length.Should().Be(0);", - "\n}" + "cashflowVars.Length.Should().NotBe(0);", + "\nactualVars.Length.Should().Be(0);", + "\ndiffs.Except(actualVars.Union(cashflowVars).Union(actualAndCashflowVars)).ToArray().Length.Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -754,7 +763,8 @@ "\n@@Actual", "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", "\nDT1.1,CF,NIC,A,,-2000", - "\nDT1.1,CF,PR,A,,-4000\";" + "\nDT1.1,CF,PR,A,,4000", + "\nDT1.1,CF,CL,A,,-3000\";" ], "metadata": {}, "execution_count": 0, @@ -775,8 +785,8 @@ "await DataSource.Partition.SetAsync(argsBestEstimate);", "\nvar ivsBestEstimateReimportActuals = await DataSource.Query().ToArrayAsync();", "\nvar diffs = ivsBestEstimateReimportActuals.Except(ivsBestEstimateReimportCashFlows, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -786,8 +796,7 @@ "cell_type": "code", "source": [ "actualVars.Length.Should().NotBe(0);", - "\ncashflowVars.Length.Should().NotBe(0);", - "\ncashflowVars.Where(x => x.EstimateType == EstimateTypes.DA).Count().Should().Be(0);" + "\ncashflowVars.Length.Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -799,8 +808,8 @@ "await DataSource.Partition.SetAsync(argsScenario);", "\nvar ivsScenarioReimportActuals = await DataSource.Query().ToArrayAsync();", "\nvar diffs = ivsScenarioReimportActuals.Except(ivsScenarioReimportCashFlows, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -809,11 +818,9 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n actualVars.Length.Should().Be(0);", - "\n cashflowVars.Length.Should().NotBe(0);", - "\n cashflowVars.Where(x => x.EstimateType == EstimateTypes.DA).Count().Should().Be(0);", - "\n}" + "diffs.Where(x => x.EstimateType == EstimateTypes.C).Count().Should().NotBe(0);", + "\nactualVars.Length.Should().Be(0);", + "\ncashflowVars.Length.Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -837,16 +844,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "await DataSource.Partition.SetAsync(argsScenario);", - "\nawait DataSource.DeleteAsync(await DataSource.Query().ToArrayAsync());" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -875,13 +872,23 @@ "\nDataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", "\nDT1.1,PR,BE,CL,C,,200,0,0,200,0,0,200,0,0,200,0,0,0,200,0,0,200,0,0,200,0,0,200,0", "\nDT1.1,NIC,BE,CL,C,,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33,-33", - "\nDT1.1,,CU,CL,C,,-71,-71,-70,-70,-69,-69,-68,-68,-67,-67,-66,-66,-65,-65,-64,-64,-63,-63,-62,-62,-61,-61,-60,-60", + "\nDT1.1,,CU,CL,C,,-719,-71,-70,-70,-69,-69,-68,-68,-67,-67,-66,-66,-65,-65,-64,-64,-63,-63,-62,-62,-61,-61,-60,-60", "\nDT1.1,,RA,CL,C,,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45,-45\";" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenario);", + "\nawait DataSource.DeleteAsync(await DataSource.Query().ToArrayAsync());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -916,8 +923,8 @@ "await DataSource.Partition.SetAsync(argsScenario);", "\nvar ivsScenarioReimportCashFlowsWithCU = await DataSource.Query().ToArrayAsync();", "\nvar diffs = ivsScenarioReimportCashFlowsWithCU.Except(ivsScenarioReimportCashflowNoCU, IfrsVariableComparer.Instance());", - "\nvar actualVars = diffs.Where(x => onlyActualETs.Contains(x.EstimateType)).ToArray();", - "\nvar cashflowVars = diffs.Where(x => onlyCashflowETs.Contains(x.EstimateType)).ToArray();" + "\nvar actualVars = diffs.Where(x => onlyActualEstimateTypes.Contains(x.EstimateType)).ToArray();", + "\nvar cashflowVars = diffs.Where(x => onlyCashflowEstimateTypes.Contains(x.EstimateType)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -926,10 +933,17 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n actualVars.Length.Should().Be(0);", - "\n cashflowVars.Length.Should().NotBe(0);", - "\n}" + "actualVars.Length.Should().Be(0);", + "\ndiffs.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Restore Constants" ], "metadata": {}, "execution_count": 0, @@ -938,7 +952,7 @@ { "cell_type": "code", "source": [ - "" + "Scenarios.EnableScenario = EnableScenarioBackup;" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ScenarioParametersImportTest.ipynb b/ifrs17-template/Test/ScenarioParametersImportTest.ipynb new file mode 100644 index 00000000..907f3f47 --- /dev/null +++ b/ifrs17-template/Test/ScenarioParametersImportTest.ipynb @@ -0,0 +1,503 @@ +{ + "metadata": { + "authors": [], + "id": "8AGRn6EDjEm0Kvo27RJFPw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Scenario Parameters Import Test

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "DataSource.Reset(x => x.ResetType().ResetType());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Setting Constants" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var EnableScenarioBackup = Scenarios.EnableScenario;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Scenarios.EnableScenario = true;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var argsBestEstimate = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Cashflow);", + "\nvar argsScenarioParameter = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"DUP10pct\", ImportFormats.Cashflow);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var estimateTypes = (await DataSource.Query().ToArrayAsync());", + "\nvar actualEstimateTypes = estimateTypes.Where(et => et.InputSource.Contains(InputSource.Actual)).Select(x => x.SystemName);", + "\nvar cashflowEstimateTypes = estimateTypes.Where(et => et.InputSource.Contains(InputSource.Cashflow)).Select(x => x.SystemName);", + "\nvar actualAndCashflowEstimateTypes = actualEstimateTypes.Intersect(cashflowEstimateTypes);", + "\nvar onlyActualEstimateTypes = actualEstimateTypes.Except(cashflowEstimateTypes);", + "\nvar onlyCashflowEstimateTypes = cashflowEstimateTypes.Except(actualEstimateTypes);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Best Estimate initialization" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var cashflowBestEstimateInit = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,", + "\n@@Cashflow", + "\nDataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", + "\nDT1.1,PR,BE,CL,C,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0", + "\nDT1.1,NIC,BE,CL,C,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25", + "\nDT1.1,,CU,CL,C,,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-3", + "\nDT1.1,,RA,CL,C,,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5", + "\nDTR1.1,PR,BE,CL,C,,50,0,0,50,0,0,50,0,0,50,0,0,50,0,0,50,0,0,50,0,0,50,0,0", + "\nDTR1.1,NIC,BE,CL,C,,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5", + "\nDTR1.1,,CU,CL,C,,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5", + "\nDTR1.1,,RA,CL,C,,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(cashflowBestEstimateInit).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var actualsBestEstimateInit = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,", + "\n@@Actual", + "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", + "\nDT1.1,CF,ACA,A,,-10", + "\nDT1.1,CF,AEA,A,,-5", + "\nDT1.1,CF,NIC,A,,-280", + "\nDT1.1,CF,PR,A,,400", + "\nDTR1.1,CF,PR,A,,-200", + "\nDTR1.1,CF,NIC,A,,140\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(actualsBestEstimateInit).WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsBestEstimate);", + "\nvar ivsBestEstimateInit = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Scenario parameters import" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var parametersScenarios = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,DUP10pct", + "\n@@SingleDataNodeParameter", + "\nDataNode,PremiumAllocation", + "\nDT1.1,0.52", + "\n@@InterDataNodeParameter", + "\nDataNode,LinkedDataNode,ReinsuranceCoverage", + "\nDT1.1,DTR1.1,0.62\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(parametersScenarios).WithFormat(ImportFormats.DataNodeParameter).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioParameter);", + "\nvar ivsScenarioParameter = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioParameter.Except(ivsBestEstimateInit, IfrsVariableComparer.Instance()).ToArray();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Count().Should().NotBe(0);", + "\ndiffs.Where(x => x.EstimateType == EstimateTypes.C).Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Re-import of the same parameters should not trigger calculations " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var log = await Import.FromString(parametersScenarios).WithFormat(ImportFormats.DataNodeParameter).WithTarget(DataSource).ExecuteAsync();", + "\nlog" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Get(Warning.VariablesAlreadyImported)).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioParameter);", + "\nvar ivsScenarioParameterSameReimport = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioParameterSameReimport.Except(ivsScenarioParameter, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Re-import of best estimate cashflow" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var cashflowBestEstimateReImport = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,", + "\n@@Cashflow", + "\nDataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", + "\nDT1.1,PR,BE,CL,C,,131,0,0,111,0,0,111,0,0,111,0,0,0,111,0,0,111,0,0,111,0,0,111,0", + "\nDT1.1,NIC,BE,CL,C,,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31,-31", + "\nDT1.1,,CU,CL,C,,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-11,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-3", + "\nDT1.1,,RA,CL,C,,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6,-2.6", + "\nDTR1.1,PR,BE,CL,C,,51,0,0,51,0,0,51,0,0,51,0,0,51,0,0,51,0,0,51,0,0,51,0,0", + "\nDTR1.1,NIC,BE,CL,C,,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13", + "\nDTR1.1,,CU,CL,C,,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5", + "\nDTR1.1,,RA,CL,C,,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31,1.31\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(cashflowBestEstimateReImport).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Best Estimate change" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsBestEstimate);", + "\nvar ivsBestEstimateReimport = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsBestEstimateReimport.Except(ivsBestEstimateInit, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario should change" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioParameter);", + "\nvar ivsScenarioParameterReimportBestEstimateCashflow = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioParameterReimportBestEstimateCashflow.Except(ivsScenarioParameter, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Re-import of scenario parameters" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var parametersScenariosReimport = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2020,12,DUP10pct", + "\n@@SingleDataNodeParameter", + "\nDataNode,PremiumAllocation", + "\nDT1.1,0.23", + "\n@@InterDataNodeParameter", + "\nDataNode,LinkedDataNode,ReinsuranceCoverage", + "\nDT1.1,DTR1.1,0.23\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(parametersScenariosReimport).WithFormat(ImportFormats.DataNodeParameter).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioParameter);", + "\nvar ivsScenarioParameterReimport = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioParameterReimport.Except(ivsScenarioParameterReimportBestEstimateCashflow, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Restore constants" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Scenarios.EnableScenario = EnableScenarioBackup;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb b/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb index 002c811c..8bdbac30 100644 --- a/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb +++ b/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "0sFHQY0OakSz69Zuyfsu4w", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -54,8 +55,7 @@ { "cell_type": "code", "source": [ - "var ws = Workspace.CreateNew();", - "\nws.InitializeFrom(DataSource);" + "var EnableScenarioBackup = Scenarios.EnableScenario;" ], "metadata": {}, "execution_count": 0, @@ -64,9 +64,7 @@ { "cell_type": "code", "source": [ - "var argsBestEstimate = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Cashflow);", - "\nvar argsScenarioYieldCurve = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"YCUP1.0pct\", ImportFormats.Cashflow);", - "\nvar argsScenarioTransactionalData = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"SRUP1.0pct\", ImportFormats.Cashflow);" + "Scenarios.EnableScenario = true;" ], "metadata": {}, "execution_count": 0, @@ -75,8 +73,11 @@ { "cell_type": "code", "source": [ - "var initStorage = new ImportStorage(argsBestEstimate, DataSource, ws);", - "\nawait initStorage.InitializeAsync();" + "var argsBestEstimate = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Cashflow);", + "\nvar argsScenarioYieldCurve = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"YCUP1.0pct\", ImportFormats.Cashflow);", + "\nvar argsScenarioTransactionalData = new ImportArgs (\"CH\", 2020, 12, Periodicity.Quarterly, \"SRUP1.0pct\", ImportFormats.Cashflow);", + "\nvar argsBestEstimateNextPeriod = new ImportArgs (\"CH\", 2021, 3, Periodicity.Quarterly, null, ImportFormats.Cashflow);", + "\nvar argsScenarioYieldCurveNextPeriod = new ImportArgs (\"CH\", 2021, 3, Periodicity.Quarterly, \"YCDW1.0pct\", ImportFormats.Cashflow);" ], "metadata": {}, "execution_count": 0, @@ -85,8 +86,9 @@ { "cell_type": "code", "source": [ - "var actualEstimateTypes = initStorage.EstimateTypesByImportFormat[ImportFormats.Actual];", - "\nvar cashflowEstimateTypes = initStorage.EstimateTypesByImportFormat[ImportFormats.Cashflow];", + "var estimateTypes = (await DataSource.Query().ToArrayAsync());", + "\nvar actualEstimateTypes = estimateTypes.Where(et => et.InputSource.Contains(InputSource.Actual)).Select(x => x.SystemName);", + "\nvar cashflowEstimateTypes = estimateTypes.Where(et => et.InputSource.Contains(InputSource.Cashflow)).Select(x => x.SystemName);", "\nvar actualAndCashflowEstimateTypes = actualEstimateTypes.Intersect(cashflowEstimateTypes);", "\nvar onlyActualEstimateTypes = actualEstimateTypes.Except(cashflowEstimateTypes);", "\nvar onlyCashflowEstimateTypes = cashflowEstimateTypes.Except(actualEstimateTypes);" @@ -257,10 +259,8 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) {", - "\n actualVars.Length.Should().Be(0);", - "\n cashflowVars.Length.Should().NotBe(0);", - "\n}" + "actualVars.Length.Should().Be(0);", + "\ncashflowVars.Length.Should().NotBe(0);" ], "metadata": {}, "execution_count": 0, @@ -269,7 +269,7 @@ { "cell_type": "markdown", "source": [ - "# Re-Import of the same Yield Curve does not trigger IFRS17 Calculations" + "# Re-import of the same yield curve should not trigger calculations" ], "metadata": {}, "execution_count": 0, @@ -278,7 +278,17 @@ { "cell_type": "code", "source": [ - "await Import.FromString(yieldCurveScenario).WithFormat(ImportFormats.YieldCurve).WithTarget(DataSource).ExecuteAsync()" + "var log = await Import.FromString(yieldCurveScenario).WithFormat(ImportFormats.YieldCurve).WithTarget(DataSource).ExecuteAsync();", + "\nlog" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Get(Warning.VariablesAlreadyImported)).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -306,7 +316,7 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) diffs.Count().Should().Be(0);" + "diffs.Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -315,7 +325,7 @@ { "cell_type": "markdown", "source": [ - "# Multiple Scenarios ", + "# Multiple Scenarios: re-import of Best Estimate yield curve", "\n", "\nIn this example, a new Cashflow for a different Scenario - SRUP1.0pct - is imported. ", "\nThe aim is to check how the Yield Curve importer behaves when a new Best Estimate Yield Curve is imported. ", @@ -372,9 +382,7 @@ "\n2020,12", "\n@@YieldCurve", "\nCurrency,Values0,Values1,Values2,Values3", - "\nEUR,0.108,0.108,0.118,0.119", - "\nCHF,0.103,0.103,0.103,0.103", - "\nUSD,0.903,0.103,0.103,0.103\";" + "\nUSD,0.006,0.004,0.004,0.005\";" ], "metadata": {}, "execution_count": 0, @@ -420,7 +428,7 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) if(EnableScenario) diffs.Count().Should().NotBe(0);" + "diffs.Count().Should().NotBe(0);" ], "metadata": {}, "execution_count": 0, @@ -457,7 +465,7 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) diffs.Count().Should().Be(0);" + "diffs.Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -494,7 +502,239 @@ { "cell_type": "code", "source": [ - "if(EnableScenario) diffs.Count().Should().NotBe(0);" + "diffs.Count().Should().NotBe(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Influence on the future: import of yield curve for previous month should not update current results" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var bestEstimateYieldCurvePast = @\"", + "\n@@Main", + "\nYear,Month", + "\n2020,6", + "\n@@YieldCurve", + "\nCurrency,Values0,Values1,Values2,Values3", + "\nUSD,0.123,0.123,0.123,0.123\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(bestEstimateYieldCurvePast).WithFormat(ImportFormats.YieldCurve).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Best Estimate should not change" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsBestEstimate);", + "\nvar ivsBestEstimateImportPast = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsBestEstimateImportPast.Except(ivsBestEstimateUpdated, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario should not change" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioYieldCurve);", + "\nvar ivsScenarioYieldCurveImportPast = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioYieldCurveImportPast.Except(ivsScenarioYieldCurveUpdated, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Next period imports" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var cashflowBestEstimateNextPeriod = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,Scenario", + "\nCH,2021,3", + "\n@@Cashflow", + "\nDataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20,Values21,Values22,Values23", + "\nDT1.1,PR,BE,CL,C,,80,0,0,80,0,0,80,0,0,80,0,0,0,80,0,0,80,0,0,80,0,0,80,0", + "\nDT1.1,NIC,BE,CL,C,,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3,-22.3", + "\nDT1.1,,RA,CL,C,,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40,-2.40\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var yieldCurveScenarioNextPeriod = @\"", + "\n@@Main", + "\nYear,Month,Scenario", + "\n2021,3,YCDW1.0pct", + "\n@@YieldCurve", + "\nCurrency,Values0,Values1,Values2,Values3", + "\nUSD,0.007,0.004,0.004,0.005\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(cashflowBestEstimateNextPeriod).WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(yieldCurveScenarioNextPeriod).WithFormat(ImportFormats.YieldCurve).WithTarget(DataSource).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Results with economic basis locked in basis should not be affected" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsBestEstimateNextPeriod);", + "\nvar ivsBestEstimateNextPeriod = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.Partition.SetAsync(argsScenarioYieldCurveNextPeriod);", + "\nvar ivsScenarioYieldCurveNextPeriod = await DataSource.Query().ToArrayAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var diffs = ivsScenarioYieldCurveNextPeriod.Except(ivsBestEstimateNextPeriod, IfrsVariableComparer.Instance());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "diffs.Where(x => x.EconomicBasis == EconomicBases.C).Count().Should().NotBe(0);", + "\ndiffs.Where(x => x.EconomicBasis == EconomicBases.L).Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Restore Constants" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Scenarios.EnableScenario = EnableScenarioBackup;" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/SequenceImportTest.ipynb b/ifrs17-template/Test/SequenceImportTest.ipynb index fec21ac1..97e3cb2b 100644 --- a/ifrs17-template/Test/SequenceImportTest.ipynb +++ b/ifrs17-template/Test/SequenceImportTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "f_2RGX4ByU-R8P1CdIhJlg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -58,7 +59,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(ws1)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -71,23 +72,13 @@ "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(ws1)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "ws1.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\nws1.Initialize(x => x.FromSource(DataSource));" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -132,7 +123,7 @@ "await Import.FromFile(\"../Files/TransactionalData/Actuals_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Actual)", "\n .WithTarget(ws2)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -145,23 +136,13 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(ws2)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "ws2.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\nws2.Initialize(x => x.FromSource(DataSource));" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index cf5f7611..6fe7644b 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "qEc2ZDMEhUGDoTw7upcthw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -30,7 +29,7 @@ "cell_type": "markdown", "source": [ "Comprehensive collection of tests executed on top of the Systemorph use cases (initialization).", - "\n
Execute this Notebook using at least 14Gb RAM." + "\n
Execute this Notebook using at least 20Gb RAM." ], "metadata": {}, "execution_count": 0, @@ -72,6 +71,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"ScenarioParametersImportTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -120,7 +128,16 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"PracticalCasesTest\"" + "#!eval-notebook \"PracticalCase-CSMSwitchTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"PracticalCase-CompareReinsuranceTest\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/CalculationEngine.ipynb b/ifrs17/CalculationEngine.ipynb index 49d163c6..ab86a1a1 100644 --- a/ifrs17/CalculationEngine.ipynb +++ b/ifrs17/CalculationEngine.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "3_nIwm38IECvWgOZZlFUPw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,13 +14,15 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "code", "source": [ "#!import \"DataModel/DataStructure\"", "\n#!import \"Report/ReportMutableScopes\"", + "\n#!import \"Report/ReportMutableScopesInteractive\"", + "\n#!import \"Report/ParameterReportMutableScopeInteractive\"", "\n#!import \"Import/Importers\"", "\n#!import \"Export/ExportConfiguration\"", "\n#!import \"Utils/TestHelper\"", @@ -33,7 +36,34 @@ { "cell_type": "code", "source": [ - "var ifrs17 = new Ifrs17(Workspace, Scopes, Report);" + "var ifrs17 = new Ifrs17(Workspace, Scopes, Report, Export);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ifrs17Interactive = new Ifrs17Interactive(Workspace, Report, Export, InteractiveObject);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var parameterInteractive = new InteractiveParameterReports(Workspace, Report, Export, InteractiveObject);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index 23d90c66..26801b20 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "XKwOq8eRDkuYqDPJOmCi3w", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,13 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -27,15 +25,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "public const bool EnableScenario = false;" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -228,6 +217,28 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Import Types" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static class ImportTypes{", + "\n public const string ExchangeRate = nameof(ExchangeRate);", + "\n public const string PartnerRating = nameof(PartnerRating);", + "\n public const string CreditDefaultRate = nameof(CreditDefaultRate);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -355,32 +366,51 @@ "\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 public const string ULE = nameof(ULE); // Unallocated Loss Adjustment Expenses", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Insurance specific" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "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": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Sensitivities" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ "public static class Scenarios{", - "\n public const string YCUP1pct = nameof(YCUP1pct); // Yield Curve Up 1.0pct", - "\n public const string YCDW1pct = nameof(YCDW1pct); // Yield Curve Down 1.0pct", - "\n public const string SRUP1pct = nameof(SRUP1pct); // Spread Rate Up 1.0pct", - "\n public const string SRDW1pct = nameof(SRDW1pct); // Spread Rate Down 1.0pct", - "\n public const string EUP1pct = nameof(EUP1pct); // Equity Up 1.0pct", - "\n public const string EDW1pct = nameof(EDW1pct); // Equity Down 1.0pct", - "\n public const string FXUP1pct = nameof(FXUP1pct); // Exchange Rate Up 1.0pct", - "\n public const string FXDW1pct = nameof(FXDW1pct); // Exchange Rate Down 1.0pct", - "\n public const string MTUP10pct = nameof(MTUP10pct); // Mortality Up 10pct", - "\n public const string MTDW10pct = nameof(MTDW10pct); // Mortality Down 10pct", - "\n public const string LUP10pct = nameof(LUP10pct); // Longevity Up 10pct", - "\n public const string LDW10pct = nameof(LDW10pct); // Longevity Down 10pct", - "\n public const string DUP10pct = nameof(DUP10pct); // Disability Up 10pct", - "\n public const string DDW10pct = nameof(DDW10pct); // Disability Down 10pct", - "\n public const string LICUP10pct = nameof(LICUP10pct); // Lic Up 10pct", - "\n public const string LICDW10pct = nameof(LICDW10pct); // Lic Down 10pct", + "\n public static bool EnableScenario = false;", + "\n public const string Default = \"Best Estimate\";", + "\n public const string All = nameof(All);", + "\n public const string Delta = nameof(Delta);", "\n}" ], "metadata": {}, @@ -390,7 +420,7 @@ { "cell_type": "markdown", "source": [ - "# Insurance specific" + "# Parameter Reports" ], "metadata": {}, "execution_count": 0, @@ -399,9 +429,14 @@ { "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", + "public static class ParameterReportType{", + "\n public const string DataNodeReport = nameof(DataNodeReport);", + "\n public const string DataNodeStateReport = nameof(DataNodeStateReport);", + "\n public const string YieldCurves = nameof(YieldCurves);", + "\n public const string SingleDataNodeReport = nameof(SingleDataNodeReport);", + "\n public const string InterDataNodeParameters = nameof(InterDataNodeParameters);", + "\n public const string PartnerRating = nameof(PartnerRating);", + "\n public const string PartnerDefaultRates = nameof(PartnerDefaultRates);", "\n}" ], "metadata": {}, diff --git a/ifrs17/Constants/Enums.ipynb b/ifrs17/Constants/Enums.ipynb index af20091f..6dea86b7 100644 --- a/ifrs17/Constants/Enums.ipynb +++ b/ifrs17/Constants/Enums.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "miNXh_kJVE2HcvY8ujKdYw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,13 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17/Constants/Validations.ipynb b/ifrs17/Constants/Validations.ipynb index 3fdcf95e..633de229 100644 --- a/ifrs17/Constants/Validations.ipynb +++ b/ifrs17/Constants/Validations.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "oGGkQrEJxUah7O388PTz2Q", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,13 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -86,6 +84,8 @@ "\n NotSupportedAocStepReference, MultipleEoP,", "\n // Data completeness", "\n MissingDataAtPosting, MissingCombinedLiability, MissingCoverageUnit, ", + "\n // Index", + "\n NegativeIndex,", "\n // Default", "\n Generic", "\n};" @@ -169,6 +169,8 @@ "\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 // Index", + "\n (Error.NegativeIndex , 0) => $\"Index was out of range. Must be non-negative.\",", "\n // Default", "\n (Error.Generic , _) => $\"{s[0]}\",", "\n (_ , _) => $\"Error not found.\"", diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index d8992bc6..40e8e34b 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "zcY4j_S910ekEPwNfp1dWA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,13 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -52,22 +50,22 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Activities,1.6.2\"", - "\n#r \"nuget:Systemorph.Arithmetics,1.6.2\"", - "\n#r \"nuget:Systemorph.Workspace,1.6.3\"", - "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.2\"", - "\n#r \"nuget:Systemorph.SharePoint,1.6.2\"", - "\n#r \"nuget:Systemorph.OneDrive,1.6.2\"", - "\n#r \"nuget:Systemorph.Scopes,1.6.2\"", - "\n#r \"nuget:Systemorph.Import,1.6.4\"", - "\n#r \"nuget:Systemorph.Test,1.6.2\"", - "\n#r \"nuget:Systemorph.Export,1.6.4\"", - "\n#r \"nuget:Systemorph.DataSetReader,1.6.4\"", - "\n#r \"nuget:Systemorph.DataSource,1.6.3\"", - "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.3\"", - "\n#r \"nuget:Systemorph.Reporting,1.6.2\"", - "\n#r \"nuget:Systemorph.Charting,1.6.2\"", - "\n#r \"nuget:Systemorph.SchemaMigrations,1.6.3\"" + "#r \"nuget:Systemorph.Activities,1.6.5\"", + "\n#r \"nuget:Systemorph.Arithmetics,1.6.5\"", + "\n#r \"nuget:Systemorph.Workspace,1.6.4\"", + "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.5\"", + "\n#r \"nuget:Systemorph.SharePoint,1.6.5\"", + "\n#r \"nuget:Systemorph.OneDrive,1.6.5\"", + "\n#r \"nuget:Systemorph.Scopes,1.6.5\"", + "\n#r \"nuget:Systemorph.Import,1.6.7\"", + "\n#r \"nuget:Systemorph.Test,1.6.5\"", + "\n#r \"nuget:Systemorph.Export,1.6.7\"", + "\n#r \"nuget:Systemorph.DataSetReader,1.6.6\"", + "\n#r \"nuget:Systemorph.DataSource,1.6.4\"", + "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.4\"", + "\n#r \"nuget:Systemorph.Reporting,1.6.5\"", + "\n#r \"nuget:Systemorph.Charting,1.6.5\"", + "\n#r \"nuget:Systemorph.SchemaMigrations,1.6.4\"" ], "metadata": {}, "execution_count": 0, @@ -1064,7 +1062,7 @@ "\n", "\nThe Credit Default Rate values must be entered with monthly granularity, i.e. every value corresponds to the default rate for a certain month. The first month entered in column Values0 always corresponds to January of 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", - "\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." + "\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. When the current period Credit Default Rate differs from previous period value, the analysis of change for the Credit Default Rate amount type computes the contribution of such update as an additional step (Credit Risk Update)." ], "metadata": {}, "execution_count": 0, @@ -1116,7 +1114,7 @@ "\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", - "\nDuring calculation, the Yield Curve values are retrieved from the DataSource. The Yield Curve Name defined for each group-of-contracts will be used to match the Name of the Yield Curve to be considered. This occurs only for the curve that is used in the computation of the Contractual Service Margin (locked-in for BBA valuation approach, current otherwise). The calculation engine allows the update of the locked-in curve during the entire inception year of the group-of-contracts. When the locked-in Yield Curve is used, the latest Yield Curve available in the system with Year earlier or equal to the inception Year of the group-of-contracts will be used. When the current Yield Curve is 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." + "\nDuring calculation, the Yield Curve values are retrieved from the DataSource. The Yield Curve Name defined for each group-of-contracts will be used to match the Name of the Yield Curve to be considered. This occurs only for the curve that is used in the computation of the Contractual Service Margin (locked-in for BBA valuation approach, current otherwise). The calculation engine allows the update of the locked-in curve during the entire inception year of the group-of-contracts. When the locked-in Yield Curve is used, the latest Yield Curve available in the system with Year earlier or equal to the inception Year of the group-of-contracts will be used. When the current Yield Curve is 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. When the current period Yield Curve differs from previous period value, the analysis of change computes the contribution of such update as an additional step (Yield Curve Update)." ], "metadata": {}, "execution_count": 0, @@ -1543,7 +1541,7 @@ "\n", "\nData Node Parameters are used to keep track of other parameters pertaining to each Data Node, and their movements in time (year and month).", "\n
PremiumAllocation : defines the weight of Premium to be included in the Experience Adjustement AoC Type of the Technical Margin and is valid only for Group of Insurance Contract with LiabilityType : Liability for Remaining Coverage.", - "\n
ReinsuranceCoverage : 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
ReinsuranceCoverage : 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. In other words, it represents the percentage to which claims in the underlying GICs are expected to be reinboursed by the Reinsurance Contracts belonging to the GRIC. For proportional contracts, this factor is given by the cession while for other contracts it should be estimated. ", "\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." ], diff --git a/ifrs17/Export/ExportConfiguration.ipynb b/ifrs17/Export/ExportConfiguration.ipynb index 1b94ed00..5268ec09 100644 --- a/ifrs17/Export/ExportConfiguration.ipynb +++ b/ifrs17/Export/ExportConfiguration.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "uk_-HpozgUOIpbUIynU8vw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index f0f40ba7..a49ba1dc 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "1-Sd2C2w2kaytthWS3cL1Q", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -805,11 +804,11 @@ "\n switch (periodType) {", "\n case PeriodType.BeginningOfPeriod :", "\n for (var i = 0; i < parentDiscountedValues.Length; i++)", - "\n ret[i] = -1d * (parentDiscountedValues[i] - parentNominalValues[i]) * (GetElementOrDefault(monthlyInterestFactor, i/12) - 1d );", + "\n ret[i] = -1d * (parentDiscountedValues[i] - parentNominalValues[i]) * (monthlyInterestFactor.GetValidElement(i/12) - 1d );", "\n break;", "\n default :", "\n for (var i = 0; i < parentDiscountedValues.Length; i++)", - "\n ret[i] = -1d * parentDiscountedValues[i] * (GetElementOrDefault(monthlyInterestFactor, i/12) - 1d );", + "\n ret[i] = -1d * parentDiscountedValues[i] * (monthlyInterestFactor.GetValidElement(i/12) - 1d );", "\n break;", "\n }", "\n ", @@ -830,8 +829,8 @@ "\n var interestOnClaimsCashflowCreditRisk = new double[nominalClaimsCashflow.Length];", "\n var effectCreditRisk = new double[nominalClaimsCashflow.Length];", "\n for (var i = nominalClaimsCashflow.Length - 1; i >= 0; i--) {", - "\n interestOnClaimsCashflow[i] = 1 / GetElementOrDefault(monthlyInterestFactor, i/12) * (interestOnClaimsCashflow.ElementAtOrDefault(i + 1) + nominalClaimsCashflow[i] - nominalClaimsCashflow.ElementAtOrDefault(i + 1));", - "\n interestOnClaimsCashflowCreditRisk[i] = 1 / GetElementOrDefault(monthlyInterestFactor, i/12) * (Math.Exp(-nonPerformanceRiskRate) * interestOnClaimsCashflowCreditRisk.ElementAtOrDefault(i + 1) + nominalClaimsCashflow[i] - nominalClaimsCashflow.ElementAtOrDefault(i + 1));", + "\n interestOnClaimsCashflow[i] = 1 / monthlyInterestFactor.GetValidElement(i/12) * (interestOnClaimsCashflow.ElementAtOrDefault(i + 1) + nominalClaimsCashflow[i] - nominalClaimsCashflow.ElementAtOrDefault(i + 1));", + "\n interestOnClaimsCashflowCreditRisk[i] = 1 / monthlyInterestFactor.GetValidElement(i/12) * (Math.Exp(-nonPerformanceRiskRate) * interestOnClaimsCashflowCreditRisk.ElementAtOrDefault(i + 1) + nominalClaimsCashflow[i] - nominalClaimsCashflow.ElementAtOrDefault(i + 1));", "\n effectCreditRisk[i] = interestOnClaimsCashflow[i] - interestOnClaimsCashflowCreditRisk[i];", "\n }", "\n ", @@ -1698,7 +1697,7 @@ "\n private double[] monthlyInterestFactor => GetScope(Identity, o => o.WithContext(EconomicBasis)).Interest;", "\n ", "\n private double interestAccretionFactor => Enumerable.Range(shift,timeStep)", - "\n .Select(i => GetElementOrDefault(monthlyInterestFactor, i/12))", + "\n .Select(i => monthlyInterestFactor.GetValidElement(i/12))", "\n .Aggregate(1d, (x, y) => x * y ) - 1d;", "\n ", "\n double TechnicalMargin.Value => AggregatedValue * interestAccretionFactor;", @@ -1855,7 +1854,13 @@ "\n", "\n### Reinsurance case", "\n", - "\nFor the reinsurance case, the switch logic is identical to the one described above, except that it uses the gross Technical Margins multiplied by the weights coming from the Reinsurance Coverage Parameter (see [Data Node Parameters](../DataModel/DataStructure#data-node-parameters)). In case a GRIC has multiple GICs, then these weighted $TM$s are aggregated." + "\nFor the reinsurance case, the switch logic is identical to the one described above, except that it uses the gross Technical Margins multiplied by the weights coming from the Reinsurance Coverage (RC) Parameter (see [Data Node Parameters](../DataModel/DataStructure#data-node-parameters)). In case a GRIC ($r$) has multiple GICs ($g$), then these weighted $TM$s are aggregated.", + "\n", + "\n$$", + "\n\\text{Weighted TM}(\\text{r}) = \\sum_{g~\\in~\\text{underlying GICs}} \\text{RC}_{g,r} \\text{TM}(g)", + "\n$$", + "\n", + "\nA Loss Recovery Component (LoReCo) for GRIC $r$ is going to be opened in case the $\\text{Weighted TM}(r)$ would be allocated to Loss Component following the above mentioned switch logic. The amount allocated to the Reinsurance CSM or LoReCo follows the computed Technical Margin computed for GRIC r as described in [Technical Margin](#technical-margin)." ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index e5136298..febe6674 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "E1E3rDAmMkWNkvB-85BY8Q", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -133,7 +132,7 @@ "\n public async Task InitializeAsync()", "\n { ", "\n //Dimensions", - "\n var estimateTypes = (await workspace.Query().ToArrayAsync());", + "\n var estimateTypes = await workspace.Query().ToArrayAsync();", "\n ", "\n EstimateTypeDimension = estimateTypes.ToDictionary(x => x.SystemName);", "\n AmountTypeDimension = (await workspace.Query().ToArrayAsync()).ToDictionary(x => x.SystemName);", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index fe8f34ec..eaf7f45f 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "-WSDeQyVl0Cc-rDGmPI73w", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,13 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -424,12 +422,12 @@ { "cell_type": "code", "source": [ - "public async Task GetArgsAndCommitPartitionAsync(IDataSet dataSet)", + "public async Task GetArgsAndCommitPartitionAsync(IDataSet dataSet, IDataSource targetDataSource)", "\n{", "\n var args = GetArgsFromMain(dataSet);", "\n if(ApplicationMessage.HasErrors()) return null;", "\n if(args.ReportingNode == default(string)) { ApplicationMessage.Log(Error.ReportingNodeInMainNotFound); return null; }", - "\n await CommitPartitionAsync(args, DataSource);", + "\n await CommitPartitionAsync(args, targetDataSource);", "\n return args;", "\n}" ], @@ -449,7 +447,7 @@ { "cell_type": "code", "source": [ - "public async Task DataNodeFactoryAsync(IDataSet dataSet, string tableName, ImportArgs args)", + "public async Task DataNodeFactoryAsync(IDataSet dataSet, string tableName, ImportArgs args, IDataSource targetDataSource)", "\n{", "\n var partition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode).ToArrayAsync()).FirstOrDefault();", "\n if(partition == null) { ApplicationMessage.Log(Error.ParsedPartitionNotFound); return; }", @@ -457,18 +455,30 @@ "\n var table = dataSet.Tables[tableName];", "\n ", "\n var dataNodesImported = table.Rows.Select(x => x.Field(nameof(RawVariable.DataNode))).ToHashSet();", - "\n var dataNodesDefined = await DataSource.Query().Where(x => dataNodesImported.Contains(x.SystemName)).ToArrayAsync();", - "\n var dataNodeStatesDefined = await DataSource.Query().Select(x => x.DataNode).ToArrayAsync();", - "\n var dataNodeParametersDefined = await DataSource.Query().Select(x => x.DataNode).ToArrayAsync(); ", + "\n var dataNodesDefined = await targetDataSource.Query().Where(x => dataNodesImported.Contains(x.SystemName)).ToArrayAsync();", + "\n var dataNodeStatesDefined = await targetDataSource.Query().Select(x => x.DataNode).ToArrayAsync();", + "\n var dataNodeParametersDefined = await targetDataSource.Query().Select(x => x.DataNode).ToArrayAsync(); ", "\n var dataNodeStatesUndefined = dataNodesImported.Where(x => x != null && !dataNodeStatesDefined.Contains(x)).ToHashSet();", "\n var dataNodeSingleParametersUndefined = dataNodesImported.Where(x => x != null &&", "\n !dataNodeParametersDefined.Contains(x) && ", "\n dataNodesDefined.SingleOrDefault(y => y.SystemName == x) is GroupOfInsuranceContract).ToHashSet();", - "\n await DataSource.UpdateAsync( dataNodeStatesUndefined.Select(x => ", - "\n new DataNodeState {DataNode = x, Year = args.Year, Month = DefaultDataNodeActivationMonth, State = State.Active, Partition = partition.Id}).ToArray() );", - "\n await DataSource.UpdateAsync( dataNodeSingleParametersUndefined.Select(x => ", - "\n new SingleDataNodeParameter {DataNode = x, Year = args.Year, Month = DefaultDataNodeActivationMonth, PremiumAllocation = DefaultPremiumExperienceAdjustmentFactor, Partition = partition.Id}).ToArray() );", - "\n await DataSource.CommitAsync();", + "\n if ((dataNodeStatesUndefined?.Any() ?? false))", + "\n await targetDataSource.UpdateAsync( dataNodeStatesUndefined.Select(x => ", + "\n new DataNodeState {DataNode = x, ", + "\n Year = args.Year, ", + "\n Month = DefaultDataNodeActivationMonth, ", + "\n State = State.Active, ", + "\n Partition = partition.Id})", + "\n .ToArray() );", + "\n if ((dataNodeSingleParametersUndefined?.Any() ?? false))", + "\n await targetDataSource.UpdateAsync( dataNodeSingleParametersUndefined.Select(x => ", + "\n new SingleDataNodeParameter {DataNode = x, ", + "\n Year = args.Year, ", + "\n Month = DefaultDataNodeActivationMonth, ", + "\n PremiumAllocation = DefaultPremiumExperienceAdjustmentFactor, ", + "\n Partition = partition.Id})", + "\n .ToArray() );", + "\n await targetDataSource.CommitAsync();", "\n}" ], "metadata": {}, @@ -498,13 +508,28 @@ "\n ImportArgs[] allArgs;", "\n switch(format)", "\n {", - "\n case ImportFormats.YieldCurve : ", + "\n case ImportFormats.Cashflow:", + "\n case ImportFormats.Actual: ", + "\n case ImportFormats.Opening:", + "\n {", + "\n if(args.Scenario != null) return args.RepeatOnce().ToArray();", + "\n var secondaryArgs = await dataSource.Query() ", + "\n .Where(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && x.Month == args.Month && x.Scenario != null)", + "\n .Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, format)).ToArrayAsync();", + "\n ", + "\n if(secondaryArgs.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", secondaryArgs.Select(x => x.Scenario)));", + "\n allArgs = args.RepeatOnce().Concat(secondaryArgs).ToArray();", + "\n break;", + "\n }", + "\n default: ", "\n {", "\n if(args.Scenario == null) {", - "\n var scenariosWithYieldCurves = await dataSource.Query().Where(x => x.Year == args.Year && x.Month == args.Month && x.Scenario != null)", - "\n .Select(x => x.Scenario).Distinct().ToArrayAsync();", + "\n var scenarios = format switch {", + "\n ImportFormats.YieldCurve => await dataSource.Query().Where(x => x.Year == args.Year && x.Month == args.Month && x.Scenario != null).Select(x => x.Scenario).Distinct().ToArrayAsync(),", + "\n ImportFormats.DataNodeParameter => await dataSource.Query().Where(x => x.Year == args.Year && x.Month == args.Month && x.Scenario != null).Select(x => x.Scenario).Distinct().ToArrayAsync()", + "\n };", "\n var targetPartitions = await dataSource.Query()", - "\n .Where(x => x.Year == args.Year && x.Month == args.Month && !scenariosWithYieldCurves.Contains(x.Scenario)).OrderBy(x => x.Scenario).ToArrayAsync();", + "\n .Where(x => x.Year == args.Year && x.Month == args.Month && !scenarios.Contains(x.Scenario)).OrderBy(x => x.Scenario).ToArrayAsync();", "\n var targetScenarios = targetPartitions.Where(x => x.Scenario != null).Select(x => x.Scenario);", "\n if(targetScenarios.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", targetScenarios));", "\n allArgs = targetPartitions.Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, ImportFormats.Cashflow)).ToArray();", @@ -516,19 +541,8 @@ "\n }", "\n break;", "\n }", - "\n default : ", - "\n {", - "\n if(args.Scenario != null) return args.RepeatOnce().ToArray();", - "\n var secondaryArgs = await DataSource.Query() ", - "\n .Where(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && x.Month == args.Month && x.Scenario != null)", - "\n .Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, ImportFormats.Cashflow)).ToArrayAsync();", - "\n ", - "\n if(secondaryArgs.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", secondaryArgs.Select(x => x.Scenario)));", - "\n allArgs = args.RepeatOnce().Concat(secondaryArgs).ToArray();", - "\n break;", - "\n }", "\n }", - "\n return allArgs.Where(x => (!EnableScenario && x.Scenario == null) || EnableScenario).ToArray();", + "\n return allArgs.Where(x => (!Scenarios.EnableScenario && x.Scenario == null) || Scenarios.EnableScenario).ToArray();", "\n}" ], "metadata": {}, @@ -550,10 +564,11 @@ "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", - "\n if(storage.DefaultPartition != storage.TargetPartition){", - "\n var bestEstimateIvs = await DataSource.LoadPartitionedDataAsync(storage.DefaultPartition);", - "\n ivs = ivs.Where(iv => Math.Abs(iv.Value) >= Precision).ToArray().Concat(", - "\n ivs.Where(iv => Math.Abs(iv.Value) < Precision).Intersect(bestEstimateIvs, EqualityComparer.Instance).Select(iv => iv with {Value = 0.0}).ToArray());", + "\n if(storage.DefaultPartition != storage.TargetPartition) {", + "\n var bestEstimateIvs = await workspaceToCompute.LoadPartitionedDataAsync(storage.DefaultPartition);", + "\n ivs = ivs.Where(iv => Math.Abs(iv.Value) >= Precision).ToArray()", + "\n .Except(bestEstimateIvs, IfrsVariableComparer.Instance(ignoreValue: false))", + "\n .Concat(ivs.Where(x => Math.Abs(x.Value) < Precision).Intersect(bestEstimateIvs, EqualityComparer.Instance).Select(x => x with {Value = 0.0}).ToArray());", "\n }", "\n", "\n workspace.Reset(x => x.ResetType());", @@ -654,10 +669,9 @@ "using static Systemorph.Vertex.Equality.IdentityPropertyExtensions;", "\npublic async static Task ValidateForMandatoryAocSteps(this IWorkspace workspace, IDataSet dataSet, HashSet mandatoryAocSteps)", "\n{ ", - "\n var excludedProperties = new[]{nameof(AocType), nameof(Novelty)};", - "\n var includingProperties = typeof(RawVariable).GetIdentityProperties().Select(x=>x.Name).Except(excludedProperties).ToArray();", + "\n var ignoreProperties = new[]{nameof(AocType), nameof(Novelty)};", "\n var missingAocStepsByIdentityProperties = (await workspace.Query().ToListAsync())", - "\n .GroupBy(x => x.ToStringWith(properties: includingProperties),", + "\n .GroupBy(x => x.ToIdentityString(ignoreProperties),", "\n x => new AocStep(x.AocType, x.Novelty),", "\n (properties, parsedAocSteps) => (properties, mandatoryAocSteps.Except(parsedAocSteps))", "\n );", @@ -787,7 +801,7 @@ "source": [ "# Yield Curves ", "\n", - "\n[Yield curves](../DataModel/DataStructure#yield-curve) are imported for a specific year, month, and scenario (not required if best estimate). This informations are collected in the main section of the file. ", + "\n[Yield curves](../DataModel/DataStructure#yield-curve) are imported for a specific year, month, and scenario (not required if best estimate). This information is collected in the main section of the file. ", "\n", "\nYield curves to be imported are compared against those already present in the DataSource and only the new ones are stored." ], @@ -804,13 +818,12 @@ "\n primaryArgs.ValidateArgsForPeriod();", "\n if(ApplicationMessage.HasErrors()) return Activity.Finish();", "\n var workspace = Workspace.CreateNew();", - "\n workspace.Initialize(x => x.FromSource(options.TargetDataSource).DisableInitialization()", - "\n .DisableInitialization().DisableInitialization());", + "\n workspace.Initialize(x => x.FromSource(options.TargetDataSource).DisableInitialization().DisableInitialization());", "\n", "\n var committedYieldCurves = await options.TargetDataSource.Query().ToArrayAsync();", "\n var hasNameColumn = dataSet.Tables[ImportFormats.YieldCurve].Columns.Any(x => x.ColumnName == nameof(YieldCurve.Name));", - "\n var importLog = await Import.FromDataSet(dataSet).WithType((dataset, datarow) => { ", - "\n var yieldCurve = new YieldCurve { ", + "\n var importLog = await Import.FromDataSet(dataSet).WithType(", + "\n (dataset, datarow) => new YieldCurve {", "\n Currency = datarow.Field(nameof(YieldCurve.Currency)),", "\n Year = primaryArgs.Year,", "\n Month = primaryArgs.Month, ", @@ -818,12 +831,11 @@ "\n Values = datarow.Table.Columns.Where(c => c.ColumnName.StartsWith(nameof(YieldCurve.Values))).OrderBy(c => c.ColumnName.Length).ThenBy(c => c.ColumnName)", "\n .Select(x => datarow.Field(x.ColumnName).CheckStringForExponentialAndConvertToDouble()).ToArray(),", "\n Name = hasNameColumn ? datarow.Field(nameof(YieldCurve.Name)) : default(string)", - "\n };", - "\n return committedYieldCurves.Contains(yieldCurve, YieldCurveComparer.Instance()) ? null : yieldCurve;", - "\n }).WithTarget(workspace).ExecuteAsync(); ", + "\n }", + "\n ).WithTarget(workspace).ExecuteAsync(); ", "\n", "\n if(importLog.Errors.Any()) return Activity.Finish().Merge(importLog); ", - "\n var toCommitYieldCurves = await workspace.Query().ToArrayAsync();", + "\n var toCommitYieldCurves = (await workspace.Query().ToArrayAsync()).Except(committedYieldCurves, YieldCurveComparer.Instance());", "\n if (!toCommitYieldCurves.Any()) {", "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported); ", "\n return Activity.Finish().Merge(importLog);", @@ -838,8 +850,7 @@ "\n foreach (var args in allArgs) {", "\n await CommitPartitionAsync(args, workspace, workspaceToCompute);", "\n var targetPartition = (Guid)(await options.TargetDataSource.Partition.GetKeyForInstanceAsync(args));", - "\n var defaultPartition = (Guid)(await options.TargetDataSource.Partition.GetKeyForInstanceAsync(", - "\n new ImportArgs(args.ReportingNode, args.Year, args.Month, default(Periodicity), null, ImportFormats.Cashflow) ));", + "\n var defaultPartition = (Guid)(await options.TargetDataSource.Partition.GetKeyForInstanceAsync(args with {Scenario = null}));", "\n if(ApplicationMessage.HasErrors()) return Activity.Finish().Merge(importLog);", "\n ", "\n // Avoid starting the computation if no best estimate cash flow has ever been imported ", @@ -890,20 +901,20 @@ { "cell_type": "code", "source": [ - "public async Task UploadDataNodesToWorkspaceAsync(IDataSet dataSet, IWorkspace workspace)", + "public async Task UploadDataNodesToWorkspaceAsync(IDataSet dataSet, IWorkspace workspace, IDataSource targetDataSource)", "\n{", "\n workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\n workspace.Initialize(x => x.FromSource(DataSource)", + "\n workspace.Initialize(x => x.FromSource(targetDataSource)", "\n .DisableInitialization()", "\n .DisableInitialization()", "\n .DisableInitialization()", "\n .DisableInitialization());", "\n ", "\n Activity.Start();", - "\n var args = await GetArgsAndCommitPartitionAsync(dataSet);", + "\n var args = await GetArgsAndCommitPartitionAsync(dataSet, targetDataSource);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", - "\n var storage = new ParsingStorage(args, DataSource, workspace);", + "\n var storage = new ParsingStorage(args, targetDataSource, workspace);", "\n await storage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", @@ -999,12 +1010,12 @@ "source": [ "Import.DefineFormat(ImportFormats.DataNode, async (options, dataSet) => {", "\n var workspace = Workspace.CreateNew();", - "\n var log = await UploadDataNodesToWorkspaceAsync(dataSet, workspace);", + "\n var log = await UploadDataNodesToWorkspaceAsync(dataSet, workspace, options.TargetDataSource);", "\n var partition = (Guid)workspace.Partition.GetCurrent(nameof(PartitionByReportingNode));", - "\n await workspace.CommitToAsync(DataSource, partition);", - "\n await workspace.CommitToAsync(DataSource, partition);", - "\n await workspace.CommitToAsync(DataSource, partition);", - "\n await workspace.CommitToAsync(DataSource, partition);", + "\n await workspace.CommitToAsync(options.TargetDataSource, partition);", + "\n await workspace.CommitToAsync(options.TargetDataSource, partition);", + "\n await workspace.CommitToAsync(options.TargetDataSource, partition);", + "\n await workspace.CommitToAsync(options.TargetDataSource, partition);", "\n return log;", "\n});" ], @@ -1024,27 +1035,18 @@ { "cell_type": "code", "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public async Task UploadDataNodeStateToWorkspaceAsync(IDataSet dataSet, IWorkspace workspace)", + "public async Task UploadDataNodeStateToWorkspaceAsync(IDataSet dataSet, IWorkspace workspace, IDataSource targetDataSource)", "\n{", "\n workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\n workspace.Initialize(x => x.FromSource(DataSource)", + "\n workspace.Initialize(x => x.FromSource(targetDataSource)", "\n .DisableInitialization()", "\n .DisableInitialization()", "\n .DisableInitialization());", "\n Activity.Start();", - "\n var args = await GetArgsAndCommitPartitionAsync(dataSet) with {ImportFormat = ImportFormats.DataNodeState};", + "\n var args = await GetArgsAndCommitPartitionAsync(dataSet, targetDataSource) with {ImportFormat = ImportFormats.DataNodeState};", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", - "\n var storage = new ParsingStorage(args, DataSource, workspace);", + "\n var storage = new ParsingStorage(args, targetDataSource, workspace);", "\n await storage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", @@ -1071,8 +1073,8 @@ "source": [ "Import.DefineFormat(ImportFormats.DataNodeState, async (options, dataSet) => {", "\n var workspace = Workspace.CreateNew();", - "\n var log = await UploadDataNodeStateToWorkspaceAsync(dataSet, workspace);", - "\n await workspace.CommitToAsync(DataSource, (Guid)workspace.Partition.GetCurrent(nameof(PartitionByReportingNode)), snapshot: false); ", + "\n var log = await UploadDataNodeStateToWorkspaceAsync(dataSet, workspace, options.TargetDataSource);", + "\n await workspace.CommitToAsync(options.TargetDataSource, (Guid)workspace.Partition.GetCurrent(nameof(PartitionByReportingNode)), snapshot: false); ", "\n return log;", "\n});" ], @@ -1092,21 +1094,12 @@ { "cell_type": "code", "source": [ - "public async Task UploadDataNodeParameterToWorkspaceAsync(IDataSet dataSet, Guid targetPartitionByReportingNodeId, IWorkspace workspace)", + "public async Task UploadDataNodeParameterToWorkspaceAsync(IDataSet dataSet, ImportArgs args, IWorkspace workspace, IDataSource targetDataSource)", "\n{", - "\n workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\n workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization()", - "\n .DisableInitialization()", - "\n .DisableInitialization());", "\n Activity.Start();", - "\n var args = await GetArgsAndCommitPartitionAsync(dataSet) with {ImportFormat = ImportFormats.DataNodeParameter};", - "\n if(Activity.HasErrors()) return Activity.Finish();", - "\n", - "\n var storage = new ParsingStorage(args, DataSource, workspace);", + "\n var storage = new ParsingStorage(args, targetDataSource, workspace);", "\n await storage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", - "\n", "\n var singleDataNode = new List();", "\n var interDataNode = new List<(string,string)>();", "\n ", @@ -1125,8 +1118,8 @@ "\n return new SingleDataNodeParameter {", "\n Year = args.Year,", "\n Month = args.Month,", + "\n Scenario = args.Scenario,", "\n Partition = storage.TargetPartitionByReportingNode.Id,", - "\n", "\n DataNode = dataNode,", "\n PremiumAllocation = (datarow.Field(nameof(SingleDataNodeParameter.PremiumAllocation)))", "\n .ToString().CheckStringForExponentialAndConvertToDouble(),", @@ -1160,6 +1153,7 @@ "\n return new InterDataNodeParameter {", "\n Year = args.Year,", "\n Month = args.Month,", + "\n Scenario = args.Scenario,", "\n Partition = storage.TargetPartitionByReportingNode.Id,", "\n DataNode = dataNodes[0],", "\n LinkedDataNode = dataNodes[1],", @@ -1169,7 +1163,6 @@ "\n .WithTarget(workspace)", "\n .ExecuteAsync();", "\n ", - "\n targetPartitionByReportingNodeId = storage.TargetPartitionByReportingNode.Id;", "\n return Activity.Finish().Merge(importLog);", "\n}" ], @@ -1181,13 +1174,53 @@ "cell_type": "code", "source": [ "Import.DefineFormat(ImportFormats.DataNodeParameter, async (options, dataSet) => {", - "\n Guid partitionId = new Guid();", + "\n Activity.Start();", + "\n var primaryArgs = GetArgsFromMain(dataSet) with {ImportFormat = ImportFormats.DataNodeParameter};", + "\n primaryArgs.ValidateArgsForPeriod();", + "\n if(ApplicationMessage.HasErrors()) return Activity.Finish();", "\n var workspace = Workspace.CreateNew();", - "\n var log = await UploadDataNodeParameterToWorkspaceAsync(dataSet, partitionId, workspace);", - "\n await workspace.CommitToAsync(DataSource, partitionId, snapshot: false);", - "\n await workspace.CommitToAsync(DataSource, partitionId, snapshot: false); ", - "\n ", - "\n return log;", + "\n workspace.Initialize(x => x.FromSource(options.TargetDataSource).DisableInitialization().DisableInitialization());", + "\n", + "\n var committedParameters = await options.TargetDataSource.Query().ToArrayAsync();", + "\n var log = await UploadDataNodeParameterToWorkspaceAsync(dataSet, primaryArgs, workspace, options.TargetDataSource); ", + "\n", + "\n if(log.Errors.Any()) return Activity.Finish().Merge(log); ", + "\n var toCommitParameters = (await workspace.Query().ToArrayAsync()).Except(committedParameters, ParametersComparer.Instance());", + "\n if (!toCommitParameters.Any()) {", + "\n ApplicationMessage.Log(Warning.VariablesAlreadyImported); ", + "\n return Activity.Finish().Merge(log);", + "\n }", + "\n", + "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.DataNodeParameter);", + "\n var targetDataNodes = toCommitParameters.Select(x => x.DataNode)", + "\n .Concat(toCommitParameters.Where(x => x is InterDataNodeParameter).Select(x => ((InterDataNodeParameter)x).LinkedDataNode)).ToHashSet();", + "\n var workspaceToCompute = Workspace.CreateNew();", + "\n workspaceToCompute.Initialize(x => x.FromSource(options.TargetDataSource).DisableInitialization());", + "\n", + "\n foreach (var args in allArgs) { ", + "\n await CommitPartitionAsync(args, workspace, workspaceToCompute);", + "\n var targetPartition = (Guid)(await options.TargetDataSource.Partition.GetKeyForInstanceAsync(args));", + "\n var defaultPartition = (Guid)(await options.TargetDataSource.Partition.GetKeyForInstanceAsync(args with {Scenario = null}));", + "\n var previousPartition = (Guid)(await options.TargetDataSource.Partition.GetKeyForInstanceAsync(args with {Scenario = null, Year = args.Year-1, Month = 12}));", + "\n await options.TargetDataSource.Partition.SetAsync(null);", + "\n if(ApplicationMessage.HasErrors()) return Activity.Finish().Merge(log);", + "\n ", + "\n // Avoid starting the computation if no best estimate cash flow and actuals has ever been imported ", + "\n if(args.Scenario == null && !(await options.TargetDataSource.Query().Where(x => x.Partition == targetPartition).Take(1).ToArrayAsync()).Any() &&", + "\n !(await options.TargetDataSource.Query().Where(x => x.Partition == targetPartition).Take(1).ToArrayAsync()).Any()) continue;", + "\n", + "\n // Only nominals corresponding to the target data nodes are added to the workspace", + "\n var nominals = await options.TargetDataSource.Query().Where(x => targetDataNodes.Contains(x.DataNode) && ", + "\n (x.Partition == targetPartition || x.Partition == defaultPartition || x.Partition == previousPartition)).ToArrayAsync();", + "\n if(nominals.Any()) await workspaceToCompute.UpdateAsync(nominals);", + "\n", + "\n log = log.Merge(await ComputeAsync(args, workspace, workspaceToCompute, false));", + "\n if(log.Errors.Any()) return Activity.Finish().Merge(log);", + "\n }", + "\n", + "\n await workspaceToCompute.UpdateAsync(toCommitParameters);", + "\n await workspaceToCompute.CommitToTargetAsync(options.TargetDataSource);", + "\n return Activity.Finish().Merge(log);", "\n});" ], "metadata": {}, @@ -1212,13 +1245,13 @@ { "cell_type": "code", "source": [ - "public async Task ParseCashflowsToWorkspaceAsync(IDataSet dataSet, ImportArgs args, IWorkspace workspace)", + "public async Task ParseCashflowsToWorkspaceAsync(IDataSet dataSet, ImportArgs args, IWorkspace workspace, IDataSource targetDataSource)", "\n{", "\n workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\n workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());", + "\n workspace.Initialize(x => x.FromSource(targetDataSource).DisableInitialization().DisableInitialization());", "\n ", "\n Activity.Start();", - "\n var parsingStorage = new ParsingStorage(args, DataSource, workspace);", + "\n var parsingStorage = new ParsingStorage(args, targetDataSource, workspace);", "\n await parsingStorage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", @@ -1286,24 +1319,24 @@ "source": [ "Import.DefineFormat(ImportFormats.Cashflow, async (options, dataSet) => {", "\n Activity.Start();", - "\n var primaryArgs = await GetArgsAndCommitPartitionAsync(dataSet) with {ImportFormat = ImportFormats.Cashflow};", + "\n var primaryArgs = await GetArgsAndCommitPartitionAsync(dataSet, options.TargetDataSource) with {ImportFormat = ImportFormats.Cashflow};", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.Cashflow);", - "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Cashflow, primaryArgs);", + "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Cashflow, primaryArgs, options.TargetDataSource);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n var workspace = Workspace.CreateNew();", - "\n var log = await ParseCashflowsToWorkspaceAsync(dataSet, primaryArgs, workspace);", + "\n var log = await ParseCashflowsToWorkspaceAsync(dataSet, primaryArgs, workspace, options.TargetDataSource);", "\n if(log.Errors.Any()) return Activity.Finish().Merge(log);", "\n", "\n var workspaceToCompute = Workspace.CreateNew();", - "\n workspaceToCompute.Initialize(x => x.FromSource(DataSource));", + "\n workspaceToCompute.Initialize(x => x.FromSource(options.TargetDataSource));", "\n foreach (var args in allArgs) {", "\n log = log.Merge(await ComputeAsync(args, workspace, workspaceToCompute, args == primaryArgs));", "\n if(log.Errors.Any()) return Activity.Finish().Merge(log);", "\n }", - "\n await workspaceToCompute.CommitToTargetAsync(DataSource);", + "\n await workspaceToCompute.CommitToTargetAsync(options.TargetDataSource);", "\n return Activity.Finish().Merge(log); ", "\n});" ], @@ -1331,15 +1364,15 @@ { "cell_type": "code", "source": [ - "public async Task ParseActualsToWorkspaceAsync(IDataSet dataSet, ImportArgs args, IWorkspace workspace)", + "public async Task ParseActualsToWorkspaceAsync(IDataSet dataSet, ImportArgs args, IWorkspace workspace, IDataSource targetDataSource)", "\n{", "\n workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\n workspace.Initialize(x => x.FromSource(DataSource)", + "\n workspace.Initialize(x => x.FromSource(targetDataSource)", "\n .DisableInitialization()", "\n .DisableInitialization());", "\n ", "\n Activity.Start();", - "\n var parsingStorage = new ParsingStorage(args, DataSource, workspace);", + "\n var parsingStorage = new ParsingStorage(args, targetDataSource, workspace);", "\n await parsingStorage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", @@ -1387,24 +1420,24 @@ "source": [ "Import.DefineFormat(ImportFormats.Actual, async (options, dataSet) => {", "\n Activity.Start();", - "\n var primaryArgs = await GetArgsAndCommitPartitionAsync(dataSet) with {ImportFormat = ImportFormats.Actual};", + "\n var primaryArgs = await GetArgsAndCommitPartitionAsync(dataSet, options.TargetDataSource) with {ImportFormat = ImportFormats.Actual};", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n var allArgs = await GetAllArgsAsync(primaryArgs, options.TargetDataSource, ImportFormats.Actual);", - "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Actual, primaryArgs);", + "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Actual, primaryArgs, options.TargetDataSource);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n var workspace = Workspace.CreateNew();", - "\n var log = await ParseActualsToWorkspaceAsync(dataSet, primaryArgs, workspace);", + "\n var log = await ParseActualsToWorkspaceAsync(dataSet, primaryArgs, workspace, options.TargetDataSource);", "\n if(log.Errors.Any()) return Activity.Finish().Merge(log);", "\n", "\n var workspaceToCompute = Workspace.CreateNew();", - "\n workspaceToCompute.Initialize(x => x.FromSource(DataSource));", + "\n workspaceToCompute.Initialize(x => x.FromSource(options.TargetDataSource));", "\n foreach (var args in allArgs) {", "\n log = log.Merge(await ComputeAsync(args, workspace, workspaceToCompute, false)); ", "\n if(log.Errors.Any()) return Activity.Finish().Merge(log);", "\n }", - "\n await workspaceToCompute.CommitToTargetAsync(DataSource);", + "\n await workspaceToCompute.CommitToTargetAsync(options.TargetDataSource);", "\n return Activity.Finish().Merge(log);", "\n});" ], @@ -1427,16 +1460,16 @@ { "cell_type": "code", "source": [ - "public async Task ParseSimpleValueToWorkspaceAsync(IDataSet dataSet, ImportArgs args, Guid targetPartitionByReportingNodeAndPeriodId, IWorkspace workspace)", + "public async Task ParseSimpleValueToWorkspaceAsync(IDataSet dataSet, ImportArgs args, Guid targetPartitionByReportingNodeAndPeriodId, IWorkspace workspace, IDataSource targetDataSource)", "\n{", "\n workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\n workspace.Initialize(x => x.FromSource(DataSource)", + "\n workspace.Initialize(x => x.FromSource(targetDataSource)", "\n .DisableInitialization()", "\n .DisableInitialization());", "\n ", "\n Activity.Start();", "\n var importFormat = args.ImportFormat;", - "\n var parsingStorage = new ParsingStorage(args, DataSource, workspace);", + "\n var parsingStorage = new ParsingStorage(args, targetDataSource, workspace);", "\n await parsingStorage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish(); ", "\n", @@ -1496,20 +1529,20 @@ "source": [ "Import.DefineFormat(ImportFormats.SimpleValue, async (options, dataSet) => {", "\n Activity.Start();", - "\n var args = await GetArgsAndCommitPartitionAsync(dataSet) with {ImportFormat = ImportFormats.SimpleValue};", + "\n var args = await GetArgsAndCommitPartitionAsync(dataSet, options.TargetDataSource) with {ImportFormat = ImportFormats.SimpleValue};", "\n if(Activity.HasErrors()) return Activity.Finish();", - "\n await DataNodeFactoryAsync(dataSet, ImportFormats.SimpleValue, args);", + "\n await DataNodeFactoryAsync(dataSet, ImportFormats.SimpleValue, args, options.TargetDataSource);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n Guid partitionId = new Guid();", "\n var workspace = Workspace.CreateNew();", - "\n var parsingLog = await ParseSimpleValueToWorkspaceAsync(dataSet, args, partitionId, workspace);", + "\n var parsingLog = await ParseSimpleValueToWorkspaceAsync(dataSet, args, partitionId, workspace, options.TargetDataSource);", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n", "\n workspace.Query().Select(v => new {v.DataNode, v.AccidentYear}).Distinct();", "\n", "\n var targetDataNodes = workspace.Query().Select(v => v.DataNode).Distinct().ToArray();", - "\n await workspace.CommitToAsync(DataSource, partitionId, snapshot : true,", + "\n await workspace.CommitToAsync(options.TargetDataSource, partitionId, snapshot : true,", "\n filter : x => targetDataNodes.Contains(x.DataNode));", "\n return Activity.Finish().Merge(parsingLog);", "\n});" @@ -1534,21 +1567,21 @@ "source": [ "Import.DefineFormat(ImportFormats.Opening, async (options, dataSet) => {", "\n Activity.Start();", - "\n var args = await GetArgsAndCommitPartitionAsync(dataSet) with {ImportFormat = ImportFormats.Opening};", + "\n var args = await GetArgsAndCommitPartitionAsync(dataSet, options.TargetDataSource) with {ImportFormat = ImportFormats.Opening};", "\n if(Activity.HasErrors()) return Activity.Finish();", - "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Opening, args);", + "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Opening, args, options.TargetDataSource);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n Guid partitionId = new Guid();", "\n var workspace = Workspace.CreateNew();", - "\n var parsingLog = await ParseSimpleValueToWorkspaceAsync(dataSet, args, partitionId, workspace);", + "\n var parsingLog = await ParseSimpleValueToWorkspaceAsync(dataSet, args, partitionId, workspace, options.TargetDataSource);", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n", "\n var workspaceToCompute = Workspace.CreateNew();", - "\n workspaceToCompute.Initialize(x => x.FromSource(DataSource));", + "\n workspaceToCompute.Initialize(x => x.FromSource(options.TargetDataSource));", "\n var calculationLog = await ComputeAsync(args, workspace, workspaceToCompute, false); ", "\n if(calculationLog.Errors.Any()) return Activity.Finish().Merge(calculationLog);", - "\n await workspaceToCompute.CommitToTargetAsync(DataSource, x => x.SnapshotMode());", + "\n await workspaceToCompute.CommitToTargetAsync(options.TargetDataSource, x => x.SnapshotMode());", "\n return Activity.Finish().Merge(parsingLog).Merge(calculationLog);", "\n})" ], diff --git a/ifrs17/OverviewCalculationEngine.ipynb b/ifrs17/OverviewCalculationEngine.ipynb index 482b71d8..df10c230 100644 --- a/ifrs17/OverviewCalculationEngine.ipynb +++ b/ifrs17/OverviewCalculationEngine.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "GWa_XHVeh026hh_HafLWog", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb new file mode 100644 index 00000000..6e2fe467 --- /dev/null +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -0,0 +1,281 @@ +{ + "metadata": { + "authors": [], + "id": "XdWtZAfDUkKgJxSlrhCSSw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Import References" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"ReportMutableScopesInteractive\"", + "\n#!import \"ParameterReportsQueries\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Parameter Forms Entity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ParameterReportFormsEntity : MutableScopeWithWorkspace", + "\nwhere TStorage : ReportStorage", + "\n{", + "\n [DropdownMethod(nameof(GetParameterReportTypes))]", + "\n string ReportType{get; set;}", + "\n", + "\n string[] GetParameterReportTypes() => typeof(ParameterReportType).GetAllPublicConstantValues();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Parameter Report Scope" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface ParameterReportScope: IMutableScope, ", + "\n ReportingNodeFormsEntity, ", + "\n MonthlyPeriodFormsEntity, ", + "\n ScenarioParameterFormsEntity,", + "\n CurrencyFormsEntity, ", + "\n ParameterReportFormsEntity", + "\n{", + "\n protected IPivotFactory report => GetStorage().Report;", + "\n protected IExportVariable export => GetStorage().Export;", + "\n protected int headerColumnWidthValue => 250;", + "\n", + "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); ", + "\n", + "\n", + "\n ImportArgs GetArgs() => new ImportArgs(ReportingNode, Year, Month, default, Scenario, default); ", + "\n", + "\n async Task GetDataNodeReport()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var data = await workspace.GetDataNodeDataReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.Portfolio)", + "\n .GroupRowsBy(x => x.DataNode)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GetDataNodeStatesReport()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var data = await workspace.GetDataNodeStateReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.GroupOfContract)", + "\n .GroupColumnsBy(x => x.Period)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GetYieldCurvesReport()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var data = await workspace.GetYieldCurveReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.GroupOfContract)", + "\n .GroupColumnsBy(x => x.YieldCurveType)", + "\n .GroupColumnsBy(x => x.Period)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GetSingleDataNodeReport()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var data = await workspace.GetSingleDataNodeReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.GroupOfContract)", + "\n .GroupColumnsBy(x => x.Period)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GetInterDataNodeParametersReport()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var data = await workspace.GetInterDataNodeParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.GroupOfContract)", + "\n .GroupRowsBy(x => x.LinkedDataNode)", + "\n .GroupColumnsBy(x => x.Period)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GetPartnerRatingReport()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var data = await workspace.GetPartnerRatingsReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.Partner)", + "\n .GroupColumnsBy(x => x.Period)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GetDefaultRatesReport()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var data = await workspace.GetCreditDefaultRatesReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.CreditRiskRating)", + "\n .GroupColumnsBy(x => x.Period)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task ToReport() => ReportType switch", + "\n {", + "\n ParameterReportType.DataNodeReport => await GetDataNodeReport(), ", + "\n ParameterReportType.DataNodeStateReport => await GetDataNodeStatesReport(), ", + "\n ParameterReportType.YieldCurves => await GetYieldCurvesReport(), ", + "\n ParameterReportType.SingleDataNodeReport => await GetSingleDataNodeReport(), ", + "\n ParameterReportType.InterDataNodeParameters => await GetInterDataNodeParametersReport(), ", + "\n ParameterReportType.PartnerRating => await GetPartnerRatingReport(), ", + "\n ParameterReportType.PartnerDefaultRates => await GetDefaultRatesReport(),", + "\n _ => null", + "\n };", + "\n", + "\n void Init(){", + "\n var task = InitReportStorageScopeAsync();", + "\n task.Wait();", + "\n }", + "\n", + "\n async Task InitReportStorageScopeAsync() { ", + "\n await GetStorage().InitializeReportIndependentCacheAsync();", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Interactive Parameter " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "class InteractiveParameterReports", + "\n{", + "\n private IPivotFactory report;", + "\n private IExportVariable export;", + "\n private InteractiveObjectVariable interactiveObject;", + "\n public ReportStorage storage;", + "\n", + "\n private IDictionary interactiveObjectCache = new Dictionary();", + "\n ", + "\n public InteractiveParameterReports(IWorkspace workspace, ", + "\n IPivotFactory report, ", + "\n IExportVariable export, ", + "\n InteractiveObjectVariable interactiveObject)", + "\n {", + "\n this.report = report;", + "\n this.export = export;", + "\n this.interactiveObject = interactiveObject;", + "\n this.storage = new ReportStorage(workspace, report, export);", + "\n }", + "\n", + "\n public void Reset(IWorkspace workspace)", + "\n {", + "\n storage = new ReportStorage(workspace, report, export);", + "\n interactiveObjectCache = new Dictionary() {};", + "\n }", + "\n", + "\n public ParameterReportScope GetReportScope(string name = null) where T : ParameterReportScope => ", + "\n interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", + "\n", + "\n public InteractiveObjectView GetFormsEntity(string name = null)", + "\n where T : ParameterReportScope", + "\n {", + "\n var key = name ?? typeof(T).Name;", + "\n if (!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", ", + "\n _ => GetReportScope(name : \"ParameterReports\"));", + "\n return ret;", + "\n }", + "\n", + "\n public InteractiveObjectView GetReport(string name = null)", + "\n where T : ParameterReportScope", + "\n {", + "\n var key = name ?? typeof(T).Name;", + "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, ", + "\n _ => GetReportScope(name : \"ParameterReports\").ToReport());", + "\n return ret;", + "\n }", + "\n", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Report/ParameterReportsQueries.ipynb b/ifrs17/Report/ParameterReportsQueries.ipynb index 229d5ae6..93780429 100644 --- a/ifrs17/Report/ParameterReportsQueries.ipynb +++ b/ifrs17/Report/ParameterReportsQueries.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "GwzN3m9sLkuSwy-TfM130g", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index aa805243..ef268227 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "6W4kCJVgzESvKeBwvjKoKA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -30,7 +29,8 @@ "cell_type": "code", "source": [ "#!import \"../Utils/EqualityComparers\"", - "\n#!import \"../Utils/Queries\"" + "\n#!import \"../Utils/Queries\"", + "\n#!import \"../Utils/ActivityLog\"" ], "metadata": {}, "execution_count": 0, @@ -116,7 +116,7 @@ "source": [ "public static async Task QueryReportVariablesSingleScenarioAsync(this IWorkspace workspace, (int Year, int Month, string ReportingNode, string Scenario) args ) {", "\n", - "\n await workspace.Partition.SetAsync(new { ReportingNode = args.ReportingNode, Scenario = (string)null}); // TODO: Scenario from args + relaxed query ", + "\n await workspace.Partition.SetAsync(new { ReportingNode = args.ReportingNode, Scenario = (string)null});", "\n await workspace.Partition.SetAsync(new { ReportingNode = args.ReportingNode, Scenario = args.Scenario, Year = args.Year, Month = args.Month });", "\n ", "\n var reportVariables = await workspace.Query()", @@ -172,11 +172,52 @@ "cell_type": "code", "source": [ "public static async Task> QueryReportVariablesAsync(this IWorkspace workspace, (int Year, int Month, string ReportingNode, string Scenario) args ) {", - "\n ReportVariable[] reportVariables = new ReportVariable[0];", - "\n if(args.Scenario != null) ", - "\n reportVariables = (await workspace.QueryReportVariablesSingleScenarioAsync((args.Year, args.Month, args.ReportingNode, null)));", - "\n return (await workspace.QueryReportVariablesSingleScenarioAsync((args.Year, args.Month, args.ReportingNode, args.Scenario)))", - "\n .Union(reportVariables.Select(x => x with {Scenario = args.Scenario}), EqualityComparer.Instance).ToArray();", + "\n var bestEstimate = (await workspace.QueryReportVariablesSingleScenarioAsync((args.Year, args.Month, args.ReportingNode, null)));", + "\n return (args.Scenario == null) ", + "\n ? bestEstimate", + "\n : (await workspace.QueryReportVariablesSingleScenarioAsync((args.Year, args.Month, args.ReportingNode, args.Scenario)))", + "\n .Union(bestEstimate.Select(x => x with {Scenario = args.Scenario}), EqualityComparer.Instance).ToArray();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Mutable Reporting Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static string ParseReportingPeriodToDisplayString(int year, int periodOfYear, char separator) => $\"{year} {separator}{periodOfYear}\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static string ParseDimensionToDisplayString(string systemName, string displayName) => $\"{displayName} ({systemName})\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static async Task<(IDictionary, IReadOnlyCollection)> GetAutocompleteMappings (this IQuerySource querySource, bool hasNullAsFirstValue = default) where T : KeyedDimension {", + "\n var query = await querySource.Query().Select(x => new { x.SystemName, GuiName = ParseDimensionToDisplayString(x.SystemName, x.DisplayName), Order = 0 }).ToArrayAsync(); //TODO extentions: populate order if type T is an orderedDimension. If it is a Hierarchical dimension then the order ", + "\n var mappingDictionary = query.SelectMany(x => new [] { new {GuiName = x.SystemName, x.SystemName}, new {GuiName = x.GuiName, x.SystemName} }).ToDictionary(x => x.GuiName, x => x.SystemName);", + "\n var orderedDropDownValues = query.OrderBy(x => x.Order).ThenBy(x => x.GuiName).Select(x => x.GuiName);", + "\n return (mappingDictionary, (hasNullAsFirstValue ? new string[]{ null }.Concat(orderedDropDownValues) : orderedDropDownValues).ToArray());", "\n}" ], "metadata": {}, diff --git a/ifrs17/Report/ReportMutableScopes.ipynb b/ifrs17/Report/ReportMutableScopes.ipynb index 358bbe69..d1d92625 100644 --- a/ifrs17/Report/ReportMutableScopes.ipynb +++ b/ifrs17/Report/ReportMutableScopes.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "DRRKzr_vVUKWocwP6A9-vw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -111,7 +112,8 @@ "\n int Year => ReportingPeriod.Year;", "\n int Month => ReportingPeriod.Month;", "\n string ReportingNode { get; set; }", - "\n string Scenario { get; set; }", + "\n string Scenario { get; set; } // TODO: Enable dropdown selection including All and Delta", + "\n string Comparison { get; set; } // TODO: only for scenario at the beginning, meant to enable general purpose comparisons ", "\n CurrencyType CurrencyType { get; set; }", "\n ", "\n ((int Year, int Month) ReportingPeriod, string ReportingNode, string Scenario, CurrencyType) ShowSettings => (ReportingPeriod, ReportingNode, Scenario, CurrencyType);", @@ -121,11 +123,22 @@ "\n", "\n IEnumerable RowSlices { get; set; }", "\n protected string[] defaultRowSlices => new string[] { };", - "\n protected string[] rowSlices => RowSlices is null ? defaultRowSlices : defaultRowSlices.Concat(RowSlices).Where(x => !forbiddenSlices.Contains(x)).ToArray();", + "\n protected string[] rowSlices => RowSlices is null ", + "\n ? defaultRowSlices ", + "\n : defaultRowSlices.Where(cs => !RowSlices.Contains(cs)).Concat(RowSlices).Where(x => !forbiddenSlices.Contains(x)).ToArray();", "\n", "\n IEnumerable ColumnSlices { get; set; }", - "\n protected string[] defaultColumnSlices => new string[] { };", - "\n protected string[] columnSlices => ColumnSlices is null ? defaultColumnSlices : defaultColumnSlices.Where(cs => !ColumnSlices.Contains(cs)).Concat(ColumnSlices).Where(x => !forbiddenSlices.Contains(x)).ToArray();", + "\n protected string[] defaultColumnSlices => new string[] { };", + "\n protected string[] columnSlices { get{", + "\n var slices = ColumnSlices is null ", + "\n ? defaultColumnSlices ", + "\n : defaultColumnSlices.Where(cs => !ColumnSlices.Contains(cs)).Concat(ColumnSlices).Where(x => !forbiddenSlices.Contains(x)).ToArray();", + "\n return Scenario == \"All\" || Scenario == \"Delta\"", + "\n ? slices.Concat(nameof(Scenario).RepeatOnce()).ToArray() ", + "\n : Scenario is null ? slices : nameof(Scenario).RepeatOnce().Concat(slices).ToArray();", + "\n }}", + "\n", + "\n // Identities", "\n protected HashSet<(ReportIdentity, CurrencyType)> GetIdentities() => GetStorage().GetIdentities(ReportingPeriod, ReportingNode, Scenario, CurrencyType);", "\n ", "\n // Filter", @@ -135,27 +148,26 @@ "\n // Scope Initialization", "\n async Task InitAsync() {", "\n var mostRecentPartition = (await workspace.Query().Where(x => x.Scenario == null).OrderBy(x => x.Year).ThenBy(x => x.Month).ToArrayAsync()).Last(); ", - "\n ", "\n ReportingPeriod = (mostRecentPartition.Year, mostRecentPartition.Month);", "\n ReportingNode = (await workspace.Query().Where(x => x.Parent == null).ToArrayAsync()).First().SystemName; // TODO: change once user permissions are available", "\n Scenario = null;", "\n CurrencyType = CurrencyType.Contractual;", "\n await GetStorage().InitializeReportIndependentCacheAsync();", - "\n }", + "\n } ", + "\n", + "\n //Report", "\n public IDataCube GetDataCube() => default;", "\n protected int headerColumnWidthValue => 250;", + "\n public Task ToReportAsync => GetReportTaskAsync();", "\n private async Task GetReportTaskAsync() {", - "\n await GetStorage().InitializeAsync(ReportingPeriod, ReportingNode, Scenario, CurrencyType);", - "\n ", - "\n return await report.ForDataCube(GetDataCube())", + "\n await GetStorage().InitializeAsync(ReportingPeriod, ReportingNode, Scenario, CurrencyType); ", + "\n return await report.ForDataCube(GetScope((ReportingPeriod, ReportingNode, Scenario, CurrencyType, Identity, dataFilter)).Cube)", "\n .WithQuerySource(workspace)", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices)", "\n .ReportGridOptions(headerColumnWidth: headerColumnWidthValue)", "\n .ExecuteAsync();", "\n }", - "\n", - "\n Task ToReportAsync => GetReportTaskAsync();", "\n}", "\n", "\npublic interface PvReport : IIfrs17Report {", @@ -214,7 +226,7 @@ "\n", "\npublic interface ExpAdjReport : IIfrs17Report {", "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"EstimateType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"AmountType\" };", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\"};", "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", "\n ? GetScopes(GetIdentities()).Aggregate().ActuarialExperienceAdjustment", "\n : GetScopes(GetIdentities()).Aggregate().ActuarialExperienceAdjustment.Filter(dataFilter);", @@ -279,7 +291,21 @@ "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", "\n ? GetScopes(GetIdentities()).Aggregate().FinancialPerformance", "\n : GetScopes(GetIdentities()).Aggregate().FinancialPerformance.Filter(dataFilter);", - "\n}" + "\n}", + "\n", + "\npublic interface Data : IMutableScope<((int year, int month) period, string reportingNode, string scenario, CurrencyType currencyType, ", + "\n string reportType, (string filterName, object filterValue)[] dataFilter)> ", + "\n{", + "\n IDataCube Cube { get{", + "\n var data = GetScope(Identity.reportType).GetDataCube();", + "\n // TODO: suggestion to place the filter here instead of having it in every applicability scope", + "\n if(Identity.scenario != Scenarios.All && Identity.scenario != Scenarios.Delta) return data;", + "\n if(Identity.scenario == Scenarios.All) return data.Select(x => x.Scenario == null? x with {Scenario = Scenarios.Default } : x).ToDataCube();", + "\n var bestEstimateById = data.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", + "\n return data.Select(x => x.Scenario == null ? x with { Scenario = Scenarios.Default } ", + "\n : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0.0) }).ToDataCube();", + "\n }}", + "\n} " ], "metadata": {}, "execution_count": 0, @@ -310,18 +336,23 @@ "\n{", "\n private Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes;", "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", + "\n private IExportVariable export;", "\n private ReportStorage Storage;", "\n private ReportUniverse reportUniverse;", "\n ", "\n //reset", - "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report);", + "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report, export);", "\n", "\n //constructor", - "\n public Ifrs17 (IWorkspace workspace, Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report)", + "\n public Ifrs17 (IWorkspace workspace, ", + "\n Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes, ", + "\n Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report,", + "\n IExportVariable export)", "\n {", "\n this.scopes = scopes; ", - "\n this.report = report; ", - "\n Storage = new ReportStorage(workspace, report);", + "\n this.report = report;", + "\n this.export = export;", + "\n Storage = new ReportStorage(workspace, report, export);", "\n reportUniverse = scopes.ForSingleton().WithStorage(Storage).ToScope();", "\n }", "\n", diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb new file mode 100644 index 00000000..d73da2e6 --- /dev/null +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -0,0 +1,1104 @@ +{ + "metadata": { + "authors": [], + "id": "SuppWclYnkyuC51Dlg-6Rg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "", + "\n

Report Mutable Scopes

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This notebook contains the set up of mutable scopes used to achieve high interactivity with reports." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# References", + "\nLibraries and other notebooks which are needed for this notebook are imported below." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"ReportScopes\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "using Systemorph.Vertex.Pivot.Builder.Interfaces;", + "\nusing Systemorph.InteractiveObjects;", + "\nusing Systemorph.Vertex.Session;", + "\nusing Systemorph.Vertex.Export;", + "\nusing Systemorph.Vertex.Export.Factory;", + "\nusing Systemorph.Vertex.InteractiveObjects;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Form Entity Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Helper Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface MutableScopeWithWorkspace : IMutableScopeWithStorage ", + "\nwhere TStorage : ReportStorage", + "\n{", + "\n protected IWorkspace workspace => GetStorage().Workspace; ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Currency Type" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface CurrencyFormsEntity : IMutableScope {", + "\n [DropdownEnum(typeof(CurrencyType))]", + "\n CurrencyType CurrencyType { get; set; } ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ScenarioFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage ", + "\n{", + "\n [DropdownMethod(nameof(GetScenarioAutocompleteAsync))]", + "\n [Display(Name = \"Scenario\")]", + "\n string ScenarioControl { get; set; }", + "\n", + "\n [NotVisible] IDictionary ScenarioMapping { get; set; }", + "\n protected string Scenario => !string.IsNullOrWhiteSpace(ScenarioControl) && ", + "\n ScenarioMapping is not null && ", + "\n ScenarioMapping.TryGetValue(ScenarioControl, out var value) ", + "\n ? value ", + "\n : null;", + "\n ", + "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", + "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", + "\n ScenarioMapping[Scenarios.Delta] = Scenarios.Delta; //TODO this behavior needs to be updated. PR#217", + "\n ScenarioMapping[Scenarios.All] = Scenarios.All;", + "\n return orderedDropDownValues.Concat(new string[] {Scenarios.Delta, Scenarios.All})", + "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", + "\n .ToArray(); ", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ScenarioParameterFormsEntity : ScenarioFormsEntity", + "\nwhere TStorage : ReportStorage ", + "\n{", + "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", + "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", + "\n .ToArray(); ", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reporting Node" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportingNode))]", + "\npublic interface ReportingNodeFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage", + "\n{", + "\n [DropdownMethod(nameof(GetReportingNodeAutocompleteAsync))]", + "\n [Display(Name = \"ReportingNode\")]", + "\n string ReportingNodeControl { get; set; }", + "\n", + "\n [NotVisible] IDictionary ReportingNodeMapping { get; set; }", + "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ", + "\n ReportingNodeMapping is not null && ", + "\n ReportingNodeMapping.TryGetValue(ReportingNodeControl, out var value)", + "\n ? value", + "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", + "\n", + "\n async Task> GetReportingNodeAutocompleteAsync(string userInput, int page, int pageSize) {", + "\n (ReportingNodeMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", + "\n }", + "\n", + "\n void InitReportingNode() {", + "\n ReportingNodeControl = ParseDimensionToDisplayString(GetStorage().InitialReportingNode.SystemName, GetStorage().InitialReportingNode.DisplayName);", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reporting Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Monthly Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportingPeriod))]", + "\npublic interface MonthlyPeriodFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage", + "\n{", + "\n [DropdownMethod(nameof(GetReportingPeriodAutocompleteAsync))]", + "\n string ReportingPeriod { get; set; }", + "\n", + "\n private char separator => 'M';", + "\n private string[] ReportingPeriodSplit => ReportingPeriod.Split(separator);", + "\n private int ParseReportingPeriod(int index) => !string.IsNullOrWhiteSpace(ReportingPeriod) && ReportingPeriodSplit is not null && Int32.TryParse(ReportingPeriodSplit.ElementAtOrDefault(index), out int value)", + "\n ? value", + "\n : default;", + "\n", + "\n protected int Year => ParseReportingPeriod(0);", + "\n protected int Month => ParseReportingPeriod(1);", + "\n", + "\n async Task> GetReportingPeriodAutocompleteAsync(string userInput, int page, int pageSize) => ", + "\n await workspace.Query()", + "\n .Where(x => x.Scenario == null)", + "\n .OrderByDescending(x => x.Year)", + "\n .ThenByDescending(x => x.Month)", + "\n .Select(x => ParseReportingPeriodToDisplayString(x.Year, x.Month, separator))", + "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", + "\n .ToArrayAsync();", + "\n", + "\n void InitReportingPeriod() {", + "\n ReportingPeriod = ParseReportingPeriodToDisplayString(GetStorage().InitialReportingPeriod.Year, GetStorage().InitialReportingPeriod.Month, separator);", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Filters" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitFilters))]", + "\npublic interface BasicFilterFormsEntity : MutableScopeWithWorkspace", + "\nwhere TStorage : ReportStorage", + "\n{", + "\n [DropdownMethod(nameof(GetFilterName))]", + "\n string FilterName { get; set; }", + "\n", + "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", + "\n [Display(Name = \"Filter Value\")]", + "\n string FilterValueControl { get; set; }", + "\n", + "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", + "\n string FilterAction { get; set; }", + "\n", + "\n protected string[] defaultFilters => new string[] {", + "\n \"\",", + "\n nameof(ReportVariable.GroupOfContract),", + "\n nameof(ReportVariable.Portfolio),", + "\n nameof(ReportVariable.LineOfBusiness),", + "\n //nameof(ReportVariable.AnnualCohort),", + "\n nameof(ReportVariable.LiabilityType),", + "\n nameof(ReportVariable.ValuationApproach),", + "\n nameof(ReportVariable.OciType),", + "\n nameof(ReportVariable.InitialProfitability), //(\\\"Profitability\\\")", + "\n };", + "\n", + "\n [NotVisible] IReadOnlyCollection specificFilters { get; set; }", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.Union(specificFilters).ToArray();", + "\n", + "\n [NotVisible] IDictionary> FilterMapping { get; set; }", + "\n protected string FilterValue => !string.IsNullOrWhiteSpace(FilterName) && !string.IsNullOrWhiteSpace(FilterValueControl) && ", + "\n FilterMapping is not null && FilterMapping.TryGetValue(FilterName, out var inner) &&", + "\n inner.TryGetValue(FilterValueControl, out var value)", + "\n ? value", + "\n : null;", + "\n", + "\n async Task> GetFilterAutocompleteAsync() where T : KeyedDimension {", + "\n (var filterMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", + "\n FilterMapping[typeof(T).Name] = filterMapping;", + "\n return orderedDropDownValues;", + "\n }", + "\n", + "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", + "\n new string[]{ null }.Concat(", + "\n (FilterName switch", + "\n {", + "\n //GetAutocompleteMappings", + "\n nameof(ReportVariable.Portfolio) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.GroupOfContract) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.LineOfBusiness) => await GetFilterAutocompleteAsync(),", + "\n //nameof(ReportVariable.AnnualCohort) => //TODO the filter is not applied because the prop is an Int", + "\n nameof(ReportVariable.LiabilityType) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.ValuationApproach) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.OciType) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.InitialProfitability) => await GetFilterAutocompleteAsync(),", + "\n", + "\n nameof(ReportVariable.Novelty) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.VariableType) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.EconomicBasis) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.AmountType) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.EstimateType) => await GetFilterAutocompleteAsync(),", + "\n _ => Enumerable.Empty().ToArray()", + "\n }).Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).OrderBy(x => x)).ToArray();", + "\n ", + "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", + "\n ", + "\n protected (string fileName, object filterValue)[] dataFilter => InputDataFilter.Select(x => (x.filterName, (object)x.filterValue)).ToArray(); //TODO this cast is needed by the Filter func", + "\n", + "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", + "\n {", + "\n if(FilterAction == \"Add\")", + "\n AddFilter(FilterName, FilterValue);", + "\n if(FilterAction == \"Remove\")", + "\n RemoveFilter(FilterName, FilterValue);", + "\n return InputDataFilter;", + "\n }", + "\n", + "\n private void AddFilter(string filterName, string filterValue)", + "\n {", + "\n if(!InputDataFilter.Contains((filterName, filterValue)))", + "\n InputDataFilter = InputDataFilter.Append((filterName, filterValue)).ToArray();", + "\n }", + "\n ", + "\n private void RemoveFilter(string filterName, string filterValue)", + "\n {", + "\n if(InputDataFilter.Contains((filterName, filterValue)))", + "\n { var f = InputDataFilter.ToList();", + "\n f.Remove((filterName, filterValue));", + "\n InputDataFilter = f.ToArray();", + "\n }", + "\n }", + "\n", + "\n void InitFilters() {", + "\n FilterMapping = new Dictionary>() ;", + "\n InputDataFilter = Enumerable.Empty<(string, string)>().ToArray();", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Slice and Dice" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface BasicSliceAndDiceRowsFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage", + "\n{", + "\n [NotVisible] string SliceRowName { get; set; }", + "\n", + "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", + "\n [NotVisible] IReadOnlyCollection defaultRowSlices { get; set; }", + "\n protected string[] rowSlices => defaultRowSlices.Union(InputRowSlices).ToArray();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface BasicSliceAndDiceColumnsFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage", + "\n{", + "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", + "\n string SliceColumnName { get; set; }", + "\n", + "\n protected IReadOnlyCollection InputColumnSlices => (SliceColumnName is null ? Enumerable.Empty() : SliceColumnName.RepeatOnce()).ToArray();", + "\n [NotVisible] IReadOnlyCollection defaultColumnSlices { get; set; }", + "\n protected string[] columnSlices => defaultColumnSlices.Union(InputColumnSlices).ToArray();", + "\n", + "\n IReadOnlyCollection GetSliceColumnNameAutocomplete() => new [] {\"\", ", + "\n nameof(ReportVariable.ReportingNode), ", + "\n nameof(ReportVariable.Scenario),", + "\n nameof(ReportVariable.Portfolio), ", + "\n nameof(ReportVariable.GroupOfContract), ", + "\n nameof(ReportVariable.LineOfBusiness),", + "\n nameof(ReportVariable.LiabilityType),", + "\n nameof(ReportVariable.InitialProfitability),", + "\n nameof(ReportVariable.ValuationApproach),", + "\n nameof(ReportVariable.AnnualCohort),", + "\n nameof(ReportVariable.OciType),", + "\n nameof(ReportVariable.IsReinsurance),", + "\n nameof(ReportVariable.AccidentYear),", + "\n ", + "\n nameof(ReportVariable.AmountType),", + "\n nameof(ReportVariable.EstimateType),", + "\n nameof(ReportVariable.EconomicBasis)};", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Generic Report Scope and Data Scope" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", + "\n IDataCube InputDataCube { get; set; }", + "\n IDataCube DataCube { get {", + "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", + "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ", + "\n ? InputDataCube ", + "\n : InputDataCube.Filter(Identity.dataFilter); ", + "\n switch (Identity.scenario)", + "\n {", + "\n case null : return filteredDataCube.Where(x => x.Scenario == null).ToDataCube();", + "\n case Scenarios.All : return filteredDataCube.Select(x => x.Scenario == null ? x with {Scenario = Scenarios.Default } : x).ToDataCube();", + "\n case Scenarios.Delta : ", + "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", + "\n return filteredDataCube.Select(x => x.Scenario == null ", + "\n ? x with { Scenario = Scenarios.Default } ", + "\n : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0.0) }).ToDataCube(); ", + "\n default : return filteredDataCube.Filter((nameof(ReportVariable.Scenario), Identity.scenario));", + "\n }", + "\n }}", + "\n} " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface ReportScope : IMutableScope, ", + "\n ReportingNodeFormsEntity, ", + "\n MonthlyPeriodFormsEntity, ", + "\n ScenarioFormsEntity, ", + "\n CurrencyFormsEntity, ", + "\n BasicSliceAndDiceRowsFormsEntity, ", + "\n BasicSliceAndDiceColumnsFormsEntity, ", + "\n BasicFilterFormsEntity {", + "\n protected IPivotFactory report => GetStorage().Report;", + "\n protected IExportVariable export => GetStorage().Export;", + "\n protected int headerColumnWidthValue => 250;", + "\n", + "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", + "\n", + "\n IDataCube GetData() => default;", + "\n", + "\n async Task ToReportAsync() {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n var dataCube = GetData();", + "\n // This is a temporary solution to avoid an error from the empty report", + "\n // Remove when the issue is solved on the platform - A.K.", + "\n if (!dataCube.ToArray().Any()) return null;", + "\n dataScope.InputDataCube = dataCube;", + "\n return await GetReportTaskAsync(dataScope.DataCube);", + "\n }", + "\n", + "\n // Using this routine is highly discouraged due to the mutlithreading issue -A.K.", + "\n // Avoid using these methods if working with the DB -- it will trigger synchronization error in access to the DB", + "\n async Task ToCsvAsync(string fileName){", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await export.ToCsv(fileName)", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices))", + "\n .WithActivityLog()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task ToExcelAsync(string fileName){", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await export.ToExcel(fileName)", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace) ", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices))", + "\n .WithActivityLog()", + "\n .ExecuteAsync();", + "\n }", + "\n ", + "\n async Task GetReportTaskAsync(IDataCube data) {", + "\n return await report.ForDataCube(data)", + "\n .WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices)", + "\n .ReportGridOptions(headerColumnWidth: headerColumnWidthValue)", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n void Init(){", + "\n var task = InitReportStorageScopeAsync();", + "\n task.Wait();", + "\n }", + "\n", + "\n async Task InitReportStorageScopeAsync() { // This has the Async issue, but imo it should come in the future", + "\n await GetStorage().InitializeReportIndependentCacheAsync();", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Report Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Best Estimate PV" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface PvReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", + "\n // SpecificFiltersFormEntity", + "\n specificFilters = new string[] {nameof(ReportVariable.AmountType)};", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Risk Adjustment PV" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface RaReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedRiskAdjustment + GetScopes(GetDataIdentities()).Aggregate().CurrentRiskAdjustment;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## FCF PV" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface FcfReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Fcf;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Written" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface WrittenReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Written;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.AmountType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Accruals" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface AccrualReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Advance + GetScopes(GetDataIdentities()).Aggregate().Overdue;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", + "\n // SpecificFiltersFormEntity", + "\n specificFilters = new string[] {nameof(ReportVariable.AmountType)};", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Deferrals" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface DeferralReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Deferrals;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Experience Adjustment" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface ExpAdjReport: ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().ActuarialExperienceAdjustment;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.EstimateType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.AmountType) };", + "\n // SpecificFiltersFormEntity", + "\n specificFilters = new string[] {nameof(ReportVariable.AmountType)};", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Technical Margin" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface TmReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LrcTechnicalMargin;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## CSM" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface CsmReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Csm + GetScopes(GetDataIdentities()).Aggregate().Lc + GetScopes(GetDataIdentities()).Aggregate().Loreco;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## LRC" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface ActLrcReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LrcActuarial;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface LrcReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() =>GetScopes(GetDataIdentities()).Aggregate().Lrc;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## LIC" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface ActLicReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LicActuarial;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface LicReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Lic;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Financial Performance" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface FpReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().FinancialPerformance;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType), nameof(ReportVariable.EstimateType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency)};", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# IFRS 17 Interactive " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This class is used to trigger the calculation of the reports and it is exposed to the end-user in the reports." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "using Systemorph.Vertex.Pivot.Builder.Interfaces;", + "\nusing Systemorph.InteractiveObjects;", + "\nusing Systemorph.Vertex.Session;", + "\npublic class Ifrs17Interactive {", + "\n private IPivotFactory report;", + "\n private IExportVariable export;", + "\n private InteractiveObjectVariable interactiveObject;", + "\n private ReportStorage storage;", + "\n", + "\n private IDictionary interactiveObjectCache = new Dictionary();", + "\n", + "\n public Ifrs17Interactive (IWorkspace workspace, ", + "\n IPivotFactory report, ", + "\n IExportVariable export,", + "\n InteractiveObjectVariable interactiveObject)", + "\n {", + "\n this.report = report;", + "\n this.export = export;", + "\n this.interactiveObject = interactiveObject;", + "\n storage = new ReportStorage(workspace, report, export);", + "\n }", + "\n", + "\n public void Reset(IWorkspace workspace) {", + "\n storage = new ReportStorage(workspace, report, export);", + "\n interactiveObjectCache = new Dictionary();", + "\n }", + "\n", + "\n public InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", + "\n var key = name ?? typeof(T).Name;", + "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", _ => GetReportScope(key));", + "\n return ret;", + "\n }", + "\n", + "\n public InteractiveObjectView GetReport(string name = null) where T : ReportScope {", + "\n var key = name ?? typeof(T).Name;", + "\n if(!interactiveObjectCache.TryGetValue(key, out var ret)){", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", + "\n _ => {", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters(); // Not used and should be improved", + "\n return scope.ToReportAsync(); ", + "\n }); ", + "\n }", + "\n return ret;", + "\n }", + "\n", + "\n public async Task ExportToCsvAsync(string fileName, bool addDateTime = false)", + "\n where T : ReportScope", + "\n {", + "\n var fullFileName = addDateTime ? AttachDateTime(fileName) : fileName; ", + "\n var scope = GetReportScope();", + "\n var _ = scope.GetFilters();", + "\n return await scope.ToCsvAsync(fullFileName);", + "\n } ", + "\n", + "\n", + "\n public async Task ExportToExcelAsync(string fileName, bool addDateTime = false)", + "\n where T : ReportScope", + "\n {", + "\n var fullFileName = addDateTime ? AttachDateTime(fileName) : fileName;", + "\n var scope = GetReportScope();", + "\n var _ = scope.GetFilters();", + "\n return await scope.ToExcelAsync(fullFileName);", + "\n }", + "\n", + "\n private string ToTwoDigitString(int number ) => number.ToString().Length == 1 ? \"0\" + number.ToString() : number.ToString();", + "\n", + "\n private string AttachDateTime(string fileName)", + "\n {", + "\n DateTime creationTime = DateTime.UtcNow;", + "\n return fileName + \"_\" + creationTime.Year.ToString() + ToTwoDigitString(creationTime.Month) + ToTwoDigitString(creationTime.Day) +", + "\n ToTwoDigitString(creationTime.Hour) + ToTwoDigitString(creationTime.Minute) + ToTwoDigitString(creationTime.Second);", + "\n }", + "\n", + "\n // This routine is still buggy, triggering an infinite loop. -- A.K.", + "\n // public InteractiveObjectView ToExcelInteractive(string fileName, bool addDateTime = false, string name = null)", + "\n // where T : ReportScope", + "\n // {", + "\n // var key = name ?? typeof(T).Name;", + "\n // var fullFileName = addDateTime ? AttachDateTime(fileName) : fileName; ", + "\n // if (!interactiveObjectCache.TryGetValue($\"{key}.xlsx\", out var ret))", + "\n // ret = interactiveObjectCache[$\"{key}.xlsx\"] = interactiveObject.CreateView($\"{key}.xlsx\", _ => ", + "\n // {", + "\n // var scope = GetReportScope();", + "\n // var filters = scope.GetFilters();", + "\n // return scope.ToExcelAsync(fullFileName);", + "\n // });", + "\n // return ret;", + "\n // }", + "\n ", + "\n ", + "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", + "\n", + "\n // Keeping the old API", + "\n public ReportScope PresentValues => GetReportScope();", + "\n public ReportScope RiskAdjustments => GetReportScope();", + "\n public ReportScope FulfillmentCashflows => GetReportScope();", + "\n public ReportScope WrittenActuals => GetReportScope();", + "\n public ReportScope AccrualActuals => GetReportScope();", + "\n public ReportScope DeferralActuals => GetReportScope();", + "\n public ReportScope ExperienceAdjustments => GetReportScope();", + "\n public ReportScope TechnicalMargins => GetReportScope();", + "\n public ReportScope AllocatedTechnicalMargins => GetReportScope();", + "\n public ReportScope ActuarialLrc => GetReportScope();", + "\n public ReportScope Lrc => GetReportScope();", + "\n public ReportScope ActuarialLic => GetReportScope();", + "\n public ReportScope Lic => GetReportScope();", + "\n public ReportScope FinancialPerformance => GetReportScope(); ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Report/ReportScopes.ipynb b/ifrs17/Report/ReportScopes.ipynb index 44563155..2c00626a 100644 --- a/ifrs17/Report/ReportScopes.ipynb +++ b/ifrs17/Report/ReportScopes.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "XO1MGMO6q0GBeTH0YLwIWA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -213,6 +212,37 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "### Retrieve constant elements from a class" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "using System.Reflection;", + "\npublic static T[] GetAllPublicConstantValues(this Type type, ", + "\n IList excludedTerms = null)", + "\n{", + "\n var selection = type", + "\n .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)", + "\n .Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(T))", + "\n .Select(x => (T)x.GetRawConstantValue())", + "\n .ToArray();", + "\n if (excludedTerms == null)", + "\n return selection;", + "\n else ", + "\n return selection.Where(x => !excludedTerms.Contains(x)).ToArray();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -448,7 +478,7 @@ "\n .Filter((\"VariableType\", AocTypes.CF));", "\n ", "\n private IDataCube BestEstimateCashflow => GetScope(Identity).BestEstimate", - "\n .Filter((\"VariableType\", AocTypes.CF))", + "\n .Filter((\"VariableType\", AocTypes.CF), (\"AmountType\",\"!CDR\"))", "\n .SelectToDataCube(rv => rv with { EconomicBasis = null, Novelty = Novelties.C });", "\n", "\n IDataCube ActuarialExperienceAdjustment => WrittenCashflow - BestEstimateCashflow;", diff --git a/ifrs17/Report/ReportStorage.ipynb b/ifrs17/Report/ReportStorage.ipynb index 4effa761..54514a51 100644 --- a/ifrs17/Report/ReportStorage.ipynb +++ b/ifrs17/Report/ReportStorage.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "jXPnCVjEo0-9rdyzYmEMfA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -106,28 +105,39 @@ { "cell_type": "code", "source": [ - "public class ReportStorage {", + "using Systemorph.Vertex.Export.Factory;", + "\npublic class ReportStorage {", "\n protected readonly IWorkspace workspace;", + "\n protected readonly IExportVariable export;", "\n private readonly Systemorph.Vertex.Hierarchies.IHierarchicalDimensionCache hierarchicalDimensionCache;", "\n private readonly Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory;", "\n ", "\n // Current Storage Settings", "\n public ((int Year, int Month) Period, string ReportingNode, string Scenario, CurrencyType CurrencyType) Args {get; private set;}", "\n ", - "\n // Cache for Aux Data", + "\n // Initial Values for Scopes DropDowns", + "\n public (string DisplayName, string SystemName) InitialReportingNode {get; private set;}", + "\n public (int Year, int Month) InitialReportingPeriod {get; private set;}", + "\n", + "\n // Aux Data", "\n private Dictionary<(int year, int month), Dictionary>> exchangeRatesByCurrencyByFxTypeAndPeriod = new(); // Fx Rates", "\n private Dictionary<(int year, int month), Dictionary> fxPeriodsByAocStepAndPeriod = new(); // FxParameter", "\n ", + "\n // Dimensions", "\n public HashSet EstimateTypesWithoutAoc {get; private set;}", + "\n public HashSet TargetScenarios {get; private set;}", "\n ", - "\n // Cache for Variables and Parameters", + "\n // Variables and Parameters", "\n private Dictionary<((int year, int month) period, string reportingNode, string scenario), Dictionary>>> variablesDictionary = new();", "\n ", "\n // Constructor", - "\n public ReportStorage(IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory) {", + "\n public ReportStorage(IWorkspace workspace, ", + "\n Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory, ", + "\n IExportVariable export) {", "\n this.workspace = workspace;", "\n this.hierarchicalDimensionCache = workspace.ToHierarchicalDimensionCache();", "\n this.reportFactory = reportFactory;", + "\n this.export = export;", "\n }", "\n ", "\n // Initializers", @@ -137,15 +147,20 @@ "\n await hierarchicalDimensionCache.InitializeAsync(); ", "\n await hierarchicalDimensionCache.InitializeAsync();", "\n await hierarchicalDimensionCache.InitializeAsync();", + "\n", + "\n // Initial Values", + "\n var mostRecentPartition = (await workspace.Query().Where(x => x.Scenario == null).OrderBy(x => x.Year).ThenBy(x => x.Month).ToArrayAsync()).LastOrDefault();", + "\n InitialReportingPeriod = (mostRecentPartition.Year, mostRecentPartition.Month);", + "\n var rootReportingNode = (await workspace.Query().Where(x => x.Parent == null).ToArrayAsync()).FirstOrDefault();", + "\n InitialReportingNode = (rootReportingNode.DisplayName, rootReportingNode.SystemName);", "\n }", "\n ", "\n public async Task InitializeAsync((int year, int month) period, string reportingNode, string scenario, CurrencyType currencyType) {", - "\n // Report Dependent Cache", - "\n", "\n // Setting the Args --> Temp for the moment", "\n Args = (period, reportingNode, scenario, currencyType);", "\n ", "\n EstimateTypesWithoutAoc = (await workspace.Query().Where(x => x.StructureType != StructureType.AoC).Select(x => x.SystemName).ToArrayAsync()).ToHashSet();", + "\n TargetScenarios = await GetScenariosAsync(scenario); ", "\n ", "\n // FX && Fx Parameters", "\n if(!exchangeRatesByCurrencyByFxTypeAndPeriod.TryGetValue(period, out var exchangeRatesByCurrencyByFxType) || !fxPeriodsByAocStepAndPeriod.TryGetValue(period, out var fxPeriodsByAocStep)) {", @@ -157,31 +172,34 @@ "\n ", "\n // Variables", "\n foreach(var rn in GetLeaves(reportingNode)) {", - "\n if(!variablesDictionary.TryGetValue((period, rn, scenario), out var variablesByIdentity)) {", - "\n variablesByIdentity = (await workspace.QueryReportVariablesAsync((period.year, period.month, rn, scenario)))", - "\n .ToDictionaryGrouped(x => new ReportIdentity {", - "\n Year = period.year,", - "\n Month = period.month,", - "\n ReportingNode = x.ReportingNode,", - "\n Scenario = x.Scenario,", - "\n Projection = x.Projection,", - "\n ContractualCurrency = x.ContractualCurrency,", - "\n FunctionalCurrency = x.FunctionalCurrency,", - "\n ValuationApproach = x.ValuationApproach,", - "\n LiabilityType = x.LiabilityType,", - "\n IsReinsurance = x.IsReinsurance,", - "\n IsOci = !string.IsNullOrWhiteSpace(x.OciType) },", - "\n x => x.ToDictionaryGrouped(y => y.EstimateType,", - "\n y => y.ToArray().ToDataCube()));", + "\n foreach(var scn in TargetScenarios) {", + "\n if(!variablesDictionary.TryGetValue((period, rn, scn), out var variablesByIdentity)) {", + "\n variablesByIdentity = (await workspace.QueryReportVariablesAsync((period.year, period.month, rn, scn)))", + "\n .ToDictionaryGrouped(x => new ReportIdentity {", + "\n Year = period.year,", + "\n Month = period.month,", + "\n ReportingNode = x.ReportingNode,", + "\n Scenario = scn,", + "\n Projection = x.Projection,", + "\n ContractualCurrency = x.ContractualCurrency,", + "\n FunctionalCurrency = x.FunctionalCurrency,", + "\n ValuationApproach = x.ValuationApproach,", + "\n LiabilityType = x.LiabilityType,", + "\n IsReinsurance = x.IsReinsurance,", + "\n IsOci = !string.IsNullOrWhiteSpace(x.OciType) },", + "\n x => x.ToDictionaryGrouped(y => y.EstimateType,", + "\n y => y.ToArray().ToDataCube()));", "\n ", - "\n variablesDictionary.Add((period, rn, scenario), variablesByIdentity);", + "\n variablesDictionary.Add((period, rn, scn), variablesByIdentity);", + "\n }", "\n }", "\n }", "\n }", "\n ", "\n // Getters for Data", "\n public IDataCube GetVariables(ReportIdentity reportIdentity, params string[] estimateTypes)", - "\n => (!variablesDictionary.TryGetValue(((reportIdentity.Year, reportIdentity.Month), reportIdentity.ReportingNode, reportIdentity.Scenario), out var variablesByIdentity) || !variablesByIdentity.TryGetValue(reportIdentity, out var variablesByEstimateType))", + "\n => (!variablesDictionary.TryGetValue(((reportIdentity.Year, reportIdentity.Month), reportIdentity.ReportingNode, reportIdentity.Scenario), out var variablesByIdentity) || ", + "\n !variablesByIdentity.TryGetValue(reportIdentity, out var variablesByEstimateType))", "\n ? Enumerable.Empty().ToDataCube()", "\n : estimateTypes.Length switch {", "\n 0 => variablesByEstimateType.SelectMany(x => x.Value).ToDataCube(),", @@ -198,20 +216,20 @@ "\n // Other getters", "\n public IWorkspace Workspace => workspace;", "\n public Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory Report => reportFactory;", + "\n public IExportVariable Export => export;", "\n", "\n public Systemorph.Vertex.Hierarchies.IHierarchy GetHierarchy() where T : class, IHierarchicalDimension => hierarchicalDimensionCache.Get();", "\n ", "\n public HashSet<(ReportIdentity, CurrencyType)> GetIdentities((int year, int month) period, string reportingNode, string scenario, CurrencyType currencyType)", - "\n => GetLeaves(reportingNode)", - "\n .SelectMany(rn => variablesDictionary.TryGetValue((period, rn, scenario), out var inner) ? inner.Keys.Select(x => (x, currencyType)) : Enumerable.Empty<(ReportIdentity, CurrencyType)>())", - "\n .ToHashSet();", + "\n => GetLeaves(reportingNode).SelectMany(rn => TargetScenarios.SelectMany(scn =>", + "\n variablesDictionary.TryGetValue((period, rn, scn), out var inner) ? inner.Keys.Select(x => (x, currencyType)) : Enumerable.Empty<(ReportIdentity, CurrencyType)>())).ToHashSet();", "\n ", "\n public double GetFx((int year, int month) period, string currentCurrency, string targetCurrency, FxPeriod fxPeriod) {", "\n if (currentCurrency == targetCurrency) return 1;", "\n if(!exchangeRatesByCurrencyByFxTypeAndPeriod.TryGetValue(period, out var exchangeRatesByCurrencyByFxType))", "\n throw new Exception ($\"No exchange rates for Period {period} were found.\");", "\n return GetCurrencyToGroupFx(exchangeRatesByCurrencyByFxType, currentCurrency, fxPeriod, GroupCurrency)", - "\n / GetCurrencyToGroupFx(exchangeRatesByCurrencyByFxType, targetCurrency, fxPeriod, GroupCurrency);", + "\n / GetCurrencyToGroupFx(exchangeRatesByCurrencyByFxType, targetCurrency, fxPeriod, GroupCurrency);", "\n }", "\n ", "\n public FxPeriod GetFxPeriod((int year, int month) period, string aocType, string novelty) => fxPeriodsByAocStepAndPeriod[period][new AocStep(aocType, novelty)];", @@ -221,6 +239,11 @@ "\n var descendants = hierarchicalDimensionCache.Get(systemName).Descendants(includeSelf: true);", "\n return descendants.Where(x => !descendants.Select(y => y.Parent).Contains(x.SystemName)).Select(x => x.SystemName).ToHashSet();", "\n }", + "\n", + "\n public async Task> GetScenariosAsync(string scenario) => ", + "\n scenario == \"Delta\" || scenario == \"All\" ", + "\n ? (await workspace.Query().Select(x => x.Scenario).ToArrayAsync()).ToHashSet()", + "\n : scenario.RepeatOnce().ToHashSet();", "\n}" ], "metadata": {}, diff --git a/ifrs17/Test/AggregateDoubleArrayTest.ipynb b/ifrs17/Test/AggregateDoubleArrayTest.ipynb index 6849995e..27cc81dc 100644 --- a/ifrs17/Test/AggregateDoubleArrayTest.ipynb +++ b/ifrs17/Test/AggregateDoubleArrayTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "9UoN9BW_ykyK_lnYPCgI_Q", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "code", diff --git a/ifrs17/Test/AocConfigurationTest.ipynb b/ifrs17/Test/AocConfigurationTest.ipynb index 164cd950..9f05c8a9 100644 --- a/ifrs17/Test/AocConfigurationTest.ipynb +++ b/ifrs17/Test/AocConfigurationTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "VfWtlFCxmU6_3pZQBTUVxg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17/Test/AocStructureTest.ipynb b/ifrs17/Test/AocStructureTest.ipynb index a230366e..3a5b4c45 100644 --- a/ifrs17/Test/AocStructureTest.ipynb +++ b/ifrs17/Test/AocStructureTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "zu2TE0r0G0-N-Fs0ghCaGg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17/Test/EqualityComparerTest.ipynb b/ifrs17/Test/EqualityComparerTest.ipynb index 444f18b3..4c97e989 100644 --- a/ifrs17/Test/EqualityComparerTest.ipynb +++ b/ifrs17/Test/EqualityComparerTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "BLeYRQvV6kmFwHU_Sk6q4g", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17/Test/ImportStorageTest.ipynb b/ifrs17/Test/ImportStorageTest.ipynb index 67a9871f..90dfa772 100644 --- a/ifrs17/Test/ImportStorageTest.ipynb +++ b/ifrs17/Test/ImportStorageTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "UBkQtzi400mCgXvIuhlVGw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -39,7 +38,17 @@ { "cell_type": "markdown", "source": [ - "# Workspace Initialization " + "# Initialization " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.SetAsync();", + "\nDataSource.Reset(x => x.ResetCurrentPartitions());" ], "metadata": {}, "execution_count": 0, @@ -59,10 +68,10 @@ { "cell_type": "code", "source": [ - "await DataSource.UpdateAsync(dt1.RepeatOnce());", - "\nawait DataSource.UpdateAsync(dtr1.RepeatOnce());", - "\nawait DataSource.UpdateAsync(new [] {dt11});", - "\nawait DataSource.UpdateAsync(new [] {dtr11});" + "await DataSource.UpdateAsync(new[]{ dt1 });", + "\nawait DataSource.UpdateAsync(new[]{ dtr1 });", + "\nawait DataSource.UpdateAsync(new[]{ dt11 });", + "\nawait DataSource.UpdateAsync(new[]{ dtr11 });" ], "metadata": {}, "execution_count": 0, @@ -71,8 +80,8 @@ { "cell_type": "code", "source": [ - "await DataSource.UpdateAsync(new [ ] {dt11State, dtr11State});", - "\nawait DataSource.UpdateAsync(new [ ] {dt11Inter});" + "await DataSource.UpdateAsync(new[]{ dt11State, dtr11State });", + "\nawait DataSource.UpdateAsync(new[]{ dt11Inter });" ], "metadata": {}, "execution_count": 0, @@ -81,7 +90,7 @@ { "cell_type": "code", "source": [ - "await DataSource.UpdateAsync(new [ ] {yieldCurve, yieldCurvePrevious});" + "await DataSource.UpdateAsync(new[]{ yieldCurve, yieldCurvePrevious });" ], "metadata": {}, "execution_count": 0, @@ -108,7 +117,7 @@ { "cell_type": "code", "source": [ - "await DataSource.UpdateAsync(new[]{partition, previousPeriodPartition});", + "await DataSource.UpdateAsync(new[]{partition, previousPeriodPartition, partitionScenarioMTUP});", "\nawait DataSource.UpdateAsync(new[]{partitionReportingNode});" ], "metadata": {}, @@ -118,7 +127,7 @@ { "cell_type": "markdown", "source": [ - "# Test" + "# Check method" ], "metadata": {}, "execution_count": 0, @@ -127,7 +136,7 @@ { "cell_type": "code", "source": [ - "public async Task CheckIfrsVariablesFromImportStorageAsync(string importFormat, IEnumerable inputDataSetForWorkspace, IEnumerable inputDataSetForDataSource, IEnumerable ivsBenchmark)", + "public async Task CheckIfrsVariablesFromImportStorageAsync(string importFormat, IEnumerable inputDataSetForWorkspace, IEnumerable inputDataSetForDataSource, IEnumerable ivsBenchmark, ImportArgs args)", "\n{", "\n Activity.Start();", "\n //Prepare Workspace and DataSource", @@ -165,11 +174,31 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Test Best Estimate" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## A", + "\n", + "\nThere is a previous year, and it's the first time Actuals are imported for the current year." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "//There is a previous year, and it's the first time Actuals are imported for the current year", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\n", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 100.0},", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", @@ -186,7 +215,7 @@ "\n basicIfrsVariable with {AocType = AocTypes.CF, Value = -10.0},", "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", - "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark, args);", "\nactivity" ], "metadata": {}, @@ -202,11 +231,22 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## B", + "\n", + "\nThere is a previous year, and it's the second time Actuals are imported for the current year (reimport)." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "//There is a previous year, and it's the second time Actuals are imported for the current year (reimport)", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\n", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 100.0},", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", @@ -229,7 +269,7 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = -20.0},", "\n };", "\n", - "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark, args);", "\nactivity" ], "metadata": {}, @@ -245,11 +285,22 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## C", + "\n", + "\nThere is a previous year, cash flow were already imported and actuals are imported for the first time." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "//There is a previous year, Cash flows were already imported and Actuals are imported for the first time", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.I, EstimateType = EstimateTypes.BE};", + "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.I, EstimateType = EstimateTypes.BE};", + "\n", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, EstimateType = EstimateTypes.AA, Novelty = Novelties.C, Value = 100.0},", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 1000.0},", @@ -274,7 +325,7 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, EstimateType = EstimateTypes.AA, Novelty = Novelties.C, Value = -20.0},", "\n };", "\n", - "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark, args);", "\nactivity" ], "metadata": {}, @@ -290,12 +341,23 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## D", + "\n", + "\nThere is a previous year, Cash flows and Actuals were already imported and Actuals are imported again." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "//There is a previous year, Cash flows and Actuals were already imported and Actuals are imported again", - "\nvar basicAdvanceActualIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "var basicAdvanceActualIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", "\nvar basicBeIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.I, EstimateType = EstimateTypes.BE};", + "\n", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n basicBeIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 1000.0},", "\n basicBeIfrsVariable with {AocType = AocTypes.BOP, Novelty = Novelties.I, Value = 1000.0},", @@ -327,7 +389,7 @@ "\n basicAdvanceActualIfrsVariable with {AocType = AocTypes.WO, Value = -20.0},", "\n };", "\n", - "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark, args);", "\nactivity" ], "metadata": {}, @@ -343,14 +405,26 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## E", + "\n", + "\nThere is a previous year for Primary Scope (GRIC10) ", + "\n", + "\nThere is a previous and current year for Secondary Scope (GIC10), ", + "\n", + "\nIt's the first time Actuals are imported for the current year" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "//There is a previous year for Primary Scope (GRIC10) ", - "\n//There is a previous and current year for Secondary Scope (GIC10), ", - "\n//It's the first time Actuals are imported for the current year", + "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfReinsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", "\n", - "\nvar basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfReinsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", "\nvar inputDataSetForDataSource = new IfrsVariable[]{", "\n //Year", "\n basicIfrsVariable with {Partition = previousPeriodPartition.Id, AocType = AocTypes.EOP, Value = 100.0},", @@ -390,7 +464,117 @@ "\n basicIfrsVariable with {AocType = AocTypes.WO, Value = 15.0},", "\n };", "\n", - "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark);", + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark, args);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test Scenario" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## A", + "\n", + "\nFor the current year Actuals are imported for Best Estimate and a given Scenario. The Relaxed query should return the union of the 2 giving priority to scenario data. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\n", + "\nvar inputDataSetForDataSource = new IfrsVariable[]{", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, Value = 100.0},", + "\n basicIfrsVariable with {AocType = AocTypes.CL, Value = 150.0},", + "\n };", + "\n", + "\nvar inputDataSetForWorkspace = new IfrsVariable[]{", + "\n basicIfrsVariable with {Partition = partitionScenarioMTUP.Id, AocType = AocTypes.CL, Value = -15.0},", + "\n basicIfrsVariable with {Partition = partitionScenarioMTUP.Id, AmountType = AmountTypes.CL, AocType = AocTypes.CL, Value = -99.0},", + "\n };", + "\n", + "\nvar ivsBenchmark = new IfrsVariable[]{", + "\n basicIfrsVariable with {Partition = partition.Id, AocType = AocTypes.BOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", + "\n basicIfrsVariable with {Partition = partition.Id, AocType = AocTypes.BOP, Value = 100.0},", + "\n basicIfrsVariable with {Partition = partitionScenarioMTUP.Id, AocType = AocTypes.CL, Value = -15.0},", + "\n basicIfrsVariable with {Partition = partitionScenarioMTUP.Id, AmountType = AmountTypes.CL, AocType = AocTypes.CL, Value = -99.0},", + "\n };", + "\n", + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark, argsScenarioMTUP);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## B", + "\n", + "\nThe primary scope is a GRIC scenario while the underlying GIC is Best Estimate." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var basicIfrsVariable = new IfrsVariable{Partition = partition.Id, DataNode = groupOfInsuranceContracts, AccidentYear = null, AmountType = AmountTypes.PR, Novelty = Novelties.C, EstimateType = EstimateTypes.AA};", + "\n", + "\nvar inputDataSetForDataSource = new IfrsVariable[]{", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", + "\n basicIfrsVariable with {AocType = AocTypes.BOP, Value = 100.0},", + "\n basicIfrsVariable with {AocType = AocTypes.CL, Value = 150.0},", + "\n};", + "\n", + "\nvar inputDataSetForWorkspace = new IfrsVariable[]{", + "\n basicIfrsVariable with {Partition = partitionScenarioMTUP.Id, DataNode = groupOfReinsuranceContracts, AocType = AocTypes.CL, Value = -15.0},", + "\n basicIfrsVariable with {Partition = partitionScenarioMTUP.Id, DataNode = groupOfReinsuranceContracts, AmountType = AmountTypes.CL, AocType = AocTypes.CL, Value = -99.0},", + "\n};", + "\n", + "\nvar ivsBenchmark = new IfrsVariable[]{", + "\n basicIfrsVariable with {Partition = partition.Id, AocType = AocTypes.BOP, EstimateType = EstimateTypes.DA, Value = 1000.0},", + "\n basicIfrsVariable with {Partition = partition.Id, AocType = AocTypes.BOP, Value = 100.0},", + "\n basicIfrsVariable with {Partition = partition.Id, AocType = AocTypes.CL, Value = 150.0},", + "\n basicIfrsVariable with {Partition = partitionScenarioMTUP.Id, DataNode = groupOfReinsuranceContracts, AocType = AocTypes.CL, Value = -15.0},", + "\n basicIfrsVariable with {Partition = partitionScenarioMTUP.Id, DataNode = groupOfReinsuranceContracts, AmountType = AmountTypes.CL, AocType = AocTypes.CL, Value = -99.0},", + "\n};", + "\n", + "\nvar activity = await CheckIfrsVariablesFromImportStorageAsync(ImportFormats.Actual, inputDataSetForWorkspace, inputDataSetForDataSource, ivsBenchmark, argsScenarioMTUP);", "\nactivity" ], "metadata": {}, diff --git a/ifrs17/Test/QueriesScenarioDataTest.ipynb b/ifrs17/Test/QueriesScenarioDataTest.ipynb new file mode 100644 index 00000000..a24898a6 --- /dev/null +++ b/ifrs17/Test/QueriesScenarioDataTest.ipynb @@ -0,0 +1,743 @@ +{ + "metadata": { + "authors": [], + "id": "rHk2-5mImky-sdiEfRUCdw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 8, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"../Utils/Queries\"", + "\n#!import \"../Report/ReportConfigurationAndUtils\"", + "\n#!import \"TestData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Initialization" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.UpdateAsync( new[] { partitionReportingNode } );", + "\nawait DataSource.UpdateAsync( new[] { partition, previousPeriodPartition, partitionScenarioMTUP, previousPeriodPartitionScenarioMTUP } );", + "\nawait DataSource.UpdateAsync( new[] { dt11 } );" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Import Queries: Raw Variables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Data definition" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var bestEstimateRawVars = new[] { new RawVariable { AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = partition.Id, Values = new[] {1.0} }, ", + "\n new RawVariable { AmountType = \"PR\", AocType = \"AU\", Novelty = \"I\", Partition = partition.Id, Values = new[] {2.0} },", + "\n new RawVariable { AmountType = \"PR\", AocType = \"EV\", Novelty = \"I\", Partition = partition.Id, Values = new[] {3.0} },", + "\n new RawVariable { AmountType = \"CL\", AocType = \"CL\", Novelty = \"I\", Partition = partition.Id, Values = new[] {4.0} },", + "\n new RawVariable { AmountType = \"CL\", AocType = \"AU\", Novelty = \"I\", Partition = partition.Id, Values = new[] {5.0} },", + "\n new RawVariable { AmountType = \"CL\", AocType = \"EV\", Novelty = \"I\", Partition = partition.Id, Values = new[] {6.0} } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var previousScenarioRawVars = new[] { new RawVariable { AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = previousPeriodPartitionScenarioMTUP.Id, Values = new[] {3.15} }, ", + "\n new RawVariable { AmountType = \"PR\", AocType = \"AU\", Novelty = \"I\", Partition = previousPeriodPartitionScenarioMTUP.Id, Values = new[] {7.17} } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var scenarioRawVars = new[] { new RawVariable { AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Values = new[] {1.1} }, ", + "\n new RawVariable { AmountType = \"PR\", AocType = \"AU\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Values = new[] {2.1} } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var newScenarioRawVars = new[] { new RawVariable { AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Values = new[] {11.0} }, ", + "\n new RawVariable { AmountType = \"CL\", AocType = \"CL\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Values = new[] {41.0} } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario Query and Workspace with new scenario", + "\n", + "\nRaw variable query test.
", + "\nScenario cashflow re-import.
", + "\nDataSource with BestEstimate and Scenario raw variable, Workspace with new raw variable for Scenario.
", + "\n " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateRawVars.Concat(scenarioRawVars).ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());", + "\nawait ws.UpdateAsync(newScenarioRawVars);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedRawVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Cashflow);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedRawVars.SelectMany(x => x.Values).Sum().Should().Be(52.0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query, Workspace with no scenario, mismatching format", + "\n", + "\nRaw variable query test.
", + "\nScenario Actual import.
", + "\nDataSource with BestEstimate and Scenario raw variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateRawVars.Concat(scenarioRawVars).ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedRawVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Actual);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedRawVars.SelectMany(x => x.Values).Sum().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query, Workspace with no scenario and DataSource with scenario", + "\n", + "\nRaw variable query test.
", + "\nScenario parameter (re-)import.
", + "\nDataSource with BestEstimate and Scenario raw variable, Workspace without any raw variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateRawVars.Concat(scenarioRawVars).ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedRawVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Cashflow);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedRawVars.SelectMany(x => x.Values).Sum().Should().Be(3.2);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query, Workspace with no scenario and DataSource with only Best Estimate", + "\n", + "\nRaw variable query test.
", + "\nScenario parameter (re-)import.
", + "\nDataSource with BestEstimate raw variable, Workspace without any raw variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateRawVars.ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedRawVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Cashflow);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedRawVars.SelectMany(x => x.Values).Sum().Should().Be(21);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query, Workspace with no scenario and DataSource with Best Estimate and previous period scenario", + "\n", + "\nRaw variable query test.
", + "\nScenario parameter (re-)import.
", + "\nDataSource with BestEstimate and previous period Scenario raw variable, Workspace without any raw variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateRawVars.Concat(previousScenarioRawVars).ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedRawVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Cashflow);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedRawVars.SelectMany(x => x.Values).Sum().Should().Be(21);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Import Queries: Ifrs Variables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Data definition" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var bestEstimateIfrsVars = new[] { new IfrsVariable { AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = partition.Id, Value = 1.0 }, ", + "\n new IfrsVariable { AmountType = \"PR\", AocType = \"AU\", Novelty = \"I\", Partition = partition.Id, Value = 2.0 },", + "\n new IfrsVariable { AmountType = \"PR\", AocType = \"EV\", Novelty = \"I\", Partition = partition.Id, Value = 3.0 },", + "\n new IfrsVariable { AmountType = \"CL\", AocType = \"CL\", Novelty = \"I\", Partition = partition.Id, Value = 4.0 },", + "\n new IfrsVariable { AmountType = \"CL\", AocType = \"AU\", Novelty = \"I\", Partition = partition.Id, Value = 5.0 },", + "\n new IfrsVariable { AmountType = \"CL\", AocType = \"EV\", Novelty = \"I\", Partition = partition.Id, Value = 6.0 } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var previousScenarioIfrsVars = new[] { new IfrsVariable { AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = previousPeriodPartitionScenarioMTUP.Id, Value = 3.15 }, ", + "\n new IfrsVariable { AmountType = \"PR\", AocType = \"AU\", Novelty = \"I\", Partition = previousPeriodPartitionScenarioMTUP.Id, Value = 7.17 } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var scenarioIfrsVars = new[] { new IfrsVariable { AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Value = 1.1 }, ", + "\n new IfrsVariable { AmountType = \"PR\", AocType = \"AU\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Value = 2.1 } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var newScenarioIfrsVars = new[] { new IfrsVariable { AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Value = 11.0 }, ", + "\n new IfrsVariable { AmountType = \"CL\", AocType = \"CL\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Value = 41.0 } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario Query and Workspace with new scenario", + "\n", + "\nIfrs variable query test.
", + "\nScenario Actual re-import.
", + "\nDataSource with BestEstimate and Scenario ifrs variable, Workspace with new ifrs variable for Scenario.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateIfrsVars.Concat(scenarioIfrsVars).ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());", + "\nawait ws.UpdateAsync(newScenarioIfrsVars);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedIfrsVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Actual);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedIfrsVars.Select(x => x.Value).Sum().Should().Be(52.0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query, Workspace with no scenario, mismatching format", + "\n", + "\nIfrs variable query test.
", + "\nScenario parameter (re-)import.
", + "\nDataSource with BestEstimate and Scenario ifrs variable, Workspace without any ifrs variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateIfrsVars.Concat(scenarioIfrsVars).ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedIfrsVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Cashflow);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedIfrsVars.Select(x => x.Value).Sum().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query, Workspace with no scenario and DataSource with scenario", + "\n", + "\nIfrs variable query test.
", + "\nScenario Actual import of an empty file.
", + "\nDataSource with BestEstimate and Scenario ifrs variable, Workspace without any ifrs variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateIfrsVars.Concat(scenarioIfrsVars).ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedIfrsVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Actual);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedIfrsVars.Select(x => x.Value).Sum().Should().Be(3.2);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query, Workspace with no new scenario and DataSource with only Best Estimate", + "\n", + "\nIfrs variable query test.
", + "\nScenario Actual import of an empty file.
", + "\nDataSource with BestEstimate ifrs variable, Workspace without any ifrs variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateIfrsVars.ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedIfrsVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Actual);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedIfrsVars.Select(x => x.Value).Sum().Should().Be(21);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query, Workspace with no scenario and DataSource with Best Estimate and previous period scenario", + "\n", + "\nIfrs variable query test.
", + "\nScenario Actual import of an empty file.
", + "\nDataSource with BestEstimate and previous period Scenario ifrs variable, Workspace without any ifrs variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync( await DataSource.Query().ToArrayAsync() );", + "\nawait DataSource.UpdateAsync( bestEstimateIfrsVars.Concat(previousScenarioIfrsVars).ToArray() );", + "\nvar ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var queriedIfrsVars = await ws.QueryPartitionedDataAsync(DataSource, partitionScenarioMTUP.Id, partition.Id, ImportFormats.Actual);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "queriedIfrsVars.Select(x => x.Value).Sum().Should().Be(21);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Report" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var bestEstimateIfrsVars = new[] { new IfrsVariable { DataNode = \"DT1.1\", AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = partition.Id, Value = 1.0 }, ", + "\n new IfrsVariable { DataNode = \"DT1.1\", AmountType = \"PR\", AocType = \"AU\", Novelty = \"I\", Partition = partition.Id, Value = 2.0 },", + "\n new IfrsVariable { DataNode = \"DT1.1\", AmountType = \"PR\", AocType = \"EV\", Novelty = \"I\", Partition = partition.Id, Value = 3.0 },", + "\n new IfrsVariable { DataNode = \"DT1.1\", AmountType = \"CL\", AocType = \"CL\", Novelty = \"I\", Partition = partition.Id, Value = 4.0 },", + "\n new IfrsVariable { DataNode = \"DT1.1\", AmountType = \"CL\", AocType = \"AU\", Novelty = \"I\", Partition = partition.Id, Value = 5.0 },", + "\n new IfrsVariable { DataNode = \"DT1.1\", AmountType = \"CL\", AocType = \"EV\", Novelty = \"I\", Partition = partition.Id, Value = 6.0 } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var scenarioIfrsVars = new[] { new IfrsVariable { DataNode = \"DT1.1\", AmountType = \"PR\", AocType = \"CL\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Value = 1.1 }, ", + "\n new IfrsVariable { DataNode = \"DT1.1\", AmountType = \"PR\", AocType = \"AU\", Novelty = \"I\", Partition = partitionScenarioMTUP.Id, Value = 2.1 } };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Best estimate query", + "\n", + "\nReport variable query test.
", + "\nReport for Best Estimate ( or Scenario Delta and Scenario All).
", + "\nDataSource and Workspace with BestEstimate and Scenario ifrs variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ws.UpdateAsync(bestEstimateIfrsVars);", + "\nawait ws.UpdateAsync(scenarioIfrsVars);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "(await ws.QueryReportVariablesAsync((args.Year, args.Month, args.ReportingNode, args.Scenario))).Select(x => x.Value).Sum().Should().Be(21);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario query", + "\n", + "\nReport variable query test.
", + "\nReport for Scenario.
", + "\nDataSource and Workspace with BestEstimate and Scenario ifrs variable.
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization());" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ws.UpdateAsync(bestEstimateIfrsVars);", + "\nawait ws.UpdateAsync(scenarioIfrsVars);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "(await ws.QueryReportVariablesAsync((args.Year, args.Month, args.ReportingNode, argsScenarioMTUP.Scenario))).Select(x => x.Value).Sum().Should().Be(21.2);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index 7e87e8b6..96b29978 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "UhYcUg0YDU2EVWpCprNDfg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "code", @@ -589,6 +588,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -608,6 +616,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -746,7 +763,6 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"B\", Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} }};", "\n", "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2016, 2, \"A\", \"BBA\");", - "\n", "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 10.1, 10.1);", "\nactivity" ], @@ -769,7 +785,7 @@ "source": [ "var expectedErrorMessage = Get(Error.YieldCurveNotFound, \"EUR\",\"2016\",\"12\",\"Best Estimate\",\"A\");", "\nvar errorMessage = activity.Errors.First().ToString();", - "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true)" + "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -786,7 +802,6 @@ "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"B\", Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} }};", "\n", "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2016, 2, \"A\", \"BBA\");", - "\n", "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 10.1, 10.1);", "\nactivity" ], @@ -798,7 +813,7 @@ "cell_type": "code", "source": [ "activity.Status.Should().Be(ActivityLogStatus.Failed);", - "\nactivity.Errors.Count().Should().Be(1)" + "\nactivity.Errors.Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -809,7 +824,70 @@ "source": [ "var expectedErrorMessage = Get(Error.YieldCurveNotFound, \"EUR\",\"2016\",\"9\",\"Best Estimate\",\"A\");", "\nvar errorMessage = activity.Errors.First().ToString();", - "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true)" + "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,\"YCUP\");", + "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"A\", Values = new double[]{0.1,0.2,0.3,0.4,0.5,0.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Values = new double[]{1.1,1.2,1.3,1.4,1.5,1.6} }, ", + "\n new YieldCurve{ Currency = \"CHF\", Year = 2020, Month = 6, Name = \"A\", Values = new double[]{3.1,3.2,3.3,3.4,3.5,3.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"B\", Values = new double[]{2.1,2.2,2.3,2.4,2.5,2.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"A\", Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Values = new double[]{9.1,9.2,9.3,9.4,9.5,9.6} },", + "\n new YieldCurve{ Currency = \"CHF\", Year = 2016, Month = 3, Name = \"A\", Values = new double[]{8.1,8.2,8.3,8.4,8.5,8.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"B\", Values = new double[]{7.1,7.2,7.3,7.4,7.5,7.6} }};", + "\n", + "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2016, 6, \"A\", \"BBA\");", + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 9.1, 1.1, 6.1);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var args = new Args(\"CH\",2020,9,Periodicity.Monthly,\"YCUP\");", + "\nvar testData = new YieldCurve[] {new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"A\", Values = new double[]{0.1,0.2,0.3,0.4,0.5,0.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Values = new double[]{1.1,1.2,1.3,1.4,1.5,1.6} }, ", + "\n new YieldCurve{ Currency = \"CHF\", Year = 2020, Month = 6, Name = \"A\", Values = new double[]{3.1,3.2,3.3,3.4,3.5,3.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Name = \"B\", Values = new double[]{2.1,2.2,2.3,2.4,2.5,2.6} }, ", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"A\", Values = new double[]{6.1,6.2,6.3,6.4,6.5,6.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Values = new double[]{9.1,9.2,9.3,9.4,9.5,9.6} },", + "\n new YieldCurve{ Currency = \"CHF\", Year = 2016, Month = 3, Name = \"A\", Values = new double[]{8.1,8.2,8.3,8.4,8.5,8.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"B\", Values = new double[]{7.1,7.2,7.3,7.4,7.5,7.6} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Scenario = \"YCUP\", Values = new double[]{90.1,9.2,9.3} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2020, Month = 6, Scenario = \"YCUP\", Values = new double[]{10.1,1.2,1.3} },", + "\n new YieldCurve{ Currency = \"EUR\", Year = 2016, Month = 3, Name = \"A\", Scenario = \"YCUP\", Values = new double[]{60.1,6.2,6.3} }, };", + "\n", + "\n(int year , int month, string yieldCurveName, string valuationApproach) dataNodeTestData = (2016, 6, \"A\", \"BBA\");", + "\nvar activity = await CheckLoadYieldCurveAsync(args, testData, dataNodeTestData, 9.1, 10.1, 60.1);", + "\nactivity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -1053,4 +1131,4 @@ "outputs": [] } ] -} \ No newline at end of file +} diff --git a/ifrs17/Test/ReportStorageTest.ipynb b/ifrs17/Test/ReportStorageTest.ipynb index 277fca1c..e5d77dbe 100644 --- a/ifrs17/Test/ReportStorageTest.ipynb +++ b/ifrs17/Test/ReportStorageTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "5NqHf0icnEqXIEcMtfnNvQ", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "code", @@ -73,7 +72,7 @@ "\n ", "\n //Create report storage", "\n var period = (year, month);", - "\n var reportStorage = new ReportStorage(Workspace, Report);", + "\n var reportStorage = new ReportStorage(Workspace, Report, Export);", "\n await reportStorage.InitializeReportIndependentCacheAsync();", "\n await reportStorage.InitializeAsync(period, \"G\", null, CurrencyType.Contractual);", "\n ", diff --git a/ifrs17/Test/TechnicalMarginTest.ipynb b/ifrs17/Test/TechnicalMarginTest.ipynb index d40c3bfd..a7b29d3d 100644 --- a/ifrs17/Test/TechnicalMarginTest.ipynb +++ b/ifrs17/Test/TechnicalMarginTest.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "OJ1IUniidUKv0PyIHZFe6w", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", diff --git a/ifrs17/Test/TestData.ipynb b/ifrs17/Test/TestData.ipynb index 1326997d..e222656a 100644 --- a/ifrs17/Test/TestData.ipynb +++ b/ifrs17/Test/TestData.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "2te-PqA6Wk2b8-olomgbmA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -221,7 +222,8 @@ "var groupOfInsuranceContracts = \"DT1.1\";", "\nvar groupOfReinsuranceContracts = \"DTR1.1\";", "\nvar reportingNode = \"CH\";", - "\nvar scenario = (string)null;" + "\nvar scenarioBestEstimate = (string)null;", + "\nvar scenarioMortalityUp = \"MTUP\";" ], "metadata": {}, "execution_count": 0, @@ -230,8 +232,10 @@ { "cell_type": "code", "source": [ - "var args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenario, ImportFormats.Actual);", - "\nvar previousArgs = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenario, ImportFormats.Actual);" + "var args = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenarioBestEstimate, ImportFormats.Actual);", + "\nvar previousArgs = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenarioBestEstimate, ImportFormats.Actual);", + "\nvar argsScenarioMTUP = new ImportArgs(reportingNode, 2021, 3, Periodicity.Quarterly, scenarioMortalityUp, ImportFormats.Actual);", + "\nvar previousScenarioArgsMTUP = new ImportArgs(reportingNode, 2020, 12, Periodicity.Quarterly, scenarioMortalityUp, ImportFormats.Actual);" ], "metadata": {}, "execution_count": 0, @@ -246,22 +250,39 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\n ReportingNode = args.ReportingNode};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ "var partition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", "\n ReportingNode = reportingNode, ", - "\n Scenario = scenario, ", + "\n Scenario = scenarioBestEstimate, ", "\n Year = args.Year,", "\n Month = args.Month };", "\nvar previousPeriodPartition = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousArgs)),", "\n ReportingNode = reportingNode, ", - "\n Scenario = scenario, ", + "\n Scenario = scenarioBestEstimate, ", "\n Year = previousArgs.Year,", "\n Month = previousArgs.Month };", - "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = args.ReportingNode};", - "\n" + "\nvar partitionScenarioMTUP = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(argsScenarioMTUP)),", + "\n ReportingNode = reportingNode, ", + "\n Scenario = scenarioMortalityUp, ", + "\n Year = args.Year,", + "\n Month = args.Month };", + "\nvar previousPeriodPartitionScenarioMTUP = new PartitionByReportingNodeAndPeriod { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(previousScenarioArgsMTUP)),", + "\n ReportingNode = reportingNode, ", + "\n Scenario = scenarioMortalityUp, ", + "\n Year = previousScenarioArgsMTUP.Year,", + "\n Month = previousScenarioArgsMTUP.Month };" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Test/Tests.ipynb b/ifrs17/Test/Tests.ipynb index a52dc9e6..aa5cba54 100644 --- a/ifrs17/Test/Tests.ipynb +++ b/ifrs17/Test/Tests.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "OJcj8lGDvkqHTMyxkmDNxg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -42,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"QueriesScenarioDataTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Utils/ActivityLog.ipynb b/ifrs17/Utils/ActivityLog.ipynb index 4bd9a413..e821c2ff 100644 --- a/ifrs17/Utils/ActivityLog.ipynb +++ b/ifrs17/Utils/ActivityLog.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "bezRpR9290SNllQh6iRIhQ", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -79,7 +80,7 @@ "cell_type": "markdown", "source": [ "## Import Export Activity ", - "\nEvery activity to and from (import or export) the DataSource is tracked by recording an ImportExportActivity. Among other information this record tracks the user who performs the action, the timestamp, the activity log, and a unique identifier which can be used to retrieve the data subject of the activity. " + "\nEvery activity to and from (import or export) the DataSource is tracked by recording an ImportExportActivity. Among other information this record tracks the user who performs the action, the timestamp, the activity log, and the unique identifier which can be used to retrieve the data subject of the activity. " ], "metadata": {}, "execution_count": 0, @@ -157,6 +158,11 @@ "\n public string Format {get; init;}", "\n protected IDataSetImportVariable DataSetReader {get; set;}", "\n protected ISessionVariable Session {get; set;}", + "\n", + "\n public KeyedImportExport() ", + "\n { ", + "\n Id = Guid.NewGuid();", + "\n }", "\n}" ], "metadata": {}, @@ -220,6 +226,14 @@ "\n{", "\n protected ImportOptions Options {get; set;}", "\n", + "\n public KeyedImport() {Id = Guid.NewGuid();}", + "\n", + "\n public abstract KeyedImport WithOptions(ImportOptions options);", + "\n", + "\n public KeyedImport WithSession(ISessionVariable session) => this with {Session = session};", + "\n", + "\n public KeyedImport WithDataSetReader(IDataSetImportVariable importVariable) => this with {DataSetReader = importVariable};", + "\n", "\n public async Task InitializeImportDataAsync()", "\n {", "\n var stream = await GenerateStreamWrapperAsync();", @@ -287,6 +301,8 @@ "\n", "\n public string Source {get; init;}", "\n", + "\n public ImportFile() : base(){;}", + "\n", "\n public ImportFile(FileImportOptions options, IDataSetImportVariable importVariable, ISessionVariable session)", "\n {", "\n Options = options;", @@ -299,7 +315,26 @@ "\n ContentType = Path.GetExtension(fileName);", "\n Source = options.Storage.GetType().Name; ", "\n Partition = GetInvolvedPartitions(options);", - "\n // Andrey Katz: Options.TargetDataSource.Partion.GetCurrent(?? What do we put here, different classes might posess various partitions, e.g. Yield Curve has none ??)", + "\n // Andrey Katz: Options.TargetDataSource.Partion.GetCurrentPartitions(?? What do we put here, different classes might posess various partitions, e.g. Yield Curve has none ??)", + "\n }", + "\n", + "\n public override ImportFile WithOptions(ImportOptions options)", + "\n {", + "\n if (options is FileImportOptions fio)", + "\n {", + "\n string fileName = fio.FileName;", + "\n return this with{Options = fio,", + "\n Name = Path.GetFileName(fileName),", + "\n Directory = Path.GetDirectoryName(fileName),", + "\n ContentType = Path.GetExtension(fileName),", + "\n Source = options.Storage.GetType().Name,", + "\n Partition = GetInvolvedPartitions(options)", + "\n };", + "\n }", + "\n else", + "\n {", + "\n throw new Exception(\"The import options must be of file import options type\");", + "\n }", "\n }", "\n", "\n public ImportFile(Guid id)", @@ -329,6 +364,8 @@ "\n{", "\n public string Content {get; init;}", "\n", + "\n public ImportString() : base(){;}", + "\n", "\n public ImportString(StringImportOptions options, IDataSetImportVariable importVariable, ISessionVariable session)", "\n {", "\n Options = options;", @@ -338,6 +375,13 @@ "\n Content = options.Content;", "\n }", "\n", + "\n public override ImportString WithOptions(ImportOptions options)", + "\n {", + "\n if (options is StringImportOptions sgio) return this with {Options = sgio, ", + "\n Content = sgio.Content};", + "\n else throw new Exception(\"The import options must be of string import options type\");", + "\n }", + "\n", "\n public ImportString(Guid id)", "\n {", "\n Id = id;", @@ -364,6 +408,14 @@ "\n Id = Guid.NewGuid();", "\n }", "\n", + "\n public ImportDataSet() : base() {;}", + "\n", + "\n public override ImportDataSet WithOptions(ImportOptions options)", + "\n {", + "\n if (options is DataSetImportOptions dsio) return this with {Options = dsio};", + "\n else throw new Exception(\"The import options must be of data set import options type\");", + "\n }", + "\n", "\n public ImportDataSet(Guid id)", "\n {", "\n Id = id;", @@ -390,6 +442,14 @@ "\n Id = Guid.NewGuid();", "\n }", "\n", + "\n public ImportStream() : base() {;}", + "\n", + "\n public override ImportStream WithOptions(ImportOptions options)", + "\n {", + "\n if (options is StreamImportOptions smio) return this with {Options = smio};", + "\n else throw new Exception(\"The import options must be of stream import options type\");", + "\n }", + "\n", "\n public ImportStream(Guid id)", "\n {", "\n Id = id;", @@ -415,92 +475,58 @@ { "cell_type": "code", "source": [ - "public record ImportBuilderWriter(ImportOptionsBuilder Builder, ", - "\n ISessionVariable Session, ", - "\n IDataSource DataSource, ", - "\n IDataSetImportVariable ImportVariable)", + "public record ImportBuilderWriter(ImportOptionsBuilder Builder) ", "\n{", + "\n public static ISessionVariable Session {get; set;}", + "\n public static IDataSource DataSource {get; set;}", + "\n public static IDataSetImportVariable ImportVariable {get; set;}", + "\n", "\n public async Task ExecuteAsync()", "\n {", "\n var log = await Builder.ExecuteAsync();", "\n var options = Builder.GetImportOptions();", - "\n var activity = new ImportExportActivity(log, Session);", - "\n bool importSucceeded = true;", - "\n switch(options)", + "\n var activity = options switch", "\n {", - "\n case FileImportOptions fio:", - "\n var importFile = new ImportFile(Guid.NewGuid());", - "\n try", - "\n {", - "\n importFile = await (new ImportFile(fio, ImportVariable, Session)).InitializeImportDataAsync() as ImportFile;", - "\n activity = activity with {SourceId = importFile.Id};", - "\n }", - "\n catch (Exception e)", - "\n {", - "\n importSucceeded = false;", - "\n activity = activity with {SourceId = null, ExceptionMessage = e.Message};", - "\n }", - "\n activity = activity with {Category = \"Import from File\"};", - "\n if (importSucceeded) await DataSource.UpdateAsync(importFile.RepeatOnce());", - "\n break;", - "\n", - "\n case StringImportOptions sgio:", - "\n var importString = new ImportString(Guid.NewGuid());", - "\n try", - "\n {", - "\n importString = await (new ImportString(sgio, ImportVariable, Session)).InitializeImportDataAsync() as ImportString;", - "\n activity = activity with {SourceId = importString.Id};", - "\n }", - "\n catch (Exception e)", - "\n {", - "\n importSucceeded = false;", - "\n activity = activity with {SourceId = null, ExceptionMessage = e.Message};", - "\n }", - "\n activity = activity with {Category = \"Import from String\"};", - "\n if (importSucceeded) await DataSource.UpdateAsync(importString.RepeatOnce());", - "\n break;", - "\n ", - "\n case StreamImportOptions smio:", - "\n var importStream = new ImportStream(Guid.NewGuid());", - "\n try", - "\n {", - "\n importStream = await (new ImportStream(smio, ImportVariable, Session)).InitializeImportDataAsync() as ImportStream;", - "\n activity = activity with {SourceId = importStream.Id};", - "\n }", - "\n catch (Exception e)", - "\n {", - "\n importSucceeded = false;", - "\n activity = activity with {SourceId = null, ExceptionMessage = e.Message};", - "\n }", - "\n activity = activity with {Category = \"Import from Stream\"};", - "\n if (importSucceeded) await DataSource.UpdateAsync(importStream.RepeatOnce());", - "\n break;", - "\n", - "\n case DataSetImportOptions dsio:", - "\n var importDataSet = new ImportDataSet(Guid.NewGuid());", - "\n try", - "\n {", - "\n importDataSet = await (new ImportDataSet(dsio, ImportVariable, Session)).InitializeImportDataAsync() as ImportDataSet;", - "\n activity = activity with {SourceId = importDataSet.Id};", - "\n }", - "\n catch (Exception e)", - "\n {", - "\n importSucceeded = false;", - "\n activity = activity with {SourceId = null, ExceptionMessage = e.Message};", - "\n }", - "\n activity = activity with {Category = \"Import from Data Set\"};", - "\n if (importSucceeded) await DataSource.UpdateAsync(importDataSet.RepeatOnce());", - "\n break;", - "\n", - "\n default:", - "\n throw new Exception(\"Import Options object is not an instance of an appropriate class.\");", - "\n break;", - "\n }", + "\n FileImportOptions fio => await ReportInputAndUpdateActivityAsync(log, fio, \"Import from File \"),", + "\n StringImportOptions sgio => await ReportInputAndUpdateActivityAsync(log, sgio, \"Import from String\"),", + "\n StreamImportOptions smio => await ReportInputAndUpdateActivityAsync(log, smio, \"Import from Stream\"),", + "\n DataSetImportOptions dsio => await ReportInputAndUpdateActivityAsync(log, dsio, \"Import from Data Set\"),", + "\n _ => null,", + "\n };", + "\n if (activity is null) throw new Exception(\"Import Options object is not an instance of an appropriate class.\");", "\n await DataSource.UpdateAsync(activity.RepeatOnce());", "\n await DataSource.CommitAsync();", "\n return log;", "\n }", - "\n}" + "\n", + "\n private async Task ReportInputAndUpdateActivityAsync(ActivityLog log, TOptions options, string categoryMessage)", + "\n where TOptions: ImportOptions", + "\n where TImport: KeyedImport, new()", + "\n {", + "\n var activity = new ImportExportActivity(log, Session);", + "\n try", + "\n {", + "\n var import = new TImport();", + "\n import = await import.WithSession(Session)", + "\n .WithDataSetReader(ImportVariable)", + "\n .WithOptions(options)", + "\n .InitializeImportDataAsync() as TImport;", + "\n activity = activity with {SourceId = import.Id, Category = categoryMessage};", + "\n await DataSource.UpdateAsync(import.RepeatOnce());", + "\n }", + "\n catch (Exception e)", + "\n {", + "\n activity = activity with {SourceId = null, ", + "\n Category = categoryMessage, ", + "\n ExceptionMessage = e.Message};", + "\n }", + "\n return activity;", + "\n }", + "\n}", + "\n", + "\nImportBuilderWriter.Session = Session;", + "\nImportBuilderWriter.DataSource = DataSource;", + "\nImportBuilderWriter.ImportVariable = DataSetReader;" ], "metadata": {}, "execution_count": 0, @@ -509,11 +535,11 @@ { "cell_type": "code", "source": [ - "public record ExportBuilderWriter(DocumentBuilder Builder, ", - "\n ISessionVariable Session, ", - "\n IDataSource DataSource, ", - "\n IDataSetImportVariable ImportVariable)", + "public record ExportBuilderWriter(DocumentBuilder Builder)", "\n{", + "\n public static ISessionVariable Session {get; set;}", + "\n public static IDataSetImportVariable ImportVariable {get; set;}", + "\n public static IDataSource DataSource {get; set;}", "\n public async Task ExecuteAsync()", "\n {", "\n var exportResult = await Builder.ExecuteAsync();", @@ -525,7 +551,10 @@ "\n await DataSource.CommitAsync();", "\n return exportResult;", "\n }", - "\n}" + "\n}", + "\nExportBuilderWriter.Session = Session;", + "\nExportBuilderWriter.DataSource = DataSource;", + "\nExportBuilderWriter.ImportVariable = DataSetReader;" ], "metadata": {}, "execution_count": 0, @@ -534,11 +563,7 @@ { "cell_type": "code", "source": [ - "public static ImportBuilderWriter WithActivityLog(this ImportOptionsBuilder builder, ", - "\n ISessionVariable session, ", - "\n IDataSource dataSource, ", - "\n IDataSetImportVariable importVariable) => ", - "\n new ImportBuilderWriter(builder, session, dataSource, importVariable);" + "public static ImportBuilderWriter WithActivityLog(this ImportOptionsBuilder builder) => new ImportBuilderWriter(builder);" ], "metadata": {}, "execution_count": 0, @@ -547,11 +572,7 @@ { "cell_type": "code", "source": [ - "public static ExportBuilderWriter WithActivityLog(this IDocumentBuilder builder, ", - "\n ISessionVariable session, ", - "\n IDataSource dataSource, ", - "\n IDataSetImportVariable importVariable) =>", - "\n new ExportBuilderWriter(builder as DocumentBuilder, session, dataSource, importVariable);" + "public static ExportBuilderWriter WithActivityLog(this IDocumentBuilder builder) => new ExportBuilderWriter(builder as DocumentBuilder);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index 990dd62b..bd39c52e 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "qGIN50NW4UaWrmm2WP47VA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,13 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False", - "toc-showmarkdowntxt": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -110,9 +108,9 @@ "\n Status = a.Status == ActivityLogStatus.Failed || b.Status == ActivityLogStatus.Failed ? ActivityLogStatus.Failed : ActivityLogStatus.Succeeded,", "\n StartDateTime = a.StartDateTime < b.StartDateTime ? a.StartDateTime : b.StartDateTime,", "\n FinishDateTime = a.FinishDateTime > b.FinishDateTime ? a.FinishDateTime : b.FinishDateTime,", - "\n Errors = a.Errors.Concat(b.Errors).ToList(),", - "\n Warnings = a.Warnings.Concat(b.Warnings).ToList(),", - "\n Infos = a.Infos.Concat(b.Infos).ToList(),", + "\n Errors = a.Errors.Concat(b.Errors).ToHashSet().ToList(),", + "\n Warnings = a.Warnings.Concat(b.Warnings).ToHashSet().ToList(),", + "\n Infos = a.Infos.Concat(b.Infos).ToHashSet().ToList(),", "\n };", "\n}", "\n", diff --git a/ifrs17/Utils/EqualityComparers.ipynb b/ifrs17/Utils/EqualityComparers.ipynb index 488dc6a8..2f713e97 100644 --- a/ifrs17/Utils/EqualityComparers.ipynb +++ b/ifrs17/Utils/EqualityComparers.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "mCSaKAKB_kOGU2Lj-Wovrw", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -13,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -139,6 +140,38 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "class ParametersComparer: IEqualityComparer", + "\n{", + "\n private ParametersComparer(){}", + "\n", + "\n public bool Equals(DataNodeParameter x, DataNodeParameter y) {", + "\n if (x == null && y == null) return true; ", + "\n if (x == null || y == null) return false; ", + "\n if (!(x.Year == y.Year && x.Month == y.Month && x.Scenario == y.Scenario)) return false; ", + "\n if (x is SingleDataNodeParameter && y is SingleDataNodeParameter && x.DataNode == y.DataNode &&", + "\n ((SingleDataNodeParameter)x).PremiumAllocation == ((SingleDataNodeParameter)y).PremiumAllocation) return true; ", + "\n if (x is InterDataNodeParameter && y is InterDataNodeParameter) {", + "\n var xi = (InterDataNodeParameter)x;", + "\n var yi = (InterDataNodeParameter)y;", + "\n if (xi.ReinsuranceCoverage != yi.ReinsuranceCoverage) return false;", + "\n if ((xi.LinkedDataNode == yi.LinkedDataNode && xi.DataNode == yi.DataNode) ||", + "\n (xi.LinkedDataNode == yi.DataNode && xi.DataNode == yi.LinkedDataNode)) return true;", + "\n }", + "\n return false;", + "\n }", + "\n\t", + "\n public int GetHashCode (DataNodeParameter x) => 0;", + "\n", + "\n public static ParametersComparer Instance() => new ParametersComparer();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Utils/Extensions.ipynb b/ifrs17/Utils/Extensions.ipynb index d23cd61e..45c921fc 100644 --- a/ifrs17/Utils/Extensions.ipynb +++ b/ifrs17/Utils/Extensions.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "NWvfpshro0mc6HFQvYxRaA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -75,18 +74,21 @@ { "cell_type": "code", "source": [ - "// because the default(T) is something else than the first/last element. What about \"static T GetValidElement(this IList array, int index)\"? ", - "\nstatic T GetElementOrDefault(this ICollection array, int index)", + "static T GetValidElement(this ICollection collection, int index)", "\n{ ", - "\n var count = array.Count;", - "\n if (array == null || count == 0)", + "\n var count = collection.Count;", + "\n if (collection == null || count == 0)", "\n return default(T);", "\n", - "\n return index < 0", - "\n ? array.ElementAt(0) // should this case be removed?", - "\n : index < count", - "\n ? array.ElementAt(index)", - "\n : array.ElementAt(count -1);", + "\n if (index < 0)", + "\n {", + "\n ApplicationMessage.Log(Error.NegativeIndex);", + "\n return default;", + "\n }", + "\n", + "\n return index < count", + "\n ? collection.ElementAt(index)", + "\n : collection.ElementAt(count -1);", "\n}" ], "metadata": {}, @@ -197,7 +199,7 @@ { "cell_type": "markdown", "source": [ - "# ToIdentityString" + "# Identity property reader" ], "metadata": {}, "execution_count": 0, @@ -206,16 +208,30 @@ { "cell_type": "code", "source": [ - "using System.Text;", - "\npublic static string ToIdentityString(this T v, params string[] excludingProperties) where T : class", - "\n{", - "\n StringBuilder sb = new StringBuilder();", - "\n var propertyInfos = v.GetType()", - "\n .GetProperties()", - "\n .Where(x => Attribute.IsDefined(x, typeof(IdentityPropertyAttribute)) && !excludingProperties.Contains(x.Name))", - "\n .OrderByDescending(x => x.PropertyType.Name).ThenByDescending(x => x.Name)", - "\n .Select(x => sb.Append(x.Name).Append(\":\").Append(v.GetType().GetProperty(x.Name)?.GetValue(v, null)).Append(\", \")).ToArray();", - "\n return propertyInfos.Count() == 0? v.ToString() : propertyInfos.Select(p => p.ToString()).ToArray().Last();", + "using static Systemorph.Vertex.Equality.IdentityPropertyExtensions;", + "\nusing System.Linq.Expressions;", + "\npublic static class IdentityReader where T : class {", + "\n private static Dictionary> ExpressionsByExcludedProperties = new();", + "\n public static string Concat(string first, string second) => first + \" \" + second;", + "\n public static string GetString(Object item) => (item == null) ? \"\" : item.ToString();", + "\n", + "\n private static Func GetToIdentityExpression(string[] excludedProperties) {", + "\n var pm = Expression.Parameter(typeof(T));", + "\n var expression = typeof(T).GetIdentityProperties().Where(x => !excludedProperties.Contains(x.Name))", + "\n .SelectMany(x => new Expression[]{ Expression.Constant(x.Name.ToString()+\":\"),", + "\n Expression.Call(typeof(IdentityReader).GetMethod(nameof(GetString)), Expression.Convert(Expression.Property(pm, x.Name), typeof(Object))) }", + "\n ).Aggregate((x, y) => Expression.Call(typeof(IdentityReader).GetMethod(nameof(IdentityReader.Concat)), x, y));", + "\n return Expression.Lambda>(expression, pm).Compile();", + "\n }", + "\n", + "\n public static string ToString(T x, string[] excludedProperties) {", + "\n var key = string.Join(\",\", excludedProperties.OrderBy(x => x));", + "\n if(!ExpressionsByExcludedProperties.TryGetValue(key, out var expression)) {", + "\n ExpressionsByExcludedProperties[key] = GetToIdentityExpression(excludedProperties);", + "\n return ExpressionsByExcludedProperties[key](x);", + "\n }", + "\n return expression(x);", + "\n }", "\n}" ], "metadata": {}, @@ -225,7 +241,7 @@ { "cell_type": "markdown", "source": [ - "# ToString with including properties" + "# ToString with excluding properties" ], "metadata": {}, "execution_count": 0, @@ -234,11 +250,10 @@ { "cell_type": "code", "source": [ - "public static string ToStringWith(this T variable, string[] properties) where T : BaseVariableIdentity", + "public static string ToIdentityString(this T variable, string[] ignoreProperties = null) where T : class", "\n{", - "\n var propertiesRead = variable.ToString().Split('{', '}')[1].Split(',');", - "\n var propertiesFiltered = propertiesRead.Where(x=> properties.Contains(x.Split('=')[0].Trim()));", - "\n return string.Join(\", \", propertiesFiltered).Trim();", + "\n if (ignoreProperties == null) ignoreProperties = new string[0];", + "\n return IdentityReader.ToString(variable, ignoreProperties);", "\n}" ], "metadata": {}, diff --git a/ifrs17/Utils/ImportCalculationMethods.ipynb b/ifrs17/Utils/ImportCalculationMethods.ipynb index 4e8270a2..6e96e64d 100644 --- a/ifrs17/Utils/ImportCalculationMethods.ipynb +++ b/ifrs17/Utils/ImportCalculationMethods.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "IA3IvuUbk0atrL8OxJVZ2Q", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -109,12 +108,12 @@ "\n if(periodType == PeriodType.BeginningOfPeriod)", "\n {", "\n for (var i = nominalValues.Length - 1; i >= 0; i--)", - "\n ret[i] = nominalValues[i] + GetElementOrDefault(ret, i + 1) * GetElementOrDefault(monthlyDiscounting, i/12);", + "\n ret[i] = nominalValues[i] + ret.GetValidElement(i + 1) * monthlyDiscounting.GetValidElement(i/12);", "\n return ret;", "\n }", "\n ", "\n for (var i = nominalValues.Length - 1; i >= 0; i--)", - "\n ret[i] = ( nominalValues[i] + GetElementOrDefault(ret, i + 1) ) * GetElementOrDefault(monthlyDiscounting, i/12);", + "\n ret[i] = ( nominalValues[i] + ret.GetValidElement(i + 1) ) * monthlyDiscounting.GetValidElement(i/12);", "\n ", "\n return ret;", "\n}" @@ -130,7 +129,7 @@ "\n{ ", "\n return Enumerable.Range(0, nominalValues.Length)", "\n .Select( t => Enumerable.Range(t, nominalValues.Length-t)", - "\n .Select( tau => nominalValues[tau] * Math.Pow(GetElementOrDefault(monthlyDiscounting, t/12), tau-t+1) * (Math.Exp(-nonPerformanceRiskRate*(tau-t)) - 1) )", + "\n .Select( tau => nominalValues[tau] * Math.Pow(monthlyDiscounting.GetValidElement(t/12), tau-t+1) * (Math.Exp(-nonPerformanceRiskRate*(tau-t)) - 1) )", "\n .Sum() )", "\n .ToArray();", "\n}" @@ -155,12 +154,12 @@ "\n if(period == PeriodType.BeginningOfPeriod)", "\n {", "\n for (var i = cdcf.Length - 1; i >= 0; i--)", - "\n cdcf[i] = values[i] + GetElementOrDefault(cdcf, i + 1) * GetElementOrDefault(yearlyDiscountRates, i/12);", + "\n cdcf[i] = values[i] + cdcf.GetValidElement(i + 1) * yearlyDiscountRates.GetValidElement(i/12);", "\n }", "\n else", "\n { ", "\n for (var i = cdcf.Length - 1; i >= 0; i--)", - "\n cdcf[i] = ( values[i] + GetElementOrDefault(cdcf, i + 1) ) * GetElementOrDefault(yearlyDiscountRates, i/12);", + "\n cdcf[i] = ( values[i] + cdcf.GetValidElement(i + 1) ) * yearlyDiscountRates.GetValidElement(i/12);", "\n }", "\n return rv with { Values = cdcf };", "\n })", diff --git a/ifrs17/Utils/Queries.ipynb b/ifrs17/Utils/Queries.ipynb index e82f52b9..ce59b274 100644 --- a/ifrs17/Utils/Queries.ipynb +++ b/ifrs17/Utils/Queries.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "COS_CBLUh0Gf_bKIABIZ0Q", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown", @@ -373,8 +372,8 @@ "\n .GroupBy(x => x.DataNode != p.Key ? x.DataNode : x.LinkedDataNode)", "\n .Select(gg =>", "\n {", - "\n var currentCandidate = gg.Where(x => x.Year == args.Year).OrderByDescending(x => x.Month).FirstOrDefault();", - "\n var previousCandidate = gg.Where(x => x.Year < args.Year).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault();", + "\n var currentCandidate = gg.Where(x => x.Year == args.Year).OrderByDescending(x => x.Month).ThenByDescending(x => x.Scenario).FirstOrDefault();", + "\n var previousCandidate = gg.Where(x => x.Year < args.Year && x.Scenario == null).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault();", "\n return (key: p.Key,", "\n currentPeriod: currentCandidate != null ? currentCandidate : previousCandidate,", "\n previousPeriod: previousCandidate != null ? previousCandidate : currentCandidate);", @@ -437,11 +436,12 @@ "\n where T : IPartitioned", "\n where P : IPartition", "\n{", - "\n var partitionBackup = (Guid)querySource.Partition.GetCurrent(typeof(P).Name);", + "\n var partitionBackup = (Guid)(querySource.Partition.GetCurrent(typeof(P).Name)?? default(Guid));", "\n await querySource.Partition.SetAsync

(partition);", "\n // Temporary workaround for physical database: where clause is necessary", "\n var data = await querySource.Query().Where(x => x.Partition == partition).ToArrayAsync();", - "\n await querySource.Partition.SetAsync

(partitionBackup);", + "\n if(partitionBackup == default(Guid)) await querySource.Partition.SetAsync

(null);", + "\n else await querySource.Partition.SetAsync

(partitionBackup);", "\n return data;", "\n}" ], diff --git a/ifrs17/Utils/TestHelper.ipynb b/ifrs17/Utils/TestHelper.ipynb index 6ae41a17..93512a05 100644 --- a/ifrs17/Utils/TestHelper.ipynb +++ b/ifrs17/Utils/TestHelper.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "vk1KfKu5Z0ytQieh3azqFQ", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -10,12 +11,10 @@ "file_extension": ".cs", "mimetype": "text/plain", "name": "C#" - }, - "toc-autonumbering": "True", - "toc-showcode": "False" + } }, "nbformat": 4, - "nbformat_minor": 5, + "nbformat_minor": 8, "cells": [ { "cell_type": "markdown",