diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 46802a93..e22c842f 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -1783,6 +1783,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 5ea716a5..cc57a4b7 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -746,8 +746,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 {", @@ -1193,8 +1193,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)", @@ -1692,8 +1692,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 ", @@ -2317,7 +2317,39 @@ { "cell_type": "code", "source": [ - "public interface ComputeIfrsVarsOpenings : ActualToIfrsVariable, DeferrableToIfrsVariable, TmToIfrsVariable", + "//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});", + "\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 , //Here Value2...etc would be needed. ", + "\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)", @@ -2336,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}"