diff --git a/full-ifrs17-template/Constants/Consts.ipynb b/full-ifrs17-template/Constants/Consts.ipynb index f39ab144..1ef5ee81 100644 --- a/full-ifrs17-template/Constants/Consts.ipynb +++ b/full-ifrs17-template/Constants/Consts.ipynb @@ -25,4 +25,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb index af8c5cf1..c9eb277e 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb @@ -82,7 +82,7 @@ { "cell_type": "code", "source": [ - "await UploadSimpleValueAsync(\"../Files/900.TransactionalData/SimpleValue_CH_2020_12.csv\")" + "//await UploadSimpleValueAsync(\"../Files/900.TransactionalData/SimpleValue_CH_2020_12.csv\") TODO: missing benchmarks" ] }, { diff --git a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb index 98187848..50a59c01 100644 --- a/full-ifrs17-template/Test/IfrsVariablesTest.ipynb +++ b/full-ifrs17-template/Test/IfrsVariablesTest.ipynb @@ -142,21 +142,11 @@ "\n var expectedNotComputed = expected.Where(x => Math.Abs(x.Value) > BenchmarkPrecision).Select(x => x.ToIdentityString()).Except(computed.Select(x => x.ToIdentityString()));", "\n var computedNotExpected = computed.Where(x => Math.Abs(x.Value) > BenchmarkPrecision).Select(x => x.ToIdentityString()).Except(expected.Select(x => x.ToIdentityString()));", "\n if (expectedNotComputed.Any())", - "\n {", "\n foreach (var error in expectedNotComputed)", - "\n {", - "\n var message = error.ToIdentityString();", - "\n errors.Add(new BenchmarkTestResult(\"Extra expected variable for: \"+ message));", - "\n }", - "\n }", + "\n errors.Add(new BenchmarkTestResult(\"Extra expected variable for: \" + error));", "\n if (computedNotExpected.Any())", - "\n {", "\n foreach (var error in computedNotExpected)", - "\n {", - "\n var message = error.ToIdentityString();", - "\n errors.Add(new BenchmarkTestResult(\"Extra computed variable for: \"+ message));", - "\n }", - "\n }", + "\n errors.Add(new BenchmarkTestResult(\"Extra computed variable for: \" + error));", "\n ", "\n var misMatchedVariables = expected.Concat(computed).AggregateOver().Where(x => Math.Abs(x.Value) > BenchmarkPrecision);", "\n if (misMatchedVariables.Any())", @@ -211,13 +201,8 @@ { "cell_type": "code", "source": [ - "var errorList = new List();" - ] - }, - { - "cell_type": "code", - "source": [ - "foreach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month)))", + "var errorList = new List();", + "\nforeach (var g in bmFiles.GroupBy(x => (ReportingNode: x.ReportingNode, Year: x.Year, Month: x.Month)))", "\n{", "\n var reportingNode = g.Key.ReportingNode;", "\n var year = g.Key.Year;", @@ -244,13 +229,13 @@ "\n var mainTab = bmDataTable.Tables[Main].Rows.First();", "\n if(!ValidateMainTab(mainTab, reportingNode, year, month))", "\n throw new Exception(\"Metadata and main tab of the Benchmark are different.\");", - "\n ", + "\n", "\n var bmTableName = bmDataTable.Tables.Single(x => x.TableName != Main).TableName;", "\n var bmVariables = bmDataTable.Tables[bmTableName].Rows.Select(x => CreateVariable(x, partition));", - "\n ", + "\n", "\n //Get the computed Data", "\n var computedVariables = computedVariablesByEstimateType.TryGetValue(bmTableName, out var ret) ? ret : Enumerable.Empty();", - "\n ", + "\n", "\n if(!computedVariables.Any()) ", "\n errorList.Add(new BenchmarkTestResult(\"No variables are computed for EstimateType: \" + bmTableName, 0, 0));", "\n //CompareAgainstBm", @@ -264,7 +249,13 @@ { "cell_type": "code", "source": [ - "errorList.Count().Should().Be(0)" + "errorList.Count().Should().Be(0);" + ] + }, + { + "cell_type": "code", + "source": [ + "errorList" ] }, { diff --git a/full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb index f82db019..e0b58e97 100644 --- a/full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -150,7 +150,7 @@ "\n// check that exporter generates only the desired columns ", "\nvar extension = \".xlsx\";", "\nvar stream = await Project.FileStorage.ReadAsync(filename + extension);", - "\nvar tables = await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync();", + "\nvar tables = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet;", "\nvar mainCols = new[]{nameof(PartitionByReportingNode.ReportingNode)};", "\nvar portfolioCols = new[]{nameof(Portfolio.SystemName),nameof(Portfolio.DisplayName),nameof(Portfolio.ContractualCurrency),", "\n nameof(Portfolio.LineOfBusiness),nameof(Portfolio.OciType),nameof(Portfolio.ValuationApproach)};", @@ -236,7 +236,7 @@ "\n// check that exporter generates only the desired columns ", "\nvar extension = \".xlsx\";", "\nvar stream = await Project.FileStorage.ReadAsync(filename + extension);", - "\nvar tables = await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync();", + "\nvar tables = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet;", "\nvar mainCols = new[]{nameof(PartitionByReportingNodeAndPeriod.ReportingNode),", "\n nameof(PartitionByReportingNodeAndPeriod.Year),", "\n nameof(PartitionByReportingNodeAndPeriod.Month)};", @@ -316,7 +316,7 @@ "\n// check that exporter generates only the desired columns ", "\nvar extension = \".xlsx\";", "\nvar stream = await Project.FileStorage.ReadAsync(filename + extension);", - "\nvar tables = await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync();", + "\nvar tables = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet;", "\nvar mainCols = new[]{nameof(PartitionByReportingNodeAndPeriod.ReportingNode),", "\n nameof(PartitionByReportingNodeAndPeriod.Year),", "\n nameof(PartitionByReportingNodeAndPeriod.Month),", diff --git a/full-ifrs17-template/Test/SpecificationsFinancialPerformance.ipynb b/full-ifrs17-template/Test/SpecificationsFinancialPerformance.ipynb index 8be275bc..7016fa12 100644 --- a/full-ifrs17-template/Test/SpecificationsFinancialPerformance.ipynb +++ b/full-ifrs17-template/Test/SpecificationsFinancialPerformance.ipynb @@ -133,13 +133,8 @@ { "cell_type": "code", "source": [ - "var identities = reportStorage.GetIdentities(period, reportingNode, null, currencyType);" - ] - }, - { - "cell_type": "code", - "source": [ - "identities" + "var identities = reportStorage.GetIdentities(period, reportingNode, null, currencyType);", + "\nidentities" ] }, { @@ -197,8 +192,8 @@ "\n .WithQuerySource(DataSource)", "\n .SliceRowsBy(\"VariableType\", \"EstimateType\")", "\n .SliceColumnsBy(CurrencyGrouper(currencyType), \"LiabilityType\",\"GroupOfContract\")", - "\n .ReportGridOptions(reportHeight: 900, headerColumnWidth: 500, groupDefaultExpanded: 3)", - "\n .ToReport() with { Height = 600 }" + "\n .WithGridOptions( o => o.WithDefaultColumn( c => c.WithWidth(260) ) with {GroupDefaultExpanded = 3, Height = 900, OnGridReady = null} )", + "\n .ToReport()" ] }, { diff --git a/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb b/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb index 5034a6ac..12b9fc30 100644 --- a/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb +++ b/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb @@ -268,14 +268,14 @@ { "cell_type": "code", "source": [ - "var expectedInterest = yearlyYieldCurve.Select( yc => (1 + yc)^( 1.0 / 12.0) );", + "var expectedInterest = yearlyYieldCurve.Select( yc => Math.Pow(1 + yc, 1.0 / 12.0) );", "\nexpectedInterest" ] }, { "cell_type": "code", "source": [ - "from yc in yearlyYieldCurve select (1 + yc)^( 1.0 / 12.0 ) " + "from yc in yearlyYieldCurve select Math.Pow(1 + yc, 1.0 / 12.0)" ] }, { @@ -299,7 +299,7 @@ { "cell_type": "code", "source": [ - "var expectedDiscount = yearlyYieldCurve.Select( yc => (1 + yc)^( -1.0 / 12.0) );", + "var expectedDiscount = yearlyYieldCurve.Select( yc => Math.Pow(1 + yc, -1.0 / 12.0) );", "\nexpectedDiscount" ] }, @@ -710,7 +710,7 @@ { "cell_type": "code", "source": [ - "var nominalClaims = nominalICO.Values + nominalNIC.Values + nominalALE.Values + nominalULE.Values;" + "var nominalClaims = Sum( Sum(nominalICO.Values, nominalNIC.Values), Sum(nominalALE.Values, nominalULE.Values) );" ] }, { @@ -1015,7 +1015,7 @@ { "cell_type": "code", "source": [ - "var expectedPresentValueMC_PR = discountedMC_PR.Values - discountedBoP_PR.Values;" + "var expectedPresentValueMC_PR = Subtract(discountedMC_PR.Values, discountedBoP_PR.Values);" ] }, { @@ -1097,7 +1097,7 @@ { "cell_type": "code", "source": [ - "var expectedPresentValueCF_PR = -1.0 * cfNominalReference_PR.Values;" + "var expectedPresentValueCF_PR = Multiply(-1.0, cfNominalReference_PR.Values);" ] }, { @@ -1428,7 +1428,7 @@ { "cell_type": "code", "source": [ - "var expectedPresentValueYCU_PR = ycReferenceDiscountedEop - discountedYcParent.Values;" + "var expectedPresentValueYCU_PR = Subtract(ycReferenceDiscountedEop, discountedYcParent.Values);" ] }, { @@ -1579,7 +1579,7 @@ { "cell_type": "code", "source": [ - "var expectedPresentValueCRU = cruExpectedDiscountedCDR - discountedCruParent.Values;" + "var expectedPresentValueCRU = Subtract(cruExpectedDiscountedCDR, discountedCruParent.Values);" ] }, { @@ -1648,8 +1648,8 @@ { "cell_type": "code", "source": [ - "var expectedPresentValueCL_PR = Test.GetScope((idCL, \"PR\", \"BE\", (int?)null)).Values -", - "\n clParents.Select(aocStep => Test.GetScope((idCL with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}, \"PR\", \"BE\", (int?)null)).Values).Aggregate();" + "var expectedPresentValueCL_PR = Subtract(Test.GetScope((idCL, \"PR\", \"BE\", (int?)null)).Values,", + "\n clParents.Select(aocStep => Test.GetScope((idCL with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}, \"PR\", \"BE\", (int?)null)).Values).Aggregate());" ] }, { diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index f5fcf571..78851b13 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -43,16 +43,17 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Workspace,1.4.1\"", - "\n#r \"nuget:Systemorph.Scopes,1.4.0\"", - "\n#r \"nuget:Systemorph.Import,1.4.0\"", - "\n#r \"nuget:Systemorph.Test,1.4.0\"", - "\n#r \"nuget:Systemorph.Export,1.4.0\"", - "\n#r \"nuget:Systemorph.DataSetReader,1.4.0\"", - "\n#r \"nuget:Systemorph.DataSource,1.4.1\"", - "\n#r \"nuget:Systemorph.DataSource.Conversions,1.4.1\"", - "\n#r \"nuget:Systemorph.Reporting,1.4.0\"", - "\n#r \"nuget:Systemorph.DomainDesigner,1.4.0\"" + "#r \"nuget:Systemorph.Arithmetics,1.5.4\"", + "\n#r \"nuget:Systemorph.Workspace,1.5.0\"", + "\n#r \"nuget:Systemorph.Scopes,1.5.2\"", + "\n#r \"nuget:Systemorph.Import,1.5.0\"", + "\n#r \"nuget:Systemorph.Test,1.5.2\"", + "\n#r \"nuget:Systemorph.Export,1.5.0\"", + "\n#r \"nuget:Systemorph.DataSetReader,1.5.0\"", + "\n#r \"nuget:Systemorph.DataSource,1.5.0\"", + "\n#r \"nuget:Systemorph.DataSource.Conversions,1.5.0\"", + "\n#r \"nuget:Systemorph.Reporting,1.5.2\"", + "\n#r \"nuget:Systemorph.DomainDesigner,1.5.0\"" ] }, { diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index c5709d0a..f172092b 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -441,7 +441,7 @@ "\n ", "\n double[] Interest => YearlyYieldCurve.Select(rate => Math.Pow(1d + rate, 1d / 12d) + Perturbation).ToArray(); ", "\n ", - "\n double[] Discount => Interest^(-1);", + "\n double[] Discount => Interest.Select(x => Math.Pow(x, -1)).ToArray();", "\n}" ] }, @@ -484,7 +484,7 @@ "\n ret[i] = Math.Exp(-nonPerformanceRiskRate) * ret.ElementAtOrDefault(i + 1) + NominalClaimsCashflow[i] - NominalClaimsCashflow.ElementAtOrDefault(i + 1);", "\n return ret; } } ", "\n ", - "\n double[] NominalCashflow.Values => PvCdrDecumulated - NominalClaimsCashflow;", + "\n double[] NominalCashflow.Values => Subtract(PvCdrDecumulated, NominalClaimsCashflow);", "\n}", "\n", "\npublic interface AllClaimsCashflow : NominalCashflow", @@ -600,7 +600,7 @@ "\n .Where(cf => cf.Count() > 0)", "\n .Aggregate();", "\n ", - "\n double[] Values => CurrentValues - PreviousValues;", + "\n double[] Values => Subtract(CurrentValues, PreviousValues);", "\n}" ] }, @@ -702,7 +702,7 @@ "\npublic interface IWithInterestAccretionForCreditRisk : IScope<(ImportIdentity Id, string AmountType, string EstimateType, int? AccidentYear), ImportStorage>", "\n{", "\n private double[] nominalClaimsCashflow => GetScope(Identity).Values;", - "\n private double[] nominalValuesCreditRisk => -1 * GetScope(Identity with {Id = Identity.Id with {AocType = AocTypes.CF}}).Values;", + "\n private double[] nominalValuesCreditRisk => Multiply(-1, GetScope(Identity with {Id = Identity.Id with {AocType = AocTypes.CF}}).Values);", "\n private double[] monthlyInterestFactor => GetScope(Identity.Id).Interest;", "\n private double nonPerformanceRiskRate => GetStorage().GetNonPerformanceRiskRate(Identity.Id);", "\n ", @@ -717,7 +717,7 @@ "\n effectCreditRisk[i] = interestOnClaimsCashflow[i] - interestOnClaimsCashflowCreditRisk[i];", "\n }", "\n ", - "\n return effectCreditRisk - nominalValuesCreditRisk;", + "\n return Subtract(effectCreditRisk, nominalValuesCreditRisk);", "\n }", "\n}" ] @@ -785,7 +785,7 @@ "\npublic interface CashflowAocStep : PresentValue", "\n{", "\n [NotVisible]", - "\n double[] PresentValue.Values => -1d * GetScope(Identity).Values;", + "\n double[] PresentValue.Values => Multiply(-1d, GetScope(Identity).Values);", "\n}", "\n", "\npublic interface PresentValueWithInterestAccretion : PresentValue, IWithInterestAccretion", @@ -1337,7 +1337,9 @@ "\n string EstimateType => EstimateTypes.BEPA;", "\n string EconomicBasis => EconomicBases.L;", "\n ", - "\n PresentValue[] ByAmountType => GetStorage().GetPremiums().Select(pr => GetStorage().GetPremiumAllocationFactor(Identity) * GetScope((Identity, pr, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis))).ToArray(); ", + "\n PresentValue[] ByAmountType => GetStorage().GetPremiums().Select(pr => ", + "\n Multiply( GetStorage().GetPremiumAllocationFactor(Identity), ", + "\n GetScope((Identity, pr, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)) ) ).ToArray(); ", "\n}", "\n", "\npublic interface DefaultValueBeExperienceAdjustmentForPremium : BeExperienceAdjustmentForPremium", @@ -1356,9 +1358,8 @@ "\n .WithApplicability(x => x.Identity.AocType != AocTypes.CF));", "\n ", "\n public ActualBase[] ByAmountTypeAndEstimateType => GetStorage().GetPremiums().SelectMany(pr => ", - "\n GetStorage().ExperienceAdjustEstimateTypeMapping.Keys", - "\n .Select(et => GetStorage().GetPremiumAllocationFactor(Identity) * ", - "\n GetScope((Identity, pr, et, (int?)null)))).ToArray(); ", + "\n GetStorage().ExperienceAdjustEstimateTypeMapping.Keys.Select(et => ", + "\n Multiply(GetStorage().GetPremiumAllocationFactor(Identity), GetScope((Identity, pr, et, (int?)null))) ) ).ToArray();", "\n}", "\n", "\npublic interface DefaultValueActualExperienceAdjustmentForPremium : ActualExperienceAdjustmentForPremium", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 0a85ee43..6be43097 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -356,11 +356,11 @@ "\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 return Activity.Finish();", "\n }", "\n ", "\n var logConfig = await Import.FromDataSet(dataSet).WithType().WithTarget(workspace).ExecuteAsync();", - "\n if(logConfig.Errors.Any()) return logConfig.RepeatOnce(); ", + "\n if(logConfig.Errors.Any()) return Activity.Finish().Merge(logConfig); ", "\n", "\n var orderByName = aocTypes.ToDictionary(x => x.SystemName, x => x.Order);", "\n var aocConfigs = (await workspace.Query().ToArrayAsync())", @@ -417,7 +417,7 @@ "\n ApplicationMessage.Log(Error.AocConfigurationOrderNotUnique);", "\n", "\n await workspace.CommitToTargetAsync(options.TargetDataSource);", - "\n return new[] {Activity.Finish(),logConfig}; ", + "\n return Activity.Finish().Merge(logConfig); ", "\n});" ] }, @@ -970,7 +970,8 @@ "\n AmountType = amountType,", "\n EstimateType = estimateType,", "\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,", - "\n Value = Multiply(GetSign((aocType, amountType, estimateType, dataNodeData.IsReinsurance), parsingStorage.HierarchyCache), datarow.Field(nameof(IfrsVariable.Value)).CheckStringForExponentialAndConvertToDouble()),", + "\n Value = GetSign((aocType, amountType, estimateType, dataNodeData.IsReinsurance), parsingStorage.HierarchyCache) ", + "\n * datarow.Field(nameof(IfrsVariable.Value)).CheckStringForExponentialAndConvertToDouble(),", "\n };", "\n return item;", "\n }, ImportFormats.Actual", @@ -1065,8 +1066,8 @@ "\n EstimateType = estimateType,", "\n EconomicBasis = economicBasis,", "\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,", - "\n Value = //GetSign((aocStep.AocType, amountType, estimateType, parsingStorage.IsDataNodeReinsurance(dataNode)), parsingStorage.HierarchyCache)", - "\n 1 // TODO, we need to adjust the inputs to have the correct sign, so that the default GetSign returns 1.", + "\n Value = GetSign((aocStep.AocType, amountType, estimateType, parsingStorage.IsDataNodeReinsurance(dataNode)), parsingStorage.HierarchyCache)", + "\n //1 // TODO, we need to adjust the inputs to have the correct sign, so that the default GetSign returns 1.", "\n * datarow.Field(nameof(IfrsVariable.Value)).CheckStringForExponentialAndConvertToDouble()", "\n };", "\n return iv;", diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index d482e339..39128784 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -32,11 +32,12 @@ { "cell_type": "code", "source": [ - "using Systemorph.Vertex.Pivot.Reporting.Builder;", + "using Systemorph.Vertex.Pivot.Builder;", + "\nusing Systemorph.Vertex.Pivot.Reporting.Builder;", "\nusing System.Collections.Immutable;", "\n", "\npublic static DataCubeReportBuilder, TVariable, TVariable ,TVariable> ReportGridOptions(", - "\n this DataCubeReportBuilder, TVariable, TVariable, TVariable> reportBuilder,", + "\n this DataCubePivotBuilder, TVariable, TVariable, TVariable> reportBuilder,", "\n int reportHeight = 700,", "\n int valueColumnWidth = 250,", "\n int headerColumnWidth = 250,", diff --git a/ifrs17/Report/ReportScopes.ipynb b/ifrs17/Report/ReportScopes.ipynb index ae87b53d..d9344d3c 100644 --- a/ifrs17/Report/ReportScopes.ipynb +++ b/ifrs17/Report/ReportScopes.ipynb @@ -140,12 +140,11 @@ "\n builder.ForScope(s => s.WithApplicability(x => x.GetStorage().EstimateTypesWithoutAoc.Contains(x.Identity.EstimateType)));", "\n ", "\n protected IDataCube Data => GetScope((Identity.ReportIdentity, Identity.EstimateType)).Data", - "\n .SelectToDataCube(x => GetScope((Identity.ReportIdentity.ContractualCurrency, ", - "\n Identity.ReportIdentity.FunctionalCurrency, ", - "\n GetStorage().GetFxPeriod(GetStorage().Args.Period, x.VariableType, x.Novelty),", - "\n (Identity.ReportIdentity.Year, Identity.ReportIdentity.Month),", - "\n Identity.CurrencyType", - "\n )).Fx * x);", + "\n .SelectToDataCube(x => Multiply( GetScope((Identity.ReportIdentity.ContractualCurrency, ", + "\n Identity.ReportIdentity.FunctionalCurrency, ", + "\n GetStorage().GetFxPeriod(GetStorage().Args.Period, x.VariableType, x.Novelty),", + "\n (Identity.ReportIdentity.Year, Identity.ReportIdentity.Month),", + "\n Identity.CurrencyType)).Fx, x ));", "\n ", "\n private IDataCube Eops => Data.Filter((\"VariableType\", AocTypes.EOP));", "\n private IDataCube NotEops => Data.Filter((\"VariableType\", \"!EOP\")); // TODO negation must be hardcoded (also to avoid string concatenation)", @@ -767,8 +766,8 @@ "\n .Where(x => GetStorage().GetHierarchy().Ancestors(x.AmountType, includeSelf: true).Any(x => x.SystemName == AmountTypes.NIC))", "\n .SelectToDataCube(v => v with { Novelty = Novelties.C, VariableType = \"ISE2\" });", "\n ", - "\n private IEnumerable ClaimsIco => WrittenAndAccruals", - "\n .Where(x => GetStorage().GetHierarchy().Ancestors(x.AmountType, includeSelf: true).Any(x => x.SystemName == AmountTypes.ICO));", + "\n private IDataCube ClaimsIco => WrittenAndAccruals", + "\n .Where(x => GetStorage().GetHierarchy().Ancestors(x.AmountType, includeSelf: true).Any(x => x.SystemName == AmountTypes.ICO)).ToDataCube();", "\n ", "\n IDataCube ClaimsIcoToIr => ClaimsIco.SelectToDataCube(v => v with { Novelty = Novelties.C, VariableType = \"IR2\" });", "\n IDataCube ClaimsIcoToIse => (-1 * ClaimsIco).SelectToDataCube(v => v with { Novelty = Novelties.C, VariableType = \"ISE5\" });", diff --git a/ifrs17/Report/ReportStorage.ipynb b/ifrs17/Report/ReportStorage.ipynb index 655f0888..0c61fe1a 100644 --- a/ifrs17/Report/ReportStorage.ipynb +++ b/ifrs17/Report/ReportStorage.ipynb @@ -94,12 +94,12 @@ "public class ReportStorage {", "\n protected readonly IWorkspace workspace;", "\n private readonly Systemorph.Vertex.Hierarchies.IHierarchicalDimensionCache hierarchicalDimensionCache;", - "\n private readonly Systemorph.Vertex.Pivot.Reporting.IReportFactory reportFactory;", + "\n private readonly Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory;", "\n ", "\n // Current Storage Settings", "\n public ((int Year, int Month) Period, string ReportingNode, string Scenario, CurrencyType CurrencyType) Args {get; private set;}", "\n ", - "\n // Cache for Aux Data ", + "\n // Cache for Aux Data", "\n private Dictionary<(int year, int month), Dictionary>> exchangeRatesByCurrencyByFxTypeAndPeriod = new(); // Fx Rates", "\n private Dictionary<(int year, int month), Dictionary> fxPeriodsByAocStepAndPeriod = new(); // FxParameter", "\n ", @@ -109,7 +109,7 @@ "\n private Dictionary<((int year, int month) period, string reportingNode, string scenario), Dictionary>>> variablesDictionary = new();", "\n ", "\n // Constructor", - "\n public ReportStorage(IWorkspace workspace, Systemorph.Vertex.Pivot.Reporting.IReportFactory reportFactory) {", + "\n public ReportStorage(IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory) {", "\n this.workspace = workspace;", "\n this.hierarchicalDimensionCache = workspace.ToHierarchicalDimensionCache();", "\n this.reportFactory = reportFactory;", @@ -182,7 +182,7 @@ "\n ", "\n // Other getters", "\n public IWorkspace Workspace => workspace;", - "\n public Systemorph.Vertex.Pivot.Reporting.IReportFactory Report => reportFactory;", + "\n public Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory Report => reportFactory;", "\n", "\n public Systemorph.Vertex.Hierarchies.IHierarchy GetHierarchy() where T : class, IHierarchicalDimension => hierarchicalDimensionCache.Get();", "\n ", diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index a03f0301..f2253bd6 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -27,7 +27,7 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Activities,1.4.0\"" + "#r \"nuget:Systemorph.Activities,1.5.1\"" ] }, { @@ -41,7 +41,7 @@ "source": [ "using Microsoft.Extensions.Logging;", "\n", - "\npublic class ApplicationMessage {", + "\npublic static class ApplicationMessage {", "\n private static ILogger log;", "\n ", "\n private static IActivityVariable activity;", @@ -87,13 +87,14 @@ "cell_type": "code", "source": [ "public static ActivityLog Merge (this ActivityLog a, ActivityLog b) {", + "\n var errors = a.Errors.Concat(b.Errors).ToList();", "\n return a with { ", + "\n Status = a.Status == ActivityLogStatus.Failed || b.Status == ActivityLogStatus.Failed ? ActivityLogStatus.Failed : ActivityLogStatus.Succeeded,", "\n StartDateTime = a.StartDateTime < b.StartDateTime ? a.StartDateTime : b.StartDateTime,", "\n FinishDateTime = a.FinishDateTime > b.FinishDateTime ? a.FinishDateTime : b.FinishDateTime,", - "\n Errors = a.Errors.Concat(b.Errors).ToList(),", - "\n Warnings = a.Warnings.Concat(b.Warnings).ToList(),", - "\n Infos = a.Infos.Concat(b.Infos).ToList(),", - "\n Status = a.Status == ActivityLogStatus.Failed || b.Status == ActivityLogStatus.Failed ? ActivityLogStatus.Failed : ActivityLogStatus.Succeeded", + "\n Errors = errors,", + "\n Warnings = errors.Any() ? new List() : a.Warnings.Concat(b.Warnings).ToList(),", + "\n Infos = errors.Any() ? new List() : a.Infos.Concat(b.Infos).ToList(),", "\n };", "\n}", "\n", diff --git a/ifrs17/Utils/Extensions.ipynb b/ifrs17/Utils/Extensions.ipynb index 9e0adcb9..0eb9c443 100644 --- a/ifrs17/Utils/Extensions.ipynb +++ b/ifrs17/Utils/Extensions.ipynb @@ -123,17 +123,15 @@ "cell_type": "code", "source": [ "using System.Text;", - "\npublic static string ToIdentityString(this T v)", - "\n where T : class", + "\npublic static string ToIdentityString(this T v) where T : class", "\n{", - "\n StringBuilder sb = new StringBuilder();", - "\n var propertyInfos = v.GetType()", - "\n .GetProperties()", - "\n .Where(x => Attribute.IsDefined(x, typeof(IdentityPropertyAttribute)))", - "\n .OrderByDescending(x => x.PropertyType.Name).ThenByDescending(x => x.Name)", - "\n .Select(x => sb.Append(x.Name).Append(\":\").Append(v.GetType().GetProperty(x.Name)?.GetValue(v, null)).Append(\", \"));", - "\n", - "\nreturn propertyInfos.Select(p => p.ToString()).ToArray().Last();", + "\n StringBuilder sb = new StringBuilder();", + "\n var propertyInfos = v.GetType()", + "\n .GetProperties()", + "\n .Where(x => Attribute.IsDefined(x, typeof(IdentityPropertyAttribute)))", + "\n .OrderByDescending(x => x.PropertyType.Name).ThenByDescending(x => x.Name)", + "\n .Select(x => sb.Append(x.Name).Append(\":\").Append(v.GetType().GetProperty(x.Name)?.GetValue(v, null)).Append(\", \")).ToArray();", + "\n return propertyInfos.Count() == 0? v.ToString() : propertyInfos.Select(p => p.ToString()).ToArray().Last();", "\n}" ] }, diff --git a/ifrs17/Utils/TestHelper.ipynb b/ifrs17/Utils/TestHelper.ipynb index a627b204..9a46850e 100644 --- a/ifrs17/Utils/TestHelper.ipynb +++ b/ifrs17/Utils/TestHelper.ipynb @@ -98,14 +98,15 @@ { "cell_type": "code", "source": [ - "public static ReportBuilder WithGridOptionsForIfrsVariable", - "\n(this ReportBuilder reportBuilder, int reportHeight = 650)", + "public static Systemorph.Vertex.Pivot.Reporting.Builder.ReportBuilder WithGridOptionsForIfrsVariable", + "\n(this Systemorph.Vertex.Pivot.Builder.PivotBuilder reportBuilder, int reportHeight = 650)", "\n{", - "\n return reportBuilder.WithGridOptions(go => go.WithColumns(cols => cols.Modify(\"Value\", c => c.WithWidth(300)", - "\n .WithFormat(\"new Intl.NumberFormat('en',{ minimumFractionDigits:2, maximumFractionDigits:2 }).format(value)\")))", - "\n .WithRows(rows => rows.Where(r => !r.RowGroup.SystemName.EndsWith(\"NullGroup\")).ToList())", - "\n .WithAutoGroupColumn(c => c.WithWidth(250) with { Pinned = \"left\" }) with { Height = reportHeight, GroupDefaultExpanded = 2, OnGridReady = null }", - "\n );", + "\n return reportBuilder.WithGridOptions(go => ", + "\n go.WithColumns(cols => cols.Modify(\"Value\", c => c.WithWidth(300)", + "\n .WithFormat(\"new Intl.NumberFormat('en',{ minimumFractionDigits:2, maximumFractionDigits:2 }).format(value)\")))", + "\n .WithRows(rows => rows.Where(r => !r.RowGroup.SystemName.EndsWith(\"NullGroup\")).ToList())", + "\n .WithAutoGroupColumn(c => c.WithWidth(250) with { Pinned = \"left\" }) with { Height = reportHeight, GroupDefaultExpanded = 2, OnGridReady = null }", + "\n );", "\n}" ] }