diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index d41923e4..956e823e 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -2042,7 +2042,7 @@ "source": [ "## Computing All Scopes", "\n", - "\nSince all the calculations defined in the various scopes are to be performed together, it is useful to introduce the scope ComputeAllScopes below, which given a certain Import Identity and Import Storage, performs all the calculations (defined above) based on the corresponding data:" + "\nSince all the calculations defined in the various scopes are to be performed together, it is useful to introduce the scopes: ComputeIfrsVarsActuals, ComputeIfrsVarsCashflows and the ComputeIfrsVarsOpenings below, which given a certain Import Format and Import Storage, performs all the calculations (defined above) based on the corresponding data:" ], "metadata": {}, "execution_count": 0, @@ -2051,9 +2051,9 @@ { "cell_type": "code", "source": [ - "public interface ComputeAllScopes: IScope //ComputeIfrsVariable", + "public interface PvToIfrsVariable: IScope", "\n{", - "\n IEnumerable PvLocked => GetScope(Identity).PresentValues.Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EconomicBasis = x.EconomicBasis, ", + "\n IEnumerable PvLocked => GetScope(Identity).PresentValues.Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EconomicBasis = x.EconomicBasis, ", "\n EstimateType = x.Identity.EstimateType, ", "\n DataNode = x.Identity.Id.DataNode, ", "\n AocType = x.Identity.Id.AocType, ", @@ -2073,6 +2073,17 @@ "\n Value = x.Value,", "\n Partition = GetStorage().TargetPartition", "\n });", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface RaToIfrsVariable: IScope", + "\n{", "\n IEnumerable RaCurrent => GetScope(Identity).PresentValues.Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EconomicBasis = x.EconomicBasis, ", "\n EstimateType = x.Identity.EstimateType, ", "\n DataNode = x.Identity.Id.DataNode, ", @@ -2093,20 +2104,17 @@ "\n Value = x.Value,", "\n Partition = GetStorage().TargetPartition", "\n });", - "\n private string EconomicBasis => Identity.ValuationApproach == ValuationApproaches.VFA ? EconomicBases.C : EconomicBases.L;", - "\n private IEnumerable amortizationFactor => Identity.AocType == AocTypes.AM", - "\n ? GetScope(Identity, o => o.WithContext(EconomicBasis))", - "\n .RepeatOnce()", - "\n .Where(x => Math.Abs(x.Value) >= Precision)", - "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", - "\n DataNode = x.Identity.DataNode,", - "\n AocType = x.Identity.AocType,", - "\n Novelty = x.Identity.Novelty,", - "\n EconomicBasis = x.EconomicBasis,", - "\n Value = x.Value,", - "\n Partition = GetStorage().TargetPartition", - "\n })", - "\n : Enumerable.Empty();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ActualToIfrsVariable: IScope", + "\n{", "\n IEnumerable Actual => GetScope(Identity).Actuals.Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EstimateType = x.Identity.EstimateType,", "\n DataNode = x.Identity.Id.DataNode,", "\n AocType = x.Identity.Id.AocType,", @@ -2134,15 +2142,36 @@ "\n Value = x.Value,", "\n Partition = GetStorage().TargetPartition", "\n });", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface DeferrableToIfrsVariable: IScope", + "\n{", "\n IEnumerable DeferrableActual => GetScope(Identity).RepeatOnce().Where(x => Math.Abs(x.Value) >= Precision).Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", - "\n DataNode = x.Identity.DataNode,", - "\n AocType = x.Identity.AocType,", - "\n Novelty = x.Identity.Novelty,", - "\n AccidentYear = null,", - "\n Value = x.Value,", - "\n Partition = GetStorage().TargetPartition", - "\n });", - "\n ", + "\n DataNode = x.Identity.DataNode,", + "\n AocType = x.Identity.AocType,", + "\n Novelty = x.Identity.Novelty,", + "\n AccidentYear = null,", + "\n Value = x.Value,", + "\n Partition = GetStorage().TargetPartition", + "\n });", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface EaForPremiumToIfrsVariable: IScope", + "\n{", "\n IEnumerable BeEAForPremium => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC", "\n || Identity.IsReinsurance", "\n ? Enumerable.Empty()", @@ -2174,7 +2203,31 @@ "\n AmountType = sc.Identity.AmountType,", "\n Value = sc.Value,", "\n Partition = GetStorage().TargetPartition });", - "\n ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface TmToIfrsVariable: IScope", + "\n{", + "\n private string EconomicBasis => Identity.ValuationApproach == ValuationApproaches.VFA ? EconomicBases.C : EconomicBases.L;", + "\n IEnumerable AmortizationFactor => Identity.AocType == AocTypes.AM", + "\n ? GetScope(Identity, o => o.WithContext(EconomicBasis))", + "\n .RepeatOnce()", + "\n .Where(x => Math.Abs(x.Value) >= Precision)", + "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", + "\n DataNode = x.Identity.DataNode,", + "\n AocType = x.Identity.AocType,", + "\n Novelty = x.Identity.Novelty,", + "\n EconomicBasis = x.EconomicBasis,", + "\n Value = x.Value,", + "\n Partition = GetStorage().TargetPartition", + "\n })", + "\n : Enumerable.Empty();", "\n IEnumerable Csms => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC", "\n ? Enumerable.Empty()", "\n : GetScope(Identity).RepeatOnce()", @@ -2208,16 +2261,6 @@ "\n Value = x.Value,", "\n Partition = GetStorage().TargetPartition", "\n });", - "\n ", - "\n IEnumerable CalculatedIfrsVariables => GetStorage().ImportFormat switch {", - "\n ImportFormats.Actual => Actual.Concat(AdvanceActual).Concat(OverdueActual).Concat(ActEAForPremium)", - "\n .Concat(DeferrableActual).Concat(Csms).Concat(Loss),", - "\n ImportFormats.Cashflow => PvLocked.Concat(PvCurrent).Concat(RaCurrent).Concat(RaLocked)", - "\n .Concat(amortizationFactor).Concat(BeEAForPremium)", - "\n .Concat(DeferrableActual).Concat(Csms).Concat(Loss),", - "\n ImportFormats.Opening => AdvanceActual.Concat(OverdueActual).Concat(DeferrableActual)", - "\n .Concat(Csms).Concat(Loss),", - "\n };", "\n}" ], "metadata": {}, @@ -2227,7 +2270,49 @@ { "cell_type": "code", "source": [ - "" + "public interface ComputeIfrsVarsActuals : ActualToIfrsVariable, DeferrableToIfrsVariable, EaForPremiumToIfrsVariable, TmToIfrsVariable", + "\n{", + "\n IEnumerable CalculatedIfrsVariables => Actual.Concat(AdvanceActual)", + "\n .Concat(OverdueActual)", + "\n .Concat(ActEAForPremium)", + "\n .Concat(DeferrableActual)", + "\n .Concat(Csms)", + "\n .Concat(Loss);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ComputeIfrsVarsCashflows : PvToIfrsVariable, RaToIfrsVariable, DeferrableToIfrsVariable, EaForPremiumToIfrsVariable, TmToIfrsVariable", + "\n{", + "\n IEnumerable CalculatedIfrsVariables => PvLocked.Concat(PvCurrent)", + "\n .Concat(RaCurrent)", + "\n .Concat(RaLocked)", + "\n .Concat(amortizationFactor)", + "\n .Concat(BeEAForPremium)", + "\n .Concat(DeferrableActual)", + "\n .Concat(Csms)", + "\n .Concat(Loss);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ComputeIfrsVarsOpenings : ActualToIfrsVariable, DeferrableToIfrsVariable, TmToIfrsVariable", + "\n{", + "\n IEnumerable CalculatedIfrsVariables => AdvanceActual.Concat(OverdueActual)", + "\n .Concat(DeferrableActual)", + "\n .Concat(Csms)", + "\n .Concat(Loss);", + "\n} " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 9e10fe50..3ec5a6aa 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);", @@ -1120,7 +1120,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);", @@ -1275,7 +1275,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);",