diff --git a/ifrs17-template/Constants/CalculationEngine.ipynb b/ifrs17-template/Constants/CalculationEngine.ipynb index 7d011d96..052892cc 100644 --- a/ifrs17-template/Constants/CalculationEngine.ipynb +++ b/ifrs17-template/Constants/CalculationEngine.ipynb @@ -22,11 +22,11 @@ "var projectName = \"ifrs17\";", "\nvar environmentName = \"v1.3.1\";", "\nvar notebookName = \"CalculationEngine\";", - "\nvar calculationEngine = $\"#!import \\\"../../{projectName}/{notebookName}\\\"\";" + "\nvar calculationEngine = $\"#!import \\\"../../{projectName}/{environmentName}/{notebookName}\\\"\";" ], "metadata": {}, "execution_count": 0, "outputs": [] } ] -} \ No newline at end of file +} diff --git a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb index d87aad73..11d9254c 100644 --- a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -508,7 +508,7 @@ "\nawait Workspace.ValidateDataNodeStatesAsync(persistentDataNodeDataByDataNode);", "\nActivity.HasErrors().Should().Be(true);", "\nvar log = Activity.Finish().Errors.First().ToString().Substring(40);", - "\n(log.Substring(0,log.Length-2) == Get(Error.ChangeDataNodeState, \"GIC1\")).Should().Be(true);" + "\n(log.Substring(0,log.Length-2) == Error.ChangeDataNodeState.GetMessage(\"GIC1\")).Should().Be(true);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ScenarioParametersImportTest.ipynb b/ifrs17-template/Test/ScenarioParametersImportTest.ipynb index ff8fd02e..0abc120e 100644 --- a/ifrs17-template/Test/ScenarioParametersImportTest.ipynb +++ b/ifrs17-template/Test/ScenarioParametersImportTest.ipynb @@ -260,7 +260,7 @@ { "cell_type": "code", "source": [ - "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Get(Warning.VariablesAlreadyImported)).Should().Be(true);" + "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Warning.VariablesAlreadyImported.GetMessage()).Should().Be(true);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb b/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb index 243164fd..cc65f604 100644 --- a/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb +++ b/ifrs17-template/Test/ScenarioYieldCurveImportTest.ipynb @@ -290,7 +290,7 @@ { "cell_type": "code", "source": [ - "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Get(Warning.VariablesAlreadyImported)).Should().Be(true);" + "((log.Warnings.FirstOrDefault()?.ToString().Remove(0,40).Remove(125,2)?? \"\") == Warning.VariablesAlreadyImported.GetMessage()).Should().Be(true);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Constants/Validations.ipynb b/ifrs17/Constants/Validations.ipynb index 49ecd6c5..b48ffbee 100644 --- a/ifrs17/Constants/Validations.ipynb +++ b/ifrs17/Constants/Validations.ipynb @@ -47,12 +47,15 @@ { "cell_type": "code", "source": [ - "public enum Warning {", - "\n // Import", - "\n ActiveDataNodeWithCashflowBOPI, VariablesAlreadyImported, VariablesAlreadyCalculated, ScenarioReCalculations, MandatoryAocStepMissing,", - "\n // Default", - "\n Generic", - "\n}; " + "public abstract class ValidationBase{", + "\n public string MessageCode {get; protected set;}", + "\n", + "\n protected ValidationBase(string messageCode){", + "\n this.MessageCode = messageCode;", + "\n }", + "\n", + "\n public abstract string GetMessage(params string[] s);", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -61,45 +64,30 @@ { "cell_type": "code", "source": [ - "public enum Error { ", - "\n // Import", - "\n NoMainTab, IncompleteMainTab, ParsingInvalidOrScientificValue, ValueTypeNotFound, ValueTypeNotValid, ", - "\n ReportingNodeInMainNotFound, YearInMainNotFound, MonthInMainNotFound, ScenarioInMainNotAvailable,", - "\n AocTypeNotValid, AocTypeCompulsoryNotFound, AocTypePositionNotSupported, AocConfigurationOrderNotUnique,", - "\n AccidentYearTypeNotValid,", - "\n // Partition", - "\n PartitionNotFound, ParsedPartitionNotFound, PartititionNameNotFound, PartitionTypeNotFound,", - "\n // Dimensions", - "\n AmountTypeNotFound, EstimateTypeNotFound, ReportingNodeNotFound, AocTypeMapNotFound, AocTypeNotFound, PortfolioGicNotFound, PortfolioGricNotFound, ", - "\n InvalidAmountTypeEstimateType, MultipleTechnicalMarginOpening, DimensionNotFound, NoScenarioOpening,", - "\n // Exchange Rate", - "\n ExchangeRateNotFound, ExchangeRateCurrency,", - "\n // Data Note State", - "\n ChangeDataNodeState, InactiveDataNodeState,", - "\n // Parameters", - "\n ReinsuranceCoverageDataNode, DuplicateInterDataNode, DuplicateSingleDataNode, MissingSingleDataNodeParameter, InvalidDataNode, InvalidDataNodeForOpening, InvalidCashFlowPeriodicity, MissingInterpolationMethod, InvalidInterpolationMethod, InvalidEconomicBasisDriver, InvalidReleasePattern,", - "\n // Storage", - "\n DataNodeNotFound, PartnerNotFound, PeriodNotFound, RatingNotFound, CreditDefaultRateNotFound, MissingPremiumAllocation, ReinsuranceCoverage, ", - "\n YieldCurveNotFound, YieldCurvePeriodNotApplicable, EconomicBasisNotFound, AccountingVariableTypeNotFound, InvalidGric, InvalidGic, ReleasePatternNotFound,", - "\n MissingPreviousPeriodData,", - "\n // Scopes", - "\n NotSupportedAocStepReference, MultipleEoP,", - "\n // Data completeness", - "\n MissingDataAtPosting, MissingCombinedLiability, MissingCoverageUnit, ", - "\n // Index", - "\n NegativeIndex,", - "\n // Default", - "\n Generic", - "\n};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Messages" + "public class Warning : ValidationBase{", + "\n", + "\n protected const string DefaultMessage = \"Warning not found.\";", + "\n", + "\n protected Warning(string messageCode) : base(messageCode) {}", + "\n", + "\n public static readonly Warning ActiveDataNodeWithCashflowBOPI = new Warning(nameof(ActiveDataNodeWithCashflowBOPI));", + "\n public static readonly Warning VariablesAlreadyImported = new Warning(nameof(VariablesAlreadyImported));", + "\n public static readonly Warning VariablesAlreadyCalculated = new Warning(nameof(VariablesAlreadyCalculated));", + "\n public static readonly Warning ScenarioReCalculations = new Warning(nameof(ScenarioReCalculations));", + "\n public static readonly Warning MandatoryAocStepMissing = new Warning(nameof(MandatoryAocStepMissing));", + "\n public static readonly Warning Generic = new Warning(nameof(Generic));", + "\n", + "\n public override string GetMessage(params string[] s) => (MessageCode, s.Length) switch{", + "\n (nameof(ActiveDataNodeWithCashflowBOPI), 1) => $\"Cash flow with AoC Type: {AocTypes.BOP} and Novelty: {Novelties.I} for Group of Contract {s[0]} is not allowed because previous period data are available.\",", + "\n (nameof(VariablesAlreadyImported), 0) => $\"The import of the current file does not contain any new data. Hence, no data will be saved or calculations will be performed.\",", + "\n (nameof(MandatoryAocStepMissing), 3) => $\"The AoC step ({s[0]}, {s[1]}) is not imported for ({s[2]}).\",", + "\n (nameof(ScenarioReCalculations), 1) => $\"The present Best Estimate import makes the result of dependent Scenarios out of date. Hence, the following Scenarios are re-calculated: {s[0]}.\", ", + "\n // Default", + "\n (nameof(Generic), _) => $\"{s[0]}\",", + "\n _ => DefaultMessage", + "\n };", + "\n ", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -108,110 +96,193 @@ { "cell_type": "code", "source": [ - "public static string Get (Error e, params string[] s) => (e, s.Length) switch ", - "\n{", - "\n // Import", - "\n (Error.NoMainTab , _) => $\"No Main tab in the parsed file.\",", - "\n (Error.IncompleteMainTab , _) => $\"Incomplete Main tab in the parsed file.\",", - "\n (Error.ParsingInvalidOrScientificValue, 1) => $\"While parsing found invalid value or real number in scientific notation: {s[0]}.\",", - "\n (Error.ValueTypeNotFound , _) => $\"Value Type not found.\",", - "\n (Error.ValueTypeNotValid , 1) => $\"The Value Type {s[0]} is invalid.\",", - "\n (Error.ReportingNodeInMainNotFound , _) => $\"Reporting Node missing from the Main tab.\",", - "\n (Error.YearInMainNotFound , _) => $\"Year missing from the Main tab.\",", - "\n (Error.MonthInMainNotFound , _) => $\"Month missing from the Main tab.\",", - "\n (Error.ScenarioInMainNotAvailable , 1) => $\"Scenario {s[0]} has not been defined.\",", - "\n (Error.AocTypeNotValid , 1) => $\"The parsed AoC Type {s[0]} is invalid.\",", - "\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]}.\",", - "\n (Error.ParsedPartitionNotFound , 4) => $\"Parsed partition not available: ReportingNode {s[0]}, Year {s[1]}, Month {s[2]}, Scenario {s[3]}.\",", - "\n (Error.PartitionTypeNotFound , 1) => $\"Partition type not found: {s[0]}.\",", - "\n // Dimensions", - "\n (Error.AmountTypeNotFound , 1) => $\"AmountType {s[0]} not found.\",", - "\n (Error.EstimateTypeNotFound , 1) => $\"EstimateType {s[0]} not found.\",", - "\n (Error.ReportingNodeNotFound , 1) => $\"Reporting Node {s[0]} not found.\",", - "\n (Error.AocTypeNotFound , 1) => $\"AoC Type {s[0]} not found.\",", - "\n (Error.AocTypeMapNotFound , 2) => $\"AoC Type {s[0]} and Novelty {s[1]} combination not defined in the mapping.\",", - "\n (Error.PortfolioGicNotFound , 2) => $\"Portfolio {s[0]} assigned to Group of Insurance Contract {s[1]} does not exist.\",", - "\n (Error.PortfolioGricNotFound , 2) => $\"Portfolio {s[0]} assigned to Group of Reinsurance Contract {s[1]} does not exist.\",", - "\n (Error.InvalidAmountTypeEstimateType , 2) => $\"Invalid combination of EstimateType {s[0]} and AmountType {s[1]}.\",", - "\n (Error.MultipleTechnicalMarginOpening , 1) => $\"Multiple opening for techincal margin are not allowed for DataNode {s[0]}.\",", - "\n (Error.DimensionNotFound , 2) => $\"Column {0} has unknown value {1}.\",", - "\n (Error.NoScenarioOpening , 0) => \"Only Best Estimate is valid Scenario for Openings\",", + "public class Error : ValidationBase{", + "\n", + "\n protected const string DefaultMessage = \"Error not found.\";", "\n ", - "\n // Exchange Rate", - "\n (Error.ExchangeRateNotFound , 2) => $\"Exchange Rate for {s[0]} {s[1]} is not present.\",", - "\n (Error.ExchangeRateCurrency , 1) => $\"{s[0]} does not have any Exchange Rate defined.\", ", - "\n // Data Node State", - "\n (Error.ChangeDataNodeState , 0) => $\"Data Node State can not change from Inactive state into Active state.\",", - "\n (Error.ChangeDataNodeState , 1) => $\"Data Node State for {s[0]} can not change from Inactive state into Active state.\",", - "\n (Error.ChangeDataNodeState , 3) => $\"Data Node State for {s[0]} can not change from {s[1]} state into {s[2]} state.\",", - "\n (Error.InactiveDataNodeState , 1) => $\"Data imported for inactive Data Node {s[0]}.\",", - "\n //Parameters", - "\n (Error.ReinsuranceCoverageDataNode , 2) => $\"Invalid Reinsurance Coverage parameter does not link a GroupOfReinsuranceContract to a GroupOfInsuranceContract. Provided GroupOfContracts are: {s[0]}, {s[1]}.\",", - "\n (Error.DuplicateInterDataNode , 2) => $\"Duplicated Inter-DataNode parameter for {s[0]}-{s[1]} is found.\",", - "\n (Error.DuplicateSingleDataNode , 1) => $\"Duplicated Single-DataNode parameter for {s[0]} is found.\",", - "\n (Error.MissingSingleDataNodeParameter , 1) => $\"Single DataNode Parameter for Data Node {s[0]} is not found.\",", - "\n (Error.InvalidDataNode , 1) => $\"Data imported for invalid Data Node {s[0]}.\",", - "\n (Error.InvalidDataNodeForOpening , 1) => $\"Data imported for invalid Data Node or for a Data Node after its inception year {s[0]}.\",", - "\n (Error.InvalidCashFlowPeriodicity , 1) => $\"Invalid CashFlowPeriodicity parameter for Data Node {s[0]}.\",", - "\n (Error.MissingInterpolationMethod , 1) => $\"Missing InterpolationMethod parameter for Data Node {s[0]}.\",", - "\n (Error.InvalidInterpolationMethod , 1) => $\"Invalid InterpolationMethod parameter for Data Node {s[0]}.\",", - "\n (Error.InvalidEconomicBasisDriver , 1) => $\"Invalid EconomicBasisDriver parameter for Data Node {s[0]}.\",", - "\n (Error.InvalidReleasePattern , 1) => $\"Invalid ReleasePattern parameters for Data Node {s[0]}.\",", + "\n protected Error(string messageCode) : base(messageCode) {}", + "\n", + "\n // Import Errors", + "\n public static readonly Error NoMainTab = new Error(nameof(NoMainTab));", + "\n public static readonly Error IncompleteMainTab = new Error(nameof(IncompleteMainTab));", + "\n public static readonly Error ParsingInvalidOrScientificValue = new Error(nameof(ParsingInvalidOrScientificValue));", + "\n public static readonly Error ValueTypeNotFound = new Error(nameof(ValueTypeNotFound));", + "\n public static readonly Error ValueTypeNotValid = new Error(nameof(ValueTypeNotValid));", + "\n public static readonly Error ReportingNodeInMainNotFound = new Error(nameof(ReportingNodeInMainNotFound));", + "\n public static readonly Error YearInMainNotFound = new Error(nameof(YearInMainNotFound));", + "\n public static readonly Error MonthInMainNotFound = new Error(nameof(MonthInMainNotFound));", + "\n public static readonly Error ScenarioInMainNotAvailable = new Error(nameof(ScenarioInMainNotAvailable));", + "\n public static readonly Error AocTypeNotValid = new Error(nameof(AocTypeNotValid));", + "\n public static readonly Error AocTypeCompulsoryNotFound = new Error(nameof(AocTypeCompulsoryNotFound));", + "\n public static readonly Error AocTypePositionNotSupported = new Error(nameof(AocTypePositionNotSupported));", + "\n public static readonly Error AocConfigurationOrderNotUnique = new Error(nameof(AocConfigurationOrderNotUnique));", + "\n public static readonly Error AccidentYearTypeNotValid = new Error(nameof(AccidentYearTypeNotValid));", + "\n", + "\n // Partition Errors", + "\n public static readonly Error PartitionNotFound = new Error(nameof(PartitionNotFound));", + "\n public static readonly Error ParsedPartitionNotFound = new Error(nameof(ParsedPartitionNotFound));", + "\n public static readonly Error PartititionNameNotFound = new Error(nameof(PartititionNameNotFound));", + "\n public static readonly Error PartitionTypeNotFound = new Error(nameof(PartitionTypeNotFound));", + "\n", + "\n // Dimensions Errors", + "\n public static readonly Error AmountTypeNotFound = new Error(nameof(AmountTypeNotFound));", + "\n public static readonly Error EstimateTypeNotFound = new Error(nameof(EstimateTypeNotFound)); ", + "\n public static readonly Error ReportingNodeNotFound = new Error(nameof(ReportingNodeNotFound));", + "\n public static readonly Error AocTypeMapNotFound = new Error(nameof(AocTypeMapNotFound));", + "\n public static readonly Error AocTypeNotFound = new Error(nameof(AocTypeNotFound));", + "\n public static readonly Error PortfolioGicNotFound = new Error(nameof(PortfolioGicNotFound));", + "\n public static readonly Error PortfolioGricNotFound = new Error(nameof(PortfolioGricNotFound));", + "\n public static readonly Error InvalidAmountTypeEstimateType = new Error(nameof(InvalidAmountTypeEstimateType));", + "\n public static readonly Error MultipleTechnicalMarginOpening = new Error(nameof(MultipleTechnicalMarginOpening));", + "\n public static readonly Error DimensionNotFound = new Error(nameof(DimensionNotFound));", + "\n public static readonly Error NoScenarioOpening = new Error(nameof(NoScenarioOpening));", + "\n", + "\n // Exchange Rate Errors", + "\n public static readonly Error ExchangeRateNotFound = new Error(nameof(ExchangeRateNotFound));", + "\n public static readonly Error ExchangeRateCurrency = new Error(nameof(ExchangeRateCurrency));", + "\n", + "\n // Data Node State Errors", + "\n public static readonly Error ChangeDataNodeState = new Error(nameof(ChangeDataNodeState));", + "\n public static readonly Error InactiveDataNodeState = new Error(nameof(InactiveDataNodeState));", + "\n", + "\n // Parameters Errors", + "\n public static readonly Error ReinsuranceCoverageDataNode = new Error(nameof(ReinsuranceCoverageDataNode));", + "\n public static readonly Error DuplicateInterDataNode = new Error(nameof(DuplicateInterDataNode));", + "\n public static readonly Error DuplicateSingleDataNode = new Error(nameof(DuplicateSingleDataNode));", + "\n public static readonly Error MissingSingleDataNodeParameter = new Error(nameof(MissingSingleDataNodeParameter));", + "\n public static readonly Error InvalidDataNode = new Error(nameof(InvalidDataNode));", + "\n public static readonly Error InvalidDataNodeForOpening = new Error(nameof(InvalidDataNodeForOpening));", + "\n public static readonly Error InvalidCashFlowPeriodicity = new Error(nameof(InvalidCashFlowPeriodicity));", + "\n public static readonly Error MissingInterpolationMethod = new Error(nameof(MissingInterpolationMethod));", + "\n public static readonly Error InvalidInterpolationMethod = new Error(nameof(InvalidInterpolationMethod));", + "\n public static readonly Error InvalidEconomicBasisDriver = new Error(nameof(InvalidEconomicBasisDriver));", + "\n public static readonly Error InvalidReleasePattern = new Error(nameof(InvalidReleasePattern));", + "\n", + "\n // Storage Errors", + "\n public static readonly Error DataNodeNotFound = new Error(nameof(DataNodeNotFound));", + "\n public static readonly Error PartnerNotFound = new Error(nameof(PartnerNotFound));", + "\n public static readonly Error PeriodNotFound = new Error(nameof(PeriodNotFound));", + "\n public static readonly Error RatingNotFound = new Error(nameof(RatingNotFound));", + "\n public static readonly Error CreditDefaultRateNotFound = new Error(nameof(CreditDefaultRateNotFound));", + "\n public static readonly Error MissingPremiumAllocation = new Error(nameof(MissingPremiumAllocation));", + "\n public static readonly Error ReinsuranceCoverage = new Error(nameof(ReinsuranceCoverage));", + "\n public static readonly Error YieldCurveNotFound = new Error(nameof(YieldCurveNotFound));", + "\n public static readonly Error YieldCurvePeriodNotApplicable = new Error(nameof(YieldCurvePeriodNotApplicable));", + "\n public static readonly Error EconomicBasisNotFound = new Error(nameof(EconomicBasisNotFound));", + "\n public static readonly Error AccountingVariableTypeNotFound = new Error(nameof(AccountingVariableTypeNotFound));", + "\n public static readonly Error InvalidGric = new Error(nameof(InvalidGric));", + "\n public static readonly Error InvalidGic = new Error(nameof(InvalidGic));", + "\n public static readonly Error ReleasePatternNotFound = new Error(nameof(ReleasePatternNotFound));", + "\n public static readonly Error MissingPreviousPeriodData = new Error(nameof(MissingPreviousPeriodData));", + "\n", + "\n // Scopes Errors; Range 110 -119", + "\n public static readonly Error NotSupportedAocStepReference = new Error(nameof(NotSupportedAocStepReference));", + "\n public static readonly Error MultipleEoP = new Error(nameof(MultipleEoP));", + "\n", + "\n // Data Completeness Errors; Range 120 - 129", + "\n public static readonly Error MissingDataAtPosting = new Error(nameof(MissingDataAtPosting));", + "\n public static readonly Error MissingCombinedLiability = new Error(nameof(MissingCombinedLiability));", + "\n public static readonly Error MissingCoverageUnit = new Error(nameof(MissingCoverageUnit));", + "\n", + "\n // Index Error ", + "\n public static readonly Error NegativeIndex = new Error(nameof(NegativeIndex));", + "\n", + "\n // Generic Errors", + "\n public static readonly Error Generic = new Error(nameof(Generic)); ", + "\n", + "\n public override string GetMessage (params string[] s) => (MessageCode, s.Length) switch{", + "\n // Import", + "\n (nameof(NoMainTab), 0) => $\"No Main tab in the parsed file.\", ", + "\n (nameof(IncompleteMainTab), _) => $\"Incomplete Main tab in the parsed file.\",", + "\n (nameof(ParsingInvalidOrScientificValue), 1) => $\"While parsing found invalid value or real number in scientific notation: {s[0]}.\",", + "\n (nameof(ValueTypeNotFound), _) => $\"Value Type not found.\",", + "\n (nameof(ValueTypeNotValid), 1) => $\"The Value Type {s[0]} is invalid.\",", + "\n (nameof(ReportingNodeInMainNotFound), _) => $\"Reporting Node missing from the Main tab.\",", + "\n (nameof(YearInMainNotFound), _) => $\"Year missing from the Main tab.\",", + "\n (nameof(MonthInMainNotFound), _) => $\"Month missing from the Main tab.\",", + "\n (nameof(ScenarioInMainNotAvailable), 1) => $\"Scenario {s[0]} has not been defined.\",", + "\n (nameof(AocTypeNotValid), 1) => $\"The parsed AoC Type {s[0]} is invalid.\",", + "\n (nameof(AocTypeCompulsoryNotFound), _) => $\"Not all compulsory AoC Types have been imported.\",", + "\n (nameof(AocTypePositionNotSupported), 1) => $\"The position of the AoC Type {s[0]} is not supported.\",", + "\n (nameof(AocConfigurationOrderNotUnique), _) => $\"Two or more AoC Configurations have the same Order.\",", + "\n (nameof(AccidentYearTypeNotValid), 1) => $\"The parsed AccidentYear {s[0]} is invalid. Expected Accident Year input of type int.\",", + "\n", + "\n // Partition", + "\n (nameof(PartitionNotFound), _) => $\"Partition do not found.\",", + "\n (nameof(ParsedPartitionNotFound), 1) => $\"Parsed partition not available: ReportingNode {s[0]}.\",", + "\n (nameof(ParsedPartitionNotFound), 4) => $\"Parsed partition not available: ReportingNode {s[0]}, Year {s[1]}, Month {s[2]}, Scenario {s[3]}.\",", + "\n (nameof(PartitionTypeNotFound), 1) => $\"Partition type not found: {s[0]}.\",", + "\n", + "\n // Dimensions", + "\n (nameof(AmountTypeNotFound), 1) => $\"AmountType {s[0]} not found.\",", + "\n (nameof(EstimateTypeNotFound), 1) => $\"EstimateType {s[0]} not found.\",", + "\n (nameof(ReportingNodeNotFound), 1) => $\"Reporting Node {s[0]} not found.\",", + "\n (nameof(AocTypeNotFound), 1) => $\"AoC Type {s[0]} not found.\",", + "\n (nameof(AocTypeMapNotFound), 2) => $\"AoC Type {s[0]} and Novelty {s[1]} combination not defined in the mapping.\",", + "\n (nameof(PortfolioGicNotFound), 2) => $\"Portfolio {s[0]} assigned to Group of Insurance Contract {s[1]} does not exist.\",", + "\n (nameof(PortfolioGricNotFound), 2) => $\"Portfolio {s[0]} assigned to Group of Reinsurance Contract {s[1]} does not exist.\",", + "\n (nameof(InvalidAmountTypeEstimateType), 2) => $\"Invalid combination of EstimateType {s[0]} and AmountType {s[1]}.\",", + "\n (nameof(MultipleTechnicalMarginOpening), 1) => $\"Multiple opening for techincal margin are not allowed for DataNode {s[0]}.\",", + "\n (nameof(DimensionNotFound), 2) => $\"Column {0} has unknown value {1}.\",", + "\n (nameof(NoScenarioOpening), 0) => \"Only Best Estimate is valid Scenario for Openings\",", "\n ", - "\n // Storage", - "\n (Error.DataNodeNotFound , 1) => $\"DataNode {s[0]} not found.\",", - "\n (Error.PartnerNotFound , 1) => $\"Partner not found for DataNode {s[0]}.\",", - "\n (Error.PeriodNotFound , 1) => $\"Invalid Period {s[0]} used during calculation. Allowed values are Current Period (0) and Previous Period (-1).\",", - "\n (Error.RatingNotFound , 1) => $\"Rating not found for Partner {s[0]}.\",", - "\n (Error.CreditDefaultRateNotFound , 1) => $\"Credit Default Rate not found for rating {s[0]}.\",", - "\n (Error.MissingPremiumAllocation , 1) => $\"Premium Allocation Rate not found for Group of Contract {s[0]}.\", // TODO: this is now a warning to be produced by a validation in the importers (default is 1)", - "\n (Error.ReinsuranceCoverage , 1) => $\"Reinsurance Allocation Rate not found for Group of Insurance Contract {s[0]}.\",", - "\n (Error.YieldCurveNotFound , 6) => $\"Yield Curve not found for DataNode {s[0]}, Currency {s[1]}, Year {s[2]}, Month {s[3]}, Scenario {(s[4] == null ? \"Best Estimate\" : s[4])} and Name {s[5]}.\",", - "\n (Error.YieldCurvePeriodNotApplicable , 2) => $\"YieldCurve period NotApplicable not valid for AoC Step with AoC Type {s[0]} and Novelty {s[1]}.\",", - "\n (Error.EconomicBasisNotFound , 1) => $\"EconomicBasis not valid for DataNode {s[0]}.\",", - "\n (Error.AccountingVariableTypeNotFound , 1) => $\"AccountingVariableType {s[0]} not found.\",", - "\n (Error.InvalidGric , 1) => $\"Invalid Group of Reinsurance Contract {s[0]} has been requested during calculation.\",", - "\n (Error.InvalidGic , 1) => $\"Invalid Group of Insurance Contract {s[0]} has been requested during calculation.\",", - "\n (Error.ReleasePatternNotFound , 2) => $\"Release pattern for Group of Contract {s[0]} and AmountType {s[1]} is not found.\",", - "\n (Error.MissingPreviousPeriodData , 3) => $\"Data for previous period (Year: {s[0]}, Month: {s[1]}) is missing for Group of contracts: {s[2]}.\",", - "\n // Scopes", - "\n (Error.NotSupportedAocStepReference , 1) => $\"Unsupported reference AoC Step for AoC Type {s[0]}.\",", - "\n (Error.MultipleEoP , 0) => $\"Closing Balance for both Csm and Lc are computed.\",", - "\n // Data Completeness", - "\n (Error.MissingDataAtPosting , 1) => $\"Missing imported data for {s[0]} DataNode.\",", - "\n (Error.MissingCombinedLiability , 2) => $\"Missing Combined Liability AoC Type for DataNode {s[0]} and AmountType {s[1]}.\",", - "\n (Error.MissingCoverageUnit , 1) => $\"Missing Coverage Unit cash flow for {s[0]} DataNode.\",", - "\n // Index", - "\n (Error.NegativeIndex , 0) => $\"Index was out of range. Must be non-negative.\",", - "\n // Default", - "\n (Error.Generic , _) => $\"{s[0]}\",", - "\n (_ , _) => $\"Error not found.\"", - "\n};", - "\n" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public static string Get (Warning w, params string[] s) => (w, s.Length) switch {", - "\n // Import", - "\n (Warning.ActiveDataNodeWithCashflowBOPI , 1) => $\"Cash flow with AoC Type: {AocTypes.BOP} and Novelty: {Novelties.I} for Group of Contract {s[0]} is not allowed because previous period data are available.\",", - "\n (Warning.VariablesAlreadyImported , 0) => $\"The import of the current file does not contain any new data. Hence, no data will be saved or calculations will be performed.\",", - "\n (Warning.MandatoryAocStepMissing , 3) => $\"The AoC step ({s[0]}, {s[1]}) is not imported for ({s[2]}).\",", - "\n (Warning.ScenarioReCalculations , 1) => $\"The present Best Estimate import makes the result of dependent Scenarios out of date. Hence, the following Scenarios are re-calculated: {s[0]}.\", ", - "\n // Default", - "\n (Warning.Generic , _) => $\"{s[0]}\",", - "\n (_ , _) => $\"Warning not found.\"", - "\n};" + "\n // Exchange Rate", + "\n (nameof(ExchangeRateNotFound), 2) => $\"Exchange Rate for {s[0]} {s[1]} is not present.\",", + "\n (nameof(ExchangeRateCurrency), 1) => $\"{s[0]} does not have any Exchange Rate defined.\",", + "\n", + "\n // Data Node State", + "\n (nameof(ChangeDataNodeState), 0) => $\"Data Node State can not change from Inactive state into Active state.\",", + "\n (nameof(ChangeDataNodeState), 1) => $\"Data Node State for {s[0]} can not change from Inactive state into Active state.\",", + "\n (nameof(ChangeDataNodeState), 3) => $\"Data Node State for {s[0]} can not change from {s[1]} state into {s[2]} state.\",", + "\n (nameof(InactiveDataNodeState), 1) => $\"Data imported for inactive Data Node {s[0]}.\",", + "\n", + "\n //Parameters", + "\n (nameof(ReinsuranceCoverageDataNode), 2) => $\"Invalid Reinsurance Coverage parameter does not link a GroupOfReinsuranceContract to a GroupOfInsuranceContract. Provided GroupOfContracts are: {s[0]}, {s[1]}.\",", + "\n (nameof(DuplicateInterDataNode), 2) => $\"Duplicated Inter-DataNode parameter for {s[0]}-{s[1]} is found.\",", + "\n (nameof(DuplicateSingleDataNode), 1) => $\"Duplicated Single-DataNode parameter for {s[0]} is found.\",", + "\n (nameof(MissingSingleDataNodeParameter), 1) => $\"Single DataNode Parameter for Data Node {s[0]} is not found.\",", + "\n (nameof(InvalidDataNode), 1) => $\"Data imported for invalid Data Node {s[0]}.\",", + "\n (nameof(InvalidDataNodeForOpening), 1) => $\"Data imported for invalid Data Node or for a Data Node after its inception year {s[0]}.\",", + "\n (nameof(InvalidCashFlowPeriodicity), 1) => $\"Invalid CashFlowPeriodicity parameter for Data Node {s[0]}.\",", + "\n (nameof(MissingInterpolationMethod), 1) => $\"Missing InterpolationMethod parameter for Data Node {s[0]}.\",", + "\n (nameof(InvalidInterpolationMethod), 1) => $\"Invalid InterpolationMethod parameter for Data Node {s[0]}.\",", + "\n (nameof(InvalidEconomicBasisDriver), 1) => $\"Invalid EconomicBasisDriver parameter for Data Node {s[0]}.\",", + "\n (nameof(InvalidReleasePattern), 1) => $\"Invalid ReleasePattern parameters for Data Node {s[0]}.\",", + "\n ", + "\n // Storage", + "\n (nameof(DataNodeNotFound), 1) => $\"DataNode {s[0]} not found.\",", + "\n (nameof(PartnerNotFound), 1) => $\"Partner not found for DataNode {s[0]}.\",", + "\n (nameof(PeriodNotFound), 1) => $\"Invalid Period {s[0]} used during calculation. Allowed values are Current Period (0) and Previous Period (-1).\",", + "\n (nameof(RatingNotFound), 1) => $\"Rating not found for Partner {s[0]}.\",", + "\n (nameof(CreditDefaultRateNotFound), 1) => $\"Credit Default Rate not found for rating {s[0]}.\",", + "\n (nameof(MissingPremiumAllocation), 1) => $\"Premium Allocation Rate not found for Group of Contract {s[0]}.\", // TODO: this is now a warning to be produced by a validation in the importers (default is 1)", + "\n (nameof(ReinsuranceCoverage), 1) => $\"Reinsurance Allocation Rate not found for Group of Insurance Contract {s[0]}.\",", + "\n (nameof(YieldCurveNotFound), 6) => $\"Yield Curve not found for DataNode {s[0]}, Currency {s[1]}, Year {s[2]}, Month {s[3]}, Scenario {(s[4] == null ? \"Best Estimate\" : s[4])} and Name {s[5]}.\",", + "\n (nameof(YieldCurvePeriodNotApplicable), 2) => $\"YieldCurve period NotApplicable not valid for AoC Step with AoC Type {s[0]} and Novelty {s[1]}.\",", + "\n (nameof(EconomicBasisNotFound), 1) => $\"EconomicBasis not valid for DataNode {s[0]}.\",", + "\n (nameof(AccountingVariableTypeNotFound), 1) => $\"AccountingVariableType {s[0]} not found.\",", + "\n (nameof(InvalidGric), 1) => $\"Invalid Group of Reinsurance Contract {s[0]} has been requested during calculation.\",", + "\n (nameof(InvalidGic), 1) => $\"Invalid Group of Insurance Contract {s[0]} has been requested during calculation.\",", + "\n (nameof(ReleasePatternNotFound), 2) => $\"Release pattern for Group of Contract {s[0]} and AmountType {s[1]} is not found.\",", + "\n (nameof(MissingPreviousPeriodData), 3) => $\"Data for previous period (Year: {s[0]}, Month: {s[1]}) is missing for Group of contracts: {s[2]}.\",", + "\n", + "\n // Scopes", + "\n (nameof(NotSupportedAocStepReference), 1) => $\"Unsupported reference AoC Step for AoC Type {s[0]}.\",", + "\n (nameof(MultipleEoP), 0) => $\"Closing Balance for both Csm and Lc are computed.\",", + "\n", + "\n // Data Completeness", + "\n (nameof(MissingDataAtPosting), 1) => $\"Missing imported data for {s[0]} DataNode.\",", + "\n (nameof(MissingCombinedLiability), 2) => $\"Missing Combined Liability AoC Type for DataNode {s[0]} and AmountType {s[1]}.\",", + "\n (nameof(MissingCoverageUnit), 1) => $\"Missing Coverage Unit cash flow for {s[0]} DataNode.\",", + "\n", + "\n // Index", + "\n (nameof(NegativeIndex), 0) => $\"Index was out of range. Must be non-negative.\", ", + "\n", + "\n // Default", + "\n (nameof(Generic), 1) => $\"{s[0]}\", ", + "\n _ => DefaultMessage", + "\n };", + "\n}" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Test/DataNodeParameterTest.ipynb b/ifrs17/Test/DataNodeParameterTest.ipynb index 758bf7e4..ed0263c0 100644 --- a/ifrs17/Test/DataNodeParameterTest.ipynb +++ b/ifrs17/Test/DataNodeParameterTest.ipynb @@ -186,9 +186,9 @@ "\nDataNodeInvalid1,DTR1.1,1", "\nDTR1.1,DataNodeInvalid2,1\";", "\n", - "\nvar errorsBm = new List(){Get(Error.InvalidDataNode, \"DataNodeInvalid0\"),", - "\n Get(Error.InvalidDataNode, \"DataNodeInvalid1\"),", - "\n Get(Error.InvalidDataNode, \"DataNodeInvalid2\")};" + "\nvar errorsBm = new List(){Error.InvalidDataNode.GetMessage(\"DataNodeInvalid0\"),", + "\n Error.InvalidDataNode.GetMessage(\"DataNodeInvalid1\"),", + "\n Error.InvalidDataNode.GetMessage(\"DataNodeInvalid2\")};" ], "metadata": {}, "execution_count": 0, @@ -231,8 +231,8 @@ "\nDTR1.1,DT1.1,1", "\nDT1.1,DTR1.1,1", "\n\";", - "\nvar errorsBm = new List(){Get(Error.DuplicateSingleDataNode, \"DT1.1\"),", - "\n Get(Error.DuplicateInterDataNode, \"DT1.1\",\"DTR1.1\"),};" + "\nvar errorsBm = new List(){Error.DuplicateSingleDataNode.GetMessage(\"DT1.1\"),", + "\n Error.DuplicateInterDataNode.GetMessage(\"DT1.1\",\"DTR1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -273,7 +273,7 @@ "\nDataNode,LinkedDataNode,ReinsuranceCoverage", "\nDT1.1,DT1.1,1", "\n\";", - "\nvar errorsBm = new List(){Get(Error.ReinsuranceCoverageDataNode, \"DT1.1\",\"DT1.1\")};" + "\nvar errorsBm = new List(){Error.ReinsuranceCoverageDataNode.GetMessage(\"DT1.1\",\"DT1.1\")};" ], "metadata": {}, "execution_count": 0, @@ -319,7 +319,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,Monthly,InvalidEntry", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidInterpolationMethod, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidInterpolationMethod.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -393,7 +393,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,Yearly,,", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidInterpolationMethod, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidInterpolationMethod.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -439,7 +439,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,A,,", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidCashFlowPeriodicity, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidCashFlowPeriodicity.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -477,7 +477,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,,Uniform,", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidCashFlowPeriodicity, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidCashFlowPeriodicity.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -514,7 +514,7 @@ "\nDataNode,PremiumAllocation,CashFlowPeriodicity,InterpolationMethod", "\nDT1.1,0.85,,,", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidCashFlowPeriodicity, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidCashFlowPeriodicity.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -560,7 +560,7 @@ "\nDataNode,PremiumAllocation,EconomicBasisDriver", "\nDT1.1,0.85,A", "\n\";", - "\nvar errorsBm = new List(){Get(Error.InvalidEconomicBasisDriver, \"DT1.1\"),};" + "\nvar errorsBm = new List(){Error.InvalidEconomicBasisDriver.GetMessage(\"DT1.1\"),};" ], "metadata": {}, "execution_count": 0, @@ -687,7 +687,7 @@ "\nDataNode,PremiumAllocation,ReleasePattern0,ReleasePattern1", "\nDT1.1,0.85,InvalidValue0,InvalidValue1", "\n\";", - "\nvar errorsBm = new List(){Get(Error.ParsingInvalidOrScientificValue, \"InvalidValue0\"),Get(Error.ParsingInvalidOrScientificValue, \"InvalidValue1\")};" + "\nvar errorsBm = new List(){Error.ParsingInvalidOrScientificValue.GetMessage(\"InvalidValue0\"), Error.ParsingInvalidOrScientificValue.GetMessage(\"InvalidValue1\")};" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Test/QueriesTest.ipynb b/ifrs17/Test/QueriesTest.ipynb index 7232f5c1..0d55a8ec 100644 --- a/ifrs17/Test/QueriesTest.ipynb +++ b/ifrs17/Test/QueriesTest.ipynb @@ -783,7 +783,7 @@ { "cell_type": "code", "source": [ - "var expectedErrorMessage = Get(Error.YieldCurveNotFound, \"DT1.1\", \"EUR\",\"2016\",\"12\",\"Best Estimate\",\"A\");", + "var expectedErrorMessage = Error.YieldCurveNotFound.GetMessage(\"DT1.1\", \"EUR\",\"2016\",\"12\",\"Best Estimate\",\"A\");", "\nvar errorMessage = activity.Errors.First().ToString();", "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true);" ], @@ -822,7 +822,7 @@ { "cell_type": "code", "source": [ - "var expectedErrorMessage = Get(Error.YieldCurveNotFound, \"DT1.1\", \"EUR\",\"2016\",\"9\",\"Best Estimate\",\"A\");", + "var expectedErrorMessage = Error.YieldCurveNotFound.GetMessage(\"DT1.1\", \"EUR\",\"2016\",\"9\",\"Best Estimate\",\"A\");", "\nvar errorMessage = activity.Errors.First().ToString();", "\nerrorMessage.Contains(expectedErrorMessage).Should().Be(true);" ], diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index 64c766ed..8e59018c 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -51,8 +51,8 @@ "\n ApplicationMessage.activity = activity;", "\n }", "\n ", - "\n public static Object Log (Error e, params string[] s) { log.LogError(Get(e,s)); return null; }", - "\n public static Object Log (Warning w, params string[] s) { log.LogWarning(Get(w,s)); return null; }", + "\n public static Object Log (Error e, params string[] s) { log.LogError(e.GetMessage(s)); return null; }", + "\n public static Object Log (Warning w, params string[] s) { log.LogWarning(w.GetMessage(s)); return null; }", "\n ", "\n public static Object Log (ActivityLog activityLog) {", "\n foreach(var error in activityLog.Errors) log.LogError(error.ToString());",