Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
48 changes: 28 additions & 20 deletions ifrs17/Import/Importers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -527,28 +527,11 @@
"\n ImportArgs[] allArgs;",
"\n switch(format)",
"\n {",
"\n case ImportFormats.Cashflow:",
"\n case ImportFormats.Actual: ",
"\n case ImportFormats.Opening:",
"\n {",
"\n if(args.Scenario != null) return args.RepeatOnce().ToArray();",
"\n var secondaryArgs = await dataSource.Query<PartitionByReportingNodeAndPeriod>() ",
"\n .Where(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && x.Month == args.Month && x.Scenario != null)",
"\n .Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, format)).ToArrayAsync();",
"\n ",
"\n if(secondaryArgs.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", secondaryArgs.Select(x => x.Scenario)));",
"\n allArgs = args.RepeatOnce().Concat(secondaryArgs).ToArray();",
"\n break;",
"\n }",
"\n default: ",
"\n case ImportFormats.YieldCurve:",
"\n {",
"\n if(args.Scenario == null) {",
"\n var scenarios = format switch {",
"\n ImportFormats.YieldCurve => await dataSource.Query<YieldCurve>().Where(x => x.Year == args.Year && x.Month == args.Month && x.Scenario != null).Select(x => x.Scenario).Distinct().ToArrayAsync(),",
"\n ImportFormats.DataNodeParameter => await dataSource.Query<DataNodeParameter>().Where(x => x.Year == args.Year && x.Month == args.Month && x.Scenario != null).Select(x => x.Scenario).Distinct().ToArrayAsync()",
"\n };",
"\n var targetPartitions = await dataSource.Query<PartitionByReportingNodeAndPeriod>()",
"\n .Where(x => x.Year == args.Year && x.Month == args.Month && !scenarios.Contains(x.Scenario)).OrderBy(x => x.Scenario).ToArrayAsync();",
"\n var scenarios = await dataSource.Query<YieldCurve>().Where(x => x.Year == args.Year && x.Month == args.Month && x.Scenario != null).Select(x => x.Scenario).Distinct().ToArrayAsync();",
"\n var targetPartitions = await dataSource.Query<PartitionByReportingNodeAndPeriod>().Where(x => x.Year == args.Year && x.Month == args.Month && !scenarios.Contains(x.Scenario)).OrderBy(x => x.Scenario).ToArrayAsync();",
"\n var targetScenarios = targetPartitions.Where(x => x.Scenario != null).Select(x => x.Scenario);",
"\n if(targetScenarios.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", targetScenarios));",
"\n allArgs = targetPartitions.Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, ImportFormats.Cashflow)).ToArray();",
Expand All @@ -560,6 +543,31 @@
"\n }",
"\n break;",
"\n }",
"\n case ImportFormats.DataNodeParameter:",
"\n {",
"\n if(args.Scenario != null)",
"\n return (args with {ImportFormat = ImportFormats.Cashflow}).RepeatOnce().ToArray();",
"\n else {",
"\n var partitionByReportingNode = (await dataSource.Query<PartitionByReportingNode>().Where(x => x.ReportingNode == args.ReportingNode).ToArrayAsync()).Single().Id;",
"\n var scenarios = await dataSource.Query<DataNodeParameter>().Where(x => x.Partition == partitionByReportingNode && x.Year == args.Year && x.Month == args.Month && x.Scenario != null).Select(x => x.Scenario).Distinct().ToArrayAsync();",
"\n var targetPartitions = await dataSource.Query<PartitionByReportingNodeAndPeriod>().Where(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && x.Month == args.Month && !scenarios.Contains(x.Scenario)).OrderBy(x => x.Scenario).ToArrayAsync();",
"\n var targetScenarios = targetPartitions.Where(x => x.Scenario != null).Select(x => x.Scenario);",
"\n if(targetScenarios.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", targetScenarios));",
"\n allArgs = targetPartitions.Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, ImportFormats.Cashflow)).ToArray();",
"\n }",
"\n break;",
"\n }",
"\n default: ",
"\n {",
"\n if(args.Scenario != null) return args.RepeatOnce().ToArray();",
"\n var secondaryArgs = await dataSource.Query<PartitionByReportingNodeAndPeriod>() ",
"\n .Where(x => x.ReportingNode == args.ReportingNode && x.Year == args.Year && x.Month == args.Month && x.Scenario != null)",
"\n .Select(x => new ImportArgs(x.ReportingNode, x.Year, x.Month, default(Periodicity), x.Scenario, format)).ToArrayAsync();",
"\n ",
"\n if(secondaryArgs.Any()) ApplicationMessage.Log(Warning.ScenarioReCalculations, String.Join(\", \", secondaryArgs.Select(x => x.Scenario)));",
"\n allArgs = args.RepeatOnce().Concat(secondaryArgs).ToArray();",
"\n break;",
"\n }",
"\n }",
"\n return allArgs.Where(x => (!Scenarios.EnableScenario && x.Scenario == null) || Scenarios.EnableScenario).ToArray();",
"\n}"
Expand Down
2 changes: 1 addition & 1 deletion ifrs17/Report/ReportStorage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"\n }",
"\n",
"\n public async Task<HashSet<string>> GetScenariosAsync(string scenario) => ",
"\n scenario == \"Delta\" || scenario == \"All\" ",
"\n scenario == Scenarios.Delta || scenario == Scenarios.All",
"\n ? (await workspace.Query<PartitionByReportingNodeAndPeriod>().Select(x => x.Scenario).ToArrayAsync()).ToHashSet()",
"\n : scenario.RepeatOnce().ToHashSet();",
"\n}"
Expand Down