From 8865a0cb3b8c231da469329c4e80a2b2914cfd59 Mon Sep 17 00:00:00 2001 From: aruiz Date: Wed, 11 Jan 2023 13:03:43 +0100 Subject: [PATCH 1/3] some starting ideas --- ifrs17/DataModel/DataStructure.ipynb | 2 + ifrs17/Import/ImportScopeCalculation.ipynb | 63 +++++++++++++++++++--- ifrs17/Import/Importers.ipynb | 2 +- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 3e6144ff..93813b39 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -1806,6 +1806,8 @@ "public record IfrsVariable : BaseDataRecord", "\n{", "\n public double Value { get; init; }", + "\n public double Value1 { get; init; }", + "\n", "\n ", "\n [NotVisible] ", "\n [Dimension(typeof(EstimateType))]", diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index 097661f1..a00d5142 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -733,8 +733,8 @@ "source": [ "public interface IWithGetValueFromValues : IScope<(ImportIdentity Id, string AmountType, string EstimateType, int? AccidentYear), ImportStorage>", "\n{", - "\n private int shift => GetStorage().GetShift(0);//Identity.Id.ProjectionPeriod", - "\n private int timeStep => GetStorage().GetTimeStep(0);//Identity.Id.ProjectionPeriod", + "\n private int shift => GetStorage().GetShift(Identity.Id.ProjectionPeriod);//Identity.Id.ProjectionPeriod", + "\n private int timeStep => GetStorage().GetTimeStep(Identity.Id.ProjectionPeriod);//Identity.Id.ProjectionPeriod", "\n ", "\n public double GetValueFromValues(double[] Values)", "\n {", @@ -1180,8 +1180,8 @@ "\n s.WithApplicability(x => x.GetStorage().ImportFormat != ImportFormats.Cashflow", "\n || x.GetStorage().IsSecondaryScope(x.Identity.DataNode)));", "\n ", - "\n private int shift => GetStorage().GetShift(0);//Identity.ProjectionPeriod", - "\n private int timeStep => GetStorage().GetTimeStep(0);//Identity.ProjectionPeriod", + "\n private int shift => GetStorage().GetShift(Identity.ProjectionPeriod);//Identity.ProjectionPeriod", + "\n private int timeStep => GetStorage().GetTimeStep(Identity.ProjectionPeriod);//Identity.ProjectionPeriod", "\n private double amortizedFactor => GetScope(Identity)", "\n .MonthlyAmortizationFactors", "\n .Skip(shift)", @@ -1679,8 +1679,8 @@ "\n", "\npublic interface TechnicalMarginForIA : TechnicalMargin", "\n{", - "\n private int timeStep => GetStorage().GetTimeStep(0);//Identity.Id.ProjectionPeriod", - "\n private int shift => GetStorage().GetShift(0);//Identity.Id.ProjectionPeriod", + "\n private int timeStep => GetStorage().GetTimeStep(Identity.ProjectionPeriod);//Identity.Id.ProjectionPeriod", + "\n private int shift => GetStorage().GetShift(Identity.ProjectionPeriod);//Identity.Id.ProjectionPeriod", "\n ", "\n private double[] monthlyInterestFactor => GetScope(Identity, o => o.WithContext(EconomicBasis)).Interest;", "\n ", @@ -2306,7 +2306,38 @@ { "cell_type": "code", "source": [ - "public interface ComputeIfrsVarsOpenings : ActualToIfrsVariable, DeferrableToIfrsVariable, TmToIfrsVariable", + "", + "\npublic interface ProjectionScopeCashflows : IScope{", + "\n IEnumerable CalculatedIfrsVariables => Enumerable.Range(0,2).Select(x => GetScope(Identity with { ProjectionPeriod = x} ).CalculatedIfrsVariables //Here Projection Period needs to be x...and then the right information needs to be found. ", + "\n .Select(y => AdjustProjection(y, x))).SelectMany(l => l).AggregateOver().Select(x => x with {Partition = GetStorage().TargetPartition});", + "\n", + "\nIfrsVariable AdjustProjection(IfrsVariable iv, int projectionPeriod){", + "\nvar ret = new IfrsVariable{ ", + "\n DataNode = iv.DataNode,", + "\n AocType = iv.AocType,", + "\n Novelty = iv.Novelty,", + "\n Partition = iv.Partition,", + "\n Value = projectionPeriod == 0 ? iv.Value : 0.0d,", + "\n Value1 = projectionPeriod == 1 ? iv.Value : 0.0d ,", + "\n EstimateType = iv.EstimateType, ", + "\n AccidentYear = iv.AccidentYear,", + "\n AmountType = iv.AmountType,", + "\n EconomicBasis = iv.EconomicBasis", + "\n };", + "\n return ret;", + "\n}", + "\n", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "", + "\npublic interface ComputeIfrsVarsOpenings : ActualToIfrsVariable, DeferrableToIfrsVariable, TmToIfrsVariable", "\n{", "\n IEnumerable CalculatedIfrsVariables => AdvanceActual.Concat(OverdueActual)", "\n .Concat(DeferrableActual)", @@ -2317,6 +2348,24 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 3ec5a6aa..1d30fe84 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -998,7 +998,7 @@ "\n ", "\n var universe = Scopes.ForStorage(storage).ToScope();", "\n var identities = universe.GetScopes(storage.DataNodesByImportScope[ImportScope.Primary]).SelectMany(s => s.Identities);", - "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", + "\n var ivs = universe.GetScopes(identities).SelectMany(x => x.CalculatedIfrsVariables);", "\n if(Activity.HasErrors()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n await workspace.UpdateAsync(ivs);", From 8c3172a2c3c5ec7279150422d672777c45fbbd39 Mon Sep 17 00:00:00 2001 From: aruiz Date: Thu, 12 Jan 2023 10:46:21 +0100 Subject: [PATCH 2/3] some comments --- ifrs17/Import/ImportScopeCalculation.ipynb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index a00d5142..7ad9bbfa 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -2306,7 +2306,8 @@ { "cell_type": "code", "source": [ - "", + "//This scope replaces ComputeIfrsVarsCashflows. Something similar should be done for other calculations that need projections. ", + "\n//Also we still need a way to make BoP for a projection Period be same as EoP for previous period. ", "\npublic interface ProjectionScopeCashflows : IScope{", "\n IEnumerable CalculatedIfrsVariables => Enumerable.Range(0,2).Select(x => GetScope(Identity with { ProjectionPeriod = x} ).CalculatedIfrsVariables //Here Projection Period needs to be x...and then the right information needs to be found. ", "\n .Select(y => AdjustProjection(y, x))).SelectMany(l => l).AggregateOver().Select(x => x with {Partition = GetStorage().TargetPartition});", @@ -2318,7 +2319,7 @@ "\n Novelty = iv.Novelty,", "\n Partition = iv.Partition,", "\n Value = projectionPeriod == 0 ? iv.Value : 0.0d,", - "\n Value1 = projectionPeriod == 1 ? iv.Value : 0.0d ,", + "\n Value1 = projectionPeriod == 1 ? iv.Value : 0.0d , //Here Value2...etc would be needed. ", "\n EstimateType = iv.EstimateType, ", "\n AccidentYear = iv.AccidentYear,", "\n AmountType = iv.AmountType,", From ab932589c82021583b9d11eb267ee6fe4e3c72af Mon Sep 17 00:00:00 2001 From: Sara Colella Date: Mon, 16 Jan 2023 17:05:31 +0100 Subject: [PATCH 3/3] fix Merge --- ifrs17/Import/ImportScopeCalculation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index 85ea7333..cc57a4b7 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -2368,7 +2368,7 @@ "\n{", "\n IEnumerable CalculatedIfrsVariables => GetStorage().ImportFormat switch {", "\n ImportFormats.Actual => GetScope(Identity).CalculatedIfrsVariables,", - "\n ImportFormats.Cashflow => GetScope(Identity).CalculatedIfrsVariables,", + "\n ImportFormats.Cashflow => GetScope(Identity).CalculatedIfrsVariables,", "\n ImportFormats.Opening => GetScope(Identity).CalculatedIfrsVariables,", "\n };", "\n}"