diff --git a/ifrs17/Constants/Validations.ipynb b/ifrs17/Constants/Validations.ipynb index 0152a7e0..c49884e8 100644 --- a/ifrs17/Constants/Validations.ipynb +++ b/ifrs17/Constants/Validations.ipynb @@ -66,6 +66,7 @@ "\n NoMainTab, IncompleteMainTab, ParsingScientificNotation, ValueTypeNotFound, ValueTypeNotValid, ", "\n ReportingNodeInMainNotFound, YearInMainNotFound, MonthInMainNotFound, ScenarioInMainNotAvailable,", "\n AocTypeNotValid, AocTypeCompulsoryNotFound, AocTypePositionNotSupported, AocConfigurationOrderNotUnique,", + "\n AccidentYearTypeNotValid,", "\n // Partition", "\n PartitionNotFound, ParsedPartitionNotFound, PartititionNameNotFound, PartitionTypeNotFound,", "\n // Dimensions", @@ -122,6 +123,7 @@ "\n (Error.AocTypeCompulsoryNotFound , _) => $\"Not all compulsory AoC Types have been imported.\",", "\n (Error.AocTypePositionNotSupported , 1) => $\"The position of the AoC Type {s[0]} is not supported.\",", "\n (Error.AocConfigurationOrderNotUnique , _) => $\"Two or more AoC Configurations have the same Order.\",", + "\n (Error.AccidentYearTypeNotValid , 1) => $\"The parsed AccidentYear {s[0]} is invalid. Expected Accident Year input of type int.\",", "\n // Partition", "\n (Error.PartitionNotFound , _) => $\"Partition do not found.\",", "\n (Error.ParsedPartitionNotFound , 1) => $\"Parsed partition not available: ReportingNode {s[0]}.\",", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 7e899cdb..7b063015 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -1369,15 +1369,21 @@ "\n if(values.Length == 0 && !parsingStorage.MandatoryAocSteps.Contains(new AocStep(aocType, novelty))) return null;", "\n }", "\n ", + "\n int? accidentYear = default;", + "\n if(hasAccidentYearColumn && datarow.Field(nameof(RawVariable.AccidentYear)) != null) {", + "\n if(!Int32.TryParse(datarow.Field(nameof(RawVariable.AccidentYear)), out var parsedAccidentYear)) { ", + "\n ApplicationMessage.Log(Error.AccidentYearTypeNotValid, datarow.Field(nameof(RawVariable.AccidentYear))); return null;", + "\n }", + "\n else accidentYear = (int?)parsedAccidentYear;", + "\n }", + "\n ", "\n var item = new RawVariable {", "\n DataNode = dataNode,", "\n AocType = aocType,", "\n Novelty = novelty,", "\n AmountType = valueType.AmountType,", "\n EstimateType = valueType.EstimateType,", - "\n AccidentYear = hasAccidentYearColumn && Int32.TryParse((datarow.Field(nameof(RawVariable.AccidentYear))), out var accidentYear)", - "\n ? accidentYear", - "\n : (int?)null,", + "\n AccidentYear = accidentYear,", "\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,", "\n Values = Multiply(GetSign(ImportFormats.Cashflow, (aocType, valueType.AmountType, valueType.EstimateType, dataNodeData.IsReinsurance), parsingStorage.HierarchyCache), values)", "\n .Interpolate(parsingStorage.GetCashFlowPeriodicity(dataNode), parsingStorage.GetInterpolationMethod(dataNode))", @@ -1467,6 +1473,8 @@ "\n await parsingStorage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", + "\n var hasAccidentYearColumn = dataSet.Tables[ImportFormats.Actual].Columns.Any(x => x.ColumnName == nameof(IfrsVariable.AccidentYear));", + "\n", "\n var importLog = await Import.FromDataSet(dataSet)", "\n .WithType ( (dataset, datarow) => {", "\n var dataNode = datarow.Field(nameof(DataNode));", @@ -1487,11 +1495,20 @@ "\n var currentPeriodValue = GetSign(ImportFormats.Actual, ", "\n (aocType, valueType.AmountType, valueType.EstimateType, dataNodeData.IsReinsurance), ", "\n parsingStorage.HierarchyCache) * datarow.Field(\"Value\").CheckStringForExponentialAndConvertToDouble();", + "\n ", + "\n int? accidentYear = default;", + "\n if(hasAccidentYearColumn && datarow.Field(nameof(RawVariable.AccidentYear)) != null) {", + "\n if(!Int32.TryParse(datarow.Field(nameof(RawVariable.AccidentYear)), out var parsedAccidentYear)) { ", + "\n ApplicationMessage.Log(Error.AccidentYearTypeNotValid, datarow.Field(nameof(RawVariable.AccidentYear))); return null;", + "\n }", + "\n else accidentYear = (int?)parsedAccidentYear;", + "\n }", + "\n ", "\n var item = new IfrsVariable {", "\n DataNode = dataNode,", "\n AocType = aocType,", "\n Novelty = Novelties.C,", - "\n AccidentYear = Int32.TryParse((datarow.Field(nameof(IfrsVariable.AccidentYear))), out var tempAccYear)? tempAccYear : (int?)null,", + "\n AccidentYear = accidentYear,", "\n AmountType = valueType.AmountType,", "\n EstimateType = valueType.EstimateType,", "\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,", @@ -1574,6 +1591,8 @@ "\n await parsingStorage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish(); ", "\n", + "\n var hasAccidentYearColumn = dataSet.Tables[importFormat].Columns.Any(x => x.ColumnName == nameof(IfrsVariable.AccidentYear));", + "\n", "\n var importLog = await Import.FromDataSet(dataSet)", "\n .WithType ( (dataset, datarow) => {", "\n var dataNode = parsingStorage.ValidateDataNode(datarow.Field(nameof(DataNode)),importFormat);", @@ -1593,11 +1612,20 @@ "\n (aocStep.AocType, amountType, estimateType, parsingStorage.IsDataNodeReinsurance(dataNode)), ", "\n parsingStorage.HierarchyCache) * datarow.Field(\"Value\")", "\n .CheckStringForExponentialAndConvertToDouble();", + "\n", + "\n int? accidentYear = default;", + "\n if(hasAccidentYearColumn && datarow.Field(nameof(RawVariable.AccidentYear)) != null) {", + "\n if(!Int32.TryParse(datarow.Field(nameof(RawVariable.AccidentYear)), out var parsedAccidentYear)) { ", + "\n ApplicationMessage.Log(Error.AccidentYearTypeNotValid, datarow.Field(nameof(RawVariable.AccidentYear))); return null;", + "\n }", + "\n else accidentYear = (int?)parsedAccidentYear;", + "\n }", + "\n", "\n var iv = new IfrsVariable {", "\n DataNode = dataNode,", "\n AocType = aocStep.AocType,", "\n Novelty = aocStep.Novelty,", - "\n AccidentYear = Int32.TryParse((datarow.Field(nameof(IfrsVariable.AccidentYear))), out var accidentYear) ? accidentYear : (int?)null,", + "\n AccidentYear = accidentYear,", "\n AmountType = amountType,", "\n EstimateType = estimateType,", "\n EconomicBasis = economicBasis,",