From b95a78c114b5412a022706c16fc5e831e21c1a11 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Tue, 11 Apr 2023 15:49:52 +0200 Subject: [PATCH 1/2] generalize get prev identities and test --- ifrs17/Test/AocStructureTest.ipynb | 331 +++++++++++++++++++- ifrs17/Utils/ImportCalculationMethods.ipynb | 17 +- 2 files changed, 335 insertions(+), 13 deletions(-) diff --git a/ifrs17/Test/AocStructureTest.ipynb b/ifrs17/Test/AocStructureTest.ipynb index c3fbbd6b..137dc188 100644 --- a/ifrs17/Test/AocStructureTest.ipynb +++ b/ifrs17/Test/AocStructureTest.ipynb @@ -378,7 +378,16 @@ "\n }},", "\n //{new AocStep(\"CF\",\"C\"), Enumerable.Empty()},", "\n };", - "\nvar activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm);", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm);", "\nactivity" ], "metadata": {}, @@ -551,6 +560,7 @@ "inputRawVariables = new RawVariable[]{", "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"EV\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", "\n};" ], @@ -565,7 +575,8 @@ "\n {", "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")}}, ", - "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"YCU\",\"I\")}},", + "\n {new AocStep(\"EV\",\"I\"), new AocStep[]{new AocStep(\"YCU\",\"I\")}},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"I\")}},", "\n };" ], "metadata": {}, @@ -582,6 +593,7 @@ "\n {new AocStep(\"CF\",\"I\"), new AocStep(\"MC\",\"I\")},", "\n {new AocStep(\"IA\",\"I\"), new AocStep(\"MC\",\"I\")},", "\n {new AocStep(\"YCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", + "\n {new AocStep(\"EV\",\"I\"), new AocStep(\"EV\",\"I\")}, ", "\n {new AocStep(\"CL\",\"C\"), new AocStep(\"CL\",\"C\")},", "\n {new AocStep(\"EA\",\"C\"), new AocStep(\"CF\",\"C\")},", "\n {new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\")},", @@ -603,15 +615,16 @@ "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\")}},", "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\")}},", + "\n {new AocStep(\"EV\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\")}},", "\n ", - "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), ", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", "\n }},", "\n ", - "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", "\n new AocStep(\"CL\",\"C\"),}},", - "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", "\n new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"),}},", - "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), new AocStep(\"EV\",\"I\"),", "\n new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\"),}},", "\n //{new AocStep(\"CF\",\"C\"), Enumerable.Empty()},", "\n };" @@ -639,6 +652,312 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Cash flow: Extend Combined Session" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Preparation" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "string newAocConfig = ", + "\n@\"@@AocConfiguration,,,,,,,,,,,", + "\nAocType,Novelty,DataType,InputSource,FxPeriod,YcPeriod,CdrPeriod,ValuationPeriod,RcPeriod,Order,Year,Month", + "\nBOP,I,Optional,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,1900,1", + "\nMC,I,Optional,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,1900,1", + "\nRCU,I,Calculated,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,30,1900,1", + "\nCF,I,Calculated,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,40,1900,1", + "\nIA,I,Calculated,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,50,1900,1", + "\nAU,I,Optional,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,60,1900,1", + "\nYCU,I,CalculatedTelescopic,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,70,1900,1", + "\nCRU,I,CalculatedTelescopic,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,80,1900,1", + "\nEV,I,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,90,1900,1", + "\nBOP,N,Optional,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,95,1900,1", + "\nCF,N,Calculated,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,110,1900,1", + "\nIA,N,Calculated,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,120,1900,1", + "\nAU,N,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,1900,1", + "\nEV,N,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,140,1900,1", + "\nCF,C,Optional,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,160,1900,1", + "\nWO,C,Optional,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,170,1900,1", + "\nEV,C,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,175,1900,1", + "\nCL,C,Mandatory,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,180,1900,1", + "\nEA,C,Calculated,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,190,1900,1", + "\nAM,C,Calculated,6,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,200,1900,1", + "\nFX,C,Calculated,0,NotApplicable,NotApplicable,NotApplicable,NotApplicable,NotApplicable,210,1900,1", + "\nEOP,C,Calculated,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,220,1900,1\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync(DataSource.Query());", + "\nawait Import.FromString(newAocConfig).WithFormat(ImportFormats.AocConfiguration).WithTarget(DataSource).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### In Force Combined" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "inputRawVariables = new RawVariable[]{", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"EV\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parentBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")}}, ", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"YCU\",\"I\")}},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"C\")}},", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "referenceBm = new Dictionary()", + "\n {", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep(\"BOP\",\"I\")},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep(\"MC\",\"I\")},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep(\"MC\",\"I\")},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep(\"MC\",\"I\")},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", + "\n {new AocStep(\"EV\",\"C\"), new AocStep(\"EV\",\"C\")},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep(\"CL\",\"C\")},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\")},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep(\"CL\",\"C\")},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "fullAocBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\")}},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\")}},", + "\n ", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), ", + "\n }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"EV\",\"C\"),}},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"),}},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\")}},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\")}},", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm);", + "\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": [ + "### InForce, NewBusiness, Combined" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "inputRawVariables = new RawVariable[]{", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"MC\", Novelty = \"I\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"BOP\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"AU\", Novelty = \"N\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"CL\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n new RawVariable{Partition = partition.Id, Values = new []{1.0}, DataNode = groupOfInsuranceContracts, AocType = \"EV\", Novelty = \"C\", AccidentYear = null, AmountType = \"PR\", EstimateType = \"BE\"},", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parentBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"MC\",\"I\")}}, ", + "\n {new AocStep(\"AU\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"YCU\",\"I\"), new AocStep(\"AU\",\"N\")}},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"EV\",\"C\")}},", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "referenceBm = new Dictionary()", + "\n {", + "\n {new AocStep(\"BOP\",\"I\"), new AocStep(\"BOP\",\"I\")},", + "\n {new AocStep(\"MC\",\"I\"), new AocStep(\"MC\",\"I\")},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep(\"MC\",\"I\")},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep(\"MC\",\"I\")},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep(\"MC\",\"I\")}, ", + "\n {new AocStep(\"BOP\",\"N\"), new AocStep(\"BOP\",\"N\")}, ", + "\n {new AocStep(\"CF\",\"N\"), new AocStep(\"BOP\",\"N\")}, ", + "\n {new AocStep(\"IA\",\"N\"), new AocStep(\"BOP\",\"N\")}, ", + "\n {new AocStep(\"AU\",\"N\"), new AocStep(\"AU\",\"N\")}, ", + "\n {new AocStep(\"EV\",\"C\"), new AocStep(\"EV\",\"C\")},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep(\"CL\",\"C\")},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep(\"CL\",\"C\")},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep(\"CL\",\"C\")},", + "\n {new AocStep(\"CF\",\"C\"), new AocStep(\"CF\",\"C\")},", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "fullAocBm = new Dictionary>()", + "\n {", + "\n {new AocStep(\"MC\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\")}},", + "\n {new AocStep(\"CF\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\")}},", + "\n {new AocStep(\"IA\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\")}},", + "\n {new AocStep(\"YCU\",\"I\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\")}},", + "\n ", + "\n {new AocStep(\"CF\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\")}},", + "\n {new AocStep(\"IA\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\")}},", + "\n {new AocStep(\"AU\",\"N\"), new AocStep[]{new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\")}},", + "\n", + "\n {new AocStep(\"EV\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"), new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"), ", + "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", + "\n }},", + "\n {new AocStep(\"CL\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", + "\n new AocStep(\"EV\",\"C\"),}},", + "\n {new AocStep(\"EA\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", + "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"),}},", + "\n {new AocStep(\"AM\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", + "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\")}},", + "\n {new AocStep(\"EOP\",\"C\"), new AocStep[]{new AocStep(\"BOP\",\"I\"), new AocStep(\"MC\",\"I\"),new AocStep(\"CF\",\"I\"), new AocStep(\"IA\",\"I\"), new AocStep(\"YCU\",\"I\"),", + "\n new AocStep(\"BOP\",\"N\"),new AocStep(\"CF\",\"N\"),new AocStep(\"IA\",\"N\"),new AocStep(\"AU\",\"N\"),", + "\n new AocStep(\"EV\",\"C\"), new AocStep(\"CL\",\"C\"), new AocStep(\"EA\",\"C\"), new AocStep(\"AM\",\"C\")}},", + "\n };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await CheckAocStepStructureAsync(inputRawVariables, parentBm, referenceBm, fullAocBm);", + "\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": [ + "### Reset" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await DataSource.DeleteAsync(DataSource.Query());", + "\nawait Import.FromString(canonicalAocConfig).WithFormat(ImportFormats.AocConfiguration).WithTarget(DataSource).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ diff --git a/ifrs17/Utils/ImportCalculationMethods.ipynb b/ifrs17/Utils/ImportCalculationMethods.ipynb index 968763ce..493ba5f1 100644 --- a/ifrs17/Utils/ImportCalculationMethods.ipynb +++ b/ifrs17/Utils/ImportCalculationMethods.ipynb @@ -46,16 +46,19 @@ { "cell_type": "code", "source": [ - "public static Dictionary> GetPreviousIdentities(IEnumerable identities)", + "public static Dictionary> GetPreviousIdentities(IEnumerable aocSteps)", "\n{", - "\n var bopNovelties = identities.Where(id => id.AocType == AocTypes.BOP).Select(id => id.Novelty);", + "\n var bopNovelties = aocSteps.Where(id => id.AocType == AocTypes.BOP).Select(id => id.Novelty);", "\n var previousStep = (new string[]{Novelties.N,Novelties.I,Novelties.C})", "\n .ToDictionary(n => n, n => bopNovelties.Contains(n) ? new AocStep(AocTypes.BOP,n) : null);", - "\n return identities.Where(id => id.AocType != AocTypes.BOP)", - "\n .ToDictionary(x => x, x => {var ret = x.AocType == AocTypes.CL ? previousStep.Where(kvp => kvp.Value != null).Select(kvp => kvp.Value).ToArray() ", - "\n : previousStep[x.Novelty].RepeatOnce();", - "\n previousStep[x.Novelty] = new AocStep(x.AocType, x.Novelty);", - "\n return ret;});", + "\n return aocSteps.Where(id => id.AocType != AocTypes.BOP)", + "\n .ToDictionary(x => x, ", + "\n x => {var isFirstCombined = x.Novelty == Novelties.C && (previousStep[Novelties.C] == null || previousStep[Novelties.C].AocType == AocTypes.BOP);", + "\n var ret = isFirstCombined", + "\n ? previousStep.Where(kvp => kvp.Value != null).Select(kvp => kvp.Value).ToArray() ", + "\n : previousStep[x.Novelty].RepeatOnce();", + "\n previousStep[x.Novelty] = new AocStep(x.AocType, x.Novelty);", + "\n return ret;});", "\n}" ], "metadata": {}, From b7624755dacb0331d27045dc96dffa5511b7d887 Mon Sep 17 00:00:00 2001 From: Slavomir Batka Date: Wed, 12 Apr 2023 15:29:42 +0200 Subject: [PATCH 2/2] add new attributes of Single DataNode Report Params --- ifrs17/Report/ParameterReportsQueries.ipynb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ifrs17/Report/ParameterReportsQueries.ipynb b/ifrs17/Report/ParameterReportsQueries.ipynb index 7e401112..13a2b8cb 100644 --- a/ifrs17/Report/ParameterReportsQueries.ipynb +++ b/ifrs17/Report/ParameterReportsQueries.ipynb @@ -130,7 +130,14 @@ "cell_type": "code", "source": [ "public record SingleDataNodeReportParameter : ReportParameter {", + "\n", "\n public double PremiumAllocation { get; init; }", + "\n", + "\n [Dimension(typeof(CashFlowPeriodicity))]", + "\n public CashFlowPeriodicity CashFlowPeriodicity { get; init; }", + "\n ", + "\n [Dimension(typeof(InterpolationMethod))]", + "\n public InterpolationMethod InterpolationMethod { get; init; } ", "\n}" ], "metadata": {}, @@ -303,7 +310,10 @@ "\n Year = y.Value.Year,", "\n Month = y.Value.Month,", "\n Scenario = y.Value.Scenario,", - "\n PremiumAllocation = y.Value.PremiumAllocation}", + "\n PremiumAllocation = y.Value.PremiumAllocation,", + "\n CashFlowPeriodicity = y.Value.CashFlowPeriodicity,", + "\n InterpolationMethod = y.Value.InterpolationMethod", + "\n }", "\n ))", "\n .ToArray();" ],