From a112d495d7137bcc84ef0a5d8e000daa631c2786 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Mon, 27 Mar 2023 17:50:26 +0200 Subject: [PATCH 01/20] Add ReimportTest notebook --- ifrs17-template/Test/ReimportTest.ipynb | 368 ++++++++++++++++++++++++ 1 file changed, 368 insertions(+) create mode 100644 ifrs17-template/Test/ReimportTest.ipynb diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb new file mode 100644 index 00000000..5bf649f1 --- /dev/null +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -0,0 +1,368 @@ +{ + "metadata": { + "authors": [], + "id": "VOS67A7-B0Omk1s4TFC3LQ", + "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": [ + "

Reimport of Transactional Data Test

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test Function" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public async Task ReimportAndCompare((string transactionalData, string importFormat)[] importInfo, DataNodeState[] dataNodeStates)", + "\n{", + "\n Activity.Start();", + "\n var workspace = Workspace.CreateNew();", + "\n workspace.Initialize(x => x.FromSource(DataSource)", + "\n .DisableInitialization());", + "\n await workspace.UpdateAsync(dataNodeStates);", + "\n", + "\n foreach(var (transactionalData, importFormat) in importInfo)", + "\n await Import.FromString(transactionalData).WithFormat(importFormat).WithTarget(workspace).ExecuteAsync();", + "\n ", + "\n var originalRawVariables = workspace.Query();", + "\n var originalIfrsVariables = workspace.Query();", + "\n", + "\n foreach(var (transactionalData, importFormat) in importInfo)", + "\n await Import.FromString(transactionalData).WithFormat(importFormat).WithTarget(workspace).ExecuteAsync();", + "\n", + "\n var reimportedRawVariables = workspace.Query();", + "\n var reimportedIfrsVariables = workspace.Query();", + "\n", + "\n List errors = new();", + "\n var missingRawVariables = originalRawVariables.Except(reimportedRawVariables);", + "\n var missingIfrsVariables = originalIfrsVariables.Except(reimportedIfrsVariables);", + "\n var extraRawVariables = reimportedRawVariables.Except(originalRawVariables);", + "\n var extraIfrsVariables = reimportedIfrsVariables.Except(originalIfrsVariables);", + "\n", + "\n if(missingRawVariables.Any()) errors.Add($\"Reimport missed the following RawVariables: {string.Join(\", \", missingRawVariables)}.\");", + "\n if(missingIfrsVariables.Any()) errors.Add($\"Reimport missed the following IfrsVariables: {string.Join(\", \", missingIfrsVariables)}.\");", + "\n if(extraRawVariables.Any()) errors.Add($\"Reimport created RawVariables that it shouldn't: {string.Join(\", \", extraRawVariables)}.\");", + "\n if(extraIfrsVariables.Any()) errors.Add($\"Reimport created IfrsVariables that it shouldn't: {string.Join(\", \", extraIfrsVariables)}.\");", + "\n ", + "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n", + "\n ApplicationMessage.Log(Warning.Generic, \"count of ifrs variables in workspace: \"+reimportedIfrsVariables.Count());", + "\n if (reimportedIfrsVariables.Any()) ApplicationMessage.Log(Warning.Generic, string.Join(\"-------------\", reimportedIfrsVariables));", + "\n", + "\n return Activity.Finish();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## General data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var args = new ImportArgs(\"CH\", 2021, 3, Periodicity.Quarterly, null, ImportFormats.Actual);", + "\nvar previousArgs = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Actual);", + "\n", + "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", + "\n ReportingNode = args.ReportingNode};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var dt11StatePrevious = new DataNodeState {", + "\n DataNode = \"DT1.1\",", + "\n State = State.Active,", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dt11State = new DataNodeState {", + "\n DataNode = \"DT1.1\",", + "\n State = State.Active,", + "\n Year = args.Year,", + "\n Month = args.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dt13State = new DataNodeState {", + "\n DataNode = \"DT1.3\",", + "\n State = State.Active,", + "\n Year = args.Year,", + "\n Month = args.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dtr11StatePrevious = new DataNodeState {", + "\n DataNode = \"DTR1.1\",", + "\n State = State.Active,", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dtr11State = new DataNodeState {", + "\n DataNode = \"DTR1.1\",", + "\n State = State.Active,", + "\n Year = args.Year,", + "\n Month = args.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "DataSource.Query().Count()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Case: One Data Node at inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var openings = ", + "\n@\"@@Main", + "\nReportingNode,Year,Month,,", + "\nCH,2020,12,,", + "\n@@Opening", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.1,C,,,72.2", + "\nDT1.1,AA,PR,,-1.5", + "\nDT1.1,OA,PR,,1.5", + "\n\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var importFormat = ImportFormats.Opening;", + "\nvar activity = await ReimportAndCompare((openings, importFormat).RepeatOnce().ToArray(), dt11StatePrevious.RepeatOnce().ToArray());", + "\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": [ + "## Case: Actuals for one Data Node at inception and one not at inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var actuals = @\"", + "\n@@Main,,,,,", + "\nReportingNode,Year,Month,,,", + "\nCH,2021,3,,,", + "\n@@Actual,,,,,", + "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", + "\nDT1.1,CF,PR,A,,90", + "\nDT1.1,CF,ICO,A,,-6", + "\nDT1.1,CF,NIC,A,,-70", + "\nDT1.1,CF,ACA,A,,-10", + "\nDT1.1,CF,AEA,A,,-5", + "\nDT1.3,CF,PR,A,,90", + "\nDT1.3,CF,ICO,A,,-6", + "\nDT1.3,CF,NIC,A,,-70", + "\nDT1.3,CF,ACA,A,,-10", + "\nDT1.3,CF,AEA,A,,-5\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var importFormat = ImportFormats.Actual;", + "\nvar activity = await ReimportAndCompare((actuals, importFormat).RepeatOnce().ToArray(), new[] {dt11State, dt11StatePrevious, dt13State});", + "\nactivity.Status.Should().Be(ActivityLogStatus.Succeeded);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "activity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Case: Openings for insurance at inception, and cashflows for linked reinsurance not at inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var openings = ", + "\n@\"@@Main", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.1,C,,,72.2", + "\nDT1.1,AA,PR,,-1.5", + "\nDT1.1,OA,PR,,1.5", + "\n\";", + "\n", + "\nvar cashflows = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,", + "\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", + "\nDTR1.1,PR,BE,MC,I,,0,-55,0,0,-55,0,0,-55,0,0,-55,0,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,NIC,BE,MC,I,,10,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,,CU,MC,I,,-5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-1.5,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,,RA,MC,I,,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,PR,BE,BOP,N,,0,-5,0,0,-5,0,0,-5,0,0,-5,0,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,NIC,BE,BOP,N,,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,,RA,BOP,N,,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,PR,BE,EV,N,,0,-2.5,0,0,-2.5,0,0,-2.5,0,0,-2.5,0,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,NIC,BE,EV,N,,5,5,5,5,5,5,5,5,5,5,5,5,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,,RA,EV,N,,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,PR,BE,CL,C,,0,-57.5,0,0,-57.5,0,0,-57.5,0,0,-57.5,0,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,NIC,BE,CL,C,,15,15,15,15,15,15,15,15,15,15,15,15,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,,CU,CL,C,,-7.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-2.5,0,0,0,0,0,0,0,0,0", + "\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,0,0,0,0,0,0,0,0,0\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var openingFormat = ImportFormats.Opening;", + "\nvar cashflowFormat = ImportFormats.Cashflow;", + "\nvar activity = await ReimportAndCompare(new[]{(openings, openingFormat), (cashflowFormat, cashflows)}, new[] {dt11State, dtr11StatePrevious, dtr11State});", + "\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": [ + "DataSource.Query().Count()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file From 0e6fa19b776bdbae52eec43ce92138a5c1f2ba6a Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 28 Mar 2023 18:11:03 +0200 Subject: [PATCH 02/20] Restructure ReimportTest nb and add notes --- ifrs17-template/Test/ReimportTest.ipynb | 401 ++++++++++++++++++++---- 1 file changed, 346 insertions(+), 55 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 5bf649f1..42831cc3 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -46,44 +46,44 @@ { "cell_type": "code", "source": [ - "public async Task ReimportAndCompare((string transactionalData, string importFormat)[] importInfo, DataNodeState[] dataNodeStates)", - "\n{", - "\n Activity.Start();", - "\n var workspace = Workspace.CreateNew();", - "\n workspace.Initialize(x => x.FromSource(DataSource)", - "\n .DisableInitialization());", - "\n await workspace.UpdateAsync(dataNodeStates);", + "// public async Task ReimportAndCompare((string transactionalData, string importFormat)[] importInfo, DataNodeState[] dataNodeStates, IWorkspace workspace)", + "\n// {", + "\n// Activity.Start();", + "\n// // var workspace = Workspace.CreateNew();", + "\n// workspace.Initialize(x => x.FromSource(DataSource)", + "\n// .DisableInitialization());", + "\n// await workspace.UpdateAsync(dataNodeStates);", "\n", - "\n foreach(var (transactionalData, importFormat) in importInfo)", - "\n await Import.FromString(transactionalData).WithFormat(importFormat).WithTarget(workspace).ExecuteAsync();", + "\n// foreach(var (transactionalData, importFormat) in importInfo)", + "\n// await Import.FromString(transactionalData).WithFormat(importFormat).WithTarget(workspace).ExecuteAsync();", "\n ", - "\n var originalRawVariables = workspace.Query();", - "\n var originalIfrsVariables = workspace.Query();", + "\n// var originalRawVariables = workspace.Query();", + "\n// var originalIfrsVariables = workspace.Query();", "\n", - "\n foreach(var (transactionalData, importFormat) in importInfo)", - "\n await Import.FromString(transactionalData).WithFormat(importFormat).WithTarget(workspace).ExecuteAsync();", + "\n// foreach(var (transactionalData, importFormat) in importInfo)", + "\n// await Import.FromString(transactionalData).WithFormat(importFormat).WithTarget(workspace).ExecuteAsync();", "\n", - "\n var reimportedRawVariables = workspace.Query();", - "\n var reimportedIfrsVariables = workspace.Query();", + "\n// var reimportedRawVariables = workspace.Query();", + "\n// var reimportedIfrsVariables = workspace.Query();", "\n", - "\n List errors = new();", - "\n var missingRawVariables = originalRawVariables.Except(reimportedRawVariables);", - "\n var missingIfrsVariables = originalIfrsVariables.Except(reimportedIfrsVariables);", - "\n var extraRawVariables = reimportedRawVariables.Except(originalRawVariables);", - "\n var extraIfrsVariables = reimportedIfrsVariables.Except(originalIfrsVariables);", + "\n// List errors = new();", + "\n// var missingRawVariables = originalRawVariables.Except(reimportedRawVariables);", + "\n// var missingIfrsVariables = originalIfrsVariables.Except(reimportedIfrsVariables);", + "\n// var extraRawVariables = reimportedRawVariables.Except(originalRawVariables);", + "\n// var extraIfrsVariables = reimportedIfrsVariables.Except(originalIfrsVariables);", "\n", - "\n if(missingRawVariables.Any()) errors.Add($\"Reimport missed the following RawVariables: {string.Join(\", \", missingRawVariables)}.\");", - "\n if(missingIfrsVariables.Any()) errors.Add($\"Reimport missed the following IfrsVariables: {string.Join(\", \", missingIfrsVariables)}.\");", - "\n if(extraRawVariables.Any()) errors.Add($\"Reimport created RawVariables that it shouldn't: {string.Join(\", \", extraRawVariables)}.\");", - "\n if(extraIfrsVariables.Any()) errors.Add($\"Reimport created IfrsVariables that it shouldn't: {string.Join(\", \", extraIfrsVariables)}.\");", + "\n// if(missingRawVariables.Any()) errors.Add($\"Reimport missed the following RawVariables: {string.Join(\", \", missingRawVariables)}.\");", + "\n// if(missingIfrsVariables.Any()) errors.Add($\"Reimport missed the following IfrsVariables: {string.Join(\", \", missingIfrsVariables)}.\");", + "\n// if(extraRawVariables.Any()) errors.Add($\"Reimport created RawVariables that it shouldn't: {string.Join(\", \", extraRawVariables)}.\");", + "\n// if(extraIfrsVariables.Any()) errors.Add($\"Reimport created IfrsVariables that it shouldn't: {string.Join(\", \", extraIfrsVariables)}.\");", "\n ", - "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n// if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", "\n", - "\n ApplicationMessage.Log(Warning.Generic, \"count of ifrs variables in workspace: \"+reimportedIfrsVariables.Count());", - "\n if (reimportedIfrsVariables.Any()) ApplicationMessage.Log(Warning.Generic, string.Join(\"-------------\", reimportedIfrsVariables));", + "\n// ApplicationMessage.Log(Warning.Generic, \"Count of ifrs variables in workspace: \"+reimportedIfrsVariables.Count());", + "\n// if (reimportedIfrsVariables.Any()) ApplicationMessage.Log(Warning.Generic, string.Join(\"\\n\", reimportedIfrsVariables));", "\n", - "\n return Activity.Finish();", - "\n}" + "\n// return Activity.Finish();", + "\n// }" ], "metadata": {}, "execution_count": 0, @@ -92,7 +92,7 @@ { "cell_type": "markdown", "source": [ - "# Test" + "# Definitions" ], "metadata": {}, "execution_count": 0, @@ -101,7 +101,7 @@ { "cell_type": "markdown", "source": [ - "## General data" + "## Args" ], "metadata": {}, "execution_count": 0, @@ -113,8 +113,18 @@ "var args = new ImportArgs(\"CH\", 2021, 3, Periodicity.Quarterly, null, ImportFormats.Actual);", "\nvar previousArgs = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Actual);", "\n", - "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)),", - "\n ReportingNode = args.ReportingNode};" + "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)), ReportingNode = args.ReportingNode };", + "\n", + "\nvar reimportTrials = 5;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## DataNodeState" ], "metadata": {}, "execution_count": 0, @@ -147,6 +157,14 @@ "\n Partition = partitionReportingNode.Id", "\n };", "\n", + "\nvar dtr13State = new DataNodeState {", + "\n DataNode = \"DTR1.3\",", + "\n State = State.Active,", + "\n Year = args.Year,", + "\n Month = args.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", "\nvar dtr11StatePrevious = new DataNodeState {", "\n DataNode = \"DTR1.1\",", "\n State = State.Active,", @@ -169,9 +187,9 @@ "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "DataSource.Query().Count()" + "# Case I: Reimport Openings for DataNode at Inception" ], "metadata": {}, "execution_count": 0, @@ -180,7 +198,18 @@ { "cell_type": "markdown", "source": [ - "## Case: One Data Node at inception" + "## Disposable Workspace" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws1 = Workspace.CreateNew();", + "\nws1.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", + "\nawait ws1.UpdateAsync(new DataNodeState [] {dt11State, dtr11State});" ], "metadata": {}, "execution_count": 0, @@ -190,10 +219,10 @@ "cell_type": "code", "source": [ "var openings = ", - "\n@\"@@Main", + "\n@\"@@Main,,,,", "\nReportingNode,Year,Month,,", - "\nCH,2020,12,,", - "\n@@Opening", + "\nCH,2021,3,,", + "\n@@Opening,,,,", "\nDataNode,EstimateType,AmountType,AccidentYear,Value", "\nDT1.1,C,,,72.2", "\nDT1.1,AA,PR,,-1.5", @@ -204,12 +233,19 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Import Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "var importFormat = ImportFormats.Opening;", - "\nvar activity = await ReimportAndCompare((openings, importFormat).RepeatOnce().ToArray(), dt11StatePrevious.RepeatOnce().ToArray());", - "\nactivity" + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws1).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -218,7 +254,10 @@ { "cell_type": "code", "source": [ - "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + "var caseIQueries = new { ", + "\n IfrsVariables = ws1.Query(), ", + "\n RawVariables = ws1.Query()", + "\n};" ], "metadata": {}, "execution_count": 0, @@ -227,7 +266,91 @@ { "cell_type": "markdown", "source": [ - "## Case: Actuals for one Data Node at inception and one not at inception" + "## Reimport Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "for (int i=0; i < reimportTrials; i++)", + "\n{", + "\n await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws1).ExecuteAsync();", + "\n}", + "\n", + "\nvar caseIQueriesReimported = new { ", + "\n IfrsVariables = ws1.Query(), ", + "\n RawVariables = ws1.Query()", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !caseIQueries.IfrsVariables.Except(caseIQueriesReimported.IfrsVariables).Any() && ", + "\n !caseIQueriesReimported.IfrsVariables.Except(caseIQueries.IfrsVariables).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !caseIQueries.RawVariables.Except(caseIQueriesReimported.RawVariables).Any() && ", + "\n !caseIQueriesReimported.RawVariables.Except(caseIQueries.RawVariables).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Case II: Reimport Actuals for DataNode at Inception and One Not at Inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Disposable Workspace" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws2 = Workspace.CreateNew();", + "\nws2.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", + "\nawait ws2.UpdateAsync(new DataNodeState [] {dt11StatePrevious, dtr11StatePrevious});//, dtr13State});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Import Phase" ], "metadata": {}, "execution_count": 0, @@ -260,9 +383,7 @@ { "cell_type": "code", "source": [ - "var importFormat = ImportFormats.Actual;", - "\nvar activity = await ReimportAndCompare((actuals, importFormat).RepeatOnce().ToArray(), new[] {dt11State, dt11StatePrevious, dt13State});", - "\nactivity.Status.Should().Be(ActivityLogStatus.Succeeded);" + "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws2).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -271,7 +392,10 @@ { "cell_type": "code", "source": [ - "activity" + "var caseIIQueries = new { ", + "\n IfrsVariables = ws2.Query(), ", + "\n RawVariables = ws2.Query()", + "\n};" ], "metadata": {}, "execution_count": 0, @@ -280,7 +404,7 @@ { "cell_type": "markdown", "source": [ - "## Case: Openings for insurance at inception, and cashflows for linked reinsurance not at inception" + "## Reimport Phase" ], "metadata": {}, "execution_count": 0, @@ -289,7 +413,117 @@ { "cell_type": "code", "source": [ - "var openings = ", + "for (int i=0; i < reimportTrials; i++)", + "\n{", + "\n await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws2).ExecuteAsync();", + "\n}", + "\n", + "\nvar caseIIQueriesReimported = new { ", + "\n IfrsVariables = ws2.Query(), ", + "\n RawVariables = ws2.Query()", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !caseIIQueries.IfrsVariables.Except(caseIIQueriesReimported.IfrsVariables).Any() && ", + "\n !caseIIQueriesReimported.IfrsVariables.Except(caseIIQueries.IfrsVariables).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !caseIIQueries.RawVariables.Except(caseIIQueriesReimported.RawVariables).Any() && ", + "\n !caseIIQueriesReimported.RawVariables.Except(caseIIQueries.RawVariables).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Case III: Openings for Insurance at Inception and Cashflows for Linked Preexisitng Reinsurance Not at Inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Disposable Workspace" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws3 = Workspace.CreateNew();", + "\nws3.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", + "\nawait ws3.UpdateAsync(new DataNodeState [] {dt11State, dtr11StatePrevious, dt11StatePrevious});//, dtr13State});" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws3.Query()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Import Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var actuals = @\"", + "\n@@Main,,,,,", + "\nReportingNode,Year,Month,,,", + "\nCH,2020,12,,,", + "\n@@Actual,,,,,", + "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", + "\nDTR1.1,CF,PR,A,,90", + "\nDTR1.1,CF,ICO,A,,-6", + "\nDTR1.1,CF,NIC,A,,-70", + "\nDTR1.1,CF,ACA,A,,-10", + "\nDTR1.1,CF,AEA,A,,-5", + "\nDTR1.3,CF,PR,A,,90", + "\nDTR1.3,CF,ICO,A,,-6", + "\nDTR1.3,CF,NIC,A,,-70", + "\nDTR1.3,CF,ACA,A,,-10", + "\nDTR1.3,CF,AEA,A,,-5\";", + "\n", + "\nvar openings = ", "\n@\"@@Main", "\nReportingNode,Year,Month,,", "\nCH,2021,3,,", @@ -328,10 +562,67 @@ { "cell_type": "code", "source": [ - "var openingFormat = ImportFormats.Opening;", - "\nvar cashflowFormat = ImportFormats.Cashflow;", - "\nvar activity = await ReimportAndCompare(new[]{(openings, openingFormat), (cashflowFormat, cashflows)}, new[] {dt11State, dtr11StatePrevious, dtr11State});", - "\nactivity" + "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws3).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws3).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws3).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var caseIIIQueries = new { ", + "\n IfrsVariables = ws3.Query(), ", + "\n RawVariables = ws3.Query()", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reimport Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "// var openingFormat = ImportFormats.Opening;", + "\n// var cashflowFormat = ImportFormats.Cashflow;", + "\n// var activity = await ReimportAndCompare(new[]{(openings, openingFormat), (cashflowFormat, cashflows)}, new[] {dt11State, dtr11StatePrevious, dtr11State});", + "\n// activity" ], "metadata": {}, "execution_count": 0, @@ -340,7 +631,7 @@ { "cell_type": "code", "source": [ - "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + "// activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, From bc0ad4f01010d805779674d0a51296170412d56b Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Thu, 30 Mar 2023 20:18:43 +0200 Subject: [PATCH 03/20] Implement all requested cases, add data and assertions --- ifrs17-template/Test/ReimportTest.ipynb | 532 +++++++++++++++++------- 1 file changed, 386 insertions(+), 146 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 42831cc3..e9456e0d 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -34,61 +34,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "# Test Function" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "// public async Task ReimportAndCompare((string transactionalData, string importFormat)[] importInfo, DataNodeState[] dataNodeStates, IWorkspace workspace)", - "\n// {", - "\n// Activity.Start();", - "\n// // var workspace = Workspace.CreateNew();", - "\n// workspace.Initialize(x => x.FromSource(DataSource)", - "\n// .DisableInitialization());", - "\n// await workspace.UpdateAsync(dataNodeStates);", - "\n", - "\n// foreach(var (transactionalData, importFormat) in importInfo)", - "\n// await Import.FromString(transactionalData).WithFormat(importFormat).WithTarget(workspace).ExecuteAsync();", - "\n ", - "\n// var originalRawVariables = workspace.Query();", - "\n// var originalIfrsVariables = workspace.Query();", - "\n", - "\n// foreach(var (transactionalData, importFormat) in importInfo)", - "\n// await Import.FromString(transactionalData).WithFormat(importFormat).WithTarget(workspace).ExecuteAsync();", - "\n", - "\n// var reimportedRawVariables = workspace.Query();", - "\n// var reimportedIfrsVariables = workspace.Query();", - "\n", - "\n// List errors = new();", - "\n// var missingRawVariables = originalRawVariables.Except(reimportedRawVariables);", - "\n// var missingIfrsVariables = originalIfrsVariables.Except(reimportedIfrsVariables);", - "\n// var extraRawVariables = reimportedRawVariables.Except(originalRawVariables);", - "\n// var extraIfrsVariables = reimportedIfrsVariables.Except(originalIfrsVariables);", - "\n", - "\n// if(missingRawVariables.Any()) errors.Add($\"Reimport missed the following RawVariables: {string.Join(\", \", missingRawVariables)}.\");", - "\n// if(missingIfrsVariables.Any()) errors.Add($\"Reimport missed the following IfrsVariables: {string.Join(\", \", missingIfrsVariables)}.\");", - "\n// if(extraRawVariables.Any()) errors.Add($\"Reimport created RawVariables that it shouldn't: {string.Join(\", \", extraRawVariables)}.\");", - "\n// if(extraIfrsVariables.Any()) errors.Add($\"Reimport created IfrsVariables that it shouldn't: {string.Join(\", \", extraIfrsVariables)}.\");", - "\n ", - "\n// if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", - "\n", - "\n// ApplicationMessage.Log(Warning.Generic, \"Count of ifrs variables in workspace: \"+reimportedIfrsVariables.Count());", - "\n// if (reimportedIfrsVariables.Any()) ApplicationMessage.Log(Warning.Generic, string.Join(\"\\n\", reimportedIfrsVariables));", - "\n", - "\n// return Activity.Finish();", - "\n// }" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -141,6 +86,14 @@ "\n Partition = partitionReportingNode.Id", "\n };", "\n", + "\nvar dtr11StatePrevious = new DataNodeState {", + "\n DataNode = \"DTR1.1\",", + "\n State = State.Active,", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", "\nvar dt11State = new DataNodeState {", "\n DataNode = \"DT1.1\",", "\n State = State.Active,", @@ -149,6 +102,22 @@ "\n Partition = partitionReportingNode.Id", "\n };", "\n", + "\nvar dtr11State = new DataNodeState {", + "\n DataNode = \"DTR1.1\",", + "\n State = State.Active,", + "\n Year = args.Year,", + "\n Month = args.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", + "\nvar dtr13StatePrevious = new DataNodeState {", + "\n DataNode = \"DTR1.3\",", + "\n State = State.Active,", + "\n Year = previousArgs.Year,", + "\n Month = previousArgs.Month,", + "\n Partition = partitionReportingNode.Id", + "\n };", + "\n", "\nvar dt13State = new DataNodeState {", "\n DataNode = \"DT1.3\",", "\n State = State.Active,", @@ -165,22 +134,21 @@ "\n Partition = partitionReportingNode.Id", "\n };", "\n", - "\nvar dtr11StatePrevious = new DataNodeState {", - "\n DataNode = \"DTR1.1\",", + "\nvar dt14State = new DataNodeState {", + "\n DataNode = \"DT1.4\",", "\n State = State.Active,", - "\n Year = previousArgs.Year,", - "\n Month = previousArgs.Month,", + "\n Year = args.Year,", + "\n Month = args.Month,", "\n Partition = partitionReportingNode.Id", "\n };", "\n", - "\nvar dtr11State = new DataNodeState {", - "\n DataNode = \"DTR1.1\",", + "\nvar dtr14State = new DataNodeState {", + "\n DataNode = \"DTR1.4\",", "\n State = State.Active,", "\n Year = args.Year,", "\n Month = args.Month,", "\n Partition = partitionReportingNode.Id", - "\n };", - "\n" + "\n };" ], "metadata": {}, "execution_count": 0, @@ -209,7 +177,17 @@ "source": [ "var ws1 = Workspace.CreateNew();", "\nws1.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws1.UpdateAsync(new DataNodeState [] {dt11State, dtr11State});" + "\nawait ws1.UpdateAsync(new DataNodeState [] { //dt11StatePrevious with {State = State.Inactive},", + "\n //dtr11StatePrevious with {State = State.Inactive},", + "\n dt11State,", + "\n dtr11State,", + "\n // dtr13StatePrevious with {State = State.Inactive},", + "\n // dt13State with {State = State.Inactive},", + "\n // dtr13State with {State = State.Inactive},", + "\n // dt14State with {State = State.Inactive},", + "\n // dtr14State with {State = State.Inactive}", + "\n }", + "\n );" ], "metadata": {}, "execution_count": 0, @@ -218,8 +196,8 @@ { "cell_type": "code", "source": [ - "var openings = ", - "\n@\"@@Main,,,,", + "var openings = @\"", + "\n@@Main,,,,", "\nReportingNode,Year,Month,,", "\nCH,2021,3,,", "\n@@Opening,,,,", @@ -301,8 +279,8 @@ { "cell_type": "code", "source": [ - "( !caseIQueries.IfrsVariables.Except(caseIQueriesReimported.IfrsVariables).Any() && ", - "\n !caseIQueriesReimported.IfrsVariables.Except(caseIQueries.IfrsVariables).Any() ).Should().Be(true);" + "( !caseIQueries.IfrsVariables.Except(caseIQueriesReimported.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", + "\n !caseIQueriesReimported.IfrsVariables.Except(caseIQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -311,8 +289,8 @@ { "cell_type": "code", "source": [ - "( !caseIQueries.RawVariables.Except(caseIQueriesReimported.RawVariables).Any() && ", - "\n !caseIQueriesReimported.RawVariables.Except(caseIQueries.RawVariables).Any() ).Should().Be(true);" + "( !caseIQueries.RawVariables.Except(caseIQueriesReimported.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", + "\n !caseIQueriesReimported.RawVariables.Except(caseIQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -341,16 +319,17 @@ "source": [ "var ws2 = Workspace.CreateNew();", "\nws2.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws2.UpdateAsync(new DataNodeState [] {dt11StatePrevious, dtr11StatePrevious});//, dtr13State});" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Import Phase" + "\nawait ws2.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", + "\n // dtr11StatePrevious with {State = State.Inactive},", + "\n dt11State,", + "\n dtr11State,", + "\n // dtr13StatePrevious with {State = State.Inactive},", + "\n dt13State,", + "\n // dtr13State with {State = State.Inactive},", + "\n // dt14State with {State = State.Inactive},", + "\n // dtr14State with {State = State.Inactive} ", + "\n }", + "\n );" ], "metadata": {}, "execution_count": 0, @@ -380,6 +359,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Import Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -439,8 +427,8 @@ { "cell_type": "code", "source": [ - "( !caseIIQueries.IfrsVariables.Except(caseIIQueriesReimported.IfrsVariables).Any() && ", - "\n !caseIIQueriesReimported.IfrsVariables.Except(caseIIQueries.IfrsVariables).Any() ).Should().Be(true);" + "( !caseIIQueries.IfrsVariables.Except(caseIIQueriesReimported.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", + "\n !caseIIQueriesReimported.IfrsVariables.Except(caseIIQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -449,8 +437,8 @@ { "cell_type": "code", "source": [ - "( !caseIIQueries.RawVariables.Except(caseIIQueriesReimported.RawVariables).Any() && ", - "\n !caseIIQueriesReimported.RawVariables.Except(caseIIQueries.RawVariables).Any() ).Should().Be(true);" + "( !caseIIQueries.RawVariables.Except(caseIIQueriesReimported.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", + "\n !caseIIQueriesReimported.RawVariables.Except(caseIIQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -479,7 +467,17 @@ "source": [ "var ws3 = Workspace.CreateNew();", "\nws3.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws3.UpdateAsync(new DataNodeState [] {dt11State, dtr11StatePrevious, dt11StatePrevious});//, dtr13State});" + "\nawait ws3.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", + "\n // dtr11StatePrevious with {State = State.Inactive},", + "\n // dt11State with {State = State.Inactive},", + "\n // dtr11State with {State = State.Inactive},", + "\n dtr13StatePrevious,", + "\n // dt13State with {State = State.Inactive},", + "\n // dtr13State with {State = State.Inactive},", + "\n dt14State,", + "\n // dtr14State with {State = State.Inactive}", + "\n }", + "\n );" ], "metadata": {}, "execution_count": 0, @@ -488,7 +486,43 @@ { "cell_type": "code", "source": [ - "ws3.Query()" + "var actuals = @\"", + "\n@@Main,,,,,", + "\nReportingNode,Year,Month,,,", + "\nCH,2021,3,,,", + "\n@@Actual,,,,,", + "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", + "\nDT1.4,CF,PR,A,,90", + "\nDT1.4,CF,ICO,A,,-6", + "\nDT1.4,CF,NIC,A,,-70", + "\nDT1.4,CF,ACA,A,,-10", + "\nDT1.4,CF,AEA,A,,-5\";", + "\n", + "\nvar openings = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.4,C,,,72.2", + "\nDT1.4,AA,PR,,-1.5", + "\nDT1.4,OA,PR,,1.5\";", + "\n", + "\nvar cashflows = @\"", + "\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", + "\nDTR1.3,PR,BE,BOP,N,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0", + "\nDTR1.3,NIC,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25", + "\nDTR1.3,,CU,BOP,N,,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-3", + "\nDTR1.3,,RA,BOP,N,,-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.3,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", + "\nDTR1.3,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", + "\nDTR1.3,,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", + "\nDTR1.3,,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", + "\n\";" ], "metadata": {}, "execution_count": 0, @@ -497,7 +531,7 @@ { "cell_type": "markdown", "source": [ - "## Import Phase" + "## Import Sequence Phase" ], "metadata": {}, "execution_count": 0, @@ -506,54 +540,10 @@ { "cell_type": "code", "source": [ - "var actuals = @\"", - "\n@@Main,,,,,", - "\nReportingNode,Year,Month,,,", - "\nCH,2020,12,,,", - "\n@@Actual,,,,,", - "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", - "\nDTR1.1,CF,PR,A,,90", - "\nDTR1.1,CF,ICO,A,,-6", - "\nDTR1.1,CF,NIC,A,,-70", - "\nDTR1.1,CF,ACA,A,,-10", - "\nDTR1.1,CF,AEA,A,,-5", - "\nDTR1.3,CF,PR,A,,90", - "\nDTR1.3,CF,ICO,A,,-6", - "\nDTR1.3,CF,NIC,A,,-70", - "\nDTR1.3,CF,ACA,A,,-10", - "\nDTR1.3,CF,AEA,A,,-5\";", - "\n", - "\nvar openings = ", - "\n@\"@@Main", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.1,C,,,72.2", - "\nDT1.1,AA,PR,,-1.5", - "\nDT1.1,OA,PR,,1.5", - "\n\";", - "\n", - "\nvar cashflows = @\"", - "\n@@Main", - "\nReportingNode,Year,Month,", - "\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", - "\nDTR1.1,PR,BE,MC,I,,0,-55,0,0,-55,0,0,-55,0,0,-55,0,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,NIC,BE,MC,I,,10,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,,CU,MC,I,,-5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-2.5,-1.5,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,,RA,MC,I,,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,PR,BE,BOP,N,,0,-5,0,0,-5,0,0,-5,0,0,-5,0,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,NIC,BE,BOP,N,,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,2.5,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,,RA,BOP,N,,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,PR,BE,EV,N,,0,-2.5,0,0,-2.5,0,0,-2.5,0,0,-2.5,0,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,NIC,BE,EV,N,,5,5,5,5,5,5,5,5,5,5,5,5,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,,RA,EV,N,,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,PR,BE,CL,C,,0,-57.5,0,0,-57.5,0,0,-57.5,0,0,-57.5,0,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,NIC,BE,CL,C,,15,15,15,15,15,15,15,15,15,15,15,15,0,0,0,0,0,0,0,0,0", - "\nDTR1.1,,CU,CL,C,,-7.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-2.5,0,0,0,0,0,0,0,0,0", - "\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,0,0,0,0,0,0,0,0,0\";" + "var ws31 = Workspace.CreateNew();", + "\nws31.Initialize(x=>x.FromSource(ws3));", + "\nawait Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws31).ExecuteAsync();", + "\nawait Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws3).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -562,7 +552,34 @@ { "cell_type": "code", "source": [ - "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws3).ExecuteAsync()" + "var caseIIIQuery1= new { ", + "\n IfrsVariables = ws31.Query(), ", + "\n RawVariables = ws31.Query()", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws32 = Workspace.CreateNew();", + "\nws32.Initialize(x=>x.FromSource(ws3).DisableInitialization().DisableInitialization());", + "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws32).ExecuteAsync();", + "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws3).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var caseIIIQuery2 = new { ", + "\n IfrsVariables = ws32.Query(), ", + "\n RawVariables = ws32.Query()", + "\n};" ], "metadata": {}, "execution_count": 0, @@ -571,7 +588,10 @@ { "cell_type": "code", "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws3).ExecuteAsync()" + "var ws33 = Workspace.CreateNew();", + "\nws33.Initialize(x=>x.FromSource(ws3).DisableInitialization().DisableInitialization());", + "\nawait Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws33).ExecuteAsync();", + "\nawait Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws3).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -580,7 +600,10 @@ { "cell_type": "code", "source": [ - "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws3).ExecuteAsync()" + "var caseIIIQuery3 = new { ", + "\n IfrsVariables = ws33.Query(), ", + "\n RawVariables = ws33.Query()", + "\n};" ], "metadata": {}, "execution_count": 0, @@ -601,7 +624,7 @@ { "cell_type": "markdown", "source": [ - "## Reimport Phase" + "## Assertions" ], "metadata": {}, "execution_count": 0, @@ -610,7 +633,13 @@ { "cell_type": "markdown", "source": [ - "## Assertions" + "
", + "\n/NOTES ", + "\n", + "\nEXCEPT(... , **Raw**VariableComparer.Instance(ignoreValue**s**: false) and ", + "\nEXCEPT(... , *Ifrs*VariableComparer.Instance(ignoreValue: false))", + "\n", + "\ncan be used to compare two queries from the workspace." ], "metadata": {}, "execution_count": 0, @@ -619,10 +648,10 @@ { "cell_type": "code", "source": [ - "// var openingFormat = ImportFormats.Opening;", - "\n// var cashflowFormat = ImportFormats.Cashflow;", - "\n// var activity = await ReimportAndCompare(new[]{(openings, openingFormat), (cashflowFormat, cashflows)}, new[] {dt11State, dtr11StatePrevious, dtr11State});", - "\n// activity" + "caseIIIQueries.IfrsVariables.Except(", + "\n caseIIIQuery1.IfrsVariables.Union(caseIIIQuery2.IfrsVariables", + "\n .Union(caseIIIQuery3.IfrsVariables))", + "\n , IfrsVariableComparer.Instance(ignoreValue: false))" ], "metadata": {}, "execution_count": 0, @@ -631,7 +660,210 @@ { "cell_type": "code", "source": [ - "// activity.Status.Should().Be(ActivityLogStatus.Succeeded);" + "caseIIIQueries.RawVariables.Except(", + "\n caseIIIQuery1.RawVariables.Union(caseIIIQuery2.RawVariables", + "\n .Union(caseIIIQuery3.RawVariables)), RawVariableComparer.Instance(ignoreValues: false)", + "\n )" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "// caseIIIQueries.RawVariables.SequenceEqual(caseIIIQuery1.RawVariables.Union(caseIIIQuery2.RawVariables.Union(caseIIIQuery3.RawVariables)))" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The assertion below shouldn't fail..." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "NOTES/", + "\n
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !caseIIIQueries.IfrsVariables.Except(", + "\n caseIIIQuery1.IfrsVariables.Union(caseIIIQuery2.IfrsVariables", + "\n .Union(caseIIIQuery3.IfrsVariables)),", + "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n ).Any() && ", + "\n !caseIIIQueries.RawVariables.Except(", + "\n caseIIIQuery1.RawVariables.Union(caseIIIQuery2.RawVariables", + "\n .Union(caseIIIQuery3.RawVariables)),", + "\n RawVariableComparer.Instance(ignoreValues: false)", + "\n ).Any()", + "\n).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Case V: Reimport Modified Openings with CSM Deletion and LC Addition for the Same DataNode" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Disposable Workspace" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws4 = Workspace.CreateNew();", + "\nws4.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", + "\nawait ws4.UpdateAsync(new DataNodeState [] { //dt11StatePrevious with {State = State.Inactive},", + "\n //dtr11StatePrevious with {State = State.Inactive},", + "\n dt11State,", + "\n dtr11State,", + "\n // dtr13StatePrevious with {State = State.Inactive},", + "\n // dt13State with {State = State.Inactive},", + "\n // dtr13State with {State = State.Inactive},", + "\n // dt14State with {State = State.Inactive},", + "\n // dtr14State with {State = State.Inactive}", + "\n }", + "\n );" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var openings = @\"", + "\n@@Main,,,,", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening,,,,", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.1,C,,,72.2", + "\nDT1.1,AA,PR,,-1.5", + "\nDT1.1,OA,PR,,1.5", + "\n\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Import Sequence Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws41 = Workspace.CreateNew();", + "\nws41.Initialize(x=>x.FromSource(ws4));", + "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws41).ExecuteAsync();", + "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws4).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var caseVQuery1 = new { ", + "\n IfrsVariables = ws41.Query(), ", + "\n RawVariables = ws41.Query()", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var openings = @\"", + "\n@@Main,,,,", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening,,,,", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.1,L,,,72.2", + "\nDT1.1,AA,PR,,-1.5", + "\nDT1.1,OA,PR,,1.5", + "\n\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws42 = Workspace.CreateNew();", + "\nws42.Initialize(x=>x.FromSource(ws4).DisableInitialization().DisableInitialization());", + "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws42).ExecuteAsync();", + "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws4).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var caseVQuery2 = new { ", + "\n IfrsVariables = ws42.Query(), ", + "\n RawVariables = ws42.Query()", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var caseVQueries = new { ", + "\n IfrsVariables = ws4.Query(), ", + "\n RawVariables = ws4.Query()", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Assertions" ], "metadata": {}, "execution_count": 0, @@ -640,7 +872,15 @@ { "cell_type": "code", "source": [ - "DataSource.Query().Count()" + "( !caseVQueries.IfrsVariables.Except(", + "\n caseVQuery1.IfrsVariables.Union(caseVQuery2.IfrsVariables),", + "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n ).Any() && ", + "\n !caseVQueries.RawVariables.Except(", + "\n caseVQuery1.RawVariables.Union(caseVQuery2.RawVariables),", + "\n RawVariableComparer.Instance(ignoreValues: false)", + "\n ).Any()", + "\n).Should().Be(true);" ], "metadata": {}, "execution_count": 0, From f40bbcdd326b704736eea6e407c547038d37503c Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 18 Apr 2023 18:23:42 +0200 Subject: [PATCH 04/20] WIP in all cases except use case 3 --- ifrs17-template/Test/ReimportTest.ipynb | 818 +++++++++++++++++++----- 1 file changed, 643 insertions(+), 175 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index e9456e0d..f5363bd0 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -14,7 +14,7 @@ } }, "nbformat": 4, - "nbformat_minor": 8, + "nbformat_minor": 5, "cells": [ { "cell_type": "markdown", @@ -52,15 +52,59 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "Create:", + "\n- Import args for year 2021", + "\n- Import args for previous year", + "\n- Partition by Reporting Node (using details from most recent args)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "var args = new ImportArgs(\"CH\", 2021, 3, Periodicity.Quarterly, null, ImportFormats.Actual);", - "\nvar previousArgs = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, ImportFormats.Actual);", + "var args = new ImportArgs(\"CH\", 2021, 3, Periodicity.Quarterly, null, null);", + "\nvar previousArgs = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, null);", "\n", - "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)), ReportingNode = args.ReportingNode };", - "\n", - "\nvar reimportTrials = 5;" + "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)), ReportingNode = args.ReportingNode };" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## DataNodeParameter" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Create 1 data node parameter" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var idtr13Parameter = new InterDataNodeParameter{", + "\n Partition = partitionReportingNode.Id,", + "\n DataNode = \"DTR1.3\",", + "\n Year = args.Year,", + "\n Month = args.Month,", + "\n LinkedDataNode = \"DT1.4\",", + "\n ReinsuranceCoverage = 1d", + "\n };" ], "metadata": {}, "execution_count": 0, @@ -75,6 +119,22 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "Create 7 data node states:", + "\n- dt11StatePrevious", + "\n- dtr11StatePrevious", + "\n- dt11State", + "\n- dtr11State", + "\n- dtr13StatePrevious", + "\n- dt13State", + "\n- dt14State" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -126,28 +186,12 @@ "\n Partition = partitionReportingNode.Id", "\n };", "\n", - "\nvar dtr13State = new DataNodeState {", - "\n DataNode = \"DTR1.3\",", - "\n State = State.Active,", - "\n Year = args.Year,", - "\n Month = args.Month,", - "\n Partition = partitionReportingNode.Id", - "\n };", - "\n", "\nvar dt14State = new DataNodeState {", "\n DataNode = \"DT1.4\",", "\n State = State.Active,", "\n Year = args.Year,", "\n Month = args.Month,", "\n Partition = partitionReportingNode.Id", - "\n };", - "\n", - "\nvar dtr14State = new DataNodeState {", - "\n DataNode = \"DTR1.4\",", - "\n State = State.Active,", - "\n Year = args.Year,", - "\n Month = args.Month,", - "\n Partition = partitionReportingNode.Id", "\n };" ], "metadata": {}, @@ -157,7 +201,16 @@ { "cell_type": "markdown", "source": [ - "# Case I: Reimport Openings for DataNode at Inception" + "# Reimport Openings for DataNode at Inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Create openings for a data node at inception (DT1.1) and import more than once." ], "metadata": {}, "execution_count": 0, @@ -175,17 +228,15 @@ { "cell_type": "code", "source": [ - "var ws1 = Workspace.CreateNew();", - "\nws1.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws1.UpdateAsync(new DataNodeState [] { //dt11StatePrevious with {State = State.Inactive},", - "\n //dtr11StatePrevious with {State = State.Inactive},", + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", + "\nawait ws.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", + "\n // dtr11StatePrevious with {State = State.Inactive},", "\n dt11State,", - "\n dtr11State,", + "\n dtr11State, // <-- linked data node", "\n // dtr13StatePrevious with {State = State.Inactive},", "\n // dt13State with {State = State.Inactive},", - "\n // dtr13State with {State = State.Inactive},", - "\n // dt14State with {State = State.Inactive},", - "\n // dtr14State with {State = State.Inactive}", + "\n // dt14State with {State = State.Inactive}", "\n }", "\n );" ], @@ -223,7 +274,16 @@ { "cell_type": "code", "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws1).ExecuteAsync()" + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries after import." ], "metadata": {}, "execution_count": 0, @@ -232,9 +292,9 @@ { "cell_type": "code", "source": [ - "var caseIQueries = new { ", - "\n IfrsVariables = ws1.Query(), ", - "\n RawVariables = ws1.Query()", + "var importQueries = new { ", + "\n IfrsVariables = ws.Query(), ", + "\n RawVariables = ws.Query()", "\n};" ], "metadata": {}, @@ -253,14 +313,27 @@ { "cell_type": "code", "source": [ - "for (int i=0; i < reimportTrials; i++)", - "\n{", - "\n await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws1).ExecuteAsync();", - "\n}", - "\n", - "\nvar caseIQueriesReimported = new { ", - "\n IfrsVariables = ws1.Query(), ", - "\n RawVariables = ws1.Query()", + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries after reimport." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var reimportQueries = new { ", + "\n IfrsVariables = ws.Query(), ", + "\n RawVariables = ws.Query()", "\n};" ], "metadata": {}, @@ -276,11 +349,42 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "$\\text{importQueries} \\subseteq \\text{reimportQueries} \\quad \\text{and}$", + "\n", + "\n$\\text{reimportQueries} \\subseteq \\text{importQueries} \\quad \\Rightarrow$ ", + "\n", + "\n$\\text{importQueries} = \\text{reimportQueries}$" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Check for IfrsVariables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "( !caseIQueries.IfrsVariables.Except(caseIQueriesReimported.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", - "\n !caseIQueriesReimported.IfrsVariables.Except(caseIQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" + "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", + "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Check for RawVariables (should be $\\emptyset$)" ], "metadata": {}, "execution_count": 0, @@ -289,8 +393,8 @@ { "cell_type": "code", "source": [ - "( !caseIQueries.RawVariables.Except(caseIQueriesReimported.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", - "\n !caseIQueriesReimported.RawVariables.Except(caseIQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" + "( !importQueries.RawVariables.Except(reimportQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", + "\n !reimportQueries.RawVariables.Except(importQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -299,7 +403,18 @@ { "cell_type": "markdown", "source": [ - "# Case II: Reimport Actuals for DataNode at Inception and One Not at Inception" + "# Reimport Actuals for Both: DataNode at Inception and DataNode and Not at Inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Create an actuals file that contains data for both a data node at inception (DT1.3) and a data node not at inception (DT1.1). ", + "\n", + "\nImport this file more than once." ], "metadata": {}, "execution_count": 0, @@ -317,17 +432,15 @@ { "cell_type": "code", "source": [ - "var ws2 = Workspace.CreateNew();", - "\nws2.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws2.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", - "\n // dtr11StatePrevious with {State = State.Inactive},", - "\n dt11State,", - "\n dtr11State,", + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", + "\nawait ws.UpdateAsync(new DataNodeState [] { dt11StatePrevious,", + "\n dtr11StatePrevious, // <-- linked data node", + "\n // dt11State with {State = State.Inactive},", + "\n // dtr11State with {State = State.Inactive},", "\n // dtr13StatePrevious with {State = State.Inactive},", "\n dt13State,", - "\n // dtr13State with {State = State.Inactive},", - "\n // dt14State with {State = State.Inactive},", - "\n // dtr14State with {State = State.Inactive} ", + "\n // dt14State with {State = State.Inactive}", "\n }", "\n );" ], @@ -371,7 +484,16 @@ { "cell_type": "code", "source": [ - "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws2).ExecuteAsync()" + "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries after import." ], "metadata": {}, "execution_count": 0, @@ -380,9 +502,9 @@ { "cell_type": "code", "source": [ - "var caseIIQueries = new { ", - "\n IfrsVariables = ws2.Query(), ", - "\n RawVariables = ws2.Query()", + "var importQueries = new { ", + "\n IfrsVariables = ws.Query(), ", + "\n RawVariables = ws.Query()", "\n};" ], "metadata": {}, @@ -401,14 +523,27 @@ { "cell_type": "code", "source": [ - "for (int i=0; i < reimportTrials; i++)", - "\n{", - "\n await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws2).ExecuteAsync();", - "\n}", - "\n", - "\nvar caseIIQueriesReimported = new { ", - "\n IfrsVariables = ws2.Query(), ", - "\n RawVariables = ws2.Query()", + "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries after reimport." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var reimportQueries = new { ", + "\n IfrsVariables = ws.Query(), ", + "\n RawVariables = ws.Query()", "\n};" ], "metadata": {}, @@ -424,11 +559,42 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "$\\text{importQueries} \\subseteq \\text{reimportQueries} \\quad \\text{and}$", + "\n", + "\n$\\text{reimportQueries} \\subseteq \\text{importQueries} \\quad \\Rightarrow$ ", + "\n", + "\n$\\text{importQueries} = \\text{reimportQueries}$" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Check for IfrsVariables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "( !caseIIQueries.IfrsVariables.Except(caseIIQueriesReimported.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", - "\n !caseIIQueriesReimported.IfrsVariables.Except(caseIIQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" + "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", + "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Check for RawVariables" ], "metadata": {}, "execution_count": 0, @@ -437,8 +603,8 @@ { "cell_type": "code", "source": [ - "( !caseIIQueries.RawVariables.Except(caseIIQueriesReimported.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", - "\n !caseIIQueriesReimported.RawVariables.Except(caseIIQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" + "( !importQueries.RawVariables.Except(reimportQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", + "\n !reimportQueries.RawVariables.Except(importQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -447,7 +613,19 @@ { "cell_type": "markdown", "source": [ - "# Case III: Openings for Insurance at Inception and Cashflows for Linked Preexisitng Reinsurance Not at Inception" + "# Import Actuals for Pre-exisitng Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Consider one GRIC (DTR1.3) that is linked to one GIC (DT1.4). The GRIC already existed the previous year, while the GIC is at inception.", + "\n- Import data for the GRIC in the previous period.", + "\n- Import Openings for the GIC in the current period.", + "\n- Import Cashflows for the GRIC in the current period." ], "metadata": {}, "execution_count": 0, @@ -465,19 +643,30 @@ { "cell_type": "code", "source": [ - "var ws3 = Workspace.CreateNew();", - "\nws3.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws3.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", + "\nawait ws.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", "\n // dtr11StatePrevious with {State = State.Inactive},", "\n // dt11State with {State = State.Inactive},", "\n // dtr11State with {State = State.Inactive},", "\n dtr13StatePrevious,", "\n // dt13State with {State = State.Inactive},", - "\n // dtr13State with {State = State.Inactive},", - "\n dt14State,", - "\n // dtr14State with {State = State.Inactive}", + "\n dt14State", "\n }", - "\n );" + "\n );", + "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { ", + "\n idtr13Parameter", + "\n }", + "\n );" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query()" ], "metadata": {}, "execution_count": 0, @@ -489,14 +678,14 @@ "var actuals = @\"", "\n@@Main,,,,,", "\nReportingNode,Year,Month,,,", - "\nCH,2021,3,,,", + "\nCH,2020,12,,,", "\n@@Actual,,,,,", "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", - "\nDT1.4,CF,PR,A,,90", - "\nDT1.4,CF,ICO,A,,-6", - "\nDT1.4,CF,NIC,A,,-70", - "\nDT1.4,CF,ACA,A,,-10", - "\nDT1.4,CF,AEA,A,,-5\";", + "\nDTR1.3,CF,PR,AA,,90", + "\nDTR1.3,CF,ICO,AA,,-6", + "\nDTR1.3,CF,NIC,AA,,-70", + "\nDTR1.3,CF,ACA,AA,,-10", + "\nDTR1.3,CF,AEA,AA,,-5\";", "\n", "\nvar openings = @\"", "\n@@Main", @@ -504,7 +693,7 @@ "\nCH,2021,3,,", "\n@@Opening", "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.4,C,,,72.2", + "\nDT1.4,C,,,1", "\nDT1.4,AA,PR,,-1.5", "\nDT1.4,OA,PR,,1.5\";", "\n", @@ -537,13 +726,31 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "### Import Actuals for the GRIC in the Previous Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "var ws31 = Workspace.CreateNew();", - "\nws31.Initialize(x=>x.FromSource(ws3));", - "\nawait Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws31).ExecuteAsync();", - "\nawait Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws3).ExecuteAsync()" + "var ws1 = Workspace.CreateNew();", + "\nws1.Initialize(x=>x.FromSource(ws));", + "\nawait Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws1).ExecuteAsync();", + "\nawait Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries of the first import." ], "metadata": {}, "execution_count": 0, @@ -552,22 +759,41 @@ { "cell_type": "code", "source": [ - "var caseIIIQuery1= new { ", - "\n IfrsVariables = ws31.Query(), ", - "\n RawVariables = ws31.Query()", + "var importQueries1= new { ", + "\n IfrsVariables = ws1.Query(), ", + "\n RawVariables = ws1.Query()", "\n};" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "### Import Openings for the GIC in the Current Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "var ws32 = Workspace.CreateNew();", - "\nws32.Initialize(x=>x.FromSource(ws3).DisableInitialization().DisableInitialization());", - "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws32).ExecuteAsync();", - "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws3).ExecuteAsync()" + "var ws2 = Workspace.CreateNew();", + "\nws2.Initialize(x=>x.FromSource(ws).DisableInitialization().DisableInitialization());", + "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws2).ExecuteAsync();", + "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "
", + "\nDELETE BELOW" ], "metadata": {}, "execution_count": 0, @@ -576,10 +802,42 @@ { "cell_type": "code", "source": [ - "var caseIIIQuery2 = new { ", - "\n IfrsVariables = ws32.Query(), ", - "\n RawVariables = ws32.Query()", - "\n};" + "// var actuals = @\"", + "\n// @@Main,,,,,", + "\n// ReportingNode,Year,Month,,,", + "\n// CH,2021,3,,,", + "\n// @@Actual,,,,,", + "\n// DataNode,AocType,AmountType,EstimateType,AccidentYear,Value", + "\n// DT1.4,CF,PR,A,,1\";", + "\n", + "\n// var openings = @\"", + "\n// @@Main", + "\n// ReportingNode,Year,Month,,", + "\n// CH,2021,3,,", + "\n// @@Opening", + "\n// DataNode,EstimateType,AmountType,AccidentYear,Value", + "\n// DT1.4,C,,,1.1\";", + "\n", + "\n// await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws1).ExecuteAsync();", + "\n// ws1.Query()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws1.Query().Union(ws2.Query(), IfrsVariableComparer.Instance(ignoreValue: false)).Except(ws.Query(), IfrsVariableComparer.Instance(ignoreValue: false))" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query()" ], "metadata": {}, "execution_count": 0, @@ -588,10 +846,35 @@ { "cell_type": "code", "source": [ - "var ws33 = Workspace.CreateNew();", - "\nws33.Initialize(x=>x.FromSource(ws3).DisableInitialization().DisableInitialization());", - "\nawait Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws33).ExecuteAsync();", - "\nawait Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws3).ExecuteAsync()" + "ws1.Query().Union(ws2.Query(), IfrsVariableComparer.Instance(ignoreValue: false))" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Except(ws1.Query().Union(ws2.Query(),IfrsVariableComparer.Instance(ignoreValue: false)), IfrsVariableComparer.Instance(ignoreValue: false))" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "DELETE ABOVE", + "\n
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries of the second import." ], "metadata": {}, "execution_count": 0, @@ -600,19 +883,49 @@ { "cell_type": "code", "source": [ - "var caseIIIQuery3 = new { ", - "\n IfrsVariables = ws33.Query(), ", - "\n RawVariables = ws33.Query()", + "var importQueries2 = new { ", + "\n IfrsVariables = ws2.Query(), ", + "\n RawVariables = ws2.Query()", "\n};" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "### Import Cashflows for the GRIC in the Current Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws3 = Workspace.CreateNew();", + "\nws3.Initialize(x=>x.FromSource(ws).DisableInitialization().DisableInitialization());", + "\nawait Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws3).ExecuteAsync();", + "\nawait Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries of the third import." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "var caseIIIQueries = new { ", + "var importQueries3 = new { ", "\n IfrsVariables = ws3.Query(), ", "\n RawVariables = ws3.Query()", "\n};" @@ -621,6 +934,27 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries after **all** imports." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var importQueries = new { ", + "\n IfrsVariables = ws.Query(), ", + "\n RawVariables = ws.Query()", + "\n};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -633,13 +967,9 @@ { "cell_type": "markdown", "source": [ - "
", - "\n/NOTES ", - "\n", - "\nEXCEPT(... , **Raw**VariableComparer.Instance(ignoreValue**s**: false) and ", - "\nEXCEPT(... , *Ifrs*VariableComparer.Instance(ignoreValue: false))", + "$\\text{RawVariableQueries} \\neq \\emptyset \\quad \\text{and}$", "\n", - "\ncan be used to compare two queries from the workspace." + "\n$\\text{IfrsVariableQueries} \\neq \\emptyset$" ], "metadata": {}, "execution_count": 0, @@ -648,10 +978,8 @@ { "cell_type": "code", "source": [ - "caseIIIQueries.IfrsVariables.Except(", - "\n caseIIIQuery1.IfrsVariables.Union(caseIIIQuery2.IfrsVariables", - "\n .Union(caseIIIQuery3.IfrsVariables))", - "\n , IfrsVariableComparer.Instance(ignoreValue: false))" + "importQueries1.IfrsVariables.Any().Should().Be(true);", + "\nimportQueries1.RawVariables.Any().Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -660,10 +988,30 @@ { "cell_type": "code", "source": [ - "caseIIIQueries.RawVariables.Except(", - "\n caseIIIQuery1.RawVariables.Union(caseIIIQuery2.RawVariables", - "\n .Union(caseIIIQuery3.RawVariables)), RawVariableComparer.Instance(ignoreValues: false)", - "\n )" + "importQueries.IfrsVariables.Any().Should().Be(true);", + "\nimportQueries.RawVariables.Any().Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "$\\text{importQueries} \\subseteq \\text{importQueries1} \\cup \\text{importQueries2} \\cup \\text{importQueries3} \\quad \\text{and}$", + "\n", + "\n$\\text{importQueries1} \\cup \\text{importQueries2} \\cup \\text{importQueries3} \\subseteq \\text{importQueries} \\quad \\Rightarrow$ ", + "\n", + "\n$\\text{importQueries} = \\text{importQueries1} \\cup \\text{importQueries2} \\cup \\text{importQueries3}$" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Check for IfrsVariables" ], "metadata": {}, "execution_count": 0, @@ -672,7 +1020,27 @@ { "cell_type": "code", "source": [ - "// caseIIIQueries.RawVariables.SequenceEqual(caseIIIQuery1.RawVariables.Union(caseIIIQuery2.RawVariables.Union(caseIIIQuery3.RawVariables)))" + "( !importQueries.IfrsVariables.Except(", + "\n importQueries1.IfrsVariables", + "\n .Union(importQueries2.IfrsVariables", + "\n .Union(importQueries3.IfrsVariables)", + "\n ),", + "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n ).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !importQueries1.IfrsVariables", + "\n .Union(importQueries2.IfrsVariables", + "\n .Union(importQueries3.IfrsVariables)).Except(", + "\n importQueries.IfrsVariables,", + "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n ).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -681,7 +1049,36 @@ { "cell_type": "markdown", "source": [ - "The assertion below shouldn't fail..." + "Check for RawVariables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !importQueries.RawVariables.Except(", + "\n importQueries1.RawVariables", + "\n .Union(importQueries2.RawVariables", + "\n .Union(importQueries3.RawVariables)", + "\n ),", + "\n RawVariableComparer.Instance(ignoreValues: false)", + "\n ).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !importQueries1.RawVariables", + "\n .Union(importQueries2.RawVariables", + "\n .Union(importQueries3.RawVariables)).Except(", + "\n importQueries.RawVariables,", + "\n RawVariableComparer.Instance(ignoreValues: false)", + "\n ).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -690,8 +1087,8 @@ { "cell_type": "markdown", "source": [ - "NOTES/", - "\n
" + "
", + "\nDELETE BELOW" ], "metadata": {}, "execution_count": 0, @@ -700,17 +1097,45 @@ { "cell_type": "code", "source": [ - "( !caseIIIQueries.IfrsVariables.Except(", - "\n caseIIIQuery1.IfrsVariables.Union(caseIIIQuery2.IfrsVariables", - "\n .Union(caseIIIQuery3.IfrsVariables)),", + "importQueries.IfrsVariables.Except(", + "\n importQueries1.IfrsVariables", + "\n .Union(importQueries2.IfrsVariables", + "\n .Union(importQueries3.IfrsVariables)", + "\n ),", "\n IfrsVariableComparer.Instance(ignoreValue: false)", - "\n ).Any() && ", - "\n !caseIIIQueries.RawVariables.Except(", - "\n caseIIIQuery1.RawVariables.Union(caseIIIQuery2.RawVariables", - "\n .Union(caseIIIQuery3.RawVariables)),", - "\n RawVariableComparer.Instance(ignoreValues: false)", - "\n ).Any()", - "\n).Should().Be(true);" + "\n )" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "importQueries1.IfrsVariables.Union(importQueries2.IfrsVariables", + "\n .Union(importQueries3.IfrsVariables))", + "\n .Except( importQueries.IfrsVariables,", + "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n )" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "DELETE ABOVE", + "\n
" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Import Modified Openings with CSM Deletion and LC Addition for DataNode at Inception" ], "metadata": {}, "execution_count": 0, @@ -719,7 +1144,9 @@ { "cell_type": "markdown", "source": [ - "# Case V: Reimport Modified Openings with CSM Deletion and LC Addition for the Same DataNode" + "Create openings for a data node at inception (DT1.1) and import. ", + "\n", + "\nImport again with the difference that CSM has been deleted and LC (for the same DataNode) has been added." ], "metadata": {}, "execution_count": 0, @@ -737,17 +1164,15 @@ { "cell_type": "code", "source": [ - "var ws4 = Workspace.CreateNew();", - "\nws4.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws4.UpdateAsync(new DataNodeState [] { //dt11StatePrevious with {State = State.Inactive},", + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", + "\nawait ws.UpdateAsync(new DataNodeState [] { //dt11StatePrevious with {State = State.Inactive},", "\n //dtr11StatePrevious with {State = State.Inactive},", "\n dt11State,", "\n dtr11State,", "\n // dtr13StatePrevious with {State = State.Inactive},", "\n // dt13State with {State = State.Inactive},", - "\n // dtr13State with {State = State.Inactive},", - "\n // dt14State with {State = State.Inactive},", - "\n // dtr14State with {State = State.Inactive}", + "\n // dt14State with {State = State.Inactive}", "\n }", "\n );" ], @@ -776,7 +1201,7 @@ { "cell_type": "markdown", "source": [ - "## Import Sequence Phase" + "## Import Phase" ], "metadata": {}, "execution_count": 0, @@ -785,10 +1210,16 @@ { "cell_type": "code", "source": [ - "var ws41 = Workspace.CreateNew();", - "\nws41.Initialize(x=>x.FromSource(ws4));", - "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws41).ExecuteAsync();", - "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws4).ExecuteAsync()" + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries after import." ], "metadata": {}, "execution_count": 0, @@ -797,9 +1228,9 @@ { "cell_type": "code", "source": [ - "var caseVQuery1 = new { ", - "\n IfrsVariables = ws41.Query(), ", - "\n RawVariables = ws41.Query()", + "var importQueries = new { ", + "\n IfrsVariables = ws.Query(), ", + "\n RawVariables = ws.Query()", "\n};" ], "metadata": {}, @@ -825,12 +1256,9 @@ "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "var ws42 = Workspace.CreateNew();", - "\nws42.Initialize(x=>x.FromSource(ws4).DisableInitialization().DisableInitialization());", - "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws42).ExecuteAsync();", - "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws4).ExecuteAsync()" + "## Reimport Phase" ], "metadata": {}, "execution_count": 0, @@ -839,10 +1267,16 @@ { "cell_type": "code", "source": [ - "var caseVQuery2 = new { ", - "\n IfrsVariables = ws42.Query(), ", - "\n RawVariables = ws42.Query()", - "\n};" + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Collect the IfrsVariable and RawVariable workspace queries after reimport." ], "metadata": {}, "execution_count": 0, @@ -851,9 +1285,9 @@ { "cell_type": "code", "source": [ - "var caseVQueries = new { ", - "\n IfrsVariables = ws4.Query(), ", - "\n RawVariables = ws4.Query()", + "var reimportQueries = new { ", + "\n IfrsVariables = ws.Query(), ", + "\n RawVariables = ws.Query()", "\n};" ], "metadata": {}, @@ -869,18 +1303,52 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "$\\text{importQueries} \\subseteq \\text{reimportQueries} \\quad \\text{and}$", + "\n", + "\n$\\text{reimportQueries} \\subseteq \\text{importQueries} \\quad \\Rightarrow$ ", + "\n", + "\n$\\text{importQueries} = \\text{reimportQueries}$" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Check IfrsVariables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "( !caseVQueries.IfrsVariables.Except(", - "\n caseVQuery1.IfrsVariables.Union(caseVQuery2.IfrsVariables),", - "\n IfrsVariableComparer.Instance(ignoreValue: false)", - "\n ).Any() && ", - "\n !caseVQueries.RawVariables.Except(", - "\n caseVQuery1.RawVariables.Union(caseVQuery2.RawVariables),", - "\n RawVariableComparer.Instance(ignoreValues: false)", - "\n ).Any()", - "\n).Should().Be(true);" + "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", + "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Check RawVariables" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "( !importQueries.RawVariables.Except(reimportQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", + "\n !reimportQueries.RawVariables.Except(importQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, From 748e5f1c328b2543e0f9c566e47a237da84cf7c6 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Wed, 3 May 2023 15:45:51 +0200 Subject: [PATCH 05/20] fix syntax in Instance() --- ifrs17-template/Test/ReimportTest.ipynb | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index f5363bd0..b14cda90 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -374,8 +374,8 @@ { "cell_type": "code", "source": [ - "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", - "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" + "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() && ", + "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -584,8 +584,8 @@ { "cell_type": "code", "source": [ - "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", - "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" + "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() && ", + "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -828,7 +828,7 @@ { "cell_type": "code", "source": [ - "ws1.Query().Union(ws2.Query(), IfrsVariableComparer.Instance(ignoreValue: false)).Except(ws.Query(), IfrsVariableComparer.Instance(ignoreValue: false))" + "ws1.Query().Union(ws2.Query(), IfrsVariableComparer.Instance(ignoreValues: false)).Except(ws.Query(), IfrsVariableComparer.Instance(ignoreValues: false))" ], "metadata": {}, "execution_count": 0, @@ -846,7 +846,7 @@ { "cell_type": "code", "source": [ - "ws1.Query().Union(ws2.Query(), IfrsVariableComparer.Instance(ignoreValue: false))" + "ws1.Query().Union(ws2.Query(), IfrsVariableComparer.Instance(ignoreValues: false))" ], "metadata": {}, "execution_count": 0, @@ -855,7 +855,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Except(ws1.Query().Union(ws2.Query(),IfrsVariableComparer.Instance(ignoreValue: false)), IfrsVariableComparer.Instance(ignoreValue: false))" + "ws.Query().Except(ws1.Query().Union(ws2.Query(),IfrsVariableComparer.Instance(ignoreValues: false)), IfrsVariableComparer.Instance(ignoreValues: false))" ], "metadata": {}, "execution_count": 0, @@ -1025,7 +1025,7 @@ "\n .Union(importQueries2.IfrsVariables", "\n .Union(importQueries3.IfrsVariables)", "\n ),", - "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n IfrsVariableComparer.Instance(ignoreValues: false)", "\n ).Any() ).Should().Be(true);" ], "metadata": {}, @@ -1039,7 +1039,7 @@ "\n .Union(importQueries2.IfrsVariables", "\n .Union(importQueries3.IfrsVariables)).Except(", "\n importQueries.IfrsVariables,", - "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n IfrsVariableComparer.Instance(ignoreValues: false)", "\n ).Any() ).Should().Be(true);" ], "metadata": {}, @@ -1102,7 +1102,7 @@ "\n .Union(importQueries2.IfrsVariables", "\n .Union(importQueries3.IfrsVariables)", "\n ),", - "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n IfrsVariableComparer.Instance(ignoreValues: false)", "\n )" ], "metadata": {}, @@ -1115,7 +1115,7 @@ "importQueries1.IfrsVariables.Union(importQueries2.IfrsVariables", "\n .Union(importQueries3.IfrsVariables))", "\n .Except( importQueries.IfrsVariables,", - "\n IfrsVariableComparer.Instance(ignoreValue: false)", + "\n IfrsVariableComparer.Instance(ignoreValues: false)", "\n )" ], "metadata": {}, @@ -1328,8 +1328,8 @@ { "cell_type": "code", "source": [ - "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() && ", - "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValue: false)).Any() ).Should().Be(true);" + "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() && ", + "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, From f56ba036b6bb3b90a27e32e75633dd9c4a2c4aae Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Thu, 4 May 2023 12:47:34 +0200 Subject: [PATCH 06/20] More work in case 3 in imports, queries and assertions --- ifrs17-template/Test/ReimportTest.ipynb | 361 ++++-------------------- 1 file changed, 53 insertions(+), 308 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index b14cda90..71bf87db 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -97,7 +97,7 @@ { "cell_type": "code", "source": [ - "var idtr13Parameter = new InterDataNodeParameter{", + "var dtr13IParameter = new InterDataNodeParameter{", "\n Partition = partitionReportingNode.Id,", "\n DataNode = \"DTR1.3\",", "\n Year = args.Year,", @@ -655,7 +655,7 @@ "\n }", "\n );", "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { ", - "\n idtr13Parameter", + "\n dtr13IParameter", "\n }", "\n );" ], @@ -663,60 +663,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "ws.Query()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var actuals = @\"", - "\n@@Main,,,,,", - "\nReportingNode,Year,Month,,,", - "\nCH,2020,12,,,", - "\n@@Actual,,,,,", - "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", - "\nDTR1.3,CF,PR,AA,,90", - "\nDTR1.3,CF,ICO,AA,,-6", - "\nDTR1.3,CF,NIC,AA,,-70", - "\nDTR1.3,CF,ACA,AA,,-10", - "\nDTR1.3,CF,AEA,AA,,-5\";", - "\n", - "\nvar openings = @\"", - "\n@@Main", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.4,C,,,1", - "\nDT1.4,AA,PR,,-1.5", - "\nDT1.4,OA,PR,,1.5\";", - "\n", - "\nvar cashflows = @\"", - "\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", - "\nDTR1.3,PR,BE,BOP,N,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0", - "\nDTR1.3,NIC,BE,BOP,N,,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25,-25", - "\nDTR1.3,,CU,BOP,N,,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-3", - "\nDTR1.3,,RA,BOP,N,,-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.3,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", - "\nDTR1.3,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", - "\nDTR1.3,,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", - "\nDTR1.3,,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", - "\n\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -738,88 +684,13 @@ { "cell_type": "code", "source": [ - "var ws1 = Workspace.CreateNew();", - "\nws1.Initialize(x=>x.FromSource(ws));", - "\nawait Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws1).ExecuteAsync();", - "\nawait Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Collect the IfrsVariable and RawVariable workspace queries of the first import." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var importQueries1= new { ", - "\n IfrsVariables = ws1.Query(), ", - "\n RawVariables = ws1.Query()", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Import Openings for the GIC in the Current Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var ws2 = Workspace.CreateNew();", - "\nws2.Initialize(x=>x.FromSource(ws).DisableInitialization().DisableInitialization());", - "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws2).ExecuteAsync();", - "\nawait Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "
", - "\nDELETE BELOW" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "// var actuals = @\"", - "\n// @@Main,,,,,", - "\n// ReportingNode,Year,Month,,,", - "\n// CH,2021,3,,,", - "\n// @@Actual,,,,,", - "\n// DataNode,AocType,AmountType,EstimateType,AccidentYear,Value", - "\n// DT1.4,CF,PR,A,,1\";", - "\n", - "\n// var openings = @\"", - "\n// @@Main", - "\n// ReportingNode,Year,Month,,", - "\n// CH,2021,3,,", - "\n// @@Opening", - "\n// DataNode,EstimateType,AmountType,AccidentYear,Value", - "\n// DT1.4,C,,,1.1\";", - "\n", - "\n// await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws1).ExecuteAsync();", - "\n// ws1.Query()" + "var actuals = @\"", + "\n@@Main,,,,,", + "\nReportingNode,Year,Month,,,", + "\nCH,2020,12,,,", + "\n@@Actual,,,,,", + "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", + "\nDTR1.3,CF,PR,AA,,1\";" ], "metadata": {}, "execution_count": 0, @@ -828,7 +699,13 @@ { "cell_type": "code", "source": [ - "ws1.Query().Union(ws2.Query(), IfrsVariableComparer.Instance(ignoreValues: false)).Except(ws.Query(), IfrsVariableComparer.Instance(ignoreValues: false))" + "var cashflows = @\"", + "\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", + "\nDTR1.3,PR,AA,BOP,N,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0\";" ], "metadata": {}, "execution_count": 0, @@ -846,7 +723,7 @@ { "cell_type": "code", "source": [ - "ws1.Query().Union(ws2.Query(), IfrsVariableComparer.Instance(ignoreValues: false))" + "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -855,26 +732,8 @@ { "cell_type": "code", "source": [ - "ws.Query().Except(ws1.Query().Union(ws2.Query(),IfrsVariableComparer.Instance(ignoreValues: false)), IfrsVariableComparer.Instance(ignoreValues: false))" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "DELETE ABOVE", - "\n
" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Collect the IfrsVariable and RawVariable workspace queries of the second import." + "var ivAfterActuals = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -883,10 +742,7 @@ { "cell_type": "code", "source": [ - "var importQueries2 = new { ", - "\n IfrsVariables = ws2.Query(), ", - "\n RawVariables = ws2.Query()", - "\n};" + "ivAfterActuals.Count().Should().Be(2);" ], "metadata": {}, "execution_count": 0, @@ -895,7 +751,7 @@ { "cell_type": "markdown", "source": [ - "### Import Cashflows for the GRIC in the Current Period" + "### Import Openings for the GIC in the Current Period" ], "metadata": {}, "execution_count": 0, @@ -904,19 +760,13 @@ { "cell_type": "code", "source": [ - "var ws3 = Workspace.CreateNew();", - "\nws3.Initialize(x=>x.FromSource(ws).DisableInitialization().DisableInitialization());", - "\nawait Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws3).ExecuteAsync();", - "\nawait Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Collect the IfrsVariable and RawVariable workspace queries of the third import." + "var openings = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.4,C,,,1\";" ], "metadata": {}, "execution_count": 0, @@ -925,19 +775,7 @@ { "cell_type": "code", "source": [ - "var importQueries3 = new { ", - "\n IfrsVariables = ws3.Query(), ", - "\n RawVariables = ws3.Query()", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Collect the IfrsVariable and RawVariable workspace queries after **all** imports." + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -946,30 +784,7 @@ { "cell_type": "code", "source": [ - "var importQueries = new { ", - "\n IfrsVariables = ws.Query(), ", - "\n RawVariables = ws.Query()", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Assertions" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "$\\text{RawVariableQueries} \\neq \\emptyset \\quad \\text{and}$", - "\n", - "\n$\\text{IfrsVariableQueries} \\neq \\emptyset$" + "ws.Query()" ], "metadata": {}, "execution_count": 0, @@ -978,8 +793,11 @@ { "cell_type": "code", "source": [ - "importQueries1.IfrsVariables.Any().Should().Be(true);", - "\nimportQueries1.RawVariables.Any().Should().Be(true);" + "var ivAfterOpenings = ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", + "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\"));" ], "metadata": {}, "execution_count": 0, @@ -988,21 +806,7 @@ { "cell_type": "code", "source": [ - "importQueries.IfrsVariables.Any().Should().Be(true);", - "\nimportQueries.RawVariables.Any().Should().Be(true);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "$\\text{importQueries} \\subseteq \\text{importQueries1} \\cup \\text{importQueries2} \\cup \\text{importQueries3} \\quad \\text{and}$", - "\n", - "\n$\\text{importQueries1} \\cup \\text{importQueries2} \\cup \\text{importQueries3} \\subseteq \\text{importQueries} \\quad \\Rightarrow$ ", - "\n", - "\n$\\text{importQueries} = \\text{importQueries1} \\cup \\text{importQueries2} \\cup \\text{importQueries3}$" + "ivAfterOpenings.Count().Should().Be(5);" ], "metadata": {}, "execution_count": 0, @@ -1011,22 +815,7 @@ { "cell_type": "markdown", "source": [ - "Check for IfrsVariables" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "( !importQueries.IfrsVariables.Except(", - "\n importQueries1.IfrsVariables", - "\n .Union(importQueries2.IfrsVariables", - "\n .Union(importQueries3.IfrsVariables)", - "\n ),", - "\n IfrsVariableComparer.Instance(ignoreValues: false)", - "\n ).Any() ).Should().Be(true);" + "### Import Cashflows for the GRIC in the Current Period" ], "metadata": {}, "execution_count": 0, @@ -1035,21 +824,13 @@ { "cell_type": "code", "source": [ - "( !importQueries1.IfrsVariables", - "\n .Union(importQueries2.IfrsVariables", - "\n .Union(importQueries3.IfrsVariables)).Except(", - "\n importQueries.IfrsVariables,", - "\n IfrsVariableComparer.Instance(ignoreValues: false)", - "\n ).Any() ).Should().Be(true);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Check for RawVariables" + "var cashflows = @\"", + "\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", + "\nDTR1.3,PR,AA,BOP,N,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0\";" ], "metadata": {}, "execution_count": 0, @@ -1058,13 +839,7 @@ { "cell_type": "code", "source": [ - "( !importQueries.RawVariables.Except(", - "\n importQueries1.RawVariables", - "\n .Union(importQueries2.RawVariables", - "\n .Union(importQueries3.RawVariables)", - "\n ),", - "\n RawVariableComparer.Instance(ignoreValues: false)", - "\n ).Any() ).Should().Be(true);" + "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -1073,22 +848,7 @@ { "cell_type": "code", "source": [ - "( !importQueries1.RawVariables", - "\n .Union(importQueries2.RawVariables", - "\n .Union(importQueries3.RawVariables)).Except(", - "\n importQueries.RawVariables,", - "\n RawVariableComparer.Instance(ignoreValues: false)", - "\n ).Any() ).Should().Be(true);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "
", - "\nDELETE BELOW" + "ws.Query()" ], "metadata": {}, "execution_count": 0, @@ -1097,13 +857,12 @@ { "cell_type": "code", "source": [ - "importQueries.IfrsVariables.Except(", - "\n importQueries1.IfrsVariables", - "\n .Union(importQueries2.IfrsVariables", - "\n .Union(importQueries3.IfrsVariables)", - "\n ),", - "\n IfrsVariableComparer.Instance(ignoreValues: false)", - "\n )" + "var ivAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", + "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -1112,21 +871,7 @@ { "cell_type": "code", "source": [ - "importQueries1.IfrsVariables.Union(importQueries2.IfrsVariables", - "\n .Union(importQueries3.IfrsVariables))", - "\n .Except( importQueries.IfrsVariables,", - "\n IfrsVariableComparer.Instance(ignoreValues: false)", - "\n )" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "DELETE ABOVE", - "\n
" + "ivAfterCashflows.Count().Should().Be(6);" ], "metadata": {}, "execution_count": 0, From 20c66cc92063579e5ee976082f1abef183dd3d8d Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Thu, 4 May 2023 16:30:42 +0200 Subject: [PATCH 07/20] Add new case and make ReimportTest pass --- ifrs17-template/Test/ReimportTest.ipynb | 402 ++++++++++++++++++++++-- 1 file changed, 371 insertions(+), 31 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 71bf87db..5b8d209f 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -244,6 +244,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Import Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -262,15 +271,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "## Import Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -448,6 +448,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Import Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -472,15 +481,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "## Import Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -699,22 +699,16 @@ { "cell_type": "code", "source": [ - "var cashflows = @\"", - "\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", - "\nDTR1.3,PR,AA,BOP,N,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0\";" + "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query()" + "### Assertions" ], "metadata": {}, "execution_count": 0, @@ -723,7 +717,7 @@ { "cell_type": "code", "source": [ - "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" + "var rvAfterActuals = ws.Query();" ], "metadata": {}, "execution_count": 0, @@ -739,6 +733,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "rvAfterActuals.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -781,10 +784,19 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "### Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "ws.Query()" + "var rvAfterActuals = ws.Query();" ], "metadata": {}, "execution_count": 0, @@ -803,6 +815,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "rvAfterActuals.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -830,7 +851,7 @@ "\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", - "\nDTR1.3,PR,AA,BOP,N,,100,0,0,100,0,0,100,0,0,100,0,0,0,100,0,0,100,0,0,100,0,0,100,0\";" + "\nDTR1.3,PR,AA,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\";" ], "metadata": {}, "execution_count": 0, @@ -845,10 +866,19 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "### Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "ws.Query()" + "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -868,6 +898,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "rvAfterCashflows.Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -877,6 +916,307 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Import Cashflows for Pre-exisitng Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Consider one GRIC (DTR1.3) that is linked to one GIC (DT1.4). The GRIC already existed the previous year, while the GIC is at inception.", + "\n- Import Cashflows for the GRIC in the previous period.", + "\n- Import Openings for the GIC in the current period.", + "\n- Import Cashflows for the GRIC in the current period." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Disposable Workspace" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", + "\nawait ws.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", + "\n // dtr11StatePrevious with {State = State.Inactive},", + "\n // dt11State with {State = State.Inactive},", + "\n // dtr11State with {State = State.Inactive},", + "\n dtr13StatePrevious,", + "\n // dt13State with {State = State.Inactive},", + "\n dt14State", + "\n }", + "\n );", + "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { ", + "\n dtr13IParameter", + "\n }", + "\n );" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Import Sequence Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Import Cashflows for the GRIC in the Previous Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var cashflows = @\"", + "\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", + "\nDTR1.3,PR,AA,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\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\"));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ivAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"F\" && x.AocType == \"AM\" && x.Novelty == \"C\"));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "rvAfterCashflows.Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ivAfterCashflows.Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Import Openings for the GIC in the Current Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var openings = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.4,C,,,1\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var rvAfterOpenings = ws.Query();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ivAfterOpenings = ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\"));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ivAfterOpenings.Count().Should().Be(3);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "rvAfterOpenings.Count().Should().Be(0); //SUSPICOUS" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Import Cashflows for the GRIC in the Current Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var cashflows = @\"", + "\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", + "\nDTR1.3,PR,AA,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\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ivAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "rvAfterCashflows.Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ivAfterCashflows.Count().Should().Be(4);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ From 98e05b661696c185f9e3aee50cfad2092af5ec78 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Thu, 4 May 2023 17:45:37 +0200 Subject: [PATCH 08/20] Cleanup --- ifrs17-template/Test/ReimportTest.ipynb | 56 ++++--------------------- 1 file changed, 7 insertions(+), 49 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 5b8d209f..9c1bc7ce 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -56,8 +56,8 @@ "cell_type": "markdown", "source": [ "Create:", - "\n- Import args for year 2021", - "\n- Import args for previous year", + "\n- Import args for current year (2021)", + "\n- Import args for previous year (2020)", "\n- Partition by Reporting Node (using details from most recent args)" ], "metadata": {}, @@ -349,19 +349,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "$\\text{importQueries} \\subseteq \\text{reimportQueries} \\quad \\text{and}$", - "\n", - "\n$\\text{reimportQueries} \\subseteq \\text{importQueries} \\quad \\Rightarrow$ ", - "\n", - "\n$\\text{importQueries} = \\text{reimportQueries}$" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -384,7 +371,7 @@ { "cell_type": "markdown", "source": [ - "Check for RawVariables (should be $\\emptyset$)" + "Check for RawVariables" ], "metadata": {}, "execution_count": 0, @@ -393,8 +380,7 @@ { "cell_type": "code", "source": [ - "( !importQueries.RawVariables.Except(reimportQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", - "\n !reimportQueries.RawVariables.Except(importQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" + "( importQueries.RawVariables.Count() == 0 && reimportQueries.RawVariables.Count() == 0 ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -559,19 +545,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "$\\text{importQueries} \\subseteq \\text{reimportQueries} \\quad \\text{and}$", - "\n", - "\n$\\text{reimportQueries} \\subseteq \\text{importQueries} \\quad \\Rightarrow$ ", - "\n", - "\n$\\text{importQueries} = \\text{reimportQueries}$" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -603,8 +576,7 @@ { "cell_type": "code", "source": [ - "( !importQueries.RawVariables.Except(reimportQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", - "\n !reimportQueries.RawVariables.Except(importQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" + "( importQueries.RawVariables.Count() == 0 && reimportQueries.RawVariables.Count() == 0 ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -623,7 +595,7 @@ "cell_type": "markdown", "source": [ "Consider one GRIC (DTR1.3) that is linked to one GIC (DT1.4). The GRIC already existed the previous year, while the GIC is at inception.", - "\n- Import data for the GRIC in the previous period.", + "\n- Import Actuals for the GRIC in the previous period.", "\n- Import Openings for the GIC in the current period.", "\n- Import Cashflows for the GRIC in the current period." ], @@ -1388,19 +1360,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "$\\text{importQueries} \\subseteq \\text{reimportQueries} \\quad \\text{and}$", - "\n", - "\n$\\text{reimportQueries} \\subseteq \\text{importQueries} \\quad \\Rightarrow$ ", - "\n", - "\n$\\text{importQueries} = \\text{reimportQueries}$" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -1432,8 +1391,7 @@ { "cell_type": "code", "source": [ - "( !importQueries.RawVariables.Except(reimportQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() && ", - "\n !reimportQueries.RawVariables.Except(importQueries.RawVariables, RawVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" + "( importQueries.RawVariables.Count() == 0 && reimportQueries.RawVariables.Count() == 0 ).Should().Be(true);" ], "metadata": {}, "execution_count": 0, From 9aecc6f0f218b6ae23dc95b5a281b396613c41d7 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Thu, 4 May 2023 19:13:40 +0200 Subject: [PATCH 09/20] Fix assertions --- ifrs17-template/Test/ReimportTest.ipynb | 86 +++++++++++++------------ 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 9c1bc7ce..13a39965 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -293,8 +293,8 @@ "cell_type": "code", "source": [ "var importQueries = new { ", - "\n IfrsVariables = ws.Query(), ", - "\n RawVariables = ws.Query()", + "\n IfrsVariables = ws.Query().ToArray(), ", + "\n RawVariables = ws.Query().ToArray()", "\n};" ], "metadata": {}, @@ -332,8 +332,8 @@ "cell_type": "code", "source": [ "var reimportQueries = new { ", - "\n IfrsVariables = ws.Query(), ", - "\n RawVariables = ws.Query()", + "\n IfrsVariables = ws.Query().ToArray(), ", + "\n RawVariables = ws.Query().ToArray()", "\n};" ], "metadata": {}, @@ -489,8 +489,8 @@ "cell_type": "code", "source": [ "var importQueries = new { ", - "\n IfrsVariables = ws.Query(), ", - "\n RawVariables = ws.Query()", + "\n IfrsVariables = ws.Query().ToArray(), ", + "\n RawVariables = ws.Query().ToArray()", "\n};" ], "metadata": {}, @@ -528,8 +528,8 @@ "cell_type": "code", "source": [ "var reimportQueries = new { ", - "\n IfrsVariables = ws.Query(), ", - "\n RawVariables = ws.Query()", + "\n IfrsVariables = ws.Query().ToArray(), ", + "\n RawVariables = ws.Query().ToArray()", "\n};" ], "metadata": {}, @@ -699,7 +699,7 @@ "cell_type": "code", "source": [ "var ivAfterActuals = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\"));" + "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -1248,8 +1248,7 @@ "\nDataNode,EstimateType,AmountType,AccidentYear,Value", "\nDT1.1,C,,,72.2", "\nDT1.1,AA,PR,,-1.5", - "\nDT1.1,OA,PR,,1.5", - "\n\";" + "\nDT1.1,OA,PR,,1.5\";" ], "metadata": {}, "execution_count": 0, @@ -1276,7 +1275,7 @@ { "cell_type": "markdown", "source": [ - "Collect the IfrsVariable and RawVariable workspace queries after import." + "## Assertions" ], "metadata": {}, "execution_count": 0, @@ -1285,10 +1284,7 @@ { "cell_type": "code", "source": [ - "var importQueries = new { ", - "\n IfrsVariables = ws.Query(), ", - "\n RawVariables = ws.Query()", - "\n};" + "var rvAfterOpenings = ws.Query();" ], "metadata": {}, "execution_count": 0, @@ -1297,25 +1293,17 @@ { "cell_type": "code", "source": [ - "var openings = @\"", - "\n@@Main,,,,", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening,,,,", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.1,L,,,72.2", - "\nDT1.1,AA,PR,,-1.5", - "\nDT1.1,OA,PR,,1.5", - "\n\";" + "var ivAfterOpenings = ws.Query();", + "\nvar ivWithCsm = ivAfterOpenings.Where(x => (x.EstimateType == \"C\"));" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "## Reimport Phase" + "rvAfterOpenings.Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -1324,7 +1312,8 @@ { "cell_type": "code", "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + "ivWithCsm.Count().Should().Be(3);", + "\nivAfterOpenings.Count().Should().Be(7);" ], "metadata": {}, "execution_count": 0, @@ -1333,7 +1322,7 @@ { "cell_type": "markdown", "source": [ - "Collect the IfrsVariable and RawVariable workspace queries after reimport." + "## Reimport Phase" ], "metadata": {}, "execution_count": 0, @@ -1342,10 +1331,24 @@ { "cell_type": "code", "source": [ - "var reimportQueries = new { ", - "\n IfrsVariables = ws.Query(), ", - "\n RawVariables = ws.Query()", - "\n};" + "var openings = @\"", + "\n@@Main,,,,", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening,,,,", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.1,L,,,72.2", + "\nDT1.1,AA,PR,,-1.5", + "\nDT1.1,OA,PR,,1.5\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -1361,9 +1364,9 @@ "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "Check IfrsVariables" + "var rvAfterOpenings = ws.Query();" ], "metadata": {}, "execution_count": 0, @@ -1372,17 +1375,17 @@ { "cell_type": "code", "source": [ - "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() && ", - "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" + "var ivAfterOpenings = ws.Query();", + "\nvar ivWithLc = ivAfterOpenings.Where(x => (x.EstimateType == \"L\"));" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "Check RawVariables" + "rvAfterOpenings.Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -1391,7 +1394,8 @@ { "cell_type": "code", "source": [ - "( importQueries.RawVariables.Count() == 0 && reimportQueries.RawVariables.Count() == 0 ).Should().Be(true);" + "ivWithLc.Count().Should().Be(3);", + "\nivAfterOpenings.Count().Should().Be(7);" ], "metadata": {}, "execution_count": 0, From 350530b81ff55577e9ac51b9db5acbebc420e9d8 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Fri, 5 May 2023 11:23:04 +0200 Subject: [PATCH 10/20] Add ReimportTest in Tests --- ifrs17-template/Test/Tests.ipynb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index c6c44706..543db90d 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -143,6 +143,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"ReimportTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ From 6624a045004da09666d85ab0db239680c22a4e06 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Fri, 5 May 2023 18:59:59 +0200 Subject: [PATCH 11/20] Fix the used memory markdown 28Gb RAM --- ifrs17-template/Test/Tests.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index c3ce1163..fc76e3cb 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -29,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 26Gb RAM." + "\n
Execute this Notebook using at least 28Gb RAM." ], "metadata": {}, "execution_count": 0, From f4d02604cbfed9875e646827d8c527e3e575b8a3 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Wed, 10 May 2023 16:00:24 +0200 Subject: [PATCH 12/20] Fix case 3 assertion and clean up --- ifrs17-template/Test/ReimportTest.ipynb | 193 ++++++++++++++++++++---- 1 file changed, 167 insertions(+), 26 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 13a39965..720b24f2 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -70,7 +70,7 @@ "var args = new ImportArgs(\"CH\", 2021, 3, Periodicity.Quarterly, null, null);", "\nvar previousArgs = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, null);", "\n", - "\nvar partitionReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)), ReportingNode = args.ReportingNode };" + "\nvar partitionByReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)), ReportingNode = args.ReportingNode };" ], "metadata": {}, "execution_count": 0, @@ -98,7 +98,7 @@ "cell_type": "code", "source": [ "var dtr13IParameter = new InterDataNodeParameter{", - "\n Partition = partitionReportingNode.Id,", + "\n Partition = partitionByReportingNode.Id,", "\n DataNode = \"DTR1.3\",", "\n Year = args.Year,", "\n Month = args.Month,", @@ -143,7 +143,7 @@ "\n State = State.Active,", "\n Year = previousArgs.Year,", "\n Month = previousArgs.Month,", - "\n Partition = partitionReportingNode.Id", + "\n Partition = partitionByReportingNode.Id", "\n };", "\n", "\nvar dtr11StatePrevious = new DataNodeState {", @@ -151,7 +151,7 @@ "\n State = State.Active,", "\n Year = previousArgs.Year,", "\n Month = previousArgs.Month,", - "\n Partition = partitionReportingNode.Id", + "\n Partition = partitionByReportingNode.Id", "\n };", "\n", "\nvar dt11State = new DataNodeState {", @@ -159,7 +159,7 @@ "\n State = State.Active,", "\n Year = args.Year,", "\n Month = args.Month,", - "\n Partition = partitionReportingNode.Id", + "\n Partition = partitionByReportingNode.Id", "\n };", "\n", "\nvar dtr11State = new DataNodeState {", @@ -167,7 +167,7 @@ "\n State = State.Active,", "\n Year = args.Year,", "\n Month = args.Month,", - "\n Partition = partitionReportingNode.Id", + "\n Partition = partitionByReportingNode.Id", "\n };", "\n", "\nvar dtr13StatePrevious = new DataNodeState {", @@ -175,7 +175,7 @@ "\n State = State.Active,", "\n Year = previousArgs.Year,", "\n Month = previousArgs.Month,", - "\n Partition = partitionReportingNode.Id", + "\n Partition = partitionByReportingNode.Id", "\n };", "\n", "\nvar dt13State = new DataNodeState {", @@ -183,7 +183,7 @@ "\n State = State.Active,", "\n Year = args.Year,", "\n Month = args.Month,", - "\n Partition = partitionReportingNode.Id", + "\n Partition = partitionByReportingNode.Id", "\n };", "\n", "\nvar dt14State = new DataNodeState {", @@ -191,7 +191,7 @@ "\n State = State.Active,", "\n Year = args.Year,", "\n Month = args.Month,", - "\n Partition = partitionReportingNode.Id", + "\n Partition = partitionByReportingNode.Id", "\n };" ], "metadata": {}, @@ -723,6 +723,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "(ws.Query().Count() == ivAfterActuals.Count()).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -805,6 +814,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "(ws.Query().Count() == ivAfterOpenings.Count()).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -823,7 +841,7 @@ "\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", - "\nDTR1.3,PR,AA,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\";" + "\nDTR1.3,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\";" ], "metadata": {}, "execution_count": 0, @@ -850,7 +868,7 @@ { "cell_type": "code", "source": [ - "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -864,7 +882,15 @@ "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -882,7 +908,25 @@ { "cell_type": "code", "source": [ - "ivAfterCashflows.Count().Should().Be(6);" + "(ws.Query().Count() == rvAfterCashflows.Count()).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ivAfterCashflows.Count().Should().Be(14);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "(ws.Query().Count() == ivAfterCashflows.Count()).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -968,7 +1012,7 @@ "\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", - "\nDTR1.3,PR,AA,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\";" + "\nDTR1.3,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\";" ], "metadata": {}, "execution_count": 0, @@ -995,7 +1039,7 @@ { "cell_type": "code", "source": [ - "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\"));" + "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -1004,7 +1048,15 @@ { "cell_type": "code", "source": [ - "var ivAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"F\" && x.AocType == \"AM\" && x.Novelty == \"C\"));" + "var ivAfterCashflows = ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -1022,7 +1074,25 @@ { "cell_type": "code", "source": [ - "ivAfterCashflows.Count().Should().Be(1);" + "(ws.Query().Count() == rvAfterCashflows.Count()).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ivAfterCashflows.Count().Should().Be(9);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "(ws.Query().Count() == ivAfterCashflows.Count()).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -1073,7 +1143,7 @@ { "cell_type": "code", "source": [ - "var rvAfterOpenings = ws.Query();" + "await ws.Partition.SetAsync(null) // necessary since two different periods correspond to two different partitions" ], "metadata": {}, "execution_count": 0, @@ -1082,7 +1152,25 @@ { "cell_type": "code", "source": [ - "var ivAfterOpenings = ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", + "var rvAfterOpenings = ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\"));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ivAfterOpenings = ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\"));" ], @@ -1093,7 +1181,7 @@ { "cell_type": "code", "source": [ - "ivAfterOpenings.Count().Should().Be(3);" + "rvAfterOpenings.Count().Should().Be(1); //Fixed after: await ws.Partition.SetAsync(null)" ], "metadata": {}, "execution_count": 0, @@ -1102,7 +1190,25 @@ { "cell_type": "code", "source": [ - "rvAfterOpenings.Count().Should().Be(0); //SUSPICOUS" + "(ws.Query().Count() == rvAfterOpenings.Count()).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ivAfterOpenings.Count().Should().Be(12);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "(ws.Query().Count() == ivAfterOpenings.Count()).Should().Be(true);" ], "metadata": {}, "execution_count": 0, @@ -1126,7 +1232,7 @@ "\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", - "\nDTR1.3,PR,AA,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\";" + "\nDTR1.3,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\";" ], "metadata": {}, "execution_count": 0, @@ -1153,7 +1259,7 @@ { "cell_type": "code", "source": [ - "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" ], "metadata": {}, "execution_count": 0, @@ -1162,10 +1268,27 @@ { "cell_type": "code", "source": [ - "var ivAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", + "var ivAfterCashflows = ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", + "\n || (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", + "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"YCU\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\"));" ], "metadata": {}, "execution_count": 0, @@ -1183,7 +1306,25 @@ { "cell_type": "code", "source": [ - "ivAfterCashflows.Count().Should().Be(4);" + "(ws.Query().Count() == rvAfterCashflows.Count()).Should().Be(true);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ivAfterCashflows.Count().Should().Be(21);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "(ws.Query().Count() == ivAfterCashflows.Count()).Should().Be(true);" ], "metadata": {}, "execution_count": 0, From 471e963541782b36784f5c4f14158d9a03e80158 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Mon, 15 May 2023 17:53:06 +0200 Subject: [PATCH 13/20] Clean up, implement feedback and update RAM md in Tests --- ifrs17-template/Test/ReimportTest.ipynb | 976 +++++++++++++++++------- ifrs17-template/Test/Tests.ipynb | 2 +- 2 files changed, 706 insertions(+), 272 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 720b24f2..e84efd7d 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -97,14 +97,7 @@ { "cell_type": "code", "source": [ - "var dtr13IParameter = new InterDataNodeParameter{", - "\n Partition = partitionByReportingNode.Id,", - "\n DataNode = \"DTR1.3\",", - "\n Year = args.Year,", - "\n Month = args.Month,", - "\n LinkedDataNode = \"DT1.4\",", - "\n ReinsuranceCoverage = 1d", - "\n };" + "var dtr13IParameter = new InterDataNodeParameter{ Partition = partitionByReportingNode.Id, DataNode = \"DTR1.3\", Year = args.Year, Month = args.Month, LinkedDataNode = \"DT1.4\", ReinsuranceCoverage = 1d };" ], "metadata": {}, "execution_count": 0, @@ -138,61 +131,19 @@ { "cell_type": "code", "source": [ - "var dt11StatePrevious = new DataNodeState {", - "\n DataNode = \"DT1.1\",", - "\n State = State.Active,", - "\n Year = previousArgs.Year,", - "\n Month = previousArgs.Month,", - "\n Partition = partitionByReportingNode.Id", - "\n };", + "var dt11StatePrevious = new DataNodeState { DataNode = \"DT1.1\", State = State.Active, Year = previousArgs.Year, Month = previousArgs.Month, Partition = partitionByReportingNode.Id };", "\n", - "\nvar dtr11StatePrevious = new DataNodeState {", - "\n DataNode = \"DTR1.1\",", - "\n State = State.Active,", - "\n Year = previousArgs.Year,", - "\n Month = previousArgs.Month,", - "\n Partition = partitionByReportingNode.Id", - "\n };", + "\nvar dtr11StatePrevious = new DataNodeState { DataNode = \"DTR1.1\", State = State.Active, Year = previousArgs.Year, Month = previousArgs.Month, Partition = partitionByReportingNode.Id };", "\n", - "\nvar dt11State = new DataNodeState {", - "\n DataNode = \"DT1.1\",", - "\n State = State.Active,", - "\n Year = args.Year,", - "\n Month = args.Month,", - "\n Partition = partitionByReportingNode.Id", - "\n };", + "\nvar dt11State = new DataNodeState { DataNode = \"DT1.1\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };", "\n", - "\nvar dtr11State = new DataNodeState {", - "\n DataNode = \"DTR1.1\",", - "\n State = State.Active,", - "\n Year = args.Year,", - "\n Month = args.Month,", - "\n Partition = partitionByReportingNode.Id", - "\n };", + "\nvar dtr11State = new DataNodeState { DataNode = \"DTR1.1\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };", "\n", - "\nvar dtr13StatePrevious = new DataNodeState {", - "\n DataNode = \"DTR1.3\",", - "\n State = State.Active,", - "\n Year = previousArgs.Year,", - "\n Month = previousArgs.Month,", - "\n Partition = partitionByReportingNode.Id", - "\n };", + "\nvar dtr13StatePrevious = new DataNodeState { DataNode = \"DTR1.3\", State = State.Active, Year = previousArgs.Year, Month = previousArgs.Month, Partition = partitionByReportingNode.Id };", "\n", - "\nvar dt13State = new DataNodeState {", - "\n DataNode = \"DT1.3\",", - "\n State = State.Active,", - "\n Year = args.Year,", - "\n Month = args.Month,", - "\n Partition = partitionByReportingNode.Id", - "\n };", + "\nvar dt13State = new DataNodeState { DataNode = \"DT1.3\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };", "\n", - "\nvar dt14State = new DataNodeState {", - "\n DataNode = \"DT1.4\",", - "\n State = State.Active,", - "\n Year = args.Year,", - "\n Month = args.Month,", - "\n Partition = partitionByReportingNode.Id", - "\n };" + "\nvar dt14State = new DataNodeState { DataNode = \"DT1.4\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };" ], "metadata": {}, "execution_count": 0, @@ -230,15 +181,8 @@ "source": [ "var ws = Workspace.CreateNew();", "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", - "\n // dtr11StatePrevious with {State = State.Inactive},", - "\n dt11State,", - "\n dtr11State, // <-- linked data node", - "\n // dtr13StatePrevious with {State = State.Inactive},", - "\n // dt13State with {State = State.Inactive},", - "\n // dt14State with {State = State.Inactive}", - "\n }", - "\n );" + "\n", + "\nawait ws.UpdateAsync(new DataNodeState [] { dt11State, dtr11State });" ], "metadata": {}, "execution_count": 0, @@ -420,15 +364,8 @@ "source": [ "var ws = Workspace.CreateNew();", "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws.UpdateAsync(new DataNodeState [] { dt11StatePrevious,", - "\n dtr11StatePrevious, // <-- linked data node", - "\n // dt11State with {State = State.Inactive},", - "\n // dtr11State with {State = State.Inactive},", - "\n // dtr13StatePrevious with {State = State.Inactive},", - "\n dt13State,", - "\n // dt14State with {State = State.Inactive}", - "\n }", - "\n );" + "\n", + "\nawait ws.UpdateAsync(new DataNodeState [] { dt11StatePrevious, dtr11StatePrevious, dt13State });" ], "metadata": {}, "execution_count": 0, @@ -617,19 +554,9 @@ "source": [ "var ws = Workspace.CreateNew();", "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", - "\nawait ws.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", - "\n // dtr11StatePrevious with {State = State.Inactive},", - "\n // dt11State with {State = State.Inactive},", - "\n // dtr11State with {State = State.Inactive},", - "\n dtr13StatePrevious,", - "\n // dt13State with {State = State.Inactive},", - "\n dt14State", - "\n }", - "\n );", - "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { ", - "\n dtr13IParameter", - "\n }", - "\n );" + "\n", + "\nawait ws.UpdateAsync(new DataNodeState [] { dtr13StatePrevious, dt14State });", + "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { dtr13IParameter });" ], "metadata": {}, "execution_count": 0, @@ -689,17 +616,7 @@ { "cell_type": "code", "source": [ - "var rvAfterActuals = ws.Query();" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var ivAfterActuals = ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\"));" + "ws.Query().Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -708,7 +625,7 @@ { "cell_type": "code", "source": [ - "rvAfterActuals.Count().Should().Be(0);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -717,7 +634,7 @@ { "cell_type": "code", "source": [ - "ivAfterActuals.Count().Should().Be(2);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -726,7 +643,7 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == ivAfterActuals.Count()).Should().Be(true);" + "ws.Query().Count().Should().Be(2);" ], "metadata": {}, "execution_count": 0, @@ -777,7 +694,25 @@ { "cell_type": "code", "source": [ - "var rvAfterActuals = ws.Query();" + "ws.Query().Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -786,11 +721,7 @@ { "cell_type": "code", "source": [ - "var ivAfterOpenings = ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", - "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\"));" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -799,7 +730,7 @@ { "cell_type": "code", "source": [ - "rvAfterActuals.Count().Should().Be(0);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -808,7 +739,7 @@ { "cell_type": "code", "source": [ - "ivAfterOpenings.Count().Should().Be(5);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -817,7 +748,7 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == ivAfterOpenings.Count()).Should().Be(true);" + "ws.Query().Count().Should().Be(5);" ], "metadata": {}, "execution_count": 0, @@ -868,7 +799,106 @@ { "cell_type": "code", "source": [ - "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 698.8857378808717)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -877,20 +907,7 @@ { "cell_type": "code", "source": [ - "var ivAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", - "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -899,7 +916,7 @@ { "cell_type": "code", "source": [ - "rvAfterCashflows.Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717 )).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -908,7 +925,7 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == rvAfterCashflows.Count()).Should().Be(true);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -917,7 +934,7 @@ { "cell_type": "code", "source": [ - "ivAfterCashflows.Count().Should().Be(14);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -926,7 +943,7 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == ivAfterCashflows.Count()).Should().Be(true);" + "ws.Query().Count().Should().Be(14);" ], "metadata": {}, "execution_count": 0, @@ -967,19 +984,9 @@ "source": [ "var ws = Workspace.CreateNew();", "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", - "\nawait ws.UpdateAsync(new DataNodeState [] { // dt11StatePrevious with {State = State.Inactive},", - "\n // dtr11StatePrevious with {State = State.Inactive},", - "\n // dt11State with {State = State.Inactive},", - "\n // dtr11State with {State = State.Inactive},", - "\n dtr13StatePrevious,", - "\n // dt13State with {State = State.Inactive},", - "\n dt14State", - "\n }", - "\n );", - "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { ", - "\n dtr13IParameter", - "\n }", - "\n );" + "\n", + "\nawait ws.UpdateAsync(new DataNodeState [] { dtr13StatePrevious, dt14State });", + "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { dtr13IParameter });" ], "metadata": {}, "execution_count": 0, @@ -1039,7 +1046,61 @@ { "cell_type": "code", "source": [ - "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\"));" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1048,15 +1109,7 @@ { "cell_type": "code", "source": [ - "var ivAfterCashflows = ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1065,7 +1118,7 @@ { "cell_type": "code", "source": [ - "rvAfterCashflows.Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1074,7 +1127,7 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == rvAfterCashflows.Count()).Should().Be(true);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1083,7 +1136,7 @@ { "cell_type": "code", "source": [ - "ivAfterCashflows.Count().Should().Be(9);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1092,7 +1145,7 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == ivAfterCashflows.Count()).Should().Be(true);" + "ws.Query().Count().Should().Be(9);" ], "metadata": {}, "execution_count": 0, @@ -1134,7 +1187,7 @@ { "cell_type": "markdown", "source": [ - "### Assertions" + "### Assertions (previous period)" ], "metadata": {}, "execution_count": 0, @@ -1143,7 +1196,7 @@ { "cell_type": "code", "source": [ - "await ws.Partition.SetAsync(null) // necessary since two different periods correspond to two different partitions" + "await ws.Partition.SetAsync(previousArgs)" ], "metadata": {}, "execution_count": 0, @@ -1152,7 +1205,7 @@ { "cell_type": "code", "source": [ - "var rvAfterOpenings = ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\"));" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1161,18 +1214,7 @@ { "cell_type": "code", "source": [ - "var ivAfterOpenings = ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\"));" + "ws.Query().Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1181,7 +1223,7 @@ { "cell_type": "code", "source": [ - "rvAfterOpenings.Count().Should().Be(1); //Fixed after: await ws.Partition.SetAsync(null)" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1190,7 +1232,7 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == rvAfterOpenings.Count()).Should().Be(true);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1199,7 +1241,7 @@ { "cell_type": "code", "source": [ - "ivAfterOpenings.Count().Should().Be(12);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1208,16 +1250,16 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == ivAfterOpenings.Count()).Should().Be(true);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Import Cashflows for the GRIC in the Current Period" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1226,13 +1268,7 @@ { "cell_type": "code", "source": [ - "var cashflows = @\"", - "\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", - "\nDTR1.3,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\";" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1241,16 +1277,16 @@ { "cell_type": "code", "source": [ - "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Assertions" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1259,7 +1295,7 @@ { "cell_type": "code", "source": [ - "var rvAfterCashflows = ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\"));" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1268,27 +1304,16 @@ { "cell_type": "code", "source": [ - "var ivAfterCashflows = ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", - "\n || (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\")", - "\n || (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"YCU\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\"));" + "ws.Query().Count().Should().Be(9);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Assertions (current period)" ], "metadata": {}, "execution_count": 0, @@ -1297,7 +1322,7 @@ { "cell_type": "code", "source": [ - "rvAfterCashflows.Count().Should().Be(1);" + "await ws.Partition.SetAsync(args)" ], "metadata": {}, "execution_count": 0, @@ -1306,7 +1331,7 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == rvAfterCashflows.Count()).Should().Be(true);" + "ws.Query().Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -1315,7 +1340,7 @@ { "cell_type": "code", "source": [ - "ivAfterCashflows.Count().Should().Be(21);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1324,27 +1349,25 @@ { "cell_type": "code", "source": [ - "(ws.Query().Count() == ivAfterCashflows.Count()).Should().Be(true);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "# Import Modified Openings with CSM Deletion and LC Addition for DataNode at Inception" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "Create openings for a data node at inception (DT1.1) and import. ", - "\n", - "\nImport again with the difference that CSM has been deleted and LC (for the same DataNode) has been added." + "ws.Query().Count().Should().Be(3);" ], "metadata": {}, "execution_count": 0, @@ -1353,7 +1376,7 @@ { "cell_type": "markdown", "source": [ - "## Disposable Workspace" + "### Import Cashflows for the GRIC in the Current Period" ], "metadata": {}, "execution_count": 0, @@ -1362,17 +1385,13 @@ { "cell_type": "code", "source": [ - "var ws = Workspace.CreateNew();", - "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\nawait ws.UpdateAsync(new DataNodeState [] { //dt11StatePrevious with {State = State.Inactive},", - "\n //dtr11StatePrevious with {State = State.Inactive},", - "\n dt11State,", - "\n dtr11State,", - "\n // dtr13StatePrevious with {State = State.Inactive},", - "\n // dt13State with {State = State.Inactive},", - "\n // dt14State with {State = State.Inactive}", - "\n }", - "\n );" + "var cashflows = @\"", + "\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", + "\nDTR1.3,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\";" ], "metadata": {}, "execution_count": 0, @@ -1381,15 +1400,7 @@ { "cell_type": "code", "source": [ - "var openings = @\"", - "\n@@Main,,,,", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening,,,,", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.1,C,,,72.2", - "\nDT1.1,AA,PR,,-1.5", - "\nDT1.1,OA,PR,,1.5\";" + "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -1398,7 +1409,7 @@ { "cell_type": "markdown", "source": [ - "## Import Phase" + "### Assertions (previous period)" ], "metadata": {}, "execution_count": 0, @@ -1407,16 +1418,16 @@ { "cell_type": "code", "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + "await ws.Partition.SetAsync(previousArgs)" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "## Assertions" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1425,7 +1436,7 @@ { "cell_type": "code", "source": [ - "var rvAfterOpenings = ws.Query();" + "ws.Query().Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1434,8 +1445,7 @@ { "cell_type": "code", "source": [ - "var ivAfterOpenings = ws.Query();", - "\nvar ivWithCsm = ivAfterOpenings.Where(x => (x.EstimateType == \"C\"));" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1444,7 +1454,7 @@ { "cell_type": "code", "source": [ - "rvAfterOpenings.Count().Should().Be(0);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1453,17 +1463,16 @@ { "cell_type": "code", "source": [ - "ivWithCsm.Count().Should().Be(3);", - "\nivAfterOpenings.Count().Should().Be(7);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "## Reimport Phase" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1472,15 +1481,7 @@ { "cell_type": "code", "source": [ - "var openings = @\"", - "\n@@Main,,,,", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening,,,,", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.1,L,,,72.2", - "\nDT1.1,AA,PR,,-1.5", - "\nDT1.1,OA,PR,,1.5\";" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1489,16 +1490,34 @@ { "cell_type": "code", "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "## Assertions" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1507,7 +1526,424 @@ { "cell_type": "code", "source": [ - "var rvAfterOpenings = ws.Query();" + "ws.Query().Count().Should().Be(9);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Assertions (current period)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ws.Partition.SetAsync(args)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -400)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.08544669484894)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -397.72149807405714)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.08544669484894)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -400)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.08544669484894)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064 )).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -0.1663616871675563)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -0.1663616871675563)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"YCU\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 0.2984757598735541)).Count().Should().Be(1);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Count().Should().Be(21);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Import Modified Openings with CSM Deletion and LC Addition for DataNode at Inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Create openings for a data node at inception (DT1.1) and import. ", + "\n", + "\nImport again with the difference that CSM has been deleted and LC (for the same DataNode) has been added." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Disposable Workspace" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", + "\n", + "\nawait ws.UpdateAsync(new DataNodeState [] { dt11State, dtr11State });" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var openings = @\"", + "\n@@Main,,,,", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening,,,,", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.1,C,,,72.2", + "\nDT1.1,AA,PR,,-1.5", + "\nDT1.1,OA,PR,,1.5\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Import Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Assertions" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Where(x => (x.EstimateType == \"C\")).Count().Should().Be(3);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ws.Query().Count().Should().Be(7);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reimport Phase" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var openings = @\"", + "\n@@Main,,,,", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening,,,,", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.1,L,,,72.2", + "\nDT1.1,AA,PR,,-1.5", + "\nDT1.1,OA,PR,,1.5\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Assertions" ], "metadata": {}, "execution_count": 0, @@ -1516,8 +1952,7 @@ { "cell_type": "code", "source": [ - "var ivAfterOpenings = ws.Query();", - "\nvar ivWithLc = ivAfterOpenings.Where(x => (x.EstimateType == \"L\"));" + "ws.Query().Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -1526,7 +1961,7 @@ { "cell_type": "code", "source": [ - "rvAfterOpenings.Count().Should().Be(0);" + "ws.Query().Where(x => (x.EstimateType == \"L\")).Count().Should().Be(3);" ], "metadata": {}, "execution_count": 0, @@ -1535,8 +1970,7 @@ { "cell_type": "code", "source": [ - "ivWithLc.Count().Should().Be(3);", - "\nivAfterOpenings.Count().Should().Be(7);" + "ws.Query().Count().Should().Be(7);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index fc76e3cb..90cbc17f 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -29,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 28Gb RAM." + "\n
Execute this Notebook using at least 32Gb RAM." ], "metadata": {}, "execution_count": 0, From fd943d15df3833efdfe9494311c15c992acf68aa Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Mon, 15 May 2023 18:45:05 +0200 Subject: [PATCH 14/20] Clean up x2 --- ifrs17-template/Test/ReimportTest.ipynb | 403 ++++++++++++------------ 1 file changed, 197 insertions(+), 206 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index e84efd7d..cf63162f 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -522,7 +522,7 @@ { "cell_type": "markdown", "source": [ - "# Import Actuals for Pre-exisitng Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" + "# Import Cashflows for Pre-exisitng Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" ], "metadata": {}, "execution_count": 0, @@ -532,7 +532,7 @@ "cell_type": "markdown", "source": [ "Consider one GRIC (DTR1.3) that is linked to one GIC (DT1.4). The GRIC already existed the previous year, while the GIC is at inception.", - "\n- Import Actuals for the GRIC in the previous period.", + "\n- Import Cashflows for the GRIC in the previous period.", "\n- Import Openings for the GIC in the current period.", "\n- Import Cashflows for the GRIC in the current period." ], @@ -574,7 +574,7 @@ { "cell_type": "markdown", "source": [ - "### Import Actuals for the GRIC in the Previous Period" + "### Import Cashflows for the GRIC in the Previous Period" ], "metadata": {}, "execution_count": 0, @@ -583,13 +583,13 @@ { "cell_type": "code", "source": [ - "var actuals = @\"", - "\n@@Main,,,,,", - "\nReportingNode,Year,Month,,,", - "\nCH,2020,12,,,", - "\n@@Actual,,,,,", - "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", - "\nDTR1.3,CF,PR,AA,,1\";" + "var cashflows = @\"", + "\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", + "\nDTR1.3,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\";" ], "metadata": {}, "execution_count": 0, @@ -598,7 +598,7 @@ { "cell_type": "code", "source": [ - "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" + "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -616,7 +616,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(0);" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -625,7 +625,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -634,7 +634,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -643,16 +643,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(2);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Import Openings for the GIC in the Current Period" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -661,13 +661,7 @@ { "cell_type": "code", "source": [ - "var openings = @\"", - "\n@@Main", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.4,C,,,1\";" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -676,16 +670,16 @@ { "cell_type": "code", "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Assertions" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -694,7 +688,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(0);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -703,7 +697,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -712,7 +706,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -721,16 +715,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(9);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "### Import Openings for the GIC in the Current Period" ], "metadata": {}, "execution_count": 0, @@ -739,7 +733,13 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "var openings = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.4,C,,,1\";" ], "metadata": {}, "execution_count": 0, @@ -748,7 +748,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(5);" + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -757,7 +757,7 @@ { "cell_type": "markdown", "source": [ - "### Import Cashflows for the GRIC in the Current Period" + "### Assertions (previous period)" ], "metadata": {}, "execution_count": 0, @@ -766,13 +766,7 @@ { "cell_type": "code", "source": [ - "var cashflows = @\"", - "\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", - "\nDTR1.3,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\";" + "await ws.Partition.SetAsync(previousArgs)" ], "metadata": {}, "execution_count": 0, @@ -781,16 +775,7 @@ { "cell_type": "code", "source": [ - "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -799,7 +784,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -808,7 +793,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -817,7 +802,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -826,7 +811,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -835,7 +820,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -844,7 +829,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -853,7 +838,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -862,7 +847,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -871,7 +856,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -880,7 +865,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -889,16 +874,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 698.8857378808717)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(9);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "### Assertions (current period)" ], "metadata": {}, "execution_count": 0, @@ -907,7 +892,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" + "await ws.Partition.SetAsync(args)" ], "metadata": {}, "execution_count": 0, @@ -916,7 +901,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717 )).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -925,7 +910,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -934,7 +919,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -943,16 +928,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(14);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "# Import Cashflows for Pre-exisitng Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" + "ws.Query().Count().Should().Be(3);" ], "metadata": {}, "execution_count": 0, @@ -961,19 +946,22 @@ { "cell_type": "markdown", "source": [ - "Consider one GRIC (DTR1.3) that is linked to one GIC (DT1.4). The GRIC already existed the previous year, while the GIC is at inception.", - "\n- Import Cashflows for the GRIC in the previous period.", - "\n- Import Openings for the GIC in the current period.", - "\n- Import Cashflows for the GRIC in the current period." + "### Import Cashflows for the GRIC in the Current Period" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "## Disposable Workspace" + "var cashflows = @\"", + "\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", + "\nDTR1.3,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\";" ], "metadata": {}, "execution_count": 0, @@ -982,11 +970,7 @@ { "cell_type": "code", "source": [ - "var ws = Workspace.CreateNew();", - "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", - "\n", - "\nawait ws.UpdateAsync(new DataNodeState [] { dtr13StatePrevious, dt14State });", - "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { dtr13IParameter });" + "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, @@ -995,16 +979,16 @@ { "cell_type": "markdown", "source": [ - "## Import Sequence Phase" + "### Assertions (previous period)" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Import Cashflows for the GRIC in the Previous Period" + "await ws.Partition.SetAsync(previousArgs)" ], "metadata": {}, "execution_count": 0, @@ -1013,13 +997,7 @@ { "cell_type": "code", "source": [ - "var cashflows = @\"", - "\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", - "\nDTR1.3,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\";" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1028,16 +1006,16 @@ { "cell_type": "code", "source": [ - "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" + "ws.Query().Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Assertions" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1046,7 +1024,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1055,7 +1033,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1064,7 +1042,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1073,7 +1051,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1082,7 +1060,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1091,7 +1069,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1100,7 +1078,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1109,7 +1087,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1118,16 +1096,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(9);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "### Assertions (current period)" ], "metadata": {}, "execution_count": 0, @@ -1136,7 +1114,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400)).Count().Should().Be(1);" + "await ws.Partition.SetAsync(args)" ], "metadata": {}, "execution_count": 0, @@ -1145,16 +1123,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(9);" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Import Openings for the GIC in the Current Period" + "ws.Query().Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1163,13 +1141,7 @@ { "cell_type": "code", "source": [ - "var openings = @\"", - "\n@@Main", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.4,C,,,1\";" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1178,16 +1150,16 @@ { "cell_type": "code", "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Assertions (previous period)" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -400)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1196,7 +1168,7 @@ { "cell_type": "code", "source": [ - "await ws.Partition.SetAsync(previousArgs)" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1205,7 +1177,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1214,7 +1186,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1223,7 +1195,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.08544669484894)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1232,7 +1204,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -397.72149807405714)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1250,7 +1222,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.08544669484894)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1259,7 +1231,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1268,7 +1240,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1277,7 +1249,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -400)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1286,7 +1258,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1295,7 +1267,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.08544669484894)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1304,16 +1276,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(9);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Assertions (current period)" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064 )).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1322,7 +1294,7 @@ { "cell_type": "code", "source": [ - "await ws.Partition.SetAsync(args)" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1331,7 +1303,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(0);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -0.1663616871675563)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1340,7 +1312,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -0.1663616871675563)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1349,7 +1321,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1358,7 +1330,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1367,16 +1339,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(3);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Import Cashflows for the GRIC in the Current Period" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"YCU\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 0.2984757598735541)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1385,22 +1357,16 @@ { "cell_type": "code", "source": [ - "var cashflows = @\"", - "\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", - "\nDTR1.3,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\";" + "ws.Query().Count().Should().Be(21);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", + { + "cell_type": "markdown", "source": [ - "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" + "# Import Actuals for Pre-exisitng Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" ], "metadata": {}, "execution_count": 0, @@ -1409,16 +1375,19 @@ { "cell_type": "markdown", "source": [ - "### Assertions (previous period)" + "Consider one GRIC (DTR1.3) that is linked to one GIC (DT1.4). The GRIC already existed the previous year, while the GIC is at inception.", + "\n- Import Actuals for the GRIC in the previous period.", + "\n- Import Openings for the GIC in the current period.", + "\n- Import Cashflows for the GRIC in the current period." ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "await ws.Partition.SetAsync(previousArgs)" + "## Disposable Workspace" ], "metadata": {}, "execution_count": 0, @@ -1427,25 +1396,29 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" + "var ws = Workspace.CreateNew();", + "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", + "\n", + "\nawait ws.UpdateAsync(new DataNodeState [] { dtr13StatePrevious, dt14State });", + "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { dtr13IParameter });" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Count().Should().Be(1);" + "## Import Sequence Phase" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "### Import Actuals for the GRIC in the Previous Period" ], "metadata": {}, "execution_count": 0, @@ -1454,7 +1427,13 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "var actuals = @\"", + "\n@@Main,,,,,", + "\nReportingNode,Year,Month,,,", + "\nCH,2020,12,,,", + "\n@@Actual,,,,,", + "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", + "\nDTR1.3,CF,PR,AA,,1\";" ], "metadata": {}, "execution_count": 0, @@ -1463,16 +1442,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" + "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" + "### Assertions" ], "metadata": {}, "execution_count": 0, @@ -1481,7 +1460,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -1490,7 +1469,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1499,7 +1478,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1508,16 +1487,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(2);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" + "### Import Openings for the GIC in the Current Period" ], "metadata": {}, "execution_count": 0, @@ -1526,25 +1505,31 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(9);" + "var openings = @\"", + "\n@@Main", + "\nReportingNode,Year,Month,,", + "\nCH,2021,3,,", + "\n@@Opening", + "\nDataNode,EstimateType,AmountType,AccidentYear,Value", + "\nDT1.4,C,,,1\";" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "### Assertions (current period)" + "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "await ws.Partition.SetAsync(args)" + "### Import Cashflows for the GRIC in the Current Period" ], "metadata": {}, "execution_count": 0, @@ -1553,7 +1538,13 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")).Count().Should().Be(1);" + "var cashflows = @\"", + "\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", + "\nDTR1.3,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\";" ], "metadata": {}, "execution_count": 0, @@ -1562,16 +1553,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(1);" + "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "### Assertions (previous period)" ], "metadata": {}, "execution_count": 0, @@ -1580,7 +1571,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "await ws.Partition.SetAsync(previousArgs)" ], "metadata": {}, "execution_count": 0, @@ -1589,7 +1580,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -400)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -1598,7 +1589,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1607,7 +1598,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1616,16 +1607,16 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(2);" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.08544669484894)).Count().Should().Be(1);" + "### Assertions (current period)" ], "metadata": {}, "execution_count": 0, @@ -1634,7 +1625,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -397.72149807405714)).Count().Should().Be(1);" + "await ws.Partition.SetAsync(args)" ], "metadata": {}, "execution_count": 0, @@ -1643,7 +1634,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1652,7 +1643,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.08544669484894)).Count().Should().Be(1);" + "ws.Query().Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1661,7 +1652,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1670,7 +1661,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1679,7 +1670,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -400)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1688,7 +1679,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1697,7 +1688,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.08544669484894)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1706,7 +1697,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1715,7 +1706,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064 )).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1724,7 +1715,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1733,7 +1724,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -0.1663616871675563)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 698.8857378808717)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1742,7 +1733,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -0.1663616871675563)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1751,7 +1742,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1760,7 +1751,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717 )).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1769,7 +1760,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1778,7 +1769,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"YCU\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 0.2984757598735541)).Count().Should().Be(1);" + "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700)).Count().Should().Be(1);" ], "metadata": {}, "execution_count": 0, @@ -1787,7 +1778,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(21);" + "ws.Query().Count().Should().Be(14);" ], "metadata": {}, "execution_count": 0, From 53525589df0bea0d6a3d869833a6be871983aa74 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 16 May 2023 14:39:06 +0200 Subject: [PATCH 15/20] Feedback --- ifrs17-template/Test/ReimportTest.ipynb | 66 ++++++++++++++++++++++--- ifrs17-template/Test/Tests.ipynb | 2 +- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index cf63162f..751e46fe 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -305,8 +305,25 @@ { "cell_type": "code", "source": [ - "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() && ", - "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" + "importQueries.IfrsVariables.Should().BeEquivalentTo(reimportQueries.IfrsVariables);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "importQueries.IfrsVariables.Count().Should().Be(7);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "reimportQueries.IfrsVariables.Count().Should().Be(7);" ], "metadata": {}, "execution_count": 0, @@ -324,7 +341,16 @@ { "cell_type": "code", "source": [ - "( importQueries.RawVariables.Count() == 0 && reimportQueries.RawVariables.Count() == 0 ).Should().Be(true);" + "importQueries.RawVariables.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "reimportQueries.RawVariables.Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -494,8 +520,25 @@ { "cell_type": "code", "source": [ - "( !importQueries.IfrsVariables.Except(reimportQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() && ", - "\n !reimportQueries.IfrsVariables.Except(importQueries.IfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false)).Any() ).Should().Be(true);" + "importQueries.IfrsVariables.Should().BeEquivalentTo(reimportQueries.IfrsVariables);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "importQueries.IfrsVariables.Count().Should().Be(20);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "reimportQueries.IfrsVariables.Count().Should().Be(20);" ], "metadata": {}, "execution_count": 0, @@ -513,7 +556,16 @@ { "cell_type": "code", "source": [ - "( importQueries.RawVariables.Count() == 0 && reimportQueries.RawVariables.Count() == 0 ).Should().Be(true);" + "importQueries.RawVariables.Count().Should().Be(0);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "reimportQueries.RawVariables.Count().Should().Be(0);" ], "metadata": {}, "execution_count": 0, @@ -1366,7 +1418,7 @@ { "cell_type": "markdown", "source": [ - "# Import Actuals for Pre-exisitng Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" + "# Import Actuals for Pre-existing Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index 90cbc17f..4bfc8e49 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -29,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 32Gb RAM." + "\n
Execute this Notebook using at least 34Gb RAM." ], "metadata": {}, "execution_count": 0, From 0d81cac9096c9b57945d6773467b37113e5f4ad6 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Fri, 19 May 2023 16:52:51 +0200 Subject: [PATCH 16/20] Restructuring and strictly keeping the "reimport" cases. --- ifrs17-template/Test/ReimportTest.ipynb | 1857 +---------------------- 1 file changed, 58 insertions(+), 1799 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 751e46fe..65e394e4 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -37,28 +37,7 @@ { "cell_type": "markdown", "source": [ - "# Definitions" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Args" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Create:", - "\n- Import args for current year (2021)", - "\n- Import args for previous year (2020)", - "\n- Partition by Reporting Node (using details from most recent args)" + "# Check Method" ], "metadata": {}, "execution_count": 0, @@ -67,10 +46,42 @@ { "cell_type": "code", "source": [ - "var args = new ImportArgs(\"CH\", 2021, 3, Periodicity.Quarterly, null, null);", - "\nvar previousArgs = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, null);", + "public async Task ReimportAndCompare((string transactionalData, string importFormat) importData, DataNodeState[] dataNodeStates)", + "\n{", + "\n var workspace = Workspace.CreateNew();", + "\n workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization());", + "\n await workspace.UpdateAsync(dataNodeStates);", "\n", - "\nvar partitionByReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)), ReportingNode = args.ReportingNode };" + "\n Activity.Start();", + "\n var importActivity = await Import.FromString(importData.transactionalData).WithFormat(importData.importFormat).WithTarget(workspace).ExecuteAsync();", + "\n if(importActivity.RepeatOnce().ToArray().HasErrors()) return importActivity;", + "\n ", + "\n var originalRawVariables = workspace.Query().ToArray();", + "\n var originalIfrsVariables = workspace.Query().ToArray();", + "\n", + "\n var reimportActivity = await Import.FromString(importData.transactionalData).WithFormat(importData.importFormat).WithTarget(workspace).ExecuteAsync();", + "\n if(reimportActivity.RepeatOnce().ToArray().HasErrors()) return reimportActivity;", + "\n", + "\n var reimportedRawVariables = workspace.Query().ToArray();", + "\n var reimportedIfrsVariables = workspace.Query().ToArray();", + "\n", + "\n List errors = new List();", + "\n var missingRawVariables = originalRawVariables.Except(reimportedRawVariables, RawVariableComparer.Instance(ignoreValues: false));", + "\n var missingIfrsVariables = originalIfrsVariables.Except(reimportedIfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false));", + "\n var extraRawVariables = reimportedRawVariables.Except(originalRawVariables, RawVariableComparer.Instance(ignoreValues: false));", + "\n var extraIfrsVariables = reimportedIfrsVariables.Except(originalIfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false));", + "\n", + "\n if(missingRawVariables.Any()) errors.Add($\"Missing RawVariables after the reimport: {string.Join(\"\\n\", missingRawVariables.ToList())}.\");", + "\n if(missingIfrsVariables.Any()) errors.Add($\"Missing IfrsVariables after the reimport: {string.Join(\"\\n\", missingIfrsVariables.ToList())}.\");", + "\n if(extraRawVariables.Any()) errors.Add($\"Extra RawVariables after the reimport: {string.Join(\"\\n\", extraRawVariables.ToList())}.\");", + "\n if(extraIfrsVariables.Any()) errors.Add($\"Extra IfrsVariables after the reimport: {string.Join(\"\\n\", extraIfrsVariables.ToList())}.\");", + "\n ", + "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", + "\n", + "\n ApplicationMessage.Log(Warning.Generic, \"Count of IfrsVariables in workspace: \" + reimportedIfrsVariables.Count());", + "\n ApplicationMessage.Log(Warning.Generic, \"Count of RawVariables in workspace: \" + reimportedRawVariables.Count());", + "\n return Activity.Finish();", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -79,7 +90,7 @@ { "cell_type": "markdown", "source": [ - "## DataNodeParameter" + "# Data Preparation" ], "metadata": {}, "execution_count": 0, @@ -88,7 +99,10 @@ { "cell_type": "markdown", "source": [ - "Create 1 data node parameter" + "Create:", + "\n- Import args for current year (2021)", + "\n- Import args for previous year (2020)", + "\n- Partition by Reporting Node (using details from most recent args)" ], "metadata": {}, "execution_count": 0, @@ -97,16 +111,10 @@ { "cell_type": "code", "source": [ - "var dtr13IParameter = new InterDataNodeParameter{ Partition = partitionByReportingNode.Id, DataNode = \"DTR1.3\", Year = args.Year, Month = args.Month, LinkedDataNode = \"DT1.4\", ReinsuranceCoverage = 1d };" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## DataNodeState" + "var args = new ImportArgs(\"CH\", 2021, 3, Periodicity.Quarterly, null, null);", + "\nvar previousArgs = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, null);", + "\n", + "\nvar partitionByReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync(args)), ReportingNode = args.ReportingNode };" ], "metadata": {}, "execution_count": 0, @@ -115,14 +123,12 @@ { "cell_type": "markdown", "source": [ - "Create 7 data node states:", + "Create 5 data node states:", "\n- dt11StatePrevious", "\n- dtr11StatePrevious", "\n- dt11State", "\n- dtr11State", - "\n- dtr13StatePrevious", - "\n- dt13State", - "\n- dt14State" + "\n- dt13State" ], "metadata": {}, "execution_count": 0, @@ -139,20 +145,7 @@ "\n", "\nvar dtr11State = new DataNodeState { DataNode = \"DTR1.1\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };", "\n", - "\nvar dtr13StatePrevious = new DataNodeState { DataNode = \"DTR1.3\", State = State.Active, Year = previousArgs.Year, Month = previousArgs.Month, Partition = partitionByReportingNode.Id };", - "\n", - "\nvar dt13State = new DataNodeState { DataNode = \"DT1.3\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };", - "\n", - "\nvar dt14State = new DataNodeState { DataNode = \"DT1.4\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Reimport Openings for DataNode at Inception" + "\nvar dt13State = new DataNodeState { DataNode = \"DT1.3\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };" ], "metadata": {}, "execution_count": 0, @@ -161,7 +154,7 @@ { "cell_type": "markdown", "source": [ - "Create openings for a data node at inception (DT1.1) and import more than once." + "# Test Transactional Data" ], "metadata": {}, "execution_count": 0, @@ -170,19 +163,7 @@ { "cell_type": "markdown", "source": [ - "## Disposable Workspace" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var ws = Workspace.CreateNew();", - "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\n", - "\nawait ws.UpdateAsync(new DataNodeState [] { dt11State, dtr11State });" + "## Reimport Openings for DataNode at Inception" ], "metadata": {}, "execution_count": 0, @@ -191,7 +172,7 @@ { "cell_type": "markdown", "source": [ - "## Import Phase" + "Create openings for a data node at inception (DT1.1) and import more than once." ], "metadata": {}, "execution_count": 0, @@ -218,130 +199,8 @@ { "cell_type": "code", "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Collect the IfrsVariable and RawVariable workspace queries after import." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var importQueries = new { ", - "\n IfrsVariables = ws.Query().ToArray(), ", - "\n RawVariables = ws.Query().ToArray()", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Reimport Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Collect the IfrsVariable and RawVariable workspace queries after reimport." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var reimportQueries = new { ", - "\n IfrsVariables = ws.Query().ToArray(), ", - "\n RawVariables = ws.Query().ToArray()", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Assertions" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Check for IfrsVariables" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "importQueries.IfrsVariables.Should().BeEquivalentTo(reimportQueries.IfrsVariables);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "importQueries.IfrsVariables.Count().Should().Be(7);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "reimportQueries.IfrsVariables.Count().Should().Be(7);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Check for RawVariables" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "importQueries.RawVariables.Count().Should().Be(0);" + "var activity = await ReimportAndCompare((openings, ImportFormats.Opening), new [] { dt11State, dtr11State });", + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -350,7 +209,7 @@ { "cell_type": "code", "source": [ - "reimportQueries.RawVariables.Count().Should().Be(0);" + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, @@ -359,7 +218,7 @@ { "cell_type": "markdown", "source": [ - "# Reimport Actuals for Both: DataNode at Inception and DataNode and Not at Inception" + "## Reimport Actuals for Both: DataNode at Inception and DataNode and Not at Inception" ], "metadata": {}, "execution_count": 0, @@ -376,36 +235,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "## Disposable Workspace" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var ws = Workspace.CreateNew();", - "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\n", - "\nawait ws.UpdateAsync(new DataNodeState [] { dt11StatePrevious, dtr11StatePrevious, dt13State });" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Import Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -433,1578 +262,8 @@ { "cell_type": "code", "source": [ - "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Collect the IfrsVariable and RawVariable workspace queries after import." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var importQueries = new { ", - "\n IfrsVariables = ws.Query().ToArray(), ", - "\n RawVariables = ws.Query().ToArray()", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Reimport Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync();" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Collect the IfrsVariable and RawVariable workspace queries after reimport." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var reimportQueries = new { ", - "\n IfrsVariables = ws.Query().ToArray(), ", - "\n RawVariables = ws.Query().ToArray()", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Assertions" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Check for IfrsVariables" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "importQueries.IfrsVariables.Should().BeEquivalentTo(reimportQueries.IfrsVariables);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "importQueries.IfrsVariables.Count().Should().Be(20);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "reimportQueries.IfrsVariables.Count().Should().Be(20);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Check for RawVariables" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "importQueries.RawVariables.Count().Should().Be(0);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "reimportQueries.RawVariables.Count().Should().Be(0);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Import Cashflows for Pre-exisitng Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Consider one GRIC (DTR1.3) that is linked to one GIC (DT1.4). The GRIC already existed the previous year, while the GIC is at inception.", - "\n- Import Cashflows for the GRIC in the previous period.", - "\n- Import Openings for the GIC in the current period.", - "\n- Import Cashflows for the GRIC in the current period." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Disposable Workspace" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var ws = Workspace.CreateNew();", - "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", - "\n", - "\nawait ws.UpdateAsync(new DataNodeState [] { dtr13StatePrevious, dt14State });", - "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { dtr13IParameter });" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Import Sequence Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Import Cashflows for the GRIC in the Previous Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var cashflows = @\"", - "\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", - "\nDTR1.3,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\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(9);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Import Openings for the GIC in the Current Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var openings = @\"", - "\n@@Main", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.4,C,,,1\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions (previous period)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await ws.Partition.SetAsync(previousArgs)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(9);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions (current period)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await ws.Partition.SetAsync(args)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(0);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(3);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Import Cashflows for the GRIC in the Current Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var cashflows = @\"", - "\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", - "\nDTR1.3,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\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions (previous period)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await ws.Partition.SetAsync(previousArgs)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.Novelty == \"C\")).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(9);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions (current period)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await ws.Partition.SetAsync(args)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.DataNode == \"DTR1.3\" && x.AocType == \"BOP\" && x.Values[0] == -400)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.08544669484894)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -397.72149807405714)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -400d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 399.08544669484894)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -399.63392949885525)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -400)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -399.08544669484894)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064 )).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -0.1663616871675563)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"IA\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == -0.1663616871675563)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CF\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 100d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"YCU\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 0.2984757598735541)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(21);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Import Actuals for Pre-existing Reinsurance, Openings for Linked Insurance and Cashflows for the Reinsurance" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Consider one GRIC (DTR1.3) that is linked to one GIC (DT1.4). The GRIC already existed the previous year, while the GIC is at inception.", - "\n- Import Actuals for the GRIC in the previous period.", - "\n- Import Openings for the GIC in the current period.", - "\n- Import Cashflows for the GRIC in the current period." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Disposable Workspace" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var ws = Workspace.CreateNew();", - "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", - "\n", - "\nawait ws.UpdateAsync(new DataNodeState [] { dtr13StatePrevious, dt14State });", - "\nawait ws.UpdateAsync(new InterDataNodeParameter [] { dtr13IParameter });" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Import Sequence Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Import Actuals for the GRIC in the Previous Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var actuals = @\"", - "\n@@Main,,,,,", - "\nReportingNode,Year,Month,,,", - "\nCH,2020,12,,,", - "\n@@Actual,,,,,", - "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", - "\nDTR1.3,CF,PR,AA,,1\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(actuals).WithFormat(ImportFormats.Actual).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(0);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(2);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Import Openings for the GIC in the Current Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var openings = @\"", - "\n@@Main", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.4,C,,,1\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Import Cashflows for the GRIC in the Current Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var cashflows = @\"", - "\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", - "\nDTR1.3,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\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(cashflows).WithFormat(ImportFormats.Cashflow).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions (previous period)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await ws.Partition.SetAsync(previousArgs)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(0);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"CF\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(2);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Assertions (current period)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await ws.Partition.SetAsync(args)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"BE\" && x.AmountType == \"PR\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\")).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"EOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"C\" && x.Values[0] == 1.0012476630625269)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"BOP\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"IA\" && x.DataNode == \"DT1.4\" && x.Novelty == \"I\" && x.Values[0] == 0.0012476630625268825)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"AA\" && x.AmountType == \"PR\" && x.AocType == \"BOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"I\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"CL\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 698.8857378808717)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"F\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == 1d)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\" && x.AocType == \"AM\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"L\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -698.8857378808717 )).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"C\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -697.2233135002064)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EconomicBasis == \"N\" && x.EstimateType == \"BE\" && x.AocType == \"EOP\" && x.DataNode == \"DTR1.3\" && x.Novelty == \"C\" && x.Values[0] == -700)).Count().Should().Be(1);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(14);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Import Modified Openings with CSM Deletion and LC Addition for DataNode at Inception" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "Create openings for a data node at inception (DT1.1) and import. ", - "\n", - "\nImport again with the difference that CSM has been deleted and LC (for the same DataNode) has been added." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Disposable Workspace" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var ws = Workspace.CreateNew();", - "\nws.Initialize(x=>x.FromSource(DataSource).DisableInitialization());", - "\n", - "\nawait ws.UpdateAsync(new DataNodeState [] { dt11State, dtr11State });" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var openings = @\"", - "\n@@Main,,,,", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening,,,,", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.1,C,,,72.2", - "\nDT1.1,AA,PR,,-1.5", - "\nDT1.1,OA,PR,,1.5\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Import Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Assertions" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(0);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"C\")).Count().Should().Be(3);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(7);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Reimport Phase" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var openings = @\"", - "\n@@Main,,,,", - "\nReportingNode,Year,Month,,", - "\nCH,2021,3,,", - "\n@@Opening,,,,", - "\nDataNode,EstimateType,AmountType,AccidentYear,Value", - "\nDT1.1,L,,,72.2", - "\nDT1.1,AA,PR,,-1.5", - "\nDT1.1,OA,PR,,1.5\";" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await Import.FromString(openings).WithFormat(ImportFormats.Opening).WithTarget(ws).ExecuteAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Assertions" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Count().Should().Be(0);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ws.Query().Where(x => (x.EstimateType == \"L\")).Count().Should().Be(3);" + "var activity = await ReimportAndCompare((actuals, ImportFormats.Actual), new[] {dt11StatePrevious, dtr11StatePrevious, dt13State});", + "\nactivity" ], "metadata": {}, "execution_count": 0, @@ -2013,7 +272,7 @@ { "cell_type": "code", "source": [ - "ws.Query().Count().Should().Be(7);" + "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" ], "metadata": {}, "execution_count": 0, From 172a13fbfc691b9b3dfa480f5e4bfa7e020da1e1 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Fri, 19 May 2023 17:03:14 +0200 Subject: [PATCH 17/20] Tests RAM markdown --- ifrs17-template/Test/Tests.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index 4bfc8e49..c3ce1163 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -29,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 34Gb RAM." + "\n
Execute this Notebook using at least 26Gb RAM." ], "metadata": {}, "execution_count": 0, From 10d1b66d1b5c98ef3fe2b873752488eb6b65f722 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Fri, 26 May 2023 19:31:45 +0200 Subject: [PATCH 18/20] Feedback + test case proposal --- ifrs17-template/Test/ReimportTest.ipynb | 80 +++++++++++++++++++++---- ifrs17-template/Test/Tests.ipynb | 18 +++--- 2 files changed, 77 insertions(+), 21 deletions(-) diff --git a/ifrs17-template/Test/ReimportTest.ipynb b/ifrs17-template/Test/ReimportTest.ipynb index 65e394e4..13952d0b 100644 --- a/ifrs17-template/Test/ReimportTest.ipynb +++ b/ifrs17-template/Test/ReimportTest.ipynb @@ -49,27 +49,27 @@ "public async Task ReimportAndCompare((string transactionalData, string importFormat) importData, DataNodeState[] dataNodeStates)", "\n{", "\n var workspace = Workspace.CreateNew();", - "\n workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization());", + "\n workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization().DisableInitialization().DisableInitialization());", "\n await workspace.UpdateAsync(dataNodeStates);", "\n", "\n Activity.Start();", "\n var importActivity = await Import.FromString(importData.transactionalData).WithFormat(importData.importFormat).WithTarget(workspace).ExecuteAsync();", "\n if(importActivity.RepeatOnce().ToArray().HasErrors()) return importActivity;", "\n ", - "\n var originalRawVariables = workspace.Query().ToArray();", - "\n var originalIfrsVariables = workspace.Query().ToArray();", + "\n var firstImportRawVariable = workspace.Query().ToArray();", + "\n var firstImportIfrsVariable = workspace.Query().ToArray();", "\n", "\n var reimportActivity = await Import.FromString(importData.transactionalData).WithFormat(importData.importFormat).WithTarget(workspace).ExecuteAsync();", "\n if(reimportActivity.RepeatOnce().ToArray().HasErrors()) return reimportActivity;", "\n", - "\n var reimportedRawVariables = workspace.Query().ToArray();", - "\n var reimportedIfrsVariables = workspace.Query().ToArray();", + "\n var secondImportRawVariable = workspace.Query().ToArray();", + "\n var secondImportIfrsVariable = workspace.Query().ToArray();", "\n", "\n List errors = new List();", - "\n var missingRawVariables = originalRawVariables.Except(reimportedRawVariables, RawVariableComparer.Instance(ignoreValues: false));", - "\n var missingIfrsVariables = originalIfrsVariables.Except(reimportedIfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false));", - "\n var extraRawVariables = reimportedRawVariables.Except(originalRawVariables, RawVariableComparer.Instance(ignoreValues: false));", - "\n var extraIfrsVariables = reimportedIfrsVariables.Except(originalIfrsVariables, IfrsVariableComparer.Instance(ignoreValues: false));", + "\n var missingRawVariables = firstImportRawVariable.Except(secondImportRawVariable, RawVariableComparer.Instance(ignoreValues: false));", + "\n var missingIfrsVariables = firstImportIfrsVariable.Except(secondImportIfrsVariable, IfrsVariableComparer.Instance(ignoreValues: false));", + "\n var extraRawVariables = secondImportRawVariable.Except(firstImportRawVariable, RawVariableComparer.Instance(ignoreValues: false));", + "\n var extraIfrsVariables = secondImportIfrsVariable.Except(firstImportIfrsVariable, IfrsVariableComparer.Instance(ignoreValues: false));", "\n", "\n if(missingRawVariables.Any()) errors.Add($\"Missing RawVariables after the reimport: {string.Join(\"\\n\", missingRawVariables.ToList())}.\");", "\n if(missingIfrsVariables.Any()) errors.Add($\"Missing IfrsVariables after the reimport: {string.Join(\"\\n\", missingIfrsVariables.ToList())}.\");", @@ -78,8 +78,8 @@ "\n ", "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", "\n", - "\n ApplicationMessage.Log(Warning.Generic, \"Count of IfrsVariables in workspace: \" + reimportedIfrsVariables.Count());", - "\n ApplicationMessage.Log(Warning.Generic, \"Count of RawVariables in workspace: \" + reimportedRawVariables.Count());", + "\n ApplicationMessage.Log(Warning.Generic, \"Count of IfrsVariables in workspace: \" + secondImportIfrsVariable.Count());", + "\n ApplicationMessage.Log(Warning.Generic, \"Count of RawVariables in workspace: \" + secondImportRawVariable.Count());", "\n return Activity.Finish();", "\n}" ], @@ -218,7 +218,7 @@ { "cell_type": "markdown", "source": [ - "## Reimport Actuals for Both: DataNode at Inception and DataNode and Not at Inception" + "## Reimport Actuals for Both: DataNode at Inception and DataNode Not at Inception" ], "metadata": {}, "execution_count": 0, @@ -278,6 +278,62 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Reimport Cashflows for Linked Reinsurance Not at Inception" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Create a cashflows file that contains data for a data node not at inception (DTR1.1). ", + "\n", + "\nImport this file more than once." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var cashflows = @\"", + "\n@@Main,,,,,,,,,,,,,,,,,,,,,,,,,,", + "\nReportingNode,Year,Month,,,,,,,,,,,,,,,,,,,,,,,,", + "\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", + "\nDTR1.1,PR,BE,CL,C,,0,-57.5,0,0,-57.5,0,0,-57.5,0,0,-57.5,0,0,0,0,0,0,0,0,0,0", + "\nDTR1.1,NIC,BE,CL,C,,15,15,15,15,15,15,15,15,15,15,15,15,0,0,0,0,0,0,0,0,0", + "\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,0,0,0,0,0,0,0,0,0\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var activity = await ReimportAndCompare((cashflows, ImportFormats.Cashflow), new[] {dt11StatePrevious, dtr11StatePrevious});", + "\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": [ diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index c3ce1163..6190ae51 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -44,6 +44,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"ReimportTest\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -143,15 +152,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "#!eval-notebook \"ReimportTest\"" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ From aa9b40ab1b9cddb069dc243662405dece3eadf01 Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 11 Jul 2023 14:28:44 +0200 Subject: [PATCH 19/20] RAM md in Tests --- ifrs17-template/Test/Tests.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index 70fdb698..d9888270 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -29,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 26Gb RAM." + "\n
Execute this Notebook using at least 28Gb RAM." ], "metadata": {}, "execution_count": 0, From 57b31f7cfc36c6ed37e93cd3426adae7fe31f5dd Mon Sep 17 00:00:00 2001 From: nnikolopoulos Date: Tue, 11 Jul 2023 15:03:34 +0200 Subject: [PATCH 20/20] Correct RAM in Tests --- ifrs17-template/Test/Tests.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index d9888270..0c80a36b 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -29,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 28Gb RAM." + "\n
Execute this Notebook using at least 32Gb RAM." ], "metadata": {}, "execution_count": 0,