Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log an Error for Invalid AY Types #316

Merged
merged 6 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ifrs17/Constants/Validations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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]}.\",",
Expand Down
47 changes: 44 additions & 3 deletions ifrs17/Import/Importers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1369,13 +1369,24 @@
"\n if(values.Length == 0 && !parsingStorage.MandatoryAocSteps.Contains(new AocStep(aocType, novelty))) return null;",
"\n }",
"\n ",
"\n var accidentYearInput = default(string);",
"\n if(hasAccidentYearColumn)",
"\n {",
"\n accidentYearInput = (datarow.Field<string>(nameof(RawVariable.AccidentYear)));",
"\n if(!Int32.TryParse(accidentYearInput, out _) && accidentYearInput != null) ",
"\n {",
"\n ApplicationMessage.Log(Error.AccidentYearTypeNotValid, accidentYearInput);",
"\n return null;",
"\n }",
"\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<string>(nameof(RawVariable.AccidentYear))), out var accidentYear)",
"\n AccidentYear = hasAccidentYearColumn && Int32.TryParse(accidentYearInput, out var accidentYear)",
"\n ? accidentYear",
"\n : (int?)null,",
"\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,",
Expand Down Expand Up @@ -1467,6 +1478,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<IfrsVariable> ( (dataset, datarow) => {",
"\n var dataNode = datarow.Field<string>(nameof(DataNode));",
Expand All @@ -1487,11 +1500,24 @@
"\n var currentPeriodValue = GetSign(ImportFormats.Actual, ",
"\n (aocType, valueType.AmountType, valueType.EstimateType, dataNodeData.IsReinsurance), ",
"\n parsingStorage.HierarchyCache) * datarow.Field<string>(\"Value\").CheckStringForExponentialAndConvertToDouble();",
"\n ",
"\n var accidentYearInput = default(string);",
"\n if(hasAccidentYearColumn)",
"\n {",
"\n accidentYearInput = (datarow.Field<string>(nameof(IfrsVariable.AccidentYear)));",
"\n if(!Int32.TryParse(accidentYearInput, out _) && accidentYearInput != default(string))",
"\n {",
"\n accidentYearInput = (datarow.Field<string>(nameof(IfrsVariable.AccidentYear)));",
"\n ApplicationMessage.Log(Error.AccidentYearTypeNotValid, accidentYearInput);",
"\n return null;",
"\n }",
"\n }",
"\n ",
"\n var item = new IfrsVariable {",
"\n DataNode = dataNode,",
"\n AocType = aocType,",
"\n Novelty = Novelties.C,",
"\n AccidentYear = Int32.TryParse((datarow.Field<string>(nameof(IfrsVariable.AccidentYear))), out var tempAccYear)? tempAccYear : (int?)null,",
"\n AccidentYear = Int32.TryParse(accidentYearInput, out var tempAccYear)? tempAccYear : (int?)null,",
"\n AmountType = valueType.AmountType,",
"\n EstimateType = valueType.EstimateType,",
"\n Partition = parsingStorage.TargetPartitionByReportingNodeAndPeriod.Id,",
Expand Down Expand Up @@ -1574,6 +1600,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<IfrsVariable> ( (dataset, datarow) => {",
"\n var dataNode = parsingStorage.ValidateDataNode(datarow.Field<string>(nameof(DataNode)),importFormat);",
Expand All @@ -1593,11 +1621,24 @@
"\n (aocStep.AocType, amountType, estimateType, parsingStorage.IsDataNodeReinsurance(dataNode)), ",
"\n parsingStorage.HierarchyCache) * datarow.Field<string>(\"Value\")",
"\n .CheckStringForExponentialAndConvertToDouble();",
"\n",
"\n var accidentYearInput = default(string);",
"\n if(hasAccidentYearColumn)",
"\n {",
"\n accidentYearInput = (datarow.Field<string>(nameof(IfrsVariable.AccidentYear)));",
"\n if(!Int32.TryParse(accidentYearInput, out _) && accidentYearInput != default(string))",
"\n {",
"\n accidentYearInput = (datarow.Field<string>(nameof(IfrsVariable.AccidentYear)));",
"\n ApplicationMessage.Log(Error.AccidentYearTypeNotValid, accidentYearInput);",
"\n return null;",
"\n }",
"\n }",
"\n",
"\n var iv = new IfrsVariable {",
"\n DataNode = dataNode,",
"\n AocType = aocStep.AocType,",
"\n Novelty = aocStep.Novelty,",
"\n AccidentYear = Int32.TryParse((datarow.Field<string>(nameof(IfrsVariable.AccidentYear))), out var accidentYear) ? accidentYear : (int?)null,",
"\n AccidentYear = Int32.TryParse(accidentYearInput, out var accidentYear) ? accidentYear : (int?)null,",
"\n AmountType = amountType,",
"\n EstimateType = estimateType,",
"\n EconomicBasis = economicBasis,",
Expand Down