diff --git a/ifrs17-template/Files/DataNodes/DataNodeParameters_CH_2020_12.csv b/ifrs17-template/Files/DataNodes/DataNodeParameters_CH_2020_12.csv index 4d8c0860..55accc65 100644 --- a/ifrs17-template/Files/DataNodes/DataNodeParameters_CH_2020_12.csv +++ b/ifrs17-template/Files/DataNodes/DataNodeParameters_CH_2020_12.csv @@ -3,7 +3,7 @@ ReportingNode,Year,Month CH,2020,12 ,, @@SingleDataNodeParameter,, -DataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod,ReleasePattern0,ReleasePattern1,ReleasePattern2,ReleasePattern3,ReleasePattern4 +DataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod,EconomicBasisDriver,ReleasePattern0,ReleasePattern1,ReleasePattern2,ReleasePattern3,ReleasePattern4 GicComplex,0.8,Monthly, DT1.1,0.8,Monthly, DT1.2,0.8,Monthly, @@ -15,7 +15,7 @@ DT2.2,0.8,Monthly, DT3.1,0.8,Monthly, DT4.1,0.8,Monthly, DT10.1,0,Yearly,Uniform, -DT10.2,0,Yearly,Uniform,1.41,1.14,0.87,0.58 +DT10.2,0,Yearly,Uniform,N,1.41,1.14,0.87,0.58 ,, @@InterDataNodeParameter,, DataNode,LinkedDataNode,ReinsuranceCoverage diff --git a/ifrs17-template/Import/InteractWithImportScopes/EvaluateImportScopes.ipynb b/ifrs17-template/Import/InteractWithImportScopes/EvaluateImportScopes.ipynb index 87af97cf..aa205240 100644 --- a/ifrs17-template/Import/InteractWithImportScopes/EvaluateImportScopes.ipynb +++ b/ifrs17-template/Import/InteractWithImportScopes/EvaluateImportScopes.ipynb @@ -79,7 +79,16 @@ { "cell_type": "code", "source": [ - "await Import.FromFile(\"../../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", + "ProjectionCount = 5;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await Import.FromFile(\"../../Files/TransactionalData/NominalCashflowsPAA_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", "\n .WithActivityLog()", @@ -229,7 +238,7 @@ { "cell_type": "code", "source": [ - "var ivs = Scopes.ForIdentities(identities, storage).ToScopes().SelectMany(x => x.PvLocked.Concat(x.PvCurrent)).ToArray();" + "int projection = 0;" ], "metadata": {}, "execution_count": 0, @@ -238,7 +247,7 @@ { "cell_type": "code", "source": [ - "var ivs = Scopes.ForIdentities(identities, storage).ToScopes().SelectMany(x => x.CumulatedNominal).ToArray();" + "var ivs = Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod = projection}), storage).ToScopes().SelectMany(x => x.PvLocked.Concat(x.PvCurrent)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -247,7 +256,7 @@ { "cell_type": "code", "source": [ - "var ivs = Scopes.ForIdentities(identities, storage).ToScopes().SelectMany(x => x.RaCurrent.Concat(x.RaLocked)).ToArray();" + "var ivs = Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod = projection}), storage).ToScopes().SelectMany(x => x.CumulatedNominal).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -256,7 +265,7 @@ { "cell_type": "code", "source": [ - "var ivs = Scopes.ForIdentities(identities, storage).ToScopes().SelectMany(x => x.Actual.Concat(x.AdvanceActual).Concat(x.OverdueActual)).ToArray();" + "var ivs = Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod = projection}), storage).ToScopes().SelectMany(x => x.RaCurrent.Concat(x.RaLocked)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -265,7 +274,7 @@ { "cell_type": "code", "source": [ - "var ivs = Scopes.ForIdentities(identities, storage).ToScopes().SelectMany(x => x.DeferrableActual).ToArray();" + "var ivs = Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod = projection}), storage).ToScopes().SelectMany(x => x.Actual.Concat(x.AdvanceActual).Concat(x.OverdueActual)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -274,7 +283,7 @@ { "cell_type": "code", "source": [ - "var ivs = Scopes.ForIdentities(identities, storage).ToScopes().SelectMany(x => x.BeEAForPremium.Concat(x.ActEAForPremium)).ToArray();" + "var ivs = Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod = projection}), storage).ToScopes().SelectMany(x => x.Deferrable).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -283,7 +292,7 @@ { "cell_type": "code", "source": [ - "var ivs = Scopes.ForIdentities(identities, storage).ToScopes().SelectMany(x => x.BeEAForPremium.Concat(x.ActEAForPremium)).ToArray();" + "var ivs = Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod = projection}), storage).ToScopes().SelectMany(x => x.DeferrableAmFactor).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -292,7 +301,16 @@ { "cell_type": "code", "source": [ - "var ivs = Scopes.ForIdentities(identities, storage).ToScopes().SelectMany(x => x.AmortizationFactor.Concat(x.Csms).Concat(x.Loss)).ToArray();" + "var ivs = Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod = projection}), storage).ToScopes().SelectMany(x => x.BeEAForPremium.Concat(x.ActEAForPremium)).ToArray();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ivs = Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod = projection}), storage).ToScopes().SelectMany(x => x.AmortizationFactor.Concat(x.Csms).Concat(x.Loss)).ToArray();" ], "metadata": {}, "execution_count": 0, @@ -307,6 +325,44 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Temporary test of DAC for PAA" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var iv = Enumerable.Range(0,5).SelectMany(p=>", + "\n Scopes.ForIdentities(identities.Select(id => id with {ProjectionPeriod=p}), storage)", + "\n .ToScopes().SelectMany(x => x.Deferrable))", + "\n.AggregateProjections().Where(x => x.Values.Any(v => Math.Abs(v) > Precision ))", + "\n.ToArray();", + "\n", + "\nvar eops= iv.Where(x => x.AocType == \"EOP\");", + "\nvar ams = iv.Where(x => x.AocType == \"AM\" && x.EstimateType == \"DA\");", + "\n", + "\niv" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "//Testing", + "\n(Math.Abs(eops.Single(x => x.AccidentYear == 0).Values.First() - 647.5)< Precision, Math.Abs(eops.Single(x => x.AccidentYear == 2).Values.First() - 918.125)< Precision, ", + "\nMath.Abs(ams.Single(x => x.AccidentYear == 0).Values.First() - -352.5)< Precision, Math.Abs(ams.Single(x => x.AccidentYear == 2).Values.First() - -381.87499999999994)< Precision)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index 58e7824b..1c622293 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -388,6 +388,8 @@ "\n public const string ALE = nameof(ALE); // Allocated Loss Adjustment Expenses", "\n public const string ULE = nameof(ULE); // Unallocated Loss Adjustment Expenses", "\n public const string CU = nameof(CU); // Coverage Units", + "\n public const string DE = nameof(DE); // Deferrable Expenses", + "\n public const string DAE = nameof(DAE); // Deferrable Acquisition Expenses", "\n}" ], "metadata": {}, diff --git a/ifrs17/Import/2ImportScope-PresentValue.ipynb b/ifrs17/Import/2ImportScope-PresentValue.ipynb index 1149e59d..c4eb407f 100644 --- a/ifrs17/Import/2ImportScope-PresentValue.ipynb +++ b/ifrs17/Import/2ImportScope-PresentValue.ipynb @@ -892,15 +892,26 @@ "\n}", "\n", "\npublic interface AmfFromIfrsVariable : CurrentPeriodAmortizationFactor{", - "\n private double amortizationFactorForAmountType => GetStorage().GetValue(Identity.Id, Identity.AmountType, EstimateType, EconomicBasis, Identity.patternShift == 0 ? null : Identity.patternShift, Identity.Id.ProjectionPeriod);", + "\n private double amortizationFactorForAmountType => GetStorage().GetValue(Identity.Id, Identity.AmountType, EstimateType, EconomicBasis, ", + "\n Identity.patternShift == 0 ? null : Identity.patternShift, Identity.Id.ProjectionPeriod); //TODO shift of 0 is a valid value", "\n double CurrentPeriodAmortizationFactor.Value => Math.Abs(amortizationFactorForAmountType) >= Precision", "\n ? amortizationFactorForAmountType ", "\n : GetStorage().GetValue(Identity.Id, null, EstimateType, EconomicBasis, Identity.patternShift == 0 ? null : Identity.patternShift, Identity.Id.ProjectionPeriod);", + "\n string CurrentPeriodAmortizationFactor.EffectiveAmountType => Math.Abs(amortizationFactorForAmountType) >= Precision ? Identity.AmountType : null;", "\n}" ], "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/3ImportScope-Actuals.ipynb b/ifrs17/Import/3ImportScope-Actuals.ipynb index 6cf9e033..10cb341b 100644 --- a/ifrs17/Import/3ImportScope-Actuals.ipynb +++ b/ifrs17/Import/3ImportScope-Actuals.ipynb @@ -261,9 +261,16 @@ { "cell_type": "markdown", "source": [ - "## Deferrable Actuals", - "\n", - "\nFinally, Deferrable Actuals are given by", + "## Deferrable Actuals" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Finally, Deferrable Actuals are given by", "\n", "\n$$", "\n\\text{Deferrable Actual} (\\text{AoC step}) = \\left\\{", @@ -282,6 +289,24 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "public interface DiscountedAmortizationFactorForDeferrals : IScope", + "\n{", + "\n private string EconomicBasis => GetContext();", + "\n double Value => GetScope((Identity, AmountTypes.DAE, 0), o => o.WithContext(EconomicBasis)).EffectiveAmountType == AmountTypes.DAE", + "\n ? GetScope((Identity, AmountTypes.DAE, 0), o => o.WithContext(EconomicBasis)).Value", + "\n : GetScope((Identity, AmountTypes.CU, 0), o => o.WithContext(EconomicBasis)).Value;", + "\n string EffectiveAmountType => GetScope((Identity, AmountTypes.DAE, 0), o => o.WithContext(EconomicBasis)).EffectiveAmountType == AmountTypes.DAE", + "\n ? AmountTypes.DAE", + "\n : GetScope((Identity, AmountTypes.CU, 0), o => o.WithContext(EconomicBasis)).EffectiveAmountType;", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -297,32 +322,27 @@ "\n ", "\n [IdentityProperty][NotVisible][Dimension(typeof(EstimateType))]", "\n string EstimateType => EstimateTypes.DA;", - "\n ", "\n [NotVisible] string EconomicBasis => EconomicBases.L;", "\n ", "\n public double Value => GetStorage().GetValue(Identity, (string)null, EstimateType, (int?)null, Identity.ProjectionPeriod);", "\n}", "\n", - "\npublic interface DeferrableActualForCurrentBasis : DeferrableActual", - "\n{", + "\npublic interface DeferrableActualForCurrentBasis : DeferrableActual{", "\n [NotVisible] string DeferrableActual.EconomicBasis => EconomicBases.C;", "\n}", "\n", - "\npublic interface ReleaseDeferrable : DeferrableActual", - "\n{", + "\npublic interface ReleaseDeferrable : DeferrableActual{", "\n double DeferrableActual.Value => GetStorage().GetAttributableExpenseAndCommissionAmountType().Sum(at => GetScope((Identity, at, EstimateTypes.A, (int?)null)).Value);", "\n}", "\n", - "\npublic interface AmortizationDeferrable : DeferrableActual", - "\n{", - "\n private double AmortizationFactor => GetScope((Identity, AmountTypes.CU, 0), o => o.WithContext(EconomicBasis)).Value;", + "\npublic interface AmortizationDeferrable : DeferrableActual{", + "\n private double AmortizationFactor => GetScope(Identity, o => o.WithContext(EconomicBasis)).Value;", "\n private double AggregatedDeferrable => GetScope((Identity, InputSource.Actual)).Values", "\n .Sum(aocStep => GetScope(Identity with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}).Value);", "\n double DeferrableActual.Value => -1d * AggregatedDeferrable * AmortizationFactor;", "\n}", "\n", - "\npublic interface EndOfPeriodDeferrable : DeferrableActual", - "\n{", + "\npublic interface EndOfPeriodDeferrable : DeferrableActual{", "\n double DeferrableActual.Value => GetScope((Identity, InputSource.Actual)).Values", "\n .Sum(aocStep => GetScope(Identity with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}).Value);", "\n}" @@ -331,6 +351,217 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Deferrable" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Deferral variables are computed here using cashflow inputs. We distinguish between two approaches depending on the EconomicBasisDriver defined in the [DataNodeParameter](../DataModel/DataStructure#data-node-parameters):", + "\n- L (Locked-in) or C (Current) : discounting is applied (cf. [Deferrable as cumulated discounted cash flow](#deferrable-as-cumulated-discounted-cash-flow)),", + "\n- N (Nominal) : discounting is not applied (cf. [Deferrable undiscounted](#deferrable-undiscounted)).", + "\n", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Deferrable as cumulated discounted cash flow", + "\nThe cumulated discounted cash flow (CDC) or Present Value of deferral amount types is considered within this approach. ", + "\nThe AoC Chain coincides with the one defined for Present Values. In addition, an Amortization step is computed using a release pattern defined in input (in the [DataNodeParameter](../DataModel/DataStructure#data-node-parameters) or as cash flow). ", + "\n", + "\n", + "\n$$", + "\n\\text{Deferrable} (\\text{AoC step}) = \\left\\{", + "\n\\begin{array}{rl}", + "\n0 ~, & \\text{if AoC Step's AoC Type = CF } \\\\", + "\n\\text{PV}(\\text{CF})- \\text{Actual Base}(\\text{CF})|_{\\text{Estimate Type = A}} ~, & \\text{if AoC Step's AoC Type = EA } \\\\", + "\n- \\text{Amortization Factor} \\cdot \\sum_{\\text{Previous AoC Step}} \\text{Deferrable}(\\text{AoC Step}) ~, & \\text{if AoC Step's AoC Type = AM } \\\\", + "\n\\sum_{\\text{Previous AoC Step}} \\text{Deferrable}(\\text{AoC Step}) ~, & \\text{if AoC Step's AoC Type = EOP } \\\\", + "\n\\text{PV}(\\text{AoC Step}) ~, & \\text{ otherwise } \\\\", + "\n\\end{array}", + "\n\\right.", + "\n$$" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface DiscountedDeferrable : IScope", + "\n{", + "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", + "\n builder.ForScope(s => s //compute with IfrsVariable?", + "\n //.WithApplicability(x => x.Identity.AocType == AocTypes.BOP && x.Identity.Novelty == Novelties.I && x.Identity.ProjectionPeriod > 0)", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.BOP && x.Identity.Novelty == Novelties.I)", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.CF)", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EA)", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.AM)", + "\n .WithApplicability(x => x.Identity.AocType == AocTypes.EOP)", + "\n );", + "\n [IdentityProperty][NotVisible][Dimension(typeof(EstimateType))]", + "\n string EstimateType => EstimateTypes.DA;", + "\n string AmountType => null;", + "\n", + "\n [NotVisible] string EconomicBasis => GetStorage().GetEconomicBasisDriver(Identity.DataNode);", + "\n ", + "\n double Value => GetStorage().GetDeferrableExpenses().Sum(at => ", + "\n GetScope((Identity, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value);", + "\n}", + "\n", + "\npublic interface DeferrableForBOP : DiscountedDeferrable {", + "\n double DiscountedDeferrable.Value => GetStorage().GetValue(Identity, null, EstimateTypes.DA, EconomicBasis, (int?)null, Identity.ProjectionPeriod);", + "\n}", + "\n", + "\npublic interface DeferrableDefaultValue : DiscountedDeferrable {", + "\n double DiscountedDeferrable.Value => default;", + "\n}", + "\n", + "\npublic interface DeferrableEa : DiscountedDeferrable {", + "\n private string referenceAocType => GetScope(Identity).Value.AocType;", + "\n double DiscountedDeferrable.Value => GetStorage().GetDeferrableExpenses().Sum(at =>", + "\n GetStorage().GetNovelties(referenceAocType, InputSource.Cashflow)", + "\n .Sum(n => GetScope((Identity with {AocType = referenceAocType, Novelty = n}, at, EstimateTypes.BE, (int?)null), o => o.WithContext(EconomicBasis)).Value) -", + "\n GetScope((Identity with {AocType = referenceAocType, Novelty = Novelties.C}, at, EstimateTypes.A, (int?)null)).Value);", + "\n}", + "\n", + "\npublic interface DeferrableAm : DiscountedDeferrable {", + "\n private double AmortizationFactor => GetScope(Identity, o => o.WithContext(EconomicBasis)).Value;", + "\n private double AggregatedValue => GetScope((Identity, InputSource.Cashflow)).Values", + "\n .Sum(aocStep => GetScope(Identity with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}).Value);", + "\n double DiscountedDeferrable.Value => -1d * AggregatedValue * AmortizationFactor;", + "\n}", + "\n", + "\npublic interface DeferrableEoP : DiscountedDeferrable {", + "\n double DiscountedDeferrable.Value => GetScope((Identity, InputSource.Cashflow)).Values", + "\n .Sum(aocStep => GetScope(Identity with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}).Value);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Deferrable undiscounted", + "\nThe nominal cash flow of deferral amount types is considered within this approach. ", + "\nAs Present Values are not used here, this methodology allows to amortize and release expenses occurring in different months within the reporting period. ", + "\nThis is achieved by applying a shift to the release pattern. For this reason, this approach is to be used with a release pattern defined in the [DataNodeParameter](../DataModel/DataStructure#data-node-parameters).", + "\n", + "\nThe AoC Chain is simplified and considers: ", + "\n- BOP (I as opening value to be entered as cash flow, N for new expenses)", + "\n- AM,", + "\n- EOP.", + "\n", + "\n", + "\n$$", + "\n\\text{Deferrable} (\\text{AoC step}) = \\left\\{", + "\n\\begin{array}{rl}", + "\n", + "\n\\text{Previous Period EOP} ~, & \\text{if AoC Step's AoC Type = BOP } \\\\", + "\n- \\text{Amortization Factor}(shift) \\cdot \\sum_{\\text{Previous AoC Step}} \\text{Deferrable}(\\text{AoC Step}) ~, & \\text{if AoC Step's AoC Type = AM } \\\\", + "\n\\sum_{\\text{Previous AoC Step}} \\text{Deferrable}(\\text{AoC Step}) ~, & \\text{if AoC Step's AoC Type = EOP } \\\\", + "\n0 ~, & \\text{ otherwise } \\\\", + "\n\\end{array}", + "\n\\right.", + "\n$$", + "\n", + "\nwhere the $shift$ corresponds to the month at which the cost occurs (starting from 0).", + "\n", + "\n" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "//TODO : ", + "\n// EstimateType from DA to DAC", + "\n// BOP,I only through Opening. ", + "\npublic interface NominalDeferrable : IScope<(ImportIdentity Id, int MonthlyShift), ImportStorage>", + "\n{", + "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", + "\n builder.ForScope(s => s", + "\n .WithApplicability(x => x.Identity.Id.AocType == AocTypes.BOP && x.Identity.Id.Novelty == Novelties.I && x.Identity.Id.ProjectionPeriod > 0)", + "\n .WithApplicability(x => x.Identity.Id.AocType == AocTypes.BOP)", + "\n .WithApplicability(x => x.Identity.Id.AocType == AocTypes.CL)", + "\n .WithApplicability(x => x.Identity.Id.AocType == AocTypes.AM)", + "\n .WithApplicability(x => x.Identity.Id.AocType == AocTypes.EOP)", + "\n );", + "\n ", + "\n [IdentityProperty][NotVisible][Dimension(typeof(EstimateType))]", + "\n string EstimateType => EstimateTypes.DA;", + "\n string AmountType => null;", + "\n ", + "\n [NotVisible] string EconomicBasis => EconomicBases.N;", + "\n double Value => default;", + "\n}", + "\n", + "\npublic interface BoPDeferrableProjection : NominalDeferrable{", + "\n double NominalDeferrable.Value => GetScope((", + "\n Identity.Id with {AocType = AocTypes.EOP, Novelty = Novelties.C, ProjectionPeriod = Identity.Id.ProjectionPeriod - 1}, ", + "\n Identity.MonthlyShift)).Value;", + "\n}", + "\n", + "\npublic interface BoPDeferrable : NominalDeferrable{", + "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", + "\n builder.ForScope(s => s.WithApplicability(x => x.GetStorage().ImportFormat != ImportFormats.Cashflow", + "\n || x.GetStorage().IsSecondaryScope(x.Identity.Id.DataNode)", + "\n || (x.Identity.Id.Novelty == Novelties.I && !x.GetStorage().IsInceptionYear(x.Identity.Id.DataNode)) ));", + "\n private int projectionShift => GetStorage().GetShift(Identity.Id.ProjectionPeriod);", + "\n double NominalDeferrable.Value => GetScope((Identity.Id, AmountTypes.DAE, EstimateTypes.BE, (int?)null)).Values", + "\n .Skip(projectionShift + Identity.MonthlyShift).FirstOrDefault();", + "\n}", + "\n", + "\npublic interface NominalDeferrableFromIfrsVariable : NominalDeferrable{", + "\n double NominalDeferrable.Value => GetStorage().GetValue(Identity.Id, null, EstimateTypes.DA, EconomicBasis, Identity.MonthlyShift, Identity.Id.ProjectionPeriod);", + "\n}", + "\n", + "\npublic interface ClDeferrable : NominalDeferrable{", + "\n private int projectionShift => GetStorage().GetShift(Identity.Id.ProjectionPeriod);", + "\n private IEnumerable previousAocSteps => GetScope((Identity.Id, InputSource.Cashflow)).Values;", + "\n double referenceCashflow => previousAocSteps", + "\n .GroupBy(x => x.Novelty, (k, aocs) => aocs.Last())", + "\n .Sum(aoc => GetScope((Identity.Id with {AocType = aoc.AocType, Novelty = aoc.Novelty}, AmountTypes.DAE, EstimateTypes.BE, (int?)null)).Values", + "\n .Skip(projectionShift + Identity.MonthlyShift).FirstOrDefault());", + "\n ", + "\n double NominalDeferrable.Value => referenceCashflow >= Precision //if no previous RawVariable, use IfrsVariable", + "\n ? referenceCashflow ", + "\n : GetScope((Identity.Id with {AocType = AocTypes.BOP, Novelty = Novelties.I}, Identity.MonthlyShift)).Value +", + "\n GetScope((Identity.Id with {AocType = AocTypes.BOP, Novelty = Novelties.N}, Identity.MonthlyShift)).Value;", + "\n}", + "\n", + "\npublic interface AmDeferrable : NominalDeferrable{", + "\n private AocStep referenceAocStep => GetScope(Identity.Id).Value;//CL,C", + "\n private double referenceCashflow => GetScope((Identity.Id with {AocType = referenceAocStep.AocType, Novelty = referenceAocStep.Novelty}, Identity.MonthlyShift)).Value;", + "\n", + "\n double NominalDeferrable.Value => -1d * referenceCashflow * GetScope((Identity.Id, AmountTypes.DAE, Identity.MonthlyShift), o => o.WithContext(EconomicBasis)).Value;", + "\n}", + "\n", + "\npublic interface EopDeferrable : NominalDeferrable{", + "\n private IEnumerable previousAocSteps => GetScope((Identity.Id, InputSource.Cashflow)).Values;", + "\n double NominalDeferrable.Value => previousAocSteps.Sum(aocStep => GetScope((Identity.Id with {AocType = aocStep.AocType, Novelty = aocStep.Novelty}, Identity.MonthlyShift)).Value);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb index 1eb166db..1213f860 100644 --- a/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb +++ b/ifrs17/Import/5ImportScope-ToIfrsVar.ipynb @@ -203,9 +203,9 @@ { "cell_type": "code", "source": [ - "public interface DeferrableToIfrsVariable: IScope", + "public interface DeferrableActualToIfrsVariable: IScope", "\n{", - "\n IEnumerable DeferrableActual => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC ", + "\n IEnumerable DeferrableActual => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC //todo move up in the scope chain(is this correct?)", "\n ? Enumerable.Empty()", "\n : GetScope(Identity).RepeatOnce().Select(x => ", "\n new IfrsVariable{ EstimateType = x.EstimateType,", @@ -221,6 +221,95 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "public interface DeferrableCashflowToIfrsVariable: IScope", + "\n{", + "\n private int timeStep => GetStorage().GetTimeStep(Identity.ProjectionPeriod); ", + "\n", + "\n IEnumerable Deferrable => GetStorage().GetEconomicBasisDriver(Identity.DataNode) switch {", + "\n EconomicBases.N => Enumerable.Range(0, timeStep).SelectMany(shift => ", + "\n GetScope((Identity, shift)).RepeatOnce()", + "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", + "\n EconomicBasis = EconomicBases.N,", + "\n DataNode = x.Identity.Id.DataNode,", + "\n AocType = x.Identity.Id.AocType,", + "\n Novelty = x.Identity.Id.Novelty,", + "\n AccidentYear = shift,", + "\n Values = SetProjectionValue(x.Value, x.Identity.Id.ProjectionPeriod),", + "\n Partition = GetStorage().TargetPartition }", + "\n )),", + "\n _ => GetScope(Identity).RepeatOnce()", + "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", + "\n EconomicBasis = x.EconomicBasis,", + "\n DataNode = x.Identity.DataNode,", + "\n AocType = x.Identity.AocType,", + "\n Novelty = x.Identity.Novelty,", + "\n Values = SetProjectionValue(x.Value, x.Identity.ProjectionPeriod),", + "\n Partition = GetStorage().TargetPartition }", + "\n ),", + "\n };", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface DeferrableToIfrsVariable: IScope", + "\n{", + "\n IEnumerable Deferrable => GetStorage().DataNodeDataBySystemName[Identity.DataNode].ValuationApproach == ValuationApproaches.PAA", + "\n ? GetScope(Identity).Deferrable", + "\n : GetScope(Identity).DeferrableActual;", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface DeferrableAmortizationFactorToIfrsVariable: IScope", + "\n{", + "\n private string EconomicBasis => GetStorage().GetEconomicBasisDriver(Identity.DataNode);", + "\n", + "\n IEnumerable DeferrableAmFactor => (GetStorage().GetEconomicBasisDriver(Identity.DataNode), Identity.AocType) switch {", + "\n (EconomicBases.N, AocTypes.AM) => GetScope(Identity).Deferrable", + "\n .Where(x => x.Values != null && Math.Abs(x.Values.GetValidElement(Identity.ProjectionPeriod)) >= Precision)", + "\n .Select(x => x.AccidentYear.Value).SelectMany(shift => ", + "\n GetScope((Identity, AmountTypes.DAE, shift), o => o.WithContext(EconomicBases.N)).RepeatOnce() //hardcoded AmountType: DAE for pattern", + "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", + "\n EconomicBasis = EconomicBases.N,", + "\n DataNode = x.Identity.Id.DataNode,", + "\n AocType = Identity.AocType,", + "\n Novelty = Identity.Novelty,", + "\n AmountType = x.EffectiveAmountType,", + "\n AccidentYear = shift,", + "\n Values = SetProjectionValue(x.Value, x.Identity.Id.ProjectionPeriod),", + "\n Partition = GetStorage().TargetPartition }", + "\n )),", + "\n (_, AocTypes.AM) => GetScope(Identity, o => o.WithContext(EconomicBasis)).RepeatOnce()", + "\n .Select(x => new IfrsVariable{ EstimateType = EstimateTypes.F,", + "\n EconomicBasis = EconomicBasis,", + "\n DataNode = x.Identity.DataNode,", + "\n AocType = x.Identity.AocType,", + "\n Novelty = x.Identity.Novelty,", + "\n AmountType = x.EffectiveAmountType,", + "\n Values = SetProjectionValue(x.Value, x.Identity.ProjectionPeriod),", + "\n Partition = GetStorage().TargetPartition }", + "\n ),", + "\n (_, _) => Enumerable.Empty(),", + "\n };", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Import/6ImportScope-Compute.ipynb b/ifrs17/Import/6ImportScope-Compute.ipynb index a3b94c0f..c755d4d9 100644 --- a/ifrs17/Import/6ImportScope-Compute.ipynb +++ b/ifrs17/Import/6ImportScope-Compute.ipynb @@ -78,7 +78,7 @@ "public interface ComputeIfrsVarsActuals : ActualToIfrsVariable, DeferrableToIfrsVariable, EaForPremiumToIfrsVariable, TmToIfrsVariable", "\n{", "\n IEnumerable CalculatedIfrsVariables => Actual.Concat(AdvanceActual).Concat(OverdueActual)", - "\n .Concat(ActEAForPremium).Concat(DeferrableActual).Concat(Csms).Concat(Loss);", + "\n .Concat(ActEAForPremium).Concat(Deferrable).Concat(Csms).Concat(Loss);", "\n}" ], "metadata": {}, @@ -97,13 +97,15 @@ { "cell_type": "code", "source": [ - "public interface ComputeIfrsVarsCashflows : PvToIfrsVariable, RaToIfrsVariable, DeferrableToIfrsVariable, EaForPremiumToIfrsVariable, TmToIfrsVariable, NominalToIfrsVariable", + "public interface ComputeIfrsVarsCashflows : PvToIfrsVariable, RaToIfrsVariable, DeferrableToIfrsVariable, EaForPremiumToIfrsVariable, TmToIfrsVariable, NominalToIfrsVariable, DeferrableAmortizationFactorToIfrsVariable", "\n{", + "\n private IEnumerable amortizationFactors => AmortizationFactor.Union(DeferrableAmFactor, EqualityComparer.Instance);", + "\n ", "\n IEnumerable CalculatedIfrsVariables => Identity.ValuationApproach switch {", - "\n ValuationApproaches.VFA => PvCurrent.Concat(CumulatedNominal).Concat(RaCurrent).Concat(AmortizationFactor)", - "\n .Concat(BeEAForPremium).Concat(DeferrableActual).Concat(Csms).Concat(Loss),", - "\n _ => PvLocked.Concat(PvCurrent).Concat(CumulatedNominal).Concat(RaCurrent).Concat(RaLocked).Concat(AmortizationFactor)", - "\n .Concat(BeEAForPremium).Concat(DeferrableActual).Concat(Csms).Concat(Loss),", + "\n ValuationApproaches.VFA => PvCurrent.Concat(CumulatedNominal).Concat(RaCurrent).Concat(amortizationFactors)", + "\n .Concat(BeEAForPremium).Concat(Deferrable).Concat(Csms).Concat(Loss),", + "\n _ => PvLocked.Concat(PvCurrent).Concat(CumulatedNominal).Concat(RaCurrent).Concat(RaLocked).Concat(amortizationFactors)", + "\n .Concat(BeEAForPremium).Concat(Deferrable).Concat(Csms).Concat(Loss),", "\n };", "\n}" ], @@ -149,7 +151,7 @@ "public interface ComputeIfrsVarsOpenings : ActualToIfrsVariable, DeferrableToIfrsVariable, TmToIfrsVariable", "\n{", "\n IEnumerable CalculatedIfrsVariables => AdvanceActual.Concat(OverdueActual)", - "\n .Concat(DeferrableActual).Concat(Csms).Concat(Loss);", + "\n .Concat(Deferrable).Concat(Csms).Concat(Loss);", "\n}" ], "metadata": {}, diff --git a/ifrs17/Import/ImportStorage.ipynb b/ifrs17/Import/ImportStorage.ipynb index 25000183..588c1ce3 100644 --- a/ifrs17/Import/ImportStorage.ipynb +++ b/ifrs17/Import/ImportStorage.ipynb @@ -373,7 +373,7 @@ "\n if (patternFromCashflow.Any())", "\n return (amountType, Enumerable.Repeat(0d, patternShift).Concat(patternFromCashflow).ToArray());", "\n ", - "\n double[] patternFromParameter = default;", + "\n double[] patternFromParameter = Enumerable.Empty().ToArray();", "\n if(!SingleDataNodeParametersByGoc.TryGetValue(identity.DataNode, out var dataNodeParameterByPeriod))", "\n return (null, patternFromParameter);", "\n", @@ -389,7 +389,8 @@ "\n ", "\n public string GetEconomicBasisDriver(string dataNode) => ", "\n SingleDataNodeParametersByGoc.TryGetValue(dataNode, out var singleDataNodeParameter)", - "\n ? singleDataNodeParameter[CurrentPeriod].EconomicBasisDriver : default;", + "\n ? singleDataNodeParameter[CurrentPeriod].EconomicBasisDriver ", + "\n : GetDefaultEconomicBasisDriver(DataNodeDataBySystemName[dataNode].ValuationApproach, DataNodeDataBySystemName[dataNode].LiabilityType);", "\n ", "\n public bool IsInceptionYear(string dataNode) => SingleDataNodeParametersByGoc.TryGetValue(dataNode, out var singleDataNodeParameter)", "\n ? singleDataNodeParameter[CurrentPeriod].Year == CurrentReportingPeriod.Year : default;", @@ -416,6 +417,7 @@ "\n public IEnumerable GetAttributableExpenseAndCommissionAmountType() => hierarchyCache.Get(AmountTypes.ACA).Descendants(includeSelf : true).Select(x => x.SystemName)", "\n .Concat(hierarchyCache.Get(AmountTypes.AEA).Descendants(includeSelf : true).Select(x => x.SystemName));", "\n public IEnumerable GetInvestmentClaims() => hierarchyCache.Get(AmountTypes.ICO).Descendants(includeSelf : true).Select(x => x.SystemName);", + "\n public IEnumerable GetDeferrableExpenses() => hierarchyCache.Get(AmountTypes.DE).Descendants(includeSelf : true).Select(x => x.SystemName);", "\n public IEnumerable GetPremiums() => hierarchyCache.Get(AmountTypes.PR).Descendants(includeSelf : true).Select(x => x.SystemName);", "\n public IEnumerable GetClaims() => hierarchyCache.Get(AmountTypes.CL).Descendants().Select(x => x.SystemName);", "\n}" diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index ea6c34b1..36210b9b 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -244,12 +244,7 @@ "\n", "\n public string ValidateEconomicBasisDriver(string eb, string goc){", "\n if(string.IsNullOrEmpty(eb))", - "\n return (DataNodeDataBySystemName[goc].ValuationApproach, DataNodeDataBySystemName[goc].LiabilityType) switch {", - "\n (ValuationApproaches.BBA, _) => EconomicBases.L,", - "\n (ValuationApproaches.VFA, _) => EconomicBases.C,", - "\n (ValuationApproaches.PAA, LiabilityTypes.LIC) => EconomicBases.C,", - "\n _ => EconomicBases.N,", - "\n };", + "\n return GetDefaultEconomicBasisDriver(DataNodeDataBySystemName[goc].ValuationApproach, DataNodeDataBySystemName[goc].LiabilityType);", "\n if(!economicBasis.Contains(eb)){", "\n ApplicationMessage.Log(Error.InvalidEconomicBasisDriver, goc);", "\n return null;", @@ -521,6 +516,8 @@ "\n Year = args.Year, ", "\n Month = DefaultDataNodeActivationMonth, ", "\n PremiumAllocation = DefaultPremiumExperienceAdjustmentFactor, ", + "\n EconomicBasisDriver = GetDefaultEconomicBasisDriver(dataNodesDefined.SingleOrDefault(y => y.SystemName == x)?.ValuationApproach, ", + "\n dataNodesDefined.SingleOrDefault(y => y.SystemName == x)?.LiabilityType),", "\n Partition = partition.Id})", "\n .ToArray() );", "\n await targetDataSource.CommitAsync();", diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index c8f60f08..c86bb80e 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -138,8 +138,10 @@ "\n Novelty = iv.Novelty, ", "\n AmountType = iv.AmountType, ", "\n EconomicBasis = iv.EconomicBasis, ", - "\n AccidentYear = iv.AccidentYear == null ? default : (int)iv.AccidentYear,", - "\n ServicePeriod = goc.LiabilityType == LiabilityTypes.LIC", + "\n AccidentYear = goc.LiabilityType == LiabilityTypes.LIC && iv.AccidentYear.HasValue", + "\n ? iv.AccidentYear.Value", + "\n : default,", + "\n ServicePeriod = goc.LiabilityType == LiabilityTypes.LIC && iv.AccidentYear.HasValue", "\n ? iv.AccidentYear == args.Year ? ServicePeriod.CurrentService : ServicePeriod.PastService", "\n\t\t\t\t : ServicePeriod.NotApplicable,", "\n Projection = orderedProjectionConfigurations.ElementAtOrDefault(ind).SystemName,", diff --git a/ifrs17/Utils/ImportCalculationMethods.ipynb b/ifrs17/Utils/ImportCalculationMethods.ipynb index 384ccdae..3ab4e8a9 100644 --- a/ifrs17/Utils/ImportCalculationMethods.ipynb +++ b/ifrs17/Utils/ImportCalculationMethods.ipynb @@ -213,6 +213,31 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Economic Basis Driver default" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static string GetDefaultEconomicBasisDriver(string valuationApproach, string liabilityType) {", + "\n return (valuationApproach, liabilityType) switch {", + "\n (ValuationApproaches.BBA, _) => EconomicBases.L,", + "\n (ValuationApproaches.VFA, _) => EconomicBases.C,", + "\n (ValuationApproaches.PAA, LiabilityTypes.LIC) => EconomicBases.C,", + "\n _ => EconomicBases.N,", + "\n };", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [