diff --git a/full-ifrs17-template/Constants/Consts.ipynb b/full-ifrs17-template/Constants/Consts.ipynb new file mode 100644 index 00000000..f39ab144 --- /dev/null +++ b/full-ifrs17-template/Constants/Consts.ipynb @@ -0,0 +1,28 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "var projectName = \"ifrs17ce\";", + "\nvar environmentName = \"dev\";", + "\nvar notebookName = \"CalculationEngine\";", + "\nvar calculationEngine = $\"#!import \\\"//{projectName}/{environmentName}/{notebookName}\\\"\";" + ] + } + ] +} \ No newline at end of file diff --git a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb index 293cb431..cf90dac4 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb @@ -29,7 +29,8 @@ { "cell_type": "code", "source": [ - "#!import \"//ifrs17ce/dev/CalculationEngine\"" + "#!import \"../Constants/Consts\"", + "\n#!eval calculationEngine" ] }, { @@ -77,7 +78,6 @@ "\n .WithType()", "\n .WithType()", "\n .WithType()", - "\n .WithType()", "\n .WithType()", "\n .WithType()", "\n .WithType()", @@ -97,6 +97,12 @@ "\n .ExecuteAsync()" ] }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../Files/DimensionsAndPartitions.csv\").WithFormat(\"AocConfiguration\").WithTarget(DataSource).ExecuteAsync()" + ] + }, { "cell_type": "code", "source": [ diff --git a/full-ifrs17-template/Test/Tests.ipynb b/full-ifrs17-template/Test/Tests.ipynb index 40b15ba1..47f5ea85 100644 --- a/full-ifrs17-template/Test/Tests.ipynb +++ b/full-ifrs17-template/Test/Tests.ipynb @@ -41,12 +41,6 @@ "#!eval-notebook \"ReportStorageTest\"" ] }, - { - "cell_type": "code", - "source": [ - "#!eval-notebook \"QueriesTest\"" - ] - }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index 79179ff2..423a41b4 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -198,9 +198,12 @@ "public static class AocTypes{", "\n public const string BOP = nameof(BOP);", "\n public const string MC = nameof(MC);", + "\n public const string PC = nameof(PC);", "\n public const string RCU = nameof(RCU);", "\n public const string CF = nameof(CF);", "\n public const string IA = nameof(IA);", + "\n public const string AU = nameof(AU);", + "\n public const string FAU = nameof(FAU);", "\n public const string YCU = nameof(YCU);", "\n public const string CRU = nameof(CRU);", "\n public const string WO = nameof(WO);", diff --git a/ifrs17/Constants/Validations.ipynb b/ifrs17/Constants/Validations.ipynb index 56dec561..afd2e82e 100644 --- a/ifrs17/Constants/Validations.ipynb +++ b/ifrs17/Constants/Validations.ipynb @@ -53,7 +53,8 @@ "source": [ "public enum Error { ", "\n // Import", - "\n NoMainTab, IncompleteMainTab, ParsingScientificNotation, ValueTypeNotFound, ValueTypeNotValid, AocTypeNotValid,", + "\n NoMainTab, IncompleteMainTab, ParsingScientificNotation, ValueTypeNotFound, ValueTypeNotValid, ", + "\n AocTypeNotValid, AocTypeCompulsoryNotFound, AocTypePositionNotSupported, AocConfigurationOrderNotUnique,", "\n // Partition", "\n PartitionNotFound, ParsedPartitionNotFound, PartititionNameNotFound, PartitionTypeNotFound,", "\n // Dimensions", @@ -95,6 +96,9 @@ "\n (Error.ValueTypeNotFound , _) => $\"Value Type not found.\",", "\n (Error.ValueTypeNotValid , 1) => $\"The Value Type {s[0]} is invalid.\",", "\n (Error.AocTypeNotValid , 1) => $\"The parsed AocType {s[0]} is invalid.\",", + "\n (Error.AocTypeCompulsoryNotFound , _) => $\"Not all compulsory AocTypes have been imported.\",", + "\n (Error.AocTypePositionNotSupported , 1) => $\"The position of the AocType {s[0]} is not supported.\",", + "\n (Error.AocConfigurationOrderNotUnique , _) => $\"Two or more Aoc Configurations have the same Order.\",", "\n // Partition", "\n (Error.PartitionNotFound , _) => $\"Partition do not found.\",", "\n (Error.ParsedPartitionNotFound , 1) => $\"Parsed partition not available: ReportingNode {s[0]}.\",", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 4b2d2a5a..f2963181 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -266,7 +266,7 @@ { "cell_type": "code", "source": [ - "public async Task DataNodeFactoryAsync (string file, string tab, ImportArgs args)", + "public async Task DataNodeFactoryAsync(string file, string tab, ImportArgs args)", "\n{", "\n var partition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode && p.Scenario == null).ToArrayAsync()).SingleOrDefault();", "\n if(partition == null) { ApplicationMessage.Log(Error.ParsedPartitionNotFound); return; }", @@ -274,13 +274,12 @@ "\n var extension = System.IO.Path.GetExtension(file);", "\n var stream = await Project.FileStorage.ReadAsync(file);", "\n var target = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet.Tables[tab];", - "\n ", "\n", "\n var dataNodesImported = target.Rows.Select(x => x.Field(nameof(RawVariable.DataNode))).ToHashSet();", "\n var dataNodesDefined = await DataSource.Query().Where(x => dataNodesImported.Contains(x.SystemName)).ToArrayAsync();", "\n var dataNodeStatesDefined = await DataSource.Query().Select(x => x.DataNode).ToArrayAsync();", "\n var dataNodeParametersDefined = await DataSource.Query().Select(x => x.DataNode).ToArrayAsync(); ", - "\n ", + "\n", "\n var dataNodeStatesUndefined = dataNodesImported.Where(x => x != null && !dataNodeStatesDefined.Contains(x)).ToHashSet();", "\n var dataNodeSingleParametersUndefined = dataNodesImported.Where(x => x != null &&", "\n !dataNodeParametersDefined.Contains(x) && ", @@ -291,7 +290,7 @@ "\n", "\n await DataSource.UpdateAsync( dataNodeSingleParametersUndefined.Select(x => ", "\n new SingleDataNodeParameter {DataNode = x, Year = args.Year, Month = DefaultDataNodeActivationMonth, PremiumAllocation = DefaultPremiumExperienceAdjustmentFactor, Partition = partition.Id}).ToArray() );", - "\n ", + "\n", "\n await DataSource.CommitAsync();", "\n}" ] @@ -319,6 +318,109 @@ "\n}" ] }, + { + "cell_type": "markdown", + "source": [ + "### Analysis of Change Configuration" + ] + }, + { + "cell_type": "markdown", + "source": [ + "The Analysis of Change configuration is parsed from the input file and complemented with defaults to allow for an easy insertion of new AOC steps. ", + "\n", + "\nAfter having checked that the AocTypes loaded in the target DataSource are including all the compulsory ones, default configurations are generated on the basis of the AocTypes ordering. ", + "\n", + "\nThe following categories have been identified based on the *Order* of the novel AOC step:", + "\n", + "\n| Category | Default added with same configuration of |", + "\n| --------------------- | ----------------------------------------------------- |", + "\n| Order < RCU | MC with Novelty I |", + "\n| RCU < Order < CF | RCU with Novelty I |", + "\n| IA < Order < YCU | AU with both Novelty I and N |", + "\n| CRU < Order < WO | EV with Novelty I and N |", + "\n| WO < Order < CL | WO with Novelty C (only for Import Source = Actual) |", + "\n", + "\nThe new Aoc Configurations are created with the same order of the Aoc Types. " + ] + }, + { + "cell_type": "code", + "source": [ + "Import.DefineFormat(\"AocConfiguration\", async (options, dataSet) => {", + "\n Activity.Start();", + "\n var workspace = Workspace.CreateNew();", + "\n workspace.InitializeFrom(options.TargetDataSource);", + "\n", + "\n var aocTypes = await options.TargetDataSource.Query().OrderBy(x => x.Order).ToArrayAsync();", + "\n var aocTypesCompulsory = typeof(AocTypes).GetFields().Select(x => (string)x.Name);", + "\n if(aocTypesCompulsory.Where(x => !aocTypes.Select(x => x.SystemName).Contains(x)).Any()) {", + "\n ApplicationMessage.Log(Error.AocTypeCompulsoryNotFound);", + "\n return Activity.Finish().RepeatOnce();", + "\n }", + "\n ", + "\n var logConfig = await Import.FromDataSet(dataSet).WithType().WithTarget(workspace).ExecuteAsync();", + "\n if(logConfig.Errors.Any()) return logConfig.RepeatOnce(); ", + "\n", + "\n var orderByName = aocTypes.ToDictionary(x => x.SystemName, x => x.Order);", + "\n var aocConfigs = (await workspace.Query().ToArrayAsync())", + "\n .GroupBy(x => (x.AocType, x.Novelty))", + "\n .Select(y => y.OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).FirstOrDefault())", + "\n .ToDictionary(x => (x.AocType, x.Novelty));", + "\n var aocOrder = aocConfigs.ToDictionary(x => x.Key, x => x.Value.Order);", + "\n var newAocTypes = orderByName.Keys.Where(x => !aocConfigs.Keys.Contains((x, Novelties.I)) && ", + "\n !aocConfigs.Keys.Contains((x, Novelties.N)) && ", + "\n !aocConfigs.Keys.Contains((x, Novelties.C)) && ", + "\n !aocTypes.Any(y => y.Parent == x) &&", + "\n !aocTypesCompulsory.Contains(x)).ToArray();", + "\n", + "\n foreach(var newAocType in newAocTypes) {", + "\n if(orderByName[newAocType] < orderByName[AocTypes.RCU])", + "\n {", + "\n var step = (AocTypes.MC, Novelties.I);", + "\n await workspace.UpdateAsync( aocConfigs[step] with { AocType = newAocType, DataType = DataType.Optional, Order = ++aocOrder[step] }); ", + "\n }", + "\n else if(orderByName[newAocType] > orderByName[AocTypes.RCU] && orderByName[newAocType] < orderByName[AocTypes.CF]) ", + "\n {", + "\n var step = (AocTypes.RCU, Novelties.I);", + "\n await workspace.UpdateAsync( aocConfigs[step] with { AocType = newAocType, DataType = DataType.Optional, Order = ++aocOrder[step] });", + "\n }", + "\n else if(orderByName[newAocType] > orderByName[AocTypes.IA] && orderByName[newAocType] < orderByName[AocTypes.YCU]) ", + "\n {", + "\n foreach (var novelty in new[]{Novelties.I, Novelties.N}) {", + "\n var step = (AocTypes.AU, novelty);", + "\n var order = orderByName[newAocType] < orderByName[AocTypes.AU]? ++aocOrder[(AocTypes.IA, novelty)] : ++aocOrder[(AocTypes.AU, novelty)];", + "\n await workspace.UpdateAsync( aocConfigs[step] with { AocType = newAocType, DataType = DataType.Optional, Order = order } );", + "\n }", + "\n }", + "\n else if(orderByName[newAocType] > orderByName[AocTypes.CRU] && orderByName[newAocType] < orderByName[AocTypes.WO])", + "\n {", + "\n var stepI = (AocTypes.EV, Novelties.I);", + "\n var orderI = orderByName[newAocType] < orderByName[AocTypes.EV]? ++aocOrder[(AocTypes.CRU, Novelties.I)] : ++aocOrder[(AocTypes.EV, Novelties.I)];", + "\n await workspace.UpdateAsync( aocConfigs[stepI] with { AocType = newAocType, DataType = DataType.Optional, Order = orderI } );", + "\n", + "\n var stepN = (AocTypes.EV, Novelties.N);", + "\n var orderN = orderByName[newAocType] < orderByName[AocTypes.EV]? ++aocOrder[(AocTypes.AU, Novelties.N)] : ++aocOrder[(AocTypes.EV, Novelties.N)];", + "\n await workspace.UpdateAsync( aocConfigs[stepN] with { AocType = newAocType, DataType = DataType.Optional, Order = orderN } );", + "\n }", + "\n else if(orderByName[newAocType] > orderByName[AocTypes.WO] && orderByName[newAocType] < orderByName[AocTypes.CL])", + "\n {", + "\n var step = (AocTypes.WO, Novelties.C);", + "\n await workspace.UpdateAsync( aocConfigs[step] with { AocType = newAocType, DataType = DataType.Optional, Order = ++aocOrder[step] } );", + "\n }", + "\n else", + "\n ApplicationMessage.Log(Error.AocTypePositionNotSupported);", + "\n };", + "\n", + "\n var aocConfigsFinal = await workspace.Query().ToArrayAsync();", + "\n if(aocConfigsFinal.GroupBy(x => x.Order).Any(x => x.Count() > 1))", + "\n ApplicationMessage.Log(Error.AocConfigurationOrderNotUnique);", + "\n", + "\n await workspace.CommitToTargetAsync(options.TargetDataSource);", + "\n return new[] {Activity.Finish(),logConfig}; ", + "\n});" + ] + }, { "cell_type": "markdown", "source": [ @@ -492,7 +594,6 @@ "\n await CommitToDatabase(partition);", "\n await CommitToDatabase(partition);", "\n await CommitToDatabase(partition);", - "\n ", "\n return log;", "\n}" ] diff --git a/ifrs17/Test/AocConfigurationTest.ipynb b/ifrs17/Test/AocConfigurationTest.ipynb new file mode 100644 index 00000000..501b0574 --- /dev/null +++ b/ifrs17/Test/AocConfigurationTest.ipynb @@ -0,0 +1,328 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Test Aoc Configuration

" + ] + }, + { + "cell_type": "code", + "source": [ + "#!import \"../CalculationEngine\"" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Workspace Initialization " + ] + }, + { + "cell_type": "code", + "source": [ + "string novelties = ", + "\n@\"@@Novelty", + "\nSystemName,DisplayName,Parent,Order", + "\nI,In Force,,1", + "\nN,New Business,,10", + "\nC,Combined,,20\";" + ] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromString(novelties).WithType().WithTarget(DataSource).ExecuteAsync()" + ] + }, + { + "cell_type": "code", + "source": [ + "var workspace = Workspace.CreateNew();", + "\nworkspace.InitializeFrom(DataSource);" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Canonical Aoc Types and Configurations" + ] + }, + { + "cell_type": "code", + "source": [ + "string canonicalAocTypes = ", + "\n@\"@@AocType,,,,,,,,,,,", + "\nSystemName,DisplayName,Parent,Order,,,,,,,,", + "\nBOP,Opening Balance,,10,,,,,,,,", + "\nMC,Model Correction,,20,,,,,,,,", + "\nPC,Portfolio Changes,,30,,,,,,,,", + "\nRCU,Reinsurance Coverage Update,PC,40,,,,,,,,", + "\nCF,Cash flow,,50,,,,,,,,", + "\nIA,Interest Accretion,,60,,,,,,,,", + "\nAU,Assumption Update,,70,,,,,,,,", + "\nFAU,Financial Assumption Update,,80,,,,,,,,", + "\nYCU,Yield Curve Update,FAU,90,,,,,,,,", + "\nCRU,Credit Risk Update,FAU,100,,,,,,,,", + "\nEV,Experience Variance,,110,,,,,,,,", + "\nWO,Write-Off,,120,,,,,,,,", + "\nCL,Combined Liabilities,,130,,,,,,,,", + "\nEA,Experience Adjustment,,140,,,,,,,,", + "\nAM,Amortization,,150,,,,,,,,", + "\nFX,FX Impact,,160,,,,,,,,", + "\nEOP,Closing Balance,,170,,,,,,,,\";" + ] + }, + { + "cell_type": "code", + "source": [ + "string canonicalAocConfig = ", + "\n@\"@@AocConfiguration,,,,,,,,,,,", + "\nAocType,Novelty,DataType,InputSource,FxPeriod,YcPeriod,CdrPeriod,ValuationPeriod,RcPeriod,Order,Year,Month", + "\nBOP,I,Optional,7,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,10,1900,1", + "\nMC,I,Optional,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,20,1900,1", + "\nRCU,I,Calculated,4,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,30,1900,1", + "\nCF,I,Calculated,4,Average,NotApplicable,BeginningOfPeriod,Delta,EndOfPeriod,40,1900,1", + "\nIA,I,Calculated,5,Average,BeginningOfPeriod,BeginningOfPeriod,Delta,EndOfPeriod,50,1900,1", + "\nAU,I,Optional,4,EndOfPeriod,BeginningOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,60,1900,1", + "\nYCU,I,CalculatedTelescopic,4,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,EndOfPeriod,70,1900,1", + "\nCRU,I,CalculatedTelescopic,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,80,1900,1", + "\nEV,I,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,90,1900,1", + "\nBOP,N,Optional,4,Average,EndOfPeriod,EndOfPeriod,BeginningOfPeriod,EndOfPeriod,95,1900,1", + "\nCF,N,Calculated,4,Average,NotApplicable,EndOfPeriod,Delta,EndOfPeriod,110,1900,1", + "\nIA,N,Calculated,4,Average,EndOfPeriod,EndOfPeriod,Delta,EndOfPeriod,120,1900,1", + "\nAU,N,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,130,1900,1", + "\nEV,N,Optional,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,140,1900,1", + "\nCF,C,Optional,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,160,1900,1", + "\nWO,C,Optional,2,Average,NotApplicable,NotApplicable,NotApplicable,NotApplicable,170,1900,1", + "\nCL,C,Mandatory,4,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,180,1900,1", + "\nEA,C,Calculated,4,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,190,1900,1", + "\nAM,C,Calculated,6,EndOfPeriod,NotApplicable,NotApplicable,NotApplicable,EndOfPeriod,200,1900,1", + "\nFX,C,Calculated,0,NotApplicable,NotApplicable,NotApplicable,NotApplicable,NotApplicable,210,1900,1", + "\nEOP,C,Calculated,6,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,EndOfPeriod,220,1900,1\";" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Test" + ] + }, + { + "cell_type": "code", + "source": [ + "public async Task CheckAocConfigurationDefault(AocType[] newAocTypes)", + "\n{", + "\n await workspace.DeleteAsync( await workspace.Query().ToArrayAsync() );", + "\n await workspace.DeleteAsync( await workspace.Query().ToArrayAsync() );", + "\n await workspace.CommitAsync();", + "\n", + "\n var aocTypeLog = await Import.FromString(canonicalAocTypes).WithType().WithTarget(workspace).ExecuteAsync();", + "\n aocTypeLog.Errors.Any().Should().Be(false);", + "\n", + "\n await workspace.UpdateAsync(newAocTypes);", + "\n await workspace.CommitAsync();", + "\n", + "\n return await Import.FromString(canonicalAocConfig).WithFormat(\"AocConfiguration\").WithTarget(workspace).ExecuteAsync();", + "\n}" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## NewAoc < RCU" + ] + }, + { + "cell_type": "code", + "source": [ + "var aocConfigLog = await CheckAocConfigurationDefault( new[]{ new AocType{SystemName = \"A1\", DisplayName = \"a1\", Order = 25} } );", + "\naocConfigLog.Errors.Any().Should().Be(false);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.MC && x.Novelty == Novelties.I) with {AocType = \"A1\", Order = 21, DataType = DataType.Optional};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## RCU < NewAoc < CF" + ] + }, + { + "cell_type": "code", + "source": [ + "var aocConfigLog = await CheckAocConfigurationDefault( new[]{ new AocType{SystemName = \"A1\", DisplayName = \"a1\", Order = 45} } );", + "\naocConfigLog.Errors.Any().Should().Be(false);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.RCU && x.Novelty == Novelties.I) with {AocType = \"A1\", Order = 31, DataType = DataType.Optional};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## IA < NewAoc < YCU" + ] + }, + { + "cell_type": "code", + "source": [ + "var aocConfigLog = await CheckAocConfigurationDefault( new[]{ new AocType{SystemName = \"A1\", DisplayName = \"a1\", Order = 82} } );", + "\naocConfigLog.Errors.Any().Should().Be(false);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.AU && x.Novelty == Novelties.I) with {AocType = \"A1\", Order = 61, DataType = DataType.Optional};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.AU && x.Novelty == Novelties.N) with {AocType = \"A1\", Order = 131, DataType = DataType.Optional};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## CRU < NewAoc < EV" + ] + }, + { + "cell_type": "code", + "source": [ + "var aocConfigLog = await CheckAocConfigurationDefault( new[]{ new AocType{SystemName = \"A1\", DisplayName = \"a1\", Order = 106} } );", + "\naocConfigLog.Errors.Any().Should().Be(false);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.EV && x.Novelty == Novelties.I) with {AocType = \"A1\", Order = 81};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.EV && x.Novelty == Novelties.N) with {AocType = \"A1\", Order = 131};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## EV < NewAoc < WO" + ] + }, + { + "cell_type": "code", + "source": [ + "var aocConfigLog = await CheckAocConfigurationDefault( new[]{ new AocType{SystemName = \"A1\", DisplayName = \"a1\", Order = 116} } );", + "\naocConfigLog.Errors.Any().Should().Be(false);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.EV && x.Novelty == Novelties.I) with {AocType = \"A1\", Order = 91};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.EV && x.Novelty == Novelties.N) with {AocType = \"A1\", Order = 141};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## WO < NewAoc < CL" + ] + }, + { + "cell_type": "code", + "source": [ + "var aocConfigLog = await CheckAocConfigurationDefault( new[]{ new AocType{SystemName = \"A1\", DisplayName = \"a1\", Order = 125} } );", + "\naocConfigLog.Errors.Any().Should().Be(false);" + ] + }, + { + "cell_type": "code", + "source": [ + "var newConfigExpected = (await workspace.Query().ToArrayAsync()).First(x => ", + "\n x.AocType == AocTypes.WO && x.Novelty == Novelties.C) with {AocType = \"A1\", Order = 171};", + "\nvar newConfigCalculated = await workspace.Query().Where(x => x == newConfigExpected).ToArrayAsync();", + "\nnewConfigCalculated.Count().Should().Be(1);" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## Two or more Aoc Config with same Order" + ] + }, + { + "cell_type": "code", + "source": [ + "var aocConfigLog = await CheckAocConfigurationDefault( new[]{ new AocType{SystemName = \"A1\", DisplayName = \"a1\", Order = 111},", + "\n new AocType{SystemName = \"A2\", DisplayName = \"a1\", Order = 112},", + "\n new AocType{SystemName = \"A3\", DisplayName = \"a1\", Order = 113},", + "\n new AocType{SystemName = \"A4\", DisplayName = \"a1\", Order = 114},", + "\n new AocType{SystemName = \"A5\", DisplayName = \"a1\", Order = 115} } );", + "\n(aocConfigLog.Errors.First().ToString() == \"ActivityMessageNotification { Message = Two or more Aoc Configurations have the same Order. }\").Should().Be(true);" + ] + }, + { + "cell_type": "code", + "source": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/full-ifrs17-template/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb similarity index 99% rename from full-ifrs17-template/Test/QueriesTest.ipynb rename to ifrs17/Test/QueriesTest.ipynb index 8fdabb4a..07990aa7 100644 --- a/full-ifrs17-template/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -20,7 +20,7 @@ { "cell_type": "code", "source": [ - "#!import \"//ifrs17ce/dev/CalculationEngine\"" + "#!import \"../CalculationEngine\"" ] }, { diff --git a/ifrs17/Test/Tests.ipynb b/ifrs17/Test/Tests.ipynb new file mode 100644 index 00000000..e49d0f33 --- /dev/null +++ b/ifrs17/Test/Tests.ipynb @@ -0,0 +1,37 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Tests

" + ] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"AocConfigurationTest\"" + ] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"QueriesTest\"" + ] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index d5b26c8b..a03f0301 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -53,10 +53,10 @@ "\n }", "\n ", "\n public static Object Log (Error e, params string[] s) { log.LogError(Get(e,s)); return null; }", - "\n ", "\n public static Object Log (Warning w, params string[] s) { log.LogWarning(Get(w,s)); return null; }", "\n ", "\n public static bool HasErrors () => activity.HasErrors();", + "\n public static bool HasWarnings () => activity.HasWarnings();", "\n}" ] },