From 2adaf2aa4b6b1236bf2f3180f957a5bda8b4302c Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Fri, 10 Feb 2023 13:04:16 +0100 Subject: [PATCH 01/55] copying over --- .../Report/ReportConfigurationAndUtils.ipynb | 32 + ifrs17/Report/ReportMutableScopes2.ipynb | 769 ++++++++++++++++++ ifrs17/Report/ReportStorage.ipynb | 10 + 3 files changed, 811 insertions(+) create mode 100644 ifrs17/Report/ReportMutableScopes2.ipynb diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index 5d077303..ba5f5ad2 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -183,6 +183,38 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Mutable Reporting Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static async Task<(IDictionary, IReadOnlyCollection)> GetAutocompleteMappings (this IQuerySource querySource, bool hasNullAsFirstValue = default) where T : KeyedDimension {", + "\n var query = await querySource.Query().Select(x => new { x.SystemName, GuiName = $\"{x.DisplayName} ({x.SystemName})\", Order = 0 }).ToArrayAsync();", + "\n var mappingDictionary = query.ToDictionary(x => x.GuiName, x => x.SystemName);", + "\n var orderedDropDownValues = query.OrderBy(x => x.Order).ThenBy(x => x.GuiName).Select(x => x.GuiName);", + "\n return (mappingDictionary, (hasNullAsFirstValue ? new string[]{ null }.Concat(orderedDropDownValues) : orderedDropDownValues).ToArray());", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static string ParseReportingPeriodToDisplayString(int year, int periodOfYear, char separator) => $\"{year} {separator}{periodOfYear}\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ diff --git a/ifrs17/Report/ReportMutableScopes2.ipynb b/ifrs17/Report/ReportMutableScopes2.ipynb new file mode 100644 index 00000000..e87a7edf --- /dev/null +++ b/ifrs17/Report/ReportMutableScopes2.ipynb @@ -0,0 +1,769 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "", + "\n

Report Mutable Scopes

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This notebook contains the set up of mutable scopes used to achieve high interactivity with reports." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# References", + "\nLibraries and other notebooks which are needed for this notebook are imported below." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"ReportScopes\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Form Entity Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Helper Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface MutableScopeWithWorkspace : IMutableScopeWithStorage {", + "\n protected IWorkspace workspace => GetStorage().Workspace; ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Currency Type" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface CurrencyFormsEntity : IMutableScope {", + "\n [DropdownEnum(typeof(CurrencyType))]", + "\n CurrencyType CurrencyType { get; set; } ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ScenarioFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownMethod(nameof(GetScenarioAutocompleteAsync))]", + "\n [Display(Name = \"Scenario\")]", + "\n string ScenarioControl { get; set; }", + "\n", + "\n [NotVisible] IDictionary ScenarioMapping { get; set; }", + "\n protected string Scenario => !string.IsNullOrWhiteSpace(ScenarioControl) && ScenarioMapping is not null && ScenarioMapping.TryGetValue(ScenarioControl, out var value) ? value : null;", + "\n ", + "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", + "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", + "\n } ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reporting Node" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportingNode))]", + "\npublic interface ReportingNodeFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownMethod(nameof(GetReportingNodeAutocompleteAsync))]", + "\n [Display(Name = \"ReportingNode\")]", + "\n string ReportingNodeControl { get; set; }", + "\n", + "\n [NotVisible] IDictionary ReportingNodeMapping { get; set; }", + "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue( ReportingNodeControl, out var value)", + "\n ? value", + "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", + "\n", + "\n async Task> GetReportingNodeAutocompleteAsync(string userInput, int page, int pageSize) {", + "\n (ReportingNodeMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", + "\n }", + "\n", + "\n async void InitReportingNode() {", + "\n ReportingNodeControl = GetStorage().InitialReportingNode.DisplayName;", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reporting Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Monthly Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportingPeriod))]", + "\npublic interface MonthlyPeriodFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownMethod(nameof(GetReportingPeriodAutocompleteAsync))]", + "\n string ReportingPeriod { get; set; }", + "\n", + "\n private char separator => 'M';", + "\n private string[] ReportingPeriodSplit => ReportingPeriod.Split(separator);", + "\n private int ParseReportingPeriod(int index) => !string.IsNullOrWhiteSpace(ReportingPeriod) && ReportingPeriodSplit is not null && Int32.TryParse(ReportingPeriodSplit.ElementAtOrDefault(index), out int value)", + "\n ? value", + "\n : default;", + "\n", + "\n protected int Year => ParseReportingPeriod(0);", + "\n protected int Month => ParseReportingPeriod(1);", + "\n", + "\n async Task> GetReportingPeriodAutocompleteAsync(string userInput, int page, int pageSize) => ", + "\n await workspace.Query()", + "\n .Where(x => x.Scenario == null)", + "\n .OrderByDescending(x => x.Year)", + "\n .ThenByDescending(x => x.Month)", + "\n .Select(x => ParseReportingPeriodToDisplayString(x.Year, x.Month, separator))", + "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", + "\n .ToArrayAsync();", + "\n", + "\n async void InitReportingPeriod() {", + "\n ReportingPeriod = ParseReportingPeriodToDisplayString(GetStorage().InitialReportingPeriod.Year, GetStorage().InitialReportingPeriod.Month, separator);", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Filters" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", + "\n string FilterName { get; set; }", + "\n", + "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", + "\n string FilterValue { get; set; }", + "\n", + "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", + "\n string FilterAction { get; set; }", + "\n ", + "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", + "\n new string[]{ null }.Concat(", + "\n await (FilterName switch", + "\n {", + "\n \"GroupOfContract\" => workspace.Query().Select(x => x.SystemName),", + "\n \"Novelty\" => workspace.Query().Select(x => x.SystemName),", + "\n \"EconomicBasis\" => workspace.Query().Select(x => x.SystemName),", + "\n _ => Enumerable.Empty().AsQueryable()", + "\n }) .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).OrderBy(x => x).ToArrayAsync()).ToArray();", + "\n ", + "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", + "\n ", + "\n // This is just a cast... do we need this?", + "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null ? Enumerable.Empty<(string, object)>() : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", + "\n", + "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", + "\n {", + "\n if(FilterAction == \"Add\")", + "\n AddFilter(FilterName, FilterValue);", + "\n if(FilterAction == \"Remove\")", + "\n RemoveFilter(FilterName, FilterValue);", + "\n return InputDataFilter;", + "\n }", + "\n", + "\n private void AddFilter(string filterName, string filterValue)", + "\n {", + "\n if(InputDataFilter == null)", + "\n InputDataFilter = Enumerable.Empty<(string, string)>().ToArray();", + "\n if(!InputDataFilter.Contains((filterName, filterValue)))", + "\n InputDataFilter = InputDataFilter.Append((filterName, filterValue)).ToArray();", + "\n }", + "\n ", + "\n private void RemoveFilter(string filterName, string filterValue)", + "\n {", + "\n if(InputDataFilter != null && InputDataFilter.Contains((filterName, filterValue)))", + "\n { var f = InputDataFilter.ToList();", + "\n f.Remove((filterName, filterValue));", + "\n InputDataFilter = f.ToArray();", + "\n }", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Slice and Dice" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface BasicSliceAndDiceFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownValues(\"\", \"GroupOfContract\")]", + "\n string SliceRowName { get; set; }", + "\n", + "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", + "\n string SliceColumnName { get; set; }", + "\n", + "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", + "\n [NotVisible] IReadOnlyCollection defaultRowSlices { get; set; }", + "\n protected string[] rowSlices => defaultRowSlices.Union(InputRowSlices).ToArray();", + "\n", + "\n protected IReadOnlyCollection InputColumnSlices => (SliceColumnName is null ? Enumerable.Empty() : SliceColumnName.RepeatOnce()).ToArray();", + "\n [NotVisible] IReadOnlyCollection defaultColumnSlices { get; set; }", + "\n protected string[] columnSlices => defaultColumnSlices.Union(InputColumnSlices).ToArray();", + "\n", + "\n IReadOnlyCollection GetSliceColumnNameAutocomplete() => new [] {\"\", \"GroupOfContract\", \"AmountType\"};", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Report Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportStorageScopeAsync))]", + "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, BasicSliceAndDiceFormsEntity, BasicFilterFormsEntity {", + "\n protected Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report => GetStorage().Report;", + "\n protected int headerColumnWidthValue => 250;", + "\n", + "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", + "\n IDataCube GetDataCube(IDataCube data) => InputDataFilter == null ? data : data.Filter(dataFilter);", + "\n ", + "\n async Task GetReportTaskAsync(IDataCube data) {", + "\n return await report.ForDataCube(data)", + "\n .WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices)", + "\n .ReportGridOptions(headerColumnWidth: headerColumnWidthValue)", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task InitReportStorageScopeAsync() { // This has the Async issue, but imo it should come in the future", + "\n await GetStorage().InitializeReportIndependentCacheAsync();", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", + "\n IDataCube DataCube { get; set; }", + "\n ", + "\n IDataCube Cube { get {", + "\n if(DataCube is null) return Enumerable.Empty().ToDataCube();", + "\n", + "\n if(Identity.scenario != \"Delta\") return DataCube;", + "\n var bestEstimateById = DataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", + "\n return DataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0d) }).ToDataCube();", + "\n }}", + "\n} " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Report Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Best Estimate PV" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface PvReport : ReportScope {", + "\n", + "\n public IDataCube GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", + "\n", + "\n async Task ToReportAsync() {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.DataCube = GetData();", + "\n return await GetReportTaskAsync(dataScope.DataCube);", + "\n return await GetReportTaskAsync(GetDataCube(GetData()));", + "\n }", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Risk Adjustment PV" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Mutable Scope" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The IIfrs17Report mutable scope is created with applicabilities to control how the data for each individual report is retrieved from the [report scopes](./ReportScopes)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ReportUniverse : IMutableScopeWithStorage{}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitAsync))]", + "\npublic interface IIfrs17Report : IMutableScope {", + "\n // Infrastructure", + "\n protected IWorkspace workspace => GetStorage().Workspace;", + "\n protected Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report => GetStorage().Report;", + "\n", + "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", + "\n builder.ForScope(s => s.WithApplicability(x => x.Identity == nameof(PvReport))", + "\n .WithApplicability(x => x.Identity == nameof(RaReport))", + "\n .WithApplicability(x => x.Identity == nameof(WrittenReport))", + "\n .WithApplicability(x => x.Identity == nameof(AccrualReport))", + "\n .WithApplicability(x => x.Identity == nameof(DeferralReport))", + "\n .WithApplicability(x => x.Identity == nameof(FcfReport))", + "\n .WithApplicability(x => x.Identity == nameof(ExpAdjReport))", + "\n .WithApplicability(x => x.Identity == nameof(TmReport))", + "\n .WithApplicability(x => x.Identity == nameof(CsmReport))", + "\n .WithApplicability(x => x.Identity == nameof(ActLrcReport))", + "\n .WithApplicability(x => x.Identity == nameof(LrcReport))", + "\n .WithApplicability(x => x.Identity == nameof(ActLicReport))", + "\n .WithApplicability(x => x.Identity == nameof(LicReport))", + "\n .WithApplicability(x => x.Identity == nameof(FpReport))", + "\n );", + "\n", + "\n // Basic mutable properties", + "\n (int Year, int Month) ReportingPeriod { get; set; }", + "\n int Year => ReportingPeriod.Year;", + "\n int Month => ReportingPeriod.Month;", + "\n string ReportingNode { get; set; }", + "\n string Scenario { get; set; } // TODO: Enable dropdown selection including All and Delta", + "\n string Comparison { get; set; } // TODO: only for scenario at the beginning, meant to enable general purpose comparisons ", + "\n CurrencyType CurrencyType { get; set; }", + "\n ", + "\n ((int Year, int Month) ReportingPeriod, string ReportingNode, string Scenario, CurrencyType) ShowSettings => (ReportingPeriod, ReportingNode, Scenario, CurrencyType);", + "\n ", + "\n // Slice and Dice", + "\n protected string[] forbiddenSlices => new string[] { };", + "\n", + "\n IEnumerable RowSlices { get; set; }", + "\n protected string[] defaultRowSlices => new string[] { };", + "\n protected string[] rowSlices => RowSlices is null ? defaultRowSlices : defaultRowSlices.Concat(RowSlices).Where(x => !forbiddenSlices.Contains(x)).ToArray();", + "\n", + "\n IEnumerable ColumnSlices { get; set; }", + "\n protected string[] defaultColumnSlices => new string[] { };", + "\n protected string[] columnSlices { get{", + "\n var slices = ColumnSlices is null ? defaultColumnSlices : defaultColumnSlices.Where(cs => !ColumnSlices.Contains(cs)).Concat(ColumnSlices).Where(x => !forbiddenSlices.Contains(x)).ToArray();", + "\n return Scenario == \"All\" || Scenario == \"Delta\"", + "\n ? slices.Concat(nameof(Scenario).RepeatOnce()).ToArray() ", + "\n : Scenario is null ? slices : nameof(Scenario).RepeatOnce().Concat(slices).ToArray();", + "\n }}", + "\n", + "\n // Identities", + "\n protected HashSet<(ReportIdentity, CurrencyType)> GetIdentities() => GetStorage().GetIdentities(ReportingPeriod, ReportingNode, Scenario, CurrencyType);", + "\n ", + "\n // Filter", + "\n IEnumerable<(string filterName, string filterValue)> DataFilter { get; set; }", + "\n protected (string filterName, object filterValue)[] dataFilter => (DataFilter is null ? Enumerable.Empty<(string, object)>() : DataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", + "\n", + "\n // Scope Initialization", + "\n async Task InitAsync() {", + "\n var mostRecentPartition = (await workspace.Query().Where(x => x.Scenario == null).OrderBy(x => x.Year).ThenBy(x => x.Month).ToArrayAsync()).Last(); ", + "\n ReportingPeriod = (mostRecentPartition.Year, mostRecentPartition.Month);", + "\n ReportingNode = (await workspace.Query().Where(x => x.Parent == null).ToArrayAsync()).First().SystemName; // TODO: change once user permissions are available", + "\n Scenario = null;", + "\n CurrencyType = CurrencyType.Contractual;", + "\n await GetStorage().InitializeReportIndependentCacheAsync();", + "\n } ", + "\n", + "\n //Report", + "\n public IDataCube GetDataCube() => default;", + "\n protected int headerColumnWidthValue => 250;", + "\n public Task ToReportAsync => GetReportTaskAsync();", + "\n private async Task GetReportTaskAsync() {", + "\n await GetStorage().InitializeAsync(ReportingPeriod, ReportingNode, Scenario, CurrencyType); ", + "\n return await report.ForDataCube(GetScope((ReportingPeriod, ReportingNode, Scenario, CurrencyType, Identity, dataFilter)).Cube)", + "\n .WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices)", + "\n .ReportGridOptions(headerColumnWidth: headerColumnWidthValue)", + "\n .ExecuteAsync();", + "\n }", + "\n}", + "\n", + "\npublic interface PvReport : IIfrs17Report {", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] { \"Novelty\", \"VariableType\" };", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? (GetScopes(GetIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetIdentities()).Aggregate().CurrentBestEstimate)", + "\n : (GetScopes(GetIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetIdentities()).Aggregate().CurrentBestEstimate).Filter(dataFilter);", + "\n}", + "\n", + "\npublic interface RaReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] { \"Novelty\", \"VariableType\" };", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().LockedRiskAdjustment + ", + "\n GetScopes(GetIdentities()).Aggregate().CurrentRiskAdjustment", + "\n : GetScopes(GetIdentities()).Aggregate().LockedRiskAdjustment.Filter(dataFilter) + ", + "\n GetScopes(GetIdentities()).Aggregate().CurrentRiskAdjustment.Filter(dataFilter);", + "\n}", + "\n", + "\npublic interface WrittenReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {nameof(EconomicBasis)};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"AmountType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\"};", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().Written", + "\n : GetScopes(GetIdentities()).Aggregate().Written.Filter(dataFilter);", + "\n}", + "\n", + "\npublic interface AccrualReport : IIfrs17Report {", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\"};", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().Advance + ", + "\n GetScopes(GetIdentities()).Aggregate().Overdue", + "\n : GetScopes(GetIdentities()).Aggregate().Advance.Filter(dataFilter) + ", + "\n GetScopes(GetIdentities()).Aggregate().Overdue.Filter(dataFilter);", + "\n}", + "\n", + "\npublic interface DeferralReport : IIfrs17Report {", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().Deferrals", + "\n : GetScopes(GetIdentities()).Aggregate().Deferrals.Filter(dataFilter);", + "\n}", + "\n", + "\npublic interface FcfReport : IIfrs17Report {", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\",\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().Fcf", + "\n : GetScopes(GetIdentities()).Aggregate().Fcf.Filter(dataFilter);", + "\n}", + "\n", + "\npublic interface ExpAdjReport : IIfrs17Report {", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"EstimateType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"AmountType\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().ActuarialExperienceAdjustment", + "\n : GetScopes(GetIdentities()).Aggregate().ActuarialExperienceAdjustment.Filter(dataFilter);", + "\n}", + "\npublic interface TmReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\", nameof(EconomicBasis)};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\", \"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().LrcTechnicalMargin", + "\n : GetScopes(GetIdentities()).Aggregate().LrcTechnicalMargin.Filter(dataFilter);", + "\n}", + "\npublic interface CsmReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\", nameof(EconomicBasis)};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\", \"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().Csm + ", + "\n GetScopes(GetIdentities()).Aggregate().Lc + ", + "\n GetScopes(GetIdentities()).Aggregate().Loreco", + "\n : GetScopes(GetIdentities()).Aggregate().Csm.Filter(dataFilter) + ", + "\n GetScopes(GetIdentities()).Aggregate().Lc.Filter(dataFilter) + ", + "\n GetScopes(GetIdentities()).Aggregate().Loreco.Filter(dataFilter);", + "\n}", + "\npublic interface ActLrcReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\",\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().LrcActuarial", + "\n : GetScopes(GetIdentities()).Aggregate().LrcActuarial.Filter(dataFilter);", + "\n}", + "\npublic interface LrcReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().Lrc", + "\n : GetScopes(GetIdentities()).Aggregate().Lrc.Filter(dataFilter);", + "\n}", + "\npublic interface ActLicReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\",\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().LicActuarial", + "\n : GetScopes(GetIdentities()).Aggregate().LicActuarial.Filter(dataFilter);", + "\n}", + "\npublic interface LicReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().Lic", + "\n : GetScopes(GetIdentities()).Aggregate().Lic.Filter(dataFilter);", + "\n}", + "\npublic interface FpReport : IIfrs17Report {", + "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\", nameof(EconomicBasis)};", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\", \"EstimateType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\",\"LiabilityType\" };", + "\n int IIfrs17Report.headerColumnWidthValue => 500;", + "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", + "\n ? GetScopes(GetIdentities()).Aggregate().FinancialPerformance", + "\n : GetScopes(GetIdentities()).Aggregate().FinancialPerformance.Filter(dataFilter);", + "\n}", + "\n", + "\npublic interface Data : IMutableScope<((int year, int month) period, string reportingNode, string scenario, CurrencyType currencyType, ", + "\n string reportType, (string filterName, object filterValue)[] dataFilter)> ", + "\n{", + "\n IDataCube Cube { get{", + "\n var dataCube = GetScope(Identity.reportType).GetDataCube();", + "\n // TODO: suggestion to place the filter here instead of having it in every applicability scope", + "\n if(Identity.scenario != \"Delta\") return dataCube;", + "\n var bestEstimateById = dataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", + "\n return dataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0.0) }).ToDataCube();", + "\n }}", + "\n} " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# IFRS 17 Reports" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This class is used to trigger the calculation of the reports and it is exposed to the end-user in the reports." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public class Ifrs17 ", + "\n{", + "\n private Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes;", + "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", + "\n private ReportStorage Storage;", + "\n private ReportUniverse reportUniverse;", + "\n ", + "\n //reset", + "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report);", + "\n", + "\n //constructor", + "\n public Ifrs17 (IWorkspace workspace, Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report)", + "\n {", + "\n this.scopes = scopes; ", + "\n this.report = report; ", + "\n Storage = new ReportStorage(workspace, report);", + "\n reportUniverse = scopes.ForSingleton().WithStorage(Storage).ToScope();", + "\n }", + "\n", + "\n public IIfrs17Report PresentValues => reportUniverse.GetScope();", + "\n public IIfrs17Report RiskAdjustments => reportUniverse.GetScope();", + "\n public IIfrs17Report WrittenActuals => reportUniverse.GetScope();", + "\n public IIfrs17Report AccrualActuals => reportUniverse.GetScope();", + "\n public IIfrs17Report DeferralActuals => reportUniverse.GetScope();", + "\n public IIfrs17Report FulfillmentCashflows => reportUniverse.GetScope();", + "\n public IIfrs17Report ExperienceAdjustments => reportUniverse.GetScope();", + "\n public IIfrs17Report TechnicalMargins => reportUniverse.GetScope();", + "\n public IIfrs17Report AllocatedTechnicalMargins => reportUniverse.GetScope();", + "\n public IIfrs17Report ActuarialLrc => reportUniverse.GetScope();", + "\n public IIfrs17Report Lrc => reportUniverse.GetScope();", + "\n public IIfrs17Report ActuarialLic => reportUniverse.GetScope();", + "\n public IIfrs17Report Lic => reportUniverse.GetScope();", + "\n public IIfrs17Report FinancialPerformance => reportUniverse.GetScope();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Report/ReportStorage.ipynb b/ifrs17/Report/ReportStorage.ipynb index e2f9e843..2e3ea856 100644 --- a/ifrs17/Report/ReportStorage.ipynb +++ b/ifrs17/Report/ReportStorage.ipynb @@ -114,6 +114,10 @@ "\n // Current Storage Settings", "\n public ((int Year, int Month) Period, string ReportingNode, string Scenario, CurrencyType CurrencyType) Args {get; private set;}", "\n ", + "\n // Initial Values for Scopes DropDowns", + "\n public (string DisplayName, string SystemName) InitialReportingNode {get; private set;}", + "\n public (int Year, int Month) InitialReportingPeriod {get; private set;}", + "\n", "\n // Aux Data", "\n private Dictionary<(int year, int month), Dictionary>> exchangeRatesByCurrencyByFxTypeAndPeriod = new(); // Fx Rates", "\n private Dictionary<(int year, int month), Dictionary> fxPeriodsByAocStepAndPeriod = new(); // FxParameter", @@ -139,6 +143,12 @@ "\n await hierarchicalDimensionCache.InitializeAsync(); ", "\n await hierarchicalDimensionCache.InitializeAsync();", "\n await hierarchicalDimensionCache.InitializeAsync();", + "\n", + "\n // Initial Values", + "\n var mostRecentPartition = (await workspace.Query().Where(x => x.Scenario == null).OrderBy(x => x.Year).ThenBy(x => x.Month).ToArrayAsync()).Last();", + "\n InitialReportingPeriod = (mostRecentPartition.Year, mostRecentPartition.Month);", + "\n var rootReportingNode = (await workspace.Query().Where(x => x.Parent == null).ToArrayAsync()).First();", + "\n InitialReportingNode = (rootReportingNode.DisplayName, rootReportingNode.SystemName);", "\n }", "\n ", "\n public async Task InitializeAsync((int year, int month) period, string reportingNode, string scenario, CurrencyType currencyType) {", From 91227a51946a8706b9df4ec269118522aee6341f Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Fri, 10 Feb 2023 15:29:29 +0100 Subject: [PATCH 02/55] end of week version --- .../Report/InteractiveReports.ipynb | 81 ++ ifrs17/CalculationEngine.ipynb | 10 + .../Report/ReportConfigurationAndUtils.ipynb | 23 +- ifrs17/Report/ReportMutableScopes2.ipynb | 769 ------------------ .../ReportMutableScopesInteractive.ipynb | 529 ++++++++++++ 5 files changed, 636 insertions(+), 776 deletions(-) create mode 100644 ifrs17-template/Report/InteractiveReports.ipynb delete mode 100644 ifrs17/Report/ReportMutableScopes2.ipynb create mode 100644 ifrs17/Report/ReportMutableScopesInteractive.ipynb diff --git a/ifrs17-template/Report/InteractiveReports.ipynb b/ifrs17-template/Report/InteractiveReports.ipynb new file mode 100644 index 00000000..3feeed96 --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports.ipynb @@ -0,0 +1,81 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "", + "\n

Interactive Reports

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Set up data and configuration", + "\n", + "\nChoose to run the Reports notebook either with the set of Systemorph data in memory or with the data present in the Database: ", + "\n- #!eval-notebook \"../Database/Configure\" : connects to a physical Database", + "\n- #!eval-notebook \"../Import/CloseImportTemplate\" : uses the in-memory set up", + "\n", + "\nWe use here the in-memory set up." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../Import/CloseImportTemplate\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.PvReportFormsEntity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.PvReportGrid" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/CalculationEngine.ipynb b/ifrs17/CalculationEngine.ipynb index 49d163c6..0643d8e6 100644 --- a/ifrs17/CalculationEngine.ipynb +++ b/ifrs17/CalculationEngine.ipynb @@ -20,6 +20,7 @@ "source": [ "#!import \"DataModel/DataStructure\"", "\n#!import \"Report/ReportMutableScopes\"", + "\n#!import \"Report/ReportMutableScopesInteractive\"", "\n#!import \"Import/Importers\"", "\n#!import \"Export/ExportConfiguration\"", "\n#!import \"Utils/TestHelper\"", @@ -38,6 +39,15 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ifrs17Interactive = new Ifrs17Interactive(Workspace, Report, InteractiveObject);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index ba5f5ad2..c28e9cc8 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -195,12 +195,7 @@ { "cell_type": "code", "source": [ - "public static async Task<(IDictionary, IReadOnlyCollection)> GetAutocompleteMappings (this IQuerySource querySource, bool hasNullAsFirstValue = default) where T : KeyedDimension {", - "\n var query = await querySource.Query().Select(x => new { x.SystemName, GuiName = $\"{x.DisplayName} ({x.SystemName})\", Order = 0 }).ToArrayAsync();", - "\n var mappingDictionary = query.ToDictionary(x => x.GuiName, x => x.SystemName);", - "\n var orderedDropDownValues = query.OrderBy(x => x.Order).ThenBy(x => x.GuiName).Select(x => x.GuiName);", - "\n return (mappingDictionary, (hasNullAsFirstValue ? new string[]{ null }.Concat(orderedDropDownValues) : orderedDropDownValues).ToArray());", - "\n}" + "public static string ParseReportingPeriodToDisplayString(int year, int periodOfYear, char separator) => $\"{year} {separator}{periodOfYear}\";" ], "metadata": {}, "execution_count": 0, @@ -209,7 +204,21 @@ { "cell_type": "code", "source": [ - "public static string ParseReportingPeriodToDisplayString(int year, int periodOfYear, char separator) => $\"{year} {separator}{periodOfYear}\";" + "public static string ParseDimensionToDisplayString(string systemName, string displayName) => $\"{displayName} ({systemName})\";" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static async Task<(IDictionary, IReadOnlyCollection)> GetAutocompleteMappings (this IQuerySource querySource, bool hasNullAsFirstValue = default) where T : KeyedDimension {", + "\n var query = await querySource.Query().Select(x => new { x.SystemName, GuiName = ParseDimensionToDisplayString(x.SystemName, x.DisplayName), Order = 0 }).ToArrayAsync();", + "\n var mappingDictionary = query.ToDictionary(x => x.GuiName, x => x.SystemName);", + "\n var orderedDropDownValues = query.OrderBy(x => x.Order).ThenBy(x => x.GuiName).Select(x => x.GuiName);", + "\n return (mappingDictionary, (hasNullAsFirstValue ? new string[]{ null }.Concat(orderedDropDownValues) : orderedDropDownValues).ToArray());", + "\n}" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Report/ReportMutableScopes2.ipynb b/ifrs17/Report/ReportMutableScopes2.ipynb deleted file mode 100644 index e87a7edf..00000000 --- a/ifrs17/Report/ReportMutableScopes2.ipynb +++ /dev/null @@ -1,769 +0,0 @@ -{ - "metadata": { - "authors": [], - "kernelspec": { - "display_name": "Formula Framework", - "language": "C#", - "name": "C#" - }, - "language_info": { - "file_extension": ".cs", - "mimetype": "text/plain", - "name": "C#" - } - }, - "nbformat": 4, - "nbformat_minor": 5, - "cells": [ - { - "cell_type": "markdown", - "source": [ - "", - "\n

Report Mutable Scopes

" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "This notebook contains the set up of mutable scopes used to achieve high interactivity with reports." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# References", - "\nLibraries and other notebooks which are needed for this notebook are imported below." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "#!import \"ReportScopes\"" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Form Entity Scopes" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Helper Scopes" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public interface MutableScopeWithWorkspace : IMutableScopeWithStorage {", - "\n protected IWorkspace workspace => GetStorage().Workspace; ", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Currency Type" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public interface CurrencyFormsEntity : IMutableScope {", - "\n [DropdownEnum(typeof(CurrencyType))]", - "\n CurrencyType CurrencyType { get; set; } ", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Scenario" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public interface ScenarioFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownMethod(nameof(GetScenarioAutocompleteAsync))]", - "\n [Display(Name = \"Scenario\")]", - "\n string ScenarioControl { get; set; }", - "\n", - "\n [NotVisible] IDictionary ScenarioMapping { get; set; }", - "\n protected string Scenario => !string.IsNullOrWhiteSpace(ScenarioControl) && ScenarioMapping is not null && ScenarioMapping.TryGetValue(ScenarioControl, out var value) ? value : null;", - "\n ", - "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", - "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", - "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", - "\n } ", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Reporting Node" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "[InitializeScope(nameof(InitReportingNode))]", - "\npublic interface ReportingNodeFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownMethod(nameof(GetReportingNodeAutocompleteAsync))]", - "\n [Display(Name = \"ReportingNode\")]", - "\n string ReportingNodeControl { get; set; }", - "\n", - "\n [NotVisible] IDictionary ReportingNodeMapping { get; set; }", - "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue( ReportingNodeControl, out var value)", - "\n ? value", - "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", - "\n", - "\n async Task> GetReportingNodeAutocompleteAsync(string userInput, int page, int pageSize) {", - "\n (ReportingNodeMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", - "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", - "\n }", - "\n", - "\n async void InitReportingNode() {", - "\n ReportingNodeControl = GetStorage().InitialReportingNode.DisplayName;", - "\n }", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Reporting Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "### Monthly Period" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "[InitializeScope(nameof(InitReportingPeriod))]", - "\npublic interface MonthlyPeriodFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownMethod(nameof(GetReportingPeriodAutocompleteAsync))]", - "\n string ReportingPeriod { get; set; }", - "\n", - "\n private char separator => 'M';", - "\n private string[] ReportingPeriodSplit => ReportingPeriod.Split(separator);", - "\n private int ParseReportingPeriod(int index) => !string.IsNullOrWhiteSpace(ReportingPeriod) && ReportingPeriodSplit is not null && Int32.TryParse(ReportingPeriodSplit.ElementAtOrDefault(index), out int value)", - "\n ? value", - "\n : default;", - "\n", - "\n protected int Year => ParseReportingPeriod(0);", - "\n protected int Month => ParseReportingPeriod(1);", - "\n", - "\n async Task> GetReportingPeriodAutocompleteAsync(string userInput, int page, int pageSize) => ", - "\n await workspace.Query()", - "\n .Where(x => x.Scenario == null)", - "\n .OrderByDescending(x => x.Year)", - "\n .ThenByDescending(x => x.Month)", - "\n .Select(x => ParseReportingPeriodToDisplayString(x.Year, x.Month, separator))", - "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", - "\n .ToArrayAsync();", - "\n", - "\n async void InitReportingPeriod() {", - "\n ReportingPeriod = ParseReportingPeriodToDisplayString(GetStorage().InitialReportingPeriod.Year, GetStorage().InitialReportingPeriod.Month, separator);", - "\n }", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Filters" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", - "\n string FilterName { get; set; }", - "\n", - "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", - "\n string FilterValue { get; set; }", - "\n", - "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", - "\n string FilterAction { get; set; }", - "\n ", - "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", - "\n new string[]{ null }.Concat(", - "\n await (FilterName switch", - "\n {", - "\n \"GroupOfContract\" => workspace.Query().Select(x => x.SystemName),", - "\n \"Novelty\" => workspace.Query().Select(x => x.SystemName),", - "\n \"EconomicBasis\" => workspace.Query().Select(x => x.SystemName),", - "\n _ => Enumerable.Empty().AsQueryable()", - "\n }) .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).OrderBy(x => x).ToArrayAsync()).ToArray();", - "\n ", - "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", - "\n ", - "\n // This is just a cast... do we need this?", - "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null ? Enumerable.Empty<(string, object)>() : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", - "\n", - "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", - "\n {", - "\n if(FilterAction == \"Add\")", - "\n AddFilter(FilterName, FilterValue);", - "\n if(FilterAction == \"Remove\")", - "\n RemoveFilter(FilterName, FilterValue);", - "\n return InputDataFilter;", - "\n }", - "\n", - "\n private void AddFilter(string filterName, string filterValue)", - "\n {", - "\n if(InputDataFilter == null)", - "\n InputDataFilter = Enumerable.Empty<(string, string)>().ToArray();", - "\n if(!InputDataFilter.Contains((filterName, filterValue)))", - "\n InputDataFilter = InputDataFilter.Append((filterName, filterValue)).ToArray();", - "\n }", - "\n ", - "\n private void RemoveFilter(string filterName, string filterValue)", - "\n {", - "\n if(InputDataFilter != null && InputDataFilter.Contains((filterName, filterValue)))", - "\n { var f = InputDataFilter.ToList();", - "\n f.Remove((filterName, filterValue));", - "\n InputDataFilter = f.ToArray();", - "\n }", - "\n }", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Slice and Dice" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public interface BasicSliceAndDiceFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownValues(\"\", \"GroupOfContract\")]", - "\n string SliceRowName { get; set; }", - "\n", - "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", - "\n string SliceColumnName { get; set; }", - "\n", - "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", - "\n [NotVisible] IReadOnlyCollection defaultRowSlices { get; set; }", - "\n protected string[] rowSlices => defaultRowSlices.Union(InputRowSlices).ToArray();", - "\n", - "\n protected IReadOnlyCollection InputColumnSlices => (SliceColumnName is null ? Enumerable.Empty() : SliceColumnName.RepeatOnce()).ToArray();", - "\n [NotVisible] IReadOnlyCollection defaultColumnSlices { get; set; }", - "\n protected string[] columnSlices => defaultColumnSlices.Union(InputColumnSlices).ToArray();", - "\n", - "\n IReadOnlyCollection GetSliceColumnNameAutocomplete() => new [] {\"\", \"GroupOfContract\", \"AmountType\"};", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Report Scopes" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "[InitializeScope(nameof(InitReportStorageScopeAsync))]", - "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, BasicSliceAndDiceFormsEntity, BasicFilterFormsEntity {", - "\n protected Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report => GetStorage().Report;", - "\n protected int headerColumnWidthValue => 250;", - "\n", - "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", - "\n IDataCube GetDataCube(IDataCube data) => InputDataFilter == null ? data : data.Filter(dataFilter);", - "\n ", - "\n async Task GetReportTaskAsync(IDataCube data) {", - "\n return await report.ForDataCube(data)", - "\n .WithQuerySource(workspace)", - "\n .SliceRowsBy(rowSlices)", - "\n .SliceColumnsBy(columnSlices)", - "\n .ReportGridOptions(headerColumnWidth: headerColumnWidthValue)", - "\n .ExecuteAsync();", - "\n }", - "\n", - "\n async Task InitReportStorageScopeAsync() { // This has the Async issue, but imo it should come in the future", - "\n await GetStorage().InitializeReportIndependentCacheAsync();", - "\n }", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", - "\n IDataCube DataCube { get; set; }", - "\n ", - "\n IDataCube Cube { get {", - "\n if(DataCube is null) return Enumerable.Empty().ToDataCube();", - "\n", - "\n if(Identity.scenario != \"Delta\") return DataCube;", - "\n var bestEstimateById = DataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", - "\n return DataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0d) }).ToDataCube();", - "\n }}", - "\n} " - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Report Scopes" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Best Estimate PV" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "[InitializeScope(nameof(Init))]", - "\npublic interface PvReport : ReportScope {", - "\n", - "\n public IDataCube GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", - "\n", - "\n async Task ToReportAsync() {", - "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", - "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", - "\n dataScope.DataCube = GetData();", - "\n return await GetReportTaskAsync(dataScope.DataCube);", - "\n return await GetReportTaskAsync(GetDataCube(GetData()));", - "\n }", - "\n", - "\n void Init() {", - "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", - "\n }", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Risk Adjustment PV" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Mutable Scope" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "The IIfrs17Report mutable scope is created with applicabilities to control how the data for each individual report is retrieved from the [report scopes](./ReportScopes)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public interface ReportUniverse : IMutableScopeWithStorage{}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "[InitializeScope(nameof(InitAsync))]", - "\npublic interface IIfrs17Report : IMutableScope {", - "\n // Infrastructure", - "\n protected IWorkspace workspace => GetStorage().Workspace;", - "\n protected Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report => GetStorage().Report;", - "\n", - "\n static ApplicabilityBuilder ScopeApplicabilityBuilder(ApplicabilityBuilder builder) =>", - "\n builder.ForScope(s => s.WithApplicability(x => x.Identity == nameof(PvReport))", - "\n .WithApplicability(x => x.Identity == nameof(RaReport))", - "\n .WithApplicability(x => x.Identity == nameof(WrittenReport))", - "\n .WithApplicability(x => x.Identity == nameof(AccrualReport))", - "\n .WithApplicability(x => x.Identity == nameof(DeferralReport))", - "\n .WithApplicability(x => x.Identity == nameof(FcfReport))", - "\n .WithApplicability(x => x.Identity == nameof(ExpAdjReport))", - "\n .WithApplicability(x => x.Identity == nameof(TmReport))", - "\n .WithApplicability(x => x.Identity == nameof(CsmReport))", - "\n .WithApplicability(x => x.Identity == nameof(ActLrcReport))", - "\n .WithApplicability(x => x.Identity == nameof(LrcReport))", - "\n .WithApplicability(x => x.Identity == nameof(ActLicReport))", - "\n .WithApplicability(x => x.Identity == nameof(LicReport))", - "\n .WithApplicability(x => x.Identity == nameof(FpReport))", - "\n );", - "\n", - "\n // Basic mutable properties", - "\n (int Year, int Month) ReportingPeriod { get; set; }", - "\n int Year => ReportingPeriod.Year;", - "\n int Month => ReportingPeriod.Month;", - "\n string ReportingNode { get; set; }", - "\n string Scenario { get; set; } // TODO: Enable dropdown selection including All and Delta", - "\n string Comparison { get; set; } // TODO: only for scenario at the beginning, meant to enable general purpose comparisons ", - "\n CurrencyType CurrencyType { get; set; }", - "\n ", - "\n ((int Year, int Month) ReportingPeriod, string ReportingNode, string Scenario, CurrencyType) ShowSettings => (ReportingPeriod, ReportingNode, Scenario, CurrencyType);", - "\n ", - "\n // Slice and Dice", - "\n protected string[] forbiddenSlices => new string[] { };", - "\n", - "\n IEnumerable RowSlices { get; set; }", - "\n protected string[] defaultRowSlices => new string[] { };", - "\n protected string[] rowSlices => RowSlices is null ? defaultRowSlices : defaultRowSlices.Concat(RowSlices).Where(x => !forbiddenSlices.Contains(x)).ToArray();", - "\n", - "\n IEnumerable ColumnSlices { get; set; }", - "\n protected string[] defaultColumnSlices => new string[] { };", - "\n protected string[] columnSlices { get{", - "\n var slices = ColumnSlices is null ? defaultColumnSlices : defaultColumnSlices.Where(cs => !ColumnSlices.Contains(cs)).Concat(ColumnSlices).Where(x => !forbiddenSlices.Contains(x)).ToArray();", - "\n return Scenario == \"All\" || Scenario == \"Delta\"", - "\n ? slices.Concat(nameof(Scenario).RepeatOnce()).ToArray() ", - "\n : Scenario is null ? slices : nameof(Scenario).RepeatOnce().Concat(slices).ToArray();", - "\n }}", - "\n", - "\n // Identities", - "\n protected HashSet<(ReportIdentity, CurrencyType)> GetIdentities() => GetStorage().GetIdentities(ReportingPeriod, ReportingNode, Scenario, CurrencyType);", - "\n ", - "\n // Filter", - "\n IEnumerable<(string filterName, string filterValue)> DataFilter { get; set; }", - "\n protected (string filterName, object filterValue)[] dataFilter => (DataFilter is null ? Enumerable.Empty<(string, object)>() : DataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", - "\n", - "\n // Scope Initialization", - "\n async Task InitAsync() {", - "\n var mostRecentPartition = (await workspace.Query().Where(x => x.Scenario == null).OrderBy(x => x.Year).ThenBy(x => x.Month).ToArrayAsync()).Last(); ", - "\n ReportingPeriod = (mostRecentPartition.Year, mostRecentPartition.Month);", - "\n ReportingNode = (await workspace.Query().Where(x => x.Parent == null).ToArrayAsync()).First().SystemName; // TODO: change once user permissions are available", - "\n Scenario = null;", - "\n CurrencyType = CurrencyType.Contractual;", - "\n await GetStorage().InitializeReportIndependentCacheAsync();", - "\n } ", - "\n", - "\n //Report", - "\n public IDataCube GetDataCube() => default;", - "\n protected int headerColumnWidthValue => 250;", - "\n public Task ToReportAsync => GetReportTaskAsync();", - "\n private async Task GetReportTaskAsync() {", - "\n await GetStorage().InitializeAsync(ReportingPeriod, ReportingNode, Scenario, CurrencyType); ", - "\n return await report.ForDataCube(GetScope((ReportingPeriod, ReportingNode, Scenario, CurrencyType, Identity, dataFilter)).Cube)", - "\n .WithQuerySource(workspace)", - "\n .SliceRowsBy(rowSlices)", - "\n .SliceColumnsBy(columnSlices)", - "\n .ReportGridOptions(headerColumnWidth: headerColumnWidthValue)", - "\n .ExecuteAsync();", - "\n }", - "\n}", - "\n", - "\npublic interface PvReport : IIfrs17Report {", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] { \"Novelty\", \"VariableType\" };", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? (GetScopes(GetIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetIdentities()).Aggregate().CurrentBestEstimate)", - "\n : (GetScopes(GetIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetIdentities()).Aggregate().CurrentBestEstimate).Filter(dataFilter);", - "\n}", - "\n", - "\npublic interface RaReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] { \"Novelty\", \"VariableType\" };", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().LockedRiskAdjustment + ", - "\n GetScopes(GetIdentities()).Aggregate().CurrentRiskAdjustment", - "\n : GetScopes(GetIdentities()).Aggregate().LockedRiskAdjustment.Filter(dataFilter) + ", - "\n GetScopes(GetIdentities()).Aggregate().CurrentRiskAdjustment.Filter(dataFilter);", - "\n}", - "\n", - "\npublic interface WrittenReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {nameof(EconomicBasis)};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"AmountType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\"};", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().Written", - "\n : GetScopes(GetIdentities()).Aggregate().Written.Filter(dataFilter);", - "\n}", - "\n", - "\npublic interface AccrualReport : IIfrs17Report {", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\"};", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().Advance + ", - "\n GetScopes(GetIdentities()).Aggregate().Overdue", - "\n : GetScopes(GetIdentities()).Aggregate().Advance.Filter(dataFilter) + ", - "\n GetScopes(GetIdentities()).Aggregate().Overdue.Filter(dataFilter);", - "\n}", - "\n", - "\npublic interface DeferralReport : IIfrs17Report {", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().Deferrals", - "\n : GetScopes(GetIdentities()).Aggregate().Deferrals.Filter(dataFilter);", - "\n}", - "\n", - "\npublic interface FcfReport : IIfrs17Report {", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\",\"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().Fcf", - "\n : GetScopes(GetIdentities()).Aggregate().Fcf.Filter(dataFilter);", - "\n}", - "\n", - "\npublic interface ExpAdjReport : IIfrs17Report {", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"EstimateType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"AmountType\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().ActuarialExperienceAdjustment", - "\n : GetScopes(GetIdentities()).Aggregate().ActuarialExperienceAdjustment.Filter(dataFilter);", - "\n}", - "\npublic interface TmReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\", nameof(EconomicBasis)};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\", \"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().LrcTechnicalMargin", - "\n : GetScopes(GetIdentities()).Aggregate().LrcTechnicalMargin.Filter(dataFilter);", - "\n}", - "\npublic interface CsmReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\", nameof(EconomicBasis)};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\", \"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().Csm + ", - "\n GetScopes(GetIdentities()).Aggregate().Lc + ", - "\n GetScopes(GetIdentities()).Aggregate().Loreco", - "\n : GetScopes(GetIdentities()).Aggregate().Csm.Filter(dataFilter) + ", - "\n GetScopes(GetIdentities()).Aggregate().Lc.Filter(dataFilter) + ", - "\n GetScopes(GetIdentities()).Aggregate().Loreco.Filter(dataFilter);", - "\n}", - "\npublic interface ActLrcReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\",\"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().LrcActuarial", - "\n : GetScopes(GetIdentities()).Aggregate().LrcActuarial.Filter(dataFilter);", - "\n}", - "\npublic interface LrcReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().Lrc", - "\n : GetScopes(GetIdentities()).Aggregate().Lrc.Filter(dataFilter);", - "\n}", - "\npublic interface ActLicReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"Novelty\",\"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().LicActuarial", - "\n : GetScopes(GetIdentities()).Aggregate().LicActuarial.Filter(dataFilter);", - "\n}", - "\npublic interface LicReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\"};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\", \"EstimateType\" };", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().Lic", - "\n : GetScopes(GetIdentities()).Aggregate().Lic.Filter(dataFilter);", - "\n}", - "\npublic interface FpReport : IIfrs17Report {", - "\n string[] IIfrs17Report.forbiddenSlices => new string[] {\"AmountType\", nameof(EconomicBasis)};", - "\n string[] IIfrs17Report.defaultRowSlices => new string[] {\"VariableType\", \"EstimateType\"};", - "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { \"Currency\",\"LiabilityType\" };", - "\n int IIfrs17Report.headerColumnWidthValue => 500;", - "\n IDataCube IIfrs17Report.GetDataCube() => DataFilter == null ", - "\n ? GetScopes(GetIdentities()).Aggregate().FinancialPerformance", - "\n : GetScopes(GetIdentities()).Aggregate().FinancialPerformance.Filter(dataFilter);", - "\n}", - "\n", - "\npublic interface Data : IMutableScope<((int year, int month) period, string reportingNode, string scenario, CurrencyType currencyType, ", - "\n string reportType, (string filterName, object filterValue)[] dataFilter)> ", - "\n{", - "\n IDataCube Cube { get{", - "\n var dataCube = GetScope(Identity.reportType).GetDataCube();", - "\n // TODO: suggestion to place the filter here instead of having it in every applicability scope", - "\n if(Identity.scenario != \"Delta\") return dataCube;", - "\n var bestEstimateById = dataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", - "\n return dataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0.0) }).ToDataCube();", - "\n }}", - "\n} " - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# IFRS 17 Reports" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "This class is used to trigger the calculation of the reports and it is exposed to the end-user in the reports." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public class Ifrs17 ", - "\n{", - "\n private Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes;", - "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", - "\n private ReportStorage Storage;", - "\n private ReportUniverse reportUniverse;", - "\n ", - "\n //reset", - "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report);", - "\n", - "\n //constructor", - "\n public Ifrs17 (IWorkspace workspace, Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report)", - "\n {", - "\n this.scopes = scopes; ", - "\n this.report = report; ", - "\n Storage = new ReportStorage(workspace, report);", - "\n reportUniverse = scopes.ForSingleton().WithStorage(Storage).ToScope();", - "\n }", - "\n", - "\n public IIfrs17Report PresentValues => reportUniverse.GetScope();", - "\n public IIfrs17Report RiskAdjustments => reportUniverse.GetScope();", - "\n public IIfrs17Report WrittenActuals => reportUniverse.GetScope();", - "\n public IIfrs17Report AccrualActuals => reportUniverse.GetScope();", - "\n public IIfrs17Report DeferralActuals => reportUniverse.GetScope();", - "\n public IIfrs17Report FulfillmentCashflows => reportUniverse.GetScope();", - "\n public IIfrs17Report ExperienceAdjustments => reportUniverse.GetScope();", - "\n public IIfrs17Report TechnicalMargins => reportUniverse.GetScope();", - "\n public IIfrs17Report AllocatedTechnicalMargins => reportUniverse.GetScope();", - "\n public IIfrs17Report ActuarialLrc => reportUniverse.GetScope();", - "\n public IIfrs17Report Lrc => reportUniverse.GetScope();", - "\n public IIfrs17Report ActuarialLic => reportUniverse.GetScope();", - "\n public IIfrs17Report Lic => reportUniverse.GetScope();", - "\n public IIfrs17Report FinancialPerformance => reportUniverse.GetScope();", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - } - ] -} \ No newline at end of file diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb new file mode 100644 index 00000000..48a016a0 --- /dev/null +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -0,0 +1,529 @@ +{ + "metadata": { + "authors": [], + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "", + "\n

Report Mutable Scopes

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This notebook contains the set up of mutable scopes used to achieve high interactivity with reports." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# References", + "\nLibraries and other notebooks which are needed for this notebook are imported below." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"ReportScopes\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Form Entity Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Helper Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface MutableScopeWithWorkspace : IMutableScopeWithStorage {", + "\n protected IWorkspace workspace => GetStorage().Workspace; ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Currency Type" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface CurrencyFormsEntity : IMutableScope {", + "\n [DropdownEnum(typeof(CurrencyType))]", + "\n CurrencyType CurrencyType { get; set; } ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Scenario" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface ScenarioFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownMethod(nameof(GetScenarioAutocompleteAsync))]", + "\n [Display(Name = \"Scenario\")]", + "\n string ScenarioControl { get; set; }", + "\n", + "\n [NotVisible] IDictionary ScenarioMapping { get; set; }", + "\n protected string Scenario => !string.IsNullOrWhiteSpace(ScenarioControl) && ScenarioMapping is not null && ScenarioMapping.TryGetValue(ScenarioControl, out var value) ? value : null;", + "\n ", + "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", + "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", + "\n } ", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reporting Node" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportingNode))]", + "\npublic interface ReportingNodeFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownMethod(nameof(GetReportingNodeAutocompleteAsync))]", + "\n [Display(Name = \"ReportingNode\")]", + "\n string ReportingNodeControl { get; set; }", + "\n", + "\n [NotVisible] IDictionary ReportingNodeMapping { get; set; }", + "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue( ReportingNodeControl, out var value)", + "\n ? value", + "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", + "\n", + "\n async Task> GetReportingNodeAutocompleteAsync(string userInput, int page, int pageSize) {", + "\n (ReportingNodeMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", + "\n }", + "\n", + "\n async void InitReportingNode() {", + "\n ReportingNodeControl = ParseDimensionToDisplayString(GetStorage().InitialReportingNode.SystemName, GetStorage().InitialReportingNode.DisplayName);", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Reporting Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "### Monthly Period" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportingPeriod))]", + "\npublic interface MonthlyPeriodFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownMethod(nameof(GetReportingPeriodAutocompleteAsync))]", + "\n string ReportingPeriod { get; set; }", + "\n", + "\n private char separator => 'M';", + "\n private string[] ReportingPeriodSplit => ReportingPeriod.Split(separator);", + "\n private int ParseReportingPeriod(int index) => !string.IsNullOrWhiteSpace(ReportingPeriod) && ReportingPeriodSplit is not null && Int32.TryParse(ReportingPeriodSplit.ElementAtOrDefault(index), out int value)", + "\n ? value", + "\n : default;", + "\n", + "\n protected int Year => ParseReportingPeriod(0);", + "\n protected int Month => ParseReportingPeriod(1);", + "\n", + "\n async Task> GetReportingPeriodAutocompleteAsync(string userInput, int page, int pageSize) => ", + "\n await workspace.Query()", + "\n .Where(x => x.Scenario == null)", + "\n .OrderByDescending(x => x.Year)", + "\n .ThenByDescending(x => x.Month)", + "\n .Select(x => ParseReportingPeriodToDisplayString(x.Year, x.Month, separator))", + "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", + "\n .ToArrayAsync();", + "\n", + "\n async void InitReportingPeriod() {", + "\n ReportingPeriod = ParseReportingPeriodToDisplayString(GetStorage().InitialReportingPeriod.Year, GetStorage().InitialReportingPeriod.Month, separator);", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Filters" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", + "\n string FilterName { get; set; }", + "\n", + "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", + "\n string FilterValue { get; set; }", + "\n", + "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", + "\n string FilterAction { get; set; }", + "\n ", + "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", + "\n new string[]{ null }.Concat(", + "\n await (FilterName switch", + "\n {", + "\n \"GroupOfContract\" => workspace.Query().Select(x => x.SystemName),", + "\n \"Novelty\" => workspace.Query().Select(x => x.SystemName),", + "\n \"EconomicBasis\" => workspace.Query().Select(x => x.SystemName),", + "\n _ => Enumerable.Empty().AsQueryable()", + "\n }) .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).OrderBy(x => x).ToArrayAsync()).ToArray();", + "\n ", + "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", + "\n ", + "\n // This is just a cast... do we need this?", + "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null ? Enumerable.Empty<(string, object)>() : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", + "\n", + "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", + "\n {", + "\n if(FilterAction == \"Add\")", + "\n AddFilter(FilterName, FilterValue);", + "\n if(FilterAction == \"Remove\")", + "\n RemoveFilter(FilterName, FilterValue);", + "\n return InputDataFilter;", + "\n }", + "\n", + "\n private void AddFilter(string filterName, string filterValue)", + "\n {", + "\n if(InputDataFilter == null)", + "\n InputDataFilter = Enumerable.Empty<(string, string)>().ToArray();", + "\n if(!InputDataFilter.Contains((filterName, filterValue)))", + "\n InputDataFilter = InputDataFilter.Append((filterName, filterValue)).ToArray();", + "\n }", + "\n ", + "\n private void RemoveFilter(string filterName, string filterValue)", + "\n {", + "\n if(InputDataFilter != null && InputDataFilter.Contains((filterName, filterValue)))", + "\n { var f = InputDataFilter.ToList();", + "\n f.Remove((filterName, filterValue));", + "\n InputDataFilter = f.ToArray();", + "\n }", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Slice and Dice" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface BasicSliceAndDiceFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownValues(\"\", \"GroupOfContract\")]", + "\n string SliceRowName { get; set; }", + "\n", + "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", + "\n string SliceColumnName { get; set; }", + "\n", + "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", + "\n [NotVisible] IReadOnlyCollection defaultRowSlices { get; set; }", + "\n protected string[] rowSlices => defaultRowSlices.Union(InputRowSlices).ToArray();", + "\n", + "\n protected IReadOnlyCollection InputColumnSlices => (SliceColumnName is null ? Enumerable.Empty() : SliceColumnName.RepeatOnce()).ToArray();", + "\n [NotVisible] IReadOnlyCollection defaultColumnSlices { get; set; }", + "\n protected string[] columnSlices => defaultColumnSlices.Union(InputColumnSlices).ToArray();", + "\n", + "\n IReadOnlyCollection GetSliceColumnNameAutocomplete() => new [] {\"\", \"GroupOfContract\", \"AmountType\"};", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Report Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportStorageScopeAsync))]", + "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, BasicSliceAndDiceFormsEntity, BasicFilterFormsEntity {", + "\n protected Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report => GetStorage().Report;", + "\n protected int headerColumnWidthValue => 250;", + "\n", + "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", + "\n ", + "\n async Task GetReportTaskAsync(IDataCube data) {", + "\n return await report.ForDataCube(data)", + "\n .WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices)", + "\n .ReportGridOptions(headerColumnWidth: headerColumnWidthValue)", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task InitReportStorageScopeAsync() { // This has the Async issue, but imo it should come in the future", + "\n await GetStorage().InitializeReportIndependentCacheAsync();", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", + "\n IDataCube InputDataCube { get; set; }", + "\n", + "\n IDataCube DataCube { get {", + "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", + "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ? InputDataCube : InputDataCube.Filter(Identity.dataFilter); ", + "\n if(Identity.scenario != \"Delta\") return filteredDataCube;", + "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", + "\n return filteredDataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0d) }).ToDataCube();", + "\n }}", + "\n} " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Report Scopes" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Best Estimate PV" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface PvReport : ReportScope {", + "\n", + "\n public IDataCube GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", + "\n", + "\n async Task ToReportAsync() {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await GetReportTaskAsync(dataScope.DataCube);", + "\n }", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Risk Adjustment PV" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# IFRS 17 Reports" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This class is used to trigger the calculation of the reports and it is exposed to the end-user in the reports." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public class Ifrs17Interactive ", + "\n{", + "\n //private Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes;", + "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", + "\n private Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject;", + "\n private ReportStorage storage;", + "\n ", + "\n //reset", + "\n public void Reset(IWorkspace workspace) => storage = new ReportStorage(workspace, report);", + "\n", + "\n //constructor", + "\n public Ifrs17Interactive (IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report, Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject)", + "\n {", + "\n //this.scopes = scopes; ", + "\n this.report = report;", + "\n this.interactiveObject = interactiveObject;", + "\n storage = new ReportStorage(workspace, report);", + "\n }", + "\n ", + "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView PvReportFormsEntity =>", + "\n interactiveObject.CreateView(nameof(PvReportFormsEntity),", + "\n state => state.GetScope(nameof(PvReport), o => o.WithStorage(storage)));", + "\n ", + "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView PvReportGrid =>", + "\n interactiveObject.CreateView(nameof(PvReportGrid),", + "\n state => {", + "\n var scope = state.GetScope(nameof(PvReport), o => o.WithStorage(storage));", + "\n var filters = scope.GetFilters(); // Not used and should be improved", + "\n return scope.ToReportAsync();", + "\n });", + "\n", + "\n", + "\n //public IIfrs17Report PresentValues => reportUniverse.GetScope();", + "\n // public IIfrs17Report RiskAdjustments => reportUniverse.GetScope();", + "\n // public IIfrs17Report WrittenActuals => reportUniverse.GetScope();", + "\n // public IIfrs17Report AccrualActuals => reportUniverse.GetScope();", + "\n // public IIfrs17Report DeferralActuals => reportUniverse.GetScope();", + "\n // public IIfrs17Report FulfillmentCashflows => reportUniverse.GetScope();", + "\n // public IIfrs17Report ExperienceAdjustments => reportUniverse.GetScope();", + "\n // public IIfrs17Report TechnicalMargins => reportUniverse.GetScope();", + "\n // public IIfrs17Report AllocatedTechnicalMargins => reportUniverse.GetScope();", + "\n // public IIfrs17Report ActuarialLrc => reportUniverse.GetScope();", + "\n // public IIfrs17Report Lrc => reportUniverse.GetScope();", + "\n // public IIfrs17Report ActuarialLic => reportUniverse.GetScope();", + "\n // public IIfrs17Report Lic => reportUniverse.GetScope();", + "\n // public IIfrs17Report FinancialPerformance => reportUniverse.GetScope();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file From c83cdb8fb4f0f0df2f233f957e375fab3b10ee41 Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Wed, 15 Feb 2023 08:56:23 +0100 Subject: [PATCH 03/55] update --- .../Report/InteractiveReports.ipynb | 231 +++++++++++++++++- .../ReportMutableScopesInteractive.ipynb | 158 ++++++++---- 2 files changed, 336 insertions(+), 53 deletions(-) diff --git a/ifrs17-template/Report/InteractiveReports.ipynb b/ifrs17-template/Report/InteractiveReports.ipynb index 3feeed96..02b43e5c 100644 --- a/ifrs17-template/Report/InteractiveReports.ipynb +++ b/ifrs17-template/Report/InteractiveReports.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "wTla7_suu02MahikFpsz0A", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -43,7 +44,7 @@ { "cell_type": "code", "source": [ - "#!eval-notebook \"../Import/CloseImportTemplate\"" + "#!import \"../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -53,7 +54,7 @@ "cell_type": "code", "source": [ "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "\n//ifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -62,7 +63,229 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.PvReportFormsEntity" + "public class Ifrs17Interactive2 ", + "\n{", + "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", + "\n private Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject;", + "\n private ReportStorage storage;", + "\n", + "\n private IDictionary interactiveObjectCache = new Dictionary();", + "\n", + "\n public Ifrs17Interactive2 (IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report, Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject)", + "\n {", + "\n this.report = report;", + "\n this.interactiveObject = interactiveObject;", + "\n storage = new ReportStorage(workspace, report);", + "\n }", + "\n", + "\n public void Reset(IWorkspace workspace) {", + "\n storage = new ReportStorage(workspace, report);", + "\n interactiveObjectCache = new Dictionary();", + "\n }", + "\n", + "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", + "\n var key = name ?? typeof(T).Name;", + "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", state => state.GetScope(key, o => o.WithStorage(storage)));", + "\n return ret;", + "\n }", + "\n", + "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope, IWithToReportAsync {", + "\n var key = name ?? typeof(T).Name;", + "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", + "\n state => {", + "\n var scope = state.GetScope(key, o => o.WithStorage(storage));", + "\n //var filters = scope.GetFilters(); // Not used and should be improved", + "\n return scope.ToReportAsync();", + "\n });", + "\n return ret;", + "\n }", + "\n", + "\n public ReportScope GetReportScope() where T : ReportScope => interactiveObject.State.GetScope(typeof(T).Name, o => o.WithStorage(storage));", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var ifrs17Interactive2 = new Ifrs17Interactive2(Workspace, Report, InteractiveObject);", + "\nifrs17Interactive2.Reset(Workspace)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive2.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive2.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var storage = new ReportStorage(Workspace, Report);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + " static T ExpGetScope(Systemorph.InteractiveObjects.InteractiveObjectVariable io, object storage) {", + "\n var ret = io.State.GetScope(typeof(T).Name, o => o.WithStorage(storage));", + "\n return ret;", + "\n }" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "async static Task ExpGetReport(Systemorph.InteractiveObjects.InteractiveObjectVariable io, object storage, Func> resultFacory) ", + "\n//where T : IWithToReportAsync", + "\n {", + "\n var ret = ExpGetScope(io, storage);", + "\n return await resultFacory(ret);", + "\n }" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "//var scope = ExpGetScope(InteractiveObject, storage);", + "\n//await scope.ToReportAsync" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ExpGetReport(InteractiveObject, storage, async x => await x.ToReportAsync)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var a = ifrs17Interactive2.GetReportScope();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await a.ToReportAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var b = (PvReport) a;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await b.ToReportAsync()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "interface IA :IScope {", + "\n string M() => \"IA\";", + "\n}", + "\ninterface IB : IA {", + "\n string IA.M() => \"IB\";", + "\n}", + "\n", + "\nInteractiveObject.State.GetScope().M()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "string GetString() where T : IA, new() {", + "\n var iii = new T();", + "\n return iii.M();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" ], "metadata": {}, "execution_count": 0, @@ -71,7 +294,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.PvReportGrid" + "" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 48a016a0..9b107eda 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -1,6 +1,7 @@ { "metadata": { "authors": [], + "id": "SuppWclYnkyuC51Dlg-6Rg", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -334,6 +335,25 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", + "\n IDataCube InputDataCube { get; set; }", + "\n", + "\n IDataCube DataCube { get {", + "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", + "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ? InputDataCube : InputDataCube.Filter(Identity.dataFilter); ", + "\n if(Identity.scenario != \"Delta\") return filteredDataCube;", + "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", + "\n return filteredDataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0d) }).ToDataCube();", + "\n }}", + "\n} " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -343,7 +363,7 @@ "\n protected int headerColumnWidthValue => 250;", "\n", "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", - "\n ", + "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", "\n return await report.ForDataCube(data)", "\n .WithQuerySource(workspace)", @@ -365,17 +385,9 @@ { "cell_type": "code", "source": [ - "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", - "\n IDataCube InputDataCube { get; set; }", - "\n", - "\n IDataCube DataCube { get {", - "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", - "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ? InputDataCube : InputDataCube.Filter(Identity.dataFilter); ", - "\n if(Identity.scenario != \"Delta\") return filteredDataCube;", - "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", - "\n return filteredDataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0d) }).ToDataCube();", - "\n }}", - "\n} " + "public interface IWithToReportAsync {", + "\n async Task ToReportAsync() => default; ", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -403,9 +415,9 @@ "cell_type": "code", "source": [ "[InitializeScope(nameof(Init))]", - "\npublic interface PvReport : ReportScope {", + "\npublic interface PvReport : ReportScope, IWithToReportAsync {", "\n", - "\n public IDataCube GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", + "\n IDataCube GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", "\n", "\n async Task ToReportAsync() {", "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", @@ -464,53 +476,101 @@ { "cell_type": "code", "source": [ - "public class Ifrs17Interactive ", - "\n{", - "\n //private Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes;", + "public class Ifrs17Interactive {", "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", "\n private Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject;", "\n private ReportStorage storage;", - "\n ", - "\n //reset", - "\n public void Reset(IWorkspace workspace) => storage = new ReportStorage(workspace, report);", "\n", - "\n //constructor", + "\n private IDictionary interactiveObjectCache = new Dictionary();", + "\n", "\n public Ifrs17Interactive (IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report, Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject)", "\n {", - "\n //this.scopes = scopes; ", "\n this.report = report;", "\n this.interactiveObject = interactiveObject;", "\n storage = new ReportStorage(workspace, report);", "\n }", + "\n", + "\n public void Reset(IWorkspace workspace) {", + "\n storage = new ReportStorage(workspace, report);", + "\n interactiveObjectCache = new Dictionary();", + "\n }", + "\n", + "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", + "\n var key = name ?? typeof(T).Name;", + "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", state => state.GetScope(key, o => o.WithStorage(storage)));", + "\n return ret;", + "\n }", + "\n", + "\n // public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope {", + "\n // var key = name ?? typeof(T).Name;", + "\n // if(!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n // ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", + "\n // state => {", + "\n // var scope = state.GetScope(key, o => o.WithStorage(storage));", + "\n // //var filters = scope.GetFilters(); // Not used and should be improved", + "\n // return scope.ToReportAsync();", + "\n // });", + "\n // return ret;", + "\n // }", + "\n", + "\n public ReportScope GetReportScope() where T : ReportScope => interactiveObject.State.GetScope(typeof(T).Name, o => o.WithStorage(storage));", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "// public class Ifrs17Interactive ", + "\n// {", + "\n// //private Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes;", + "\n// private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", + "\n// private Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject;", + "\n// private ReportStorage storage;", + "\n ", + "\n// //reset", + "\n// public void Reset(IWorkspace workspace) => storage = new ReportStorage(workspace, report);", + "\n", + "\n// //constructor", + "\n// public Ifrs17Interactive (IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report, Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject)", + "\n// {", + "\n// //this.scopes = scopes; ", + "\n// this.report = report;", + "\n// this.interactiveObject = interactiveObject;", + "\n// storage = new ReportStorage(workspace, report);", + "\n// }", "\n ", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView PvReportFormsEntity =>", - "\n interactiveObject.CreateView(nameof(PvReportFormsEntity),", - "\n state => state.GetScope(nameof(PvReport), o => o.WithStorage(storage)));", + "\n// public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView PvReportFormsEntity =>", + "\n// interactiveObject.CreateView(nameof(PvReportFormsEntity),", + "\n// state => state.GetScope(nameof(PvReport), o => o.WithStorage(storage)));", "\n ", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView PvReportGrid =>", - "\n interactiveObject.CreateView(nameof(PvReportGrid),", - "\n state => {", - "\n var scope = state.GetScope(nameof(PvReport), o => o.WithStorage(storage));", - "\n var filters = scope.GetFilters(); // Not used and should be improved", - "\n return scope.ToReportAsync();", - "\n });", - "\n", - "\n", - "\n //public IIfrs17Report PresentValues => reportUniverse.GetScope();", - "\n // public IIfrs17Report RiskAdjustments => reportUniverse.GetScope();", - "\n // public IIfrs17Report WrittenActuals => reportUniverse.GetScope();", - "\n // public IIfrs17Report AccrualActuals => reportUniverse.GetScope();", - "\n // public IIfrs17Report DeferralActuals => reportUniverse.GetScope();", - "\n // public IIfrs17Report FulfillmentCashflows => reportUniverse.GetScope();", - "\n // public IIfrs17Report ExperienceAdjustments => reportUniverse.GetScope();", - "\n // public IIfrs17Report TechnicalMargins => reportUniverse.GetScope();", - "\n // public IIfrs17Report AllocatedTechnicalMargins => reportUniverse.GetScope();", - "\n // public IIfrs17Report ActuarialLrc => reportUniverse.GetScope();", - "\n // public IIfrs17Report Lrc => reportUniverse.GetScope();", - "\n // public IIfrs17Report ActuarialLic => reportUniverse.GetScope();", - "\n // public IIfrs17Report Lic => reportUniverse.GetScope();", - "\n // public IIfrs17Report FinancialPerformance => reportUniverse.GetScope();", - "\n}" + "\n// public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView PvReportGrid =>", + "\n// interactiveObject.CreateView(nameof(PvReportGrid),", + "\n// state => {", + "\n// var scope = state.GetScope(nameof(PvReport), o => o.WithStorage(storage));", + "\n// var filters = scope.GetFilters(); // Not used and should be improved", + "\n// return scope.ToReportAsync();", + "\n// });", + "\n", + "\n", + "\n// //public IIfrs17Report PresentValues => reportUniverse.GetScope();", + "\n// // public IIfrs17Report RiskAdjustments => reportUniverse.GetScope();", + "\n// // public IIfrs17Report WrittenActuals => reportUniverse.GetScope();", + "\n// // public IIfrs17Report AccrualActuals => reportUniverse.GetScope();", + "\n// // public IIfrs17Report DeferralActuals => reportUniverse.GetScope();", + "\n// // public IIfrs17Report FulfillmentCashflows => reportUniverse.GetScope();", + "\n// // public IIfrs17Report ExperienceAdjustments => reportUniverse.GetScope();", + "\n// // public IIfrs17Report TechnicalMargins => reportUniverse.GetScope();", + "\n// // public IIfrs17Report AllocatedTechnicalMargins => reportUniverse.GetScope();", + "\n// // public IIfrs17Report ActuarialLrc => reportUniverse.GetScope();", + "\n// // public IIfrs17Report Lrc => reportUniverse.GetScope();", + "\n// // public IIfrs17Report ActuarialLic => reportUniverse.GetScope();", + "\n// // public IIfrs17Report Lic => reportUniverse.GetScope();", + "\n// // public IIfrs17Report FinancialPerformance => reportUniverse.GetScope();", + "\n// }" ], "metadata": {}, "execution_count": 0, From c23cb00dab976e2e7047f687ddc724eb866382e9 Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Fri, 17 Feb 2023 08:51:29 +0100 Subject: [PATCH 04/55] safe state? --- .../Report/InteractiveReports.ipynb | 28 ++++--------------- .../ReportMutableScopesInteractive.ipynb | 2 +- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/ifrs17-template/Report/InteractiveReports.ipynb b/ifrs17-template/Report/InteractiveReports.ipynb index 02b43e5c..d30ab96a 100644 --- a/ifrs17-template/Report/InteractiveReports.ipynb +++ b/ifrs17-template/Report/InteractiveReports.ipynb @@ -86,7 +86,7 @@ "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", - "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", state => state.GetScope(key, o => o.WithStorage(storage)));", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", _ => GetReportScope());", "\n return ret;", "\n }", "\n", @@ -94,10 +94,10 @@ "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", - "\n state => {", - "\n var scope = state.GetScope(key, o => o.WithStorage(storage));", - "\n //var filters = scope.GetFilters(); // Not used and should be improved", - "\n return scope.ToReportAsync();", + "\n _ => {", + "\n var scope = GetReportScope();", + "\n var filters = scope.GetFilters(); // Not used and should be improved", + "\n return ((IWithToReportAsync)scope).ToReportAsync();", "\n });", "\n return ret;", "\n }", @@ -227,15 +227,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -282,15 +273,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 9b107eda..85a2ca2c 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -386,7 +386,7 @@ "cell_type": "code", "source": [ "public interface IWithToReportAsync {", - "\n async Task ToReportAsync() => default; ", + "\n Task ToReportAsync(); ", "\n}" ], "metadata": {}, From 099644f41ad6bb33d11907b33cb04ad3880c9b1f Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Fri, 17 Feb 2023 11:42:31 +0100 Subject: [PATCH 05/55] working version --- .../Report/InteractiveReports.ipynb | 146 ++---------------- ifrs17/DataModel/DataStructure.ipynb | 18 +-- .../ReportMutableScopesInteractive.ipynb | 19 +-- 3 files changed, 28 insertions(+), 155 deletions(-) diff --git a/ifrs17-template/Report/InteractiveReports.ipynb b/ifrs17-template/Report/InteractiveReports.ipynb index d30ab96a..64889aab 100644 --- a/ifrs17-template/Report/InteractiveReports.ipynb +++ b/ifrs17-template/Report/InteractiveReports.ipynb @@ -86,23 +86,23 @@ "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", - "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", _ => GetReportScope());", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", _ => GetReportScope(key));", "\n return ret;", "\n }", "\n", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope, IWithToReportAsync {", + "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", - "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", - "\n _ => {", - "\n var scope = GetReportScope();", - "\n var filters = scope.GetFilters(); // Not used and should be improved", - "\n return ((IWithToReportAsync)scope).ToReportAsync();", - "\n });", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", + "\n _ => {", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters(); // Not used and should be improved", + "\n return scope.ToReportAsync();", + "\n });", "\n return ret;", "\n }", "\n", - "\n public ReportScope GetReportScope() where T : ReportScope => interactiveObject.State.GetScope(typeof(T).Name, o => o.WithStorage(storage));", + "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n}" ], "metadata": {}, @@ -122,61 +122,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive2.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive2.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var storage = new ReportStorage(Workspace, Report);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - " static T ExpGetScope(Systemorph.InteractiveObjects.InteractiveObjectVariable io, object storage) {", - "\n var ret = io.State.GetScope(typeof(T).Name, o => o.WithStorage(storage));", - "\n return ret;", - "\n }" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "async static Task ExpGetReport(Systemorph.InteractiveObjects.InteractiveObjectVariable io, object storage, Func> resultFacory) ", - "\n//where T : IWithToReportAsync", - "\n {", - "\n var ret = ExpGetScope(io, storage);", - "\n return await resultFacory(ret);", - "\n }" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "//var scope = ExpGetScope(InteractiveObject, storage);", - "\n//await scope.ToReportAsync" + "ifrs17Interactive2.GetFormsEntity(\"A\")" ], "metadata": {}, "execution_count": 0, @@ -185,7 +131,7 @@ { "cell_type": "code", "source": [ - "await ExpGetReport(InteractiveObject, storage, async x => await x.ToReportAsync)" + "ifrs17Interactive2.GetReport(\"A\")" ], "metadata": {}, "execution_count": 0, @@ -194,71 +140,7 @@ { "cell_type": "code", "source": [ - "var a = ifrs17Interactive2.GetReportScope();" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await a.ToReportAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var b = (PvReport) a;" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await b.ToReportAsync()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "interface IA :IScope {", - "\n string M() => \"IA\";", - "\n}", - "\ninterface IB : IA {", - "\n string IA.M() => \"IB\";", - "\n}", - "\n", - "\nInteractiveObject.State.GetScope().M()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "string GetString() where T : IA, new() {", - "\n var iii = new T();", - "\n return iii.M();", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" + "ifrs17Interactive2.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -267,7 +149,7 @@ { "cell_type": "code", "source": [ - "" + "ifrs17Interactive2.GetReport()" ], "metadata": {}, "execution_count": 0, @@ -276,7 +158,7 @@ { "cell_type": "code", "source": [ - "" + "InteractiveObject.CreateView(\"\", _ => ifrs17Interactive2.GetReportScope())" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index b3d65bdd..53452bd8 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -50,21 +50,21 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Activities,1.6.2\"", - "\n#r \"nuget:Systemorph.Arithmetics,1.6.2\"", + "#r \"nuget:Systemorph.Activities,1.6.4\"", + "\n#r \"nuget:Systemorph.Arithmetics,1.6.4\"", "\n#r \"nuget:Systemorph.Workspace,1.6.3\"", - "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.2\"", - "\n#r \"nuget:Systemorph.SharePoint,1.6.2\"", - "\n#r \"nuget:Systemorph.OneDrive,1.6.2\"", - "\n#r \"nuget:Systemorph.Scopes,1.6.2\"", + "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.4\"", + "\n#r \"nuget:Systemorph.SharePoint,1.6.4\"", + "\n#r \"nuget:Systemorph.OneDrive,1.6.4\"", + "\n#r \"nuget:Systemorph.Scopes,1.6.4\"", "\n#r \"nuget:Systemorph.Import,1.6.4\"", - "\n#r \"nuget:Systemorph.Test,1.6.2\"", + "\n#r \"nuget:Systemorph.Test,1.6.4\"", "\n#r \"nuget:Systemorph.Export,1.6.4\"", "\n#r \"nuget:Systemorph.DataSetReader,1.6.4\"", "\n#r \"nuget:Systemorph.DataSource,1.6.3\"", "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.3\"", - "\n#r \"nuget:Systemorph.Reporting,1.6.2\"", - "\n#r \"nuget:Systemorph.Charting,1.6.2\"", + "\n#r \"nuget:Systemorph.Reporting,1.6.4\"", + "\n#r \"nuget:Systemorph.Charting,1.6.4\"", "\n#r \"nuget:Systemorph.SchemaMigrations,1.6.3\"" ], "metadata": {}, diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 85a2ca2c..50796dc6 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -364,6 +364,8 @@ "\n", "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", "\n", + "\n async Task ToReportAsync() => default;", + "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", "\n return await report.ForDataCube(data)", "\n .WithQuerySource(workspace)", @@ -382,17 +384,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "public interface IWithToReportAsync {", - "\n Task ToReportAsync(); ", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -415,11 +406,11 @@ "cell_type": "code", "source": [ "[InitializeScope(nameof(Init))]", - "\npublic interface PvReport : ReportScope, IWithToReportAsync {", - "\n", + "\npublic interface PvReport : ReportScope {", + "\n ", "\n IDataCube GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", "\n", - "\n async Task ToReportAsync() {", + "\n async Task ReportScope.ToReportAsync() {", "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", From 24f009382b66018daffd4eedb1f08dcba8aa7296 Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Fri, 17 Feb 2023 14:02:22 +0100 Subject: [PATCH 06/55] Some clean up --- .../Report/InteractiveReports.ipynb | 74 +++---------------- .../ReportMutableScopesInteractive.ipynb | 46 ++++++------ 2 files changed, 34 insertions(+), 86 deletions(-) diff --git a/ifrs17-template/Report/InteractiveReports.ipynb b/ifrs17-template/Report/InteractiveReports.ipynb index 64889aab..fbd442bc 100644 --- a/ifrs17-template/Report/InteractiveReports.ipynb +++ b/ifrs17-template/Report/InteractiveReports.ipynb @@ -54,75 +54,23 @@ "cell_type": "code", "source": [ "Workspace.InitializeFrom(DataSource);", - "\n//ifrs17Interactive.Reset(Workspace)" + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "public class Ifrs17Interactive2 ", - "\n{", - "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", - "\n private Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject;", - "\n private ReportStorage storage;", - "\n", - "\n private IDictionary interactiveObjectCache = new Dictionary();", + "# Best Estimate", "\n", - "\n public Ifrs17Interactive2 (IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report, Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject)", - "\n {", - "\n this.report = report;", - "\n this.interactiveObject = interactiveObject;", - "\n storage = new ReportStorage(workspace, report);", - "\n }", + "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#best-estimate) future cash flows are shown here in an Analysis of Change report.", "\n", - "\n public void Reset(IWorkspace workspace) {", - "\n storage = new ReportStorage(workspace, report);", - "\n interactiveObjectCache = new Dictionary();", - "\n }", + "\nThe granularity of the reported figures can be modified by changing the Column Slices options.", + "\nFor example one can add \"GroupOfContract\" to separate the contributions of the individual Group of Contracts.", "\n", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", - "\n var key = name ?? typeof(T).Name;", - "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", - "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", _ => GetReportScope(key));", - "\n return ret;", - "\n }", - "\n", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope {", - "\n var key = name ?? typeof(T).Name;", - "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", - "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", - "\n _ => {", - "\n var scope = GetReportScope(key);", - "\n var filters = scope.GetFilters(); // Not used and should be improved", - "\n return scope.ToReportAsync();", - "\n });", - "\n return ret;", - "\n }", - "\n", - "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var ifrs17Interactive2 = new Ifrs17Interactive2(Workspace, Report, InteractiveObject);", - "\nifrs17Interactive2.Reset(Workspace)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive2.GetFormsEntity(\"A\")" + "\nAggregated values are displayed when the data has a finer granularity than the one selected by the report slice options." ], "metadata": {}, "execution_count": 0, @@ -131,7 +79,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive2.GetReport(\"A\")" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -140,7 +88,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive2.GetFormsEntity()" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, @@ -149,7 +97,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive2.GetReport()" + "" ], "metadata": {}, "execution_count": 0, @@ -158,7 +106,7 @@ { "cell_type": "code", "source": [ - "InteractiveObject.CreateView(\"\", _ => ifrs17Interactive2.GetReportScope())" + "" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 50796dc6..70c2c0a2 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -364,7 +364,14 @@ "\n", "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", "\n", - "\n async Task ToReportAsync() => default;", + "\n IDataCube GetData() => default;", + "\n", + "\n async Task ToReportAsync() {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await GetReportTaskAsync(dataScope.DataCube);", + "\n }", "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", "\n return await report.ForDataCube(data)", @@ -408,14 +415,7 @@ "[InitializeScope(nameof(Init))]", "\npublic interface PvReport : ReportScope {", "\n ", - "\n IDataCube GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", - "\n", - "\n async Task ReportScope.ToReportAsync() {", - "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", - "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", - "\n dataScope.InputDataCube = GetData();", - "\n return await GetReportTaskAsync(dataScope.DataCube);", - "\n }", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", @@ -489,23 +489,23 @@ "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", - "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", state => state.GetScope(key, o => o.WithStorage(storage)));", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", _ => GetReportScope(key));", + "\n return ret;", + "\n }", + "\n", + "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope {", + "\n var key = name ?? typeof(T).Name;", + "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", + "\n _ => {", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters(); // Not used and should be improved", + "\n return scope.ToReportAsync();", + "\n });", "\n return ret;", "\n }", "\n", - "\n // public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope {", - "\n // var key = name ?? typeof(T).Name;", - "\n // if(!interactiveObjectCache.TryGetValue(key, out var ret))", - "\n // ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", - "\n // state => {", - "\n // var scope = state.GetScope(key, o => o.WithStorage(storage));", - "\n // //var filters = scope.GetFilters(); // Not used and should be improved", - "\n // return scope.ToReportAsync();", - "\n // });", - "\n // return ret;", - "\n // }", - "\n", - "\n public ReportScope GetReportScope() where T : ReportScope => interactiveObject.State.GetScope(typeof(T).Name, o => o.WithStorage(storage));", + "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n}" ], "metadata": {}, From 7942b86f22070bd61531127ac41569258fddf080 Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Mon, 20 Feb 2023 09:23:23 +0100 Subject: [PATCH 07/55] adding reports --- .../Report/InteractiveReports.ipynb | 342 +++++++++++++++ .../ReportMutableScopesInteractive.ipynb | 401 +++++++++++++++--- 2 files changed, 687 insertions(+), 56 deletions(-) diff --git a/ifrs17-template/Report/InteractiveReports.ipynb b/ifrs17-template/Report/InteractiveReports.ipynb index fbd442bc..98231218 100644 --- a/ifrs17-template/Report/InteractiveReports.ipynb +++ b/ifrs17-template/Report/InteractiveReports.ipynb @@ -103,6 +103,348 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 70c2c0a2..80f5dc19 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -440,7 +440,335 @@ { "cell_type": "code", "source": [ - "" + "[InitializeScope(nameof(Init))]", + "\npublic interface RaReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedRiskAdjustment + GetScopes(GetDataIdentities()).Aggregate().CurrentRiskAdjustment;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## FCF PV" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface FcfReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Fcf;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Written" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface WrittenReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Written;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"AmountType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Accruals" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface AccrualReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Advance + GetScopes(GetDataIdentities()).Aggregate().Overdue;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Deferrals" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface DeferralReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Deferrals;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Experience Adjustment" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface ExpAdjReport: ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().ActuarialExperienceAdjustment;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"EstimateType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"AmountType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Technical Margin" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface TmReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LrcTechnicalMargin;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## CSM" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface CsmReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Csm + GetScopes(GetDataIdentities()).Aggregate().Lc + GetScopes(GetDataIdentities()).Aggregate().Loreco;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## LRC" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface ActLrcReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LrcActuarial;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface LrcReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() =>GetScopes(GetDataIdentities()).Aggregate().Lrc;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## LIC" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface ActLicReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LicActuarial;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface LicReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().Lic;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"VariableType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Financial Performance" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(Init))]", + "\npublic interface FpReport : ReportScope {", + "\n ", + "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().FinancialPerformance;", + "\n", + "\n void Init() {", + "\n // BasicSliceAndDiceFormsEntity", + "\n defaultRowSlices = new string[] { \"VariableType\", \"EstimateType\" };", + "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", + "\n }", + "\n}" ], "metadata": {}, "execution_count": 0, @@ -506,67 +834,28 @@ "\n }", "\n", "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", + "\n", + "\n // Keeping the old API", + "\n public ReportScope PresentValues => GetReportScope();", + "\n public ReportScope RiskAdjustments => GetReportScope();", + "\n public ReportScope FulfillmentCashflows => GetReportScope();", + "\n public ReportScope WrittenActuals => GetReportScope();", + "\n public ReportScope AccrualActuals => GetReportScope();", + "\n public ReportScope DeferralActuals => GetReportScope();", + "\n public ReportScope ExperienceAdjustments => GetReportScope();", + "\n public ReportScope TechnicalMargins => GetReportScope();", + "\n public ReportScope AllocatedTechnicalMargins => GetReportScope();", + "\n public ReportScope ActuarialLrc => GetReportScope();", + "\n public ReportScope Lrc => GetReportScope();", + "\n public ReportScope ActuarialLic => GetReportScope();", + "\n public ReportScope Lic => GetReportScope();", + "\n public ReportScope FinancialPerformance => GetReportScope(); ", "\n}" ], "metadata": {}, "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "// public class Ifrs17Interactive ", - "\n// {", - "\n// //private Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes;", - "\n// private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", - "\n// private Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject;", - "\n// private ReportStorage storage;", - "\n ", - "\n// //reset", - "\n// public void Reset(IWorkspace workspace) => storage = new ReportStorage(workspace, report);", - "\n", - "\n// //constructor", - "\n// public Ifrs17Interactive (IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report, Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject)", - "\n// {", - "\n// //this.scopes = scopes; ", - "\n// this.report = report;", - "\n// this.interactiveObject = interactiveObject;", - "\n// storage = new ReportStorage(workspace, report);", - "\n// }", - "\n ", - "\n// public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView PvReportFormsEntity =>", - "\n// interactiveObject.CreateView(nameof(PvReportFormsEntity),", - "\n// state => state.GetScope(nameof(PvReport), o => o.WithStorage(storage)));", - "\n ", - "\n// public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView PvReportGrid =>", - "\n// interactiveObject.CreateView(nameof(PvReportGrid),", - "\n// state => {", - "\n// var scope = state.GetScope(nameof(PvReport), o => o.WithStorage(storage));", - "\n// var filters = scope.GetFilters(); // Not used and should be improved", - "\n// return scope.ToReportAsync();", - "\n// });", - "\n", - "\n", - "\n// //public IIfrs17Report PresentValues => reportUniverse.GetScope();", - "\n// // public IIfrs17Report RiskAdjustments => reportUniverse.GetScope();", - "\n// // public IIfrs17Report WrittenActuals => reportUniverse.GetScope();", - "\n// // public IIfrs17Report AccrualActuals => reportUniverse.GetScope();", - "\n// // public IIfrs17Report DeferralActuals => reportUniverse.GetScope();", - "\n// // public IIfrs17Report FulfillmentCashflows => reportUniverse.GetScope();", - "\n// // public IIfrs17Report ExperienceAdjustments => reportUniverse.GetScope();", - "\n// // public IIfrs17Report TechnicalMargins => reportUniverse.GetScope();", - "\n// // public IIfrs17Report AllocatedTechnicalMargins => reportUniverse.GetScope();", - "\n// // public IIfrs17Report ActuarialLrc => reportUniverse.GetScope();", - "\n// // public IIfrs17Report Lrc => reportUniverse.GetScope();", - "\n// // public IIfrs17Report ActuarialLic => reportUniverse.GetScope();", - "\n// // public IIfrs17Report Lic => reportUniverse.GetScope();", - "\n// // public IIfrs17Report FinancialPerformance => reportUniverse.GetScope();", - "\n// }" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ From bce19e23587e9e4757da0880b75b67b394724dc6 Mon Sep 17 00:00:00 2001 From: Daniel Trzesniak Date: Mon, 20 Feb 2023 14:53:49 +0100 Subject: [PATCH 08/55] update --- ifrs17/Report/ReportConfigurationAndUtils.ipynb | 2 +- ifrs17/Report/ReportMutableScopesInteractive.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index 713370ae..18ccbcc3 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -214,7 +214,7 @@ "source": [ "public static async Task<(IDictionary, IReadOnlyCollection)> GetAutocompleteMappings (this IQuerySource querySource, bool hasNullAsFirstValue = default) where T : KeyedDimension {", "\n var query = await querySource.Query().Select(x => new { x.SystemName, GuiName = ParseDimensionToDisplayString(x.SystemName, x.DisplayName), Order = 0 }).ToArrayAsync();", - "\n var mappingDictionary = query.ToDictionary(x => x.GuiName, x => x.SystemName);", + "\n var mappingDictionary = query.SelectMany(x => new [] { new {GuiName = x.SystemName, x.SystemName}, new {GuiName = x.GuiName, x.SystemName} }).ToDictionary(x => x.GuiName, x => x.SystemName);", "\n var orderedDropDownValues = query.OrderBy(x => x.Order).ThenBy(x => x.GuiName).Select(x => x.GuiName);", "\n return (mappingDictionary, (hasNullAsFirstValue ? new string[]{ null }.Concat(orderedDropDownValues) : orderedDropDownValues).ToArray());", "\n}" diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 80f5dc19..0f8c4886 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -153,7 +153,7 @@ "\n string ReportingNodeControl { get; set; }", "\n", "\n [NotVisible] IDictionary ReportingNodeMapping { get; set; }", - "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue( ReportingNodeControl, out var value)", + "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue(ReportingNodeControl, out var value)", "\n ? value", "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", "\n", From d1c45db93e14283d143ee621f7153ecfb00ceab0 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 24 Feb 2023 14:37:25 +0100 Subject: [PATCH 09/55] adding comments and todos --- .../Report/ReportConfigurationAndUtils.ipynb | 2 +- .../ReportMutableScopesInteractive.ipynb | 68 +++++++++++++------ 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index 18ccbcc3..061851c6 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -213,7 +213,7 @@ "cell_type": "code", "source": [ "public static async Task<(IDictionary, IReadOnlyCollection)> GetAutocompleteMappings (this IQuerySource querySource, bool hasNullAsFirstValue = default) where T : KeyedDimension {", - "\n var query = await querySource.Query().Select(x => new { x.SystemName, GuiName = ParseDimensionToDisplayString(x.SystemName, x.DisplayName), Order = 0 }).ToArrayAsync();", + "\n var query = await querySource.Query().Select(x => new { x.SystemName, GuiName = ParseDimensionToDisplayString(x.SystemName, x.DisplayName), Order = 0 }).ToArrayAsync(); //TODO extentions: populate order if type T is an orderedDimension. If it is a Hierarchical dimension then the order ", "\n var mappingDictionary = query.SelectMany(x => new [] { new {GuiName = x.SystemName, x.SystemName}, new {GuiName = x.GuiName, x.SystemName} }).ToDictionary(x => x.GuiName, x => x.SystemName);", "\n var orderedDropDownValues = query.OrderBy(x => x.Order).ThenBy(x => x.GuiName).Select(x => x.GuiName);", "\n return (mappingDictionary, (hasNullAsFirstValue ? new string[]{ null }.Concat(orderedDropDownValues) : orderedDropDownValues).ToArray());", diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 0f8c4886..01028811 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -116,10 +116,15 @@ { "cell_type": "code", "source": [ - "public interface ScenarioFormsEntity : MutableScopeWithWorkspace {", + "// TODO ", + "\n// Andrea functionality missing (delta,all): ", + "\n//New scope : Comparison view to compare different partitions : at the moment it can compare only scenarios => All, delta", + "\n", + "\n//This select a scenario to display", + "\npublic interface ScenarioFormsEntity : MutableScopeWithWorkspace {", "\n [DropdownMethod(nameof(GetScenarioAutocompleteAsync))]", "\n [Display(Name = \"Scenario\")]", - "\n string ScenarioControl { get; set; }", + "\n string ScenarioControl { get; set; } //TODO initialize with empty", "\n", "\n [NotVisible] IDictionary ScenarioMapping { get; set; }", "\n protected string Scenario => !string.IsNullOrWhiteSpace(ScenarioControl) && ScenarioMapping is not null && ScenarioMapping.TryGetValue(ScenarioControl, out var value) ? value : null;", @@ -150,19 +155,22 @@ "\npublic interface ReportingNodeFormsEntity : MutableScopeWithWorkspace {", "\n [DropdownMethod(nameof(GetReportingNodeAutocompleteAsync))]", "\n [Display(Name = \"ReportingNode\")]", - "\n string ReportingNodeControl { get; set; }", + "\n string ReportingNodeControl { get; set; } //TODO Rename ReportingNode => this rename goes for all cases", "\n", "\n [NotVisible] IDictionary ReportingNodeMapping { get; set; }", - "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue(ReportingNodeControl, out var value)", + "\n //TODO rename ReportingNode(SystemName)", + "\n protected string ReportingNode => // ReportingNodeMapping is not null : TODO chek this first if null call the init of the mapping and continue", + "\n !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue(ReportingNodeControl, out var value)", "\n ? value", "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", "\n", + "\n //TODO this is not init when using the old report (not interactive) : prio2", "\n async Task> GetReportingNodeAutocompleteAsync(string userInput, int page, int pageSize) {", "\n (ReportingNodeMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", "\n }", "\n", - "\n async void InitReportingNode() {", + "\n void InitReportingNode() {", "\n ReportingNodeControl = ParseDimensionToDisplayString(GetStorage().InitialReportingNode.SystemName, GetStorage().InitialReportingNode.DisplayName);", "\n }", "\n}" @@ -215,7 +223,7 @@ "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", "\n .ToArrayAsync();", "\n", - "\n async void InitReportingPeriod() {", + "\n void InitReportingPeriod() {", "\n ReportingPeriod = ParseReportingPeriodToDisplayString(GetStorage().InitialReportingPeriod.Year, GetStorage().InitialReportingPeriod.Month, separator);", "\n }", "\n}" @@ -236,8 +244,10 @@ { "cell_type": "code", "source": [ - "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", + "//TODO decide to push this intermediate state or not (final stage is with v7 dropdowns)", + "\n", + "\npublic interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")] //TODO all dimensions", "\n string FilterName { get; set; }", "\n", "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", @@ -250,7 +260,7 @@ "\n new string[]{ null }.Concat(", "\n await (FilterName switch", "\n {", - "\n \"GroupOfContract\" => workspace.Query().Select(x => x.SystemName),", + "\n \"GroupOfContract\" => workspace.Query().Select(x => x.SystemName), //TODO all dim - use GetAutocompleteMappings (put DisplayName and SystemName together) - move them to the storage?? ", "\n \"Novelty\" => workspace.Query().Select(x => x.SystemName),", "\n \"EconomicBasis\" => workspace.Query().Select(x => x.SystemName),", "\n _ => Enumerable.Empty().AsQueryable()", @@ -258,7 +268,7 @@ "\n ", "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", "\n ", - "\n // This is just a cast... do we need this?", + "\n // Filer can handle OR cases - Sire used them", "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null ? Enumerable.Empty<(string, object)>() : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", "\n", "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", @@ -304,11 +314,15 @@ { "cell_type": "code", "source": [ - "public interface BasicSliceAndDiceFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownValues(\"\", \"GroupOfContract\")]", + "//TODO with current UI selection you need Add/Remove options to support multiple selection", + "\n//else wait for the new dropdowns", + "\n//seperate the slice in two rows/columns", + "\n", + "\npublic interface BasicSliceAndDiceFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownValues(\"\", \"GroupOfContract\")] //TODO make a method to populate the options and override it in each report", "\n string SliceRowName { get; set; }", "\n", - "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", + "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))] //this is the method to override in the report", "\n string SliceColumnName { get; set; }", "\n", "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", @@ -338,16 +352,25 @@ { "cell_type": "code", "source": [ - "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", + "//TODO remove filter but you need to pass them anymore", + "\n", + "\npublic interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", "\n IDataCube InputDataCube { get; set; }", "\n", - "\n IDataCube DataCube { get {", + "\n IDataCube DataCube { get { //todo remove filter", "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ? InputDataCube : InputDataCube.Filter(Identity.dataFilter); ", "\n if(Identity.scenario != \"Delta\") return filteredDataCube;", "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", "\n return filteredDataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0d) }).ToDataCube();", "\n }}", + "\n", + "\n // IDataCube GetFilteredDataCube (filter) //method (not cached)", + "\n // {", + "\n // return (dataFilter is null || dataFilter.Length == 0) ", + "\n // ? DataCube ", + "\n // : DataCube.Filter(Identity.dataFilter); ", + "\n // }", "\n} " ], "metadata": {}, @@ -367,10 +390,12 @@ "\n IDataCube GetData() => default;", "\n", "\n async Task ToReportAsync() {", + "\n //extract data to be called in export and graph: dataScope.DataCube", "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", - "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", - "\n dataScope.InputDataCube = GetData();", - "\n return await GetReportTaskAsync(dataScope.DataCube);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));//remove dataFilter", + "\n dataScope.InputDataCube = GetData(); ", + "\n //end prepareDataAsync", + "\n return await GetReportTaskAsync(dataScope.DataCube);//call GetFilteredDataCube", "\n }", "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", @@ -382,6 +407,11 @@ "\n .ExecuteAsync();", "\n }", "\n", + "\n //TODO method for export", + "\n //TODO method for graph", + "\n", + "\n //repor .ForObject", + "\n", "\n async Task InitReportStorageScopeAsync() { // This has the Async issue, but imo it should come in the future", "\n await GetStorage().InitializeReportIndependentCacheAsync();", "\n }", @@ -416,7 +446,7 @@ "\npublic interface PvReport : ReportScope {", "\n ", "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", - "\n", + "\n//todo if you put [NotVisible] you can maybe hide the controll ", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", From d8400c9969864c71315e5318127cf8a5eded5177 Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 27 Feb 2023 16:11:36 +0100 Subject: [PATCH 10/55] Allow overwriting filter names. Add Delta and all to the scenarios list (hardcoded at this point) --- ifrs17/DataModel/DataStructure.ipynb | 18 +++++++++--------- .../ReportMutableScopesInteractive.ipynb | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 53452bd8..38dcde94 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -50,21 +50,21 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Activities,1.6.4\"", - "\n#r \"nuget:Systemorph.Arithmetics,1.6.4\"", + "#r \"nuget:Systemorph.Activities,1.6.5-ci-20230222-101910\"", + "\n#r \"nuget:Systemorph.Arithmetics,1.6.5-ci-20230222-101910\"", "\n#r \"nuget:Systemorph.Workspace,1.6.3\"", - "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.4\"", - "\n#r \"nuget:Systemorph.SharePoint,1.6.4\"", - "\n#r \"nuget:Systemorph.OneDrive,1.6.4\"", - "\n#r \"nuget:Systemorph.Scopes,1.6.4\"", + "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.5-ci-20230222-101910\"", + "\n#r \"nuget:Systemorph.SharePoint,1.6.5-ci-20230222-101910\"", + "\n#r \"nuget:Systemorph.OneDrive,1.6.5-ci-20230222-101910\"", + "\n#r \"nuget:Systemorph.Scopes,1.6.5-ci-20230222-101910\"", "\n#r \"nuget:Systemorph.Import,1.6.4\"", - "\n#r \"nuget:Systemorph.Test,1.6.4\"", + "\n#r \"nuget:Systemorph.Test,1.6.5-ci-20230222-101910\"", "\n#r \"nuget:Systemorph.Export,1.6.4\"", "\n#r \"nuget:Systemorph.DataSetReader,1.6.4\"", "\n#r \"nuget:Systemorph.DataSource,1.6.3\"", "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.3\"", - "\n#r \"nuget:Systemorph.Reporting,1.6.4\"", - "\n#r \"nuget:Systemorph.Charting,1.6.4\"", + "\n#r \"nuget:Systemorph.Reporting,1.6.5-ci-20230222-101910\"", + "\n#r \"nuget:Systemorph.Charting,1.6.5-ci-20230222-101910\"", "\n#r \"nuget:Systemorph.SchemaMigrations,1.6.3\"" ], "metadata": {}, diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 0f8c4886..29a5dca3 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -126,7 +126,9 @@ "\n ", "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", - "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", + "\n .Concat(new string[] {\"Delta\", \"All\"})", + "\n .ToArray(); ", "\n } ", "\n}" ], @@ -162,7 +164,7 @@ "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", "\n }", "\n", - "\n async void InitReportingNode() {", + "\n void InitReportingNode() {", "\n ReportingNodeControl = ParseDimensionToDisplayString(GetStorage().InitialReportingNode.SystemName, GetStorage().InitialReportingNode.DisplayName);", "\n }", "\n}" @@ -215,7 +217,7 @@ "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", "\n .ToArrayAsync();", "\n", - "\n async void InitReportingPeriod() {", + "\n void InitReportingPeriod() {", "\n ReportingPeriod = ParseReportingPeriodToDisplayString(GetStorage().InitialReportingPeriod.Year, GetStorage().InitialReportingPeriod.Month, separator);", "\n }", "\n}" @@ -237,7 +239,8 @@ "cell_type": "code", "source": [ "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", + "\n // [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", + "\n [DropdownValues(nameof(GetFilterName))]", "\n string FilterName { get; set; }", "\n", "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", @@ -245,6 +248,8 @@ "\n", "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", "\n string FilterAction { get; set; }", + "\n", + "\n virtual IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\"};", "\n ", "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", "\n new string[]{ null }.Concat(", @@ -826,9 +831,9 @@ "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", "\n _ => {", - "\n var scope = GetReportScope(key);", - "\n var filters = scope.GetFilters(); // Not used and should be improved", - "\n return scope.ToReportAsync();", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters(); // Not used and should be improved", + "\n return scope.ToReportAsync();", "\n });", "\n return ret;", "\n }", From 90442697f9e59a9ba61dbe4e260aa8d829bb7f97 Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 27 Feb 2023 18:28:17 +0100 Subject: [PATCH 11/55] all the filters are separately defined --- .../ReportMutableScopesInteractive.ipynb | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 29a5dca3..be59191e 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -240,7 +240,7 @@ "source": [ "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", "\n // [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", - "\n [DropdownValues(nameof(GetFilterName))]", + "\n [DropdownMethod(nameof(GetFilterName))]", "\n string FilterName { get; set; }", "\n", "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", @@ -427,6 +427,8 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"Novelty\", \"VariableType\", \"Currency\", \"LiabilityType\", \"GroupOfContract\"};", "\n}" ], "metadata": {}, @@ -455,6 +457,8 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"VariableType\", \"Currency\"};", "\n}" ], "metadata": {}, @@ -483,6 +487,8 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GitFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"VariableType\", \"Currency\"};", "\n}" ], "metadata": {}, @@ -511,6 +517,8 @@ "\n defaultRowSlices = new string[] { \"AmountType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"AmountType\", \"LiabilityType\", \"Currency\"};", "\n}" ], "metadata": {}, @@ -539,6 +547,9 @@ "\n defaultRowSlices = new string[] { \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"VariableType\", \"LiabilityType\", \"Currency\"};", + "\n", "\n}" ], "metadata": {}, @@ -567,6 +578,9 @@ "\n defaultRowSlices = new string[] { \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"VariableType\", \"Currency\", \"LiabilityType\"};", + "\n", "\n}" ], "metadata": {}, @@ -595,6 +609,9 @@ "\n defaultRowSlices = new string[] { \"EstimateType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"AmountType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Currency\", \"AmountType\", \"EstimateType\"};", + "\n", "\n}" ], "metadata": {}, @@ -623,6 +640,8 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"Currency\", \"VariableType\"};", "\n}" ], "metadata": {}, @@ -651,6 +670,9 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"EstimateType\", \"VariableType\"};", + "\n", "\n}" ], "metadata": {}, @@ -679,6 +701,9 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"VariableType\", \"Currency\"};", + "\n", "\n}" ], "metadata": {}, @@ -698,6 +723,9 @@ "\n defaultRowSlices = new string[] { \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"VariableType\", \"EstimateType\", \"Currency\"};", + "\n", "\n}" ], "metadata": {}, @@ -726,6 +754,9 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"VariableType\", \"EstimateType\", \"Currency\"};", + "\n", "\n}" ], "metadata": {}, @@ -745,6 +776,8 @@ "\n defaultRowSlices = new string[] { \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Currency\", \"VariableType\", \"EstimateType\"};", + "\n", "\n}" ], "metadata": {}, @@ -773,6 +806,9 @@ "\n defaultRowSlices = new string[] { \"VariableType\", \"EstimateType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", "\n }", + "\n", + "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Currency\", \"VariableType\", \"EstimateType\"};", + "\n", "\n}" ], "metadata": {}, From 0305e3f657a8474b25cace66a5348c7c9d67a18b Mon Sep 17 00:00:00 2001 From: akatz Date: Tue, 28 Feb 2023 17:44:13 +0100 Subject: [PATCH 12/55] incorporate exports. Appropriate changes to the report storage are made --- .../ReportMutableScopesInteractive.ipynb | 93 +++++++++++++++++-- ifrs17/Report/ReportStorage.ipynb | 10 +- 2 files changed, 91 insertions(+), 12 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index be59191e..bf62dd49 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -54,6 +54,20 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "using Systemorph.Vertex.Pivot.Builder.Interfaces;", + "\nusing Systemorph.InteractiveObjects;", + "\nusing Systemorph.Vertex.Session;", + "\nusing Systemorph.Vertex.Export;", + "\nusing Systemorph.Vertex.Export.Factory;", + "\nusing Systemorph.Vertex.InteractiveObjects;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -249,7 +263,9 @@ "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", "\n string FilterAction { get; set; }", "\n", - "\n virtual IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\"};", + "\n protected string[] defaultFilters => new string[] {\"\", \"GroupOfContract\", \"Portfolio\", \"LineOfBusiness\", \"AnnualCohort\"};", + "\n", + "\n IReadOnlyCollection GetFilterName() => defaultFilters;", "\n ", "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", "\n new string[]{ null }.Concat(", @@ -364,7 +380,8 @@ "source": [ "[InitializeScope(nameof(InitReportStorageScopeAsync))]", "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, BasicSliceAndDiceFormsEntity, BasicFilterFormsEntity {", - "\n protected Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report => GetStorage().Report;", + "\n protected IPivotFactory report => GetStorage().Report;", + "\n protected IExportVariable export => GetStorage().Export;", "\n protected int headerColumnWidthValue => 250;", "\n", "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", @@ -378,6 +395,28 @@ "\n return await GetReportTaskAsync(dataScope.DataCube);", "\n }", "\n", + "\n async Task ToCsvAsync(string fileName){", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await export.ToCsv(fileName)", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices))", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task ToExcelAsync(string fileName){", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await export.ToExcel(fileName)", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices))", + "\n .ExecuteAsync();", + "\n }", + "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", "\n return await report.ForDataCube(data)", "\n .WithQuerySource(workspace)", @@ -836,33 +875,41 @@ { "cell_type": "code", "source": [ - "public class Ifrs17Interactive {", - "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", - "\n private Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject;", + "using Systemorph.Vertex.Pivot.Builder.Interfaces;", + "\nusing Systemorph.InteractiveObjects;", + "\nusing Systemorph.Vertex.Session;", + "\npublic class Ifrs17Interactive {", + "\n private IPivotFactory report;", + "\n private IExportVariable export;", + "\n private InteractiveObjectVariable interactiveObject;", "\n private ReportStorage storage;", "\n", "\n private IDictionary interactiveObjectCache = new Dictionary();", "\n", - "\n public Ifrs17Interactive (IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report, Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject)", + "\n public Ifrs17Interactive (IWorkspace workspace, ", + "\n IPivotFactory report, ", + "\n IExportVariable export,", + "\n InteractiveObjectVariable interactiveObject)", "\n {", "\n this.report = report;", + "\n this.export = export;", "\n this.interactiveObject = interactiveObject;", - "\n storage = new ReportStorage(workspace, report);", + "\n storage = new ReportStorage(workspace, report, export);", "\n }", "\n", "\n public void Reset(IWorkspace workspace) {", - "\n storage = new ReportStorage(workspace, report);", + "\n storage = new ReportStorage(workspace, report, export);", "\n interactiveObjectCache = new Dictionary();", "\n }", "\n", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", + "\n public InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", _ => GetReportScope(key));", "\n return ret;", "\n }", "\n", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope {", + "\n public InteractiveObjectView GetReport(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", @@ -874,6 +921,32 @@ "\n return ret;", "\n }", "\n", + "\n public InteractiveObjectView ExportToCsv(string fileName)", + "\n where T : ReportScope", + "\n {", + "\n var key = fileName + \".csv\";", + "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, _ => {", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters();", + "\n return scope.ToCsvAsync(fileName);", + "\n });", + "\n return ret;", + "\n } ", + "\n", + "\n public InteractiveObjectView ExportToExcel(string fileName)", + "\n where T : ReportScope", + "\n {", + "\n var key = fileName + \".xls\";", + "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, _ => {", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters();", + "\n return scope.ToExcelAsync(fileName);", + "\n });", + "\n return ret;", + "\n }", + "\n", "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n", "\n // Keeping the old API", diff --git a/ifrs17/Report/ReportStorage.ipynb b/ifrs17/Report/ReportStorage.ipynb index 19fc3ff3..4d7eed27 100644 --- a/ifrs17/Report/ReportStorage.ipynb +++ b/ifrs17/Report/ReportStorage.ipynb @@ -105,8 +105,10 @@ { "cell_type": "code", "source": [ - "public class ReportStorage {", + "using Systemorph.Vertex.Export.Factory;", + "\npublic class ReportStorage {", "\n protected readonly IWorkspace workspace;", + "\n protected readonly IExportVariable export;", "\n private readonly Systemorph.Vertex.Hierarchies.IHierarchicalDimensionCache hierarchicalDimensionCache;", "\n private readonly Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory;", "\n ", @@ -129,10 +131,13 @@ "\n private Dictionary<((int year, int month) period, string reportingNode, string scenario), Dictionary>>> variablesDictionary = new();", "\n ", "\n // Constructor", - "\n public ReportStorage(IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory) {", + "\n public ReportStorage(IWorkspace workspace, ", + "\n Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory, ", + "\n IExportVariable export) {", "\n this.workspace = workspace;", "\n this.hierarchicalDimensionCache = workspace.ToHierarchicalDimensionCache();", "\n this.reportFactory = reportFactory;", + "\n this.export = export;", "\n }", "\n ", "\n // Initializers", @@ -211,6 +216,7 @@ "\n // Other getters", "\n public IWorkspace Workspace => workspace;", "\n public Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory Report => reportFactory;", + "\n public IExportVariable Export => export;", "\n", "\n public Systemorph.Vertex.Hierarchies.IHierarchy GetHierarchy() where T : class, IHierarchicalDimension => hierarchicalDimensionCache.Get();", "\n ", From eaf2000d21defb39c33470ec50bf8e5a46a27498 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Wed, 1 Mar 2023 16:45:49 +0100 Subject: [PATCH 13/55] filter changes + adapt old api --- ifrs17/CalculationEngine.ipynb | 4 +- ifrs17/Report/ReportMutableScopes.ipynb | 13 +- .../ReportMutableScopesInteractive.ipynb | 271 ++++++++++++++---- ifrs17/Report/ReportStorage.ipynb | 10 +- 4 files changed, 227 insertions(+), 71 deletions(-) diff --git a/ifrs17/CalculationEngine.ipynb b/ifrs17/CalculationEngine.ipynb index 08ea709e..4e53cb9b 100644 --- a/ifrs17/CalculationEngine.ipynb +++ b/ifrs17/CalculationEngine.ipynb @@ -35,7 +35,7 @@ { "cell_type": "code", "source": [ - "var ifrs17 = new Ifrs17(Workspace, Scopes, Report);" + "var ifrs17 = new Ifrs17(Workspace, Scopes, Report, Export);" ], "metadata": {}, "execution_count": 0, @@ -44,7 +44,7 @@ { "cell_type": "code", "source": [ - "var ifrs17Interactive = new Ifrs17Interactive(Workspace, Report, InteractiveObject);" + "var ifrs17Interactive = new Ifrs17Interactive(Workspace, Report, Export, InteractiveObject);" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Report/ReportMutableScopes.ipynb b/ifrs17/Report/ReportMutableScopes.ipynb index 91f9faf9..c08680fe 100644 --- a/ifrs17/Report/ReportMutableScopes.ipynb +++ b/ifrs17/Report/ReportMutableScopes.ipynb @@ -330,18 +330,23 @@ "\n{", "\n private Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes;", "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", + "\n private IExportVariable export;", "\n private ReportStorage Storage;", "\n private ReportUniverse reportUniverse;", "\n ", "\n //reset", - "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report);", + "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report, export);", "\n", "\n //constructor", - "\n public Ifrs17 (IWorkspace workspace, Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report)", + "\n public Ifrs17 (IWorkspace workspace, ", + "\n Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes, ", + "\n Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report,", + "\n IExportVariable export)", "\n {", "\n this.scopes = scopes; ", - "\n this.report = report; ", - "\n Storage = new ReportStorage(workspace, report);", + "\n this.report = report;", + "\n this.export = export;", + "\n Storage = new ReportStorage(workspace, report, export);", "\n reportUniverse = scopes.ForSingleton().WithStorage(Storage).ToScope();", "\n }", "\n", diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 01028811..774ec368 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -54,6 +54,20 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "using Systemorph.Vertex.Pivot.Builder.Interfaces;", + "\nusing Systemorph.InteractiveObjects;", + "\nusing Systemorph.Vertex.Session;", + "\nusing Systemorph.Vertex.Export;", + "\nusing Systemorph.Vertex.Export.Factory;", + "\nusing Systemorph.Vertex.InteractiveObjects;" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -116,22 +130,19 @@ { "cell_type": "code", "source": [ - "// TODO ", - "\n// Andrea functionality missing (delta,all): ", - "\n//New scope : Comparison view to compare different partitions : at the moment it can compare only scenarios => All, delta", - "\n", - "\n//This select a scenario to display", - "\npublic interface ScenarioFormsEntity : MutableScopeWithWorkspace {", + "public interface ScenarioFormsEntity : MutableScopeWithWorkspace {", "\n [DropdownMethod(nameof(GetScenarioAutocompleteAsync))]", "\n [Display(Name = \"Scenario\")]", - "\n string ScenarioControl { get; set; } //TODO initialize with empty", + "\n string ScenarioControl { get; set; }", "\n", "\n [NotVisible] IDictionary ScenarioMapping { get; set; }", "\n protected string Scenario => !string.IsNullOrWhiteSpace(ScenarioControl) && ScenarioMapping is not null && ScenarioMapping.TryGetValue(ScenarioControl, out var value) ? value : null;", "\n ", "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", - "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", + "\n .Concat(new string[] {\"Delta\", \"All\"})", + "\n .ToArray(); ", "\n } ", "\n}" ], @@ -139,6 +150,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Comparison" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -155,16 +175,13 @@ "\npublic interface ReportingNodeFormsEntity : MutableScopeWithWorkspace {", "\n [DropdownMethod(nameof(GetReportingNodeAutocompleteAsync))]", "\n [Display(Name = \"ReportingNode\")]", - "\n string ReportingNodeControl { get; set; } //TODO Rename ReportingNode => this rename goes for all cases", + "\n string ReportingNodeControl { get; set; }", "\n", "\n [NotVisible] IDictionary ReportingNodeMapping { get; set; }", - "\n //TODO rename ReportingNode(SystemName)", - "\n protected string ReportingNode => // ReportingNodeMapping is not null : TODO chek this first if null call the init of the mapping and continue", - "\n !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue(ReportingNodeControl, out var value)", + "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue(ReportingNodeControl, out var value)", "\n ? value", "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", "\n", - "\n //TODO this is not init when using the old report (not interactive) : prio2", "\n async Task> GetReportingNodeAutocompleteAsync(string userInput, int page, int pageSize) {", "\n (ReportingNodeMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).ToArray(); ", @@ -244,10 +261,8 @@ { "cell_type": "code", "source": [ - "//TODO decide to push this intermediate state or not (final stage is with v7 dropdowns)", - "\n", - "\npublic interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")] //TODO all dimensions", + "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownMethod(nameof(GetFilterName))]", "\n string FilterName { get; set; }", "\n", "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", @@ -255,20 +270,49 @@ "\n", "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", "\n string FilterAction { get; set; }", + "\n", + "\n protected string[] defaultFilters => new string[] {\"\", ", + "\n nameof(ReportVariable.GroupOfContract), ", + "\n nameof(ReportVariable.Portfolio), ", + "\n nameof(ReportVariable.LineOfBusiness), ", + "\n nameof(ReportVariable.AnnualCohort), ", + "\n nameof(ReportVariable.LiabilityType), ", + "\n nameof(ReportVariable.ValuationApproach),", + "\n nameof(ReportVariable.OciType),", + "\n nameof(ReportVariable.InitialProfitability), //(\"Profitability\")", + "\n };", + "\n", + "\n IReadOnlyCollection GetFilterName() => defaultFilters;", "\n ", "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", "\n new string[]{ null }.Concat(", "\n await (FilterName switch", - "\n {", - "\n \"GroupOfContract\" => workspace.Query().Select(x => x.SystemName), //TODO all dim - use GetAutocompleteMappings (put DisplayName and SystemName together) - move them to the storage?? ", - "\n \"Novelty\" => workspace.Query().Select(x => x.SystemName),", - "\n \"EconomicBasis\" => workspace.Query().Select(x => x.SystemName),", + "\n { ", + "\n nameof(ReportVariable.GroupOfContract) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.Portfolio) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.LineOfBusiness) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.AnnualCohort) => workspace.Query()", + "\n //.Where(x => InputDataFilter.Any(x => x.filterName == nameof(ReportVariable.GroupOfContract)) ", + "\n // ? InputDataFilter.Where(x => x.filterName == nameof(ReportVariable.GroupOfContract)).filterValue == x.SystemName", + "\n // : true)", + "\n .Select(x => x.AnnualCohort.ToString()).Distinct(),", + "\n nameof(ReportVariable.LiabilityType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.ValuationApproach) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.OciType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.InitialProfitability) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n", + "\n nameof(ReportVariable.Novelty) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)), //Not needed", + "\n nameof(ReportVariable.VariableType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)), //Not needed. Query VariableType??", + "\n nameof(ReportVariable.EconomicBasis) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.AmountType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.EstimateType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n ", "\n _ => Enumerable.Empty().AsQueryable()", "\n }) .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).OrderBy(x => x).ToArrayAsync()).ToArray();", "\n ", "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", "\n ", - "\n // Filer can handle OR cases - Sire used them", + "\n // This is just a cast... do we need this?", "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null ? Enumerable.Empty<(string, object)>() : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", "\n", "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", @@ -314,15 +358,11 @@ { "cell_type": "code", "source": [ - "//TODO with current UI selection you need Add/Remove options to support multiple selection", - "\n//else wait for the new dropdowns", - "\n//seperate the slice in two rows/columns", - "\n", - "\npublic interface BasicSliceAndDiceFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownValues(\"\", \"GroupOfContract\")] //TODO make a method to populate the options and override it in each report", + "public interface BasicSliceAndDiceFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownValues(\"\", \"GroupOfContract\")]", "\n string SliceRowName { get; set; }", "\n", - "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))] //this is the method to override in the report", + "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", "\n string SliceColumnName { get; set; }", "\n", "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", @@ -352,25 +392,16 @@ { "cell_type": "code", "source": [ - "//TODO remove filter but you need to pass them anymore", - "\n", - "\npublic interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", + "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", "\n IDataCube InputDataCube { get; set; }", "\n", - "\n IDataCube DataCube { get { //todo remove filter", + "\n IDataCube DataCube { get {", "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ? InputDataCube : InputDataCube.Filter(Identity.dataFilter); ", "\n if(Identity.scenario != \"Delta\") return filteredDataCube;", "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", "\n return filteredDataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0d) }).ToDataCube();", "\n }}", - "\n", - "\n // IDataCube GetFilteredDataCube (filter) //method (not cached)", - "\n // {", - "\n // return (dataFilter is null || dataFilter.Length == 0) ", - "\n // ? DataCube ", - "\n // : DataCube.Filter(Identity.dataFilter); ", - "\n // }", "\n} " ], "metadata": {}, @@ -382,7 +413,8 @@ "source": [ "[InitializeScope(nameof(InitReportStorageScopeAsync))]", "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, BasicSliceAndDiceFormsEntity, BasicFilterFormsEntity {", - "\n protected Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report => GetStorage().Report;", + "\n protected IPivotFactory report => GetStorage().Report;", + "\n protected IExportVariable export => GetStorage().Export;", "\n protected int headerColumnWidthValue => 250;", "\n", "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); // TODO, add filter for identities, if the property is exposed at this level", @@ -390,12 +422,32 @@ "\n IDataCube GetData() => default;", "\n", "\n async Task ToReportAsync() {", - "\n //extract data to be called in export and graph: dataScope.DataCube", "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", - "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));//remove dataFilter", - "\n dataScope.InputDataCube = GetData(); ", - "\n //end prepareDataAsync", - "\n return await GetReportTaskAsync(dataScope.DataCube);//call GetFilteredDataCube", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await GetReportTaskAsync(dataScope.DataCube);", + "\n }", + "\n", + "\n async Task ToCsvAsync(string fileName){", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await export.ToCsv(fileName)", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices))", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task ToExcelAsync(string fileName){", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", + "\n dataScope.InputDataCube = GetData();", + "\n return await export.ToExcel(fileName)", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices))", + "\n .ExecuteAsync();", "\n }", "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", @@ -407,11 +459,6 @@ "\n .ExecuteAsync();", "\n }", "\n", - "\n //TODO method for export", - "\n //TODO method for graph", - "\n", - "\n //repor .ForObject", - "\n", "\n async Task InitReportStorageScopeAsync() { // This has the Async issue, but imo it should come in the future", "\n await GetStorage().InitializeReportIndependentCacheAsync();", "\n }", @@ -421,6 +468,17 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "// A new scope for objects ", + "\n// No slice and dice ", + "\n// Limited filtering (date, reporting node, arg?)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -446,12 +504,15 @@ "\npublic interface PvReport : ReportScope {", "\n ", "\n IDataCube ReportScope.GetData() => GetScopes(GetDataIdentities()).Aggregate().LockedBestEstimate + GetScopes(GetDataIdentities()).Aggregate().CurrentBestEstimate;", - "\n//todo if you put [NotVisible] you can maybe hide the controll ", + "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", "\n }", + "\n", + "\n private List specificFilters => new List {\"AmountType\"};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -480,6 +541,9 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -508,6 +572,9 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -536,6 +603,9 @@ "\n defaultRowSlices = new string[] { \"AmountType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -564,6 +634,10 @@ "\n defaultRowSlices = new string[] { \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", "\n }", + "\n", + "\n private List specificFilters => new List {\"AmountType\"};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -592,6 +666,10 @@ "\n defaultRowSlices = new string[] { \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", "\n }", + "\n ", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -620,6 +698,10 @@ "\n defaultRowSlices = new string[] { \"EstimateType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"AmountType\" };", "\n }", + "\n", + "\n private List specificFilters => new List {\"AmountType\"};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -648,6 +730,9 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -676,6 +761,10 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -704,6 +793,10 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -723,6 +816,10 @@ "\n defaultRowSlices = new string[] { \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -751,6 +848,10 @@ "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -770,6 +871,9 @@ "\n defaultRowSlices = new string[] { \"VariableType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", "\n }", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -798,6 +902,10 @@ "\n defaultRowSlices = new string[] { \"VariableType\", \"EstimateType\" };", "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", "\n }", + "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n", "\n}" ], "metadata": {}, @@ -825,44 +933,81 @@ { "cell_type": "code", "source": [ - "public class Ifrs17Interactive {", - "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", - "\n private Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject;", + "using Systemorph.Vertex.Pivot.Builder.Interfaces;", + "\nusing Systemorph.InteractiveObjects;", + "\nusing Systemorph.Vertex.Session;", + "\npublic class Ifrs17Interactive {", + "\n private IPivotFactory report;", + "\n private IExportVariable export;", + "\n private InteractiveObjectVariable interactiveObject;", "\n private ReportStorage storage;", "\n", "\n private IDictionary interactiveObjectCache = new Dictionary();", "\n", - "\n public Ifrs17Interactive (IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report, Systemorph.InteractiveObjects.InteractiveObjectVariable interactiveObject)", + "\n public Ifrs17Interactive (IWorkspace workspace, ", + "\n IPivotFactory report, ", + "\n IExportVariable export,", + "\n InteractiveObjectVariable interactiveObject)", "\n {", "\n this.report = report;", + "\n this.export = export;", "\n this.interactiveObject = interactiveObject;", - "\n storage = new ReportStorage(workspace, report);", + "\n storage = new ReportStorage(workspace, report, export);", "\n }", "\n", "\n public void Reset(IWorkspace workspace) {", - "\n storage = new ReportStorage(workspace, report);", + "\n storage = new ReportStorage(workspace, report, export);", "\n interactiveObjectCache = new Dictionary();", "\n }", "\n", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", + "\n public InteractiveObjectView GetFormsEntity(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", _ => GetReportScope(key));", "\n return ret;", "\n }", "\n", - "\n public Systemorph.Vertex.InteractiveObjects.InteractiveObjectView GetReport(string name = null) where T : ReportScope {", + "\n public InteractiveObjectView GetReport(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", "\n _ => {", - "\n var scope = GetReportScope(key);", - "\n var filters = scope.GetFilters(); // Not used and should be improved", - "\n return scope.ToReportAsync();", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters(); // Not used and should be improved", + "\n return scope.ToReportAsync();", "\n });", "\n return ret;", "\n }", "\n", + "\n // Get report from object ", + "\n // Get a new scope and perform a report ", + "\n", + "\n public InteractiveObjectView ExportToCsv(string fileName)", + "\n where T : ReportScope", + "\n {", + "\n var key = fileName + \".csv\";", + "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, _ => {", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters();", + "\n return scope.ToCsvAsync(fileName);", + "\n });", + "\n return ret;", + "\n } ", + "\n", + "\n public InteractiveObjectView ExportToExcel(string fileName)", + "\n where T : ReportScope", + "\n {", + "\n var key = fileName + \".xls\";", + "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, _ => {", + "\n var scope = GetReportScope(key);", + "\n var filters = scope.GetFilters();", + "\n return scope.ToExcelAsync(fileName);", + "\n });", + "\n return ret;", + "\n }", + "\n", "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n", "\n // Keeping the old API", diff --git a/ifrs17/Report/ReportStorage.ipynb b/ifrs17/Report/ReportStorage.ipynb index 19fc3ff3..4d7eed27 100644 --- a/ifrs17/Report/ReportStorage.ipynb +++ b/ifrs17/Report/ReportStorage.ipynb @@ -105,8 +105,10 @@ { "cell_type": "code", "source": [ - "public class ReportStorage {", + "using Systemorph.Vertex.Export.Factory;", + "\npublic class ReportStorage {", "\n protected readonly IWorkspace workspace;", + "\n protected readonly IExportVariable export;", "\n private readonly Systemorph.Vertex.Hierarchies.IHierarchicalDimensionCache hierarchicalDimensionCache;", "\n private readonly Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory;", "\n ", @@ -129,10 +131,13 @@ "\n private Dictionary<((int year, int month) period, string reportingNode, string scenario), Dictionary>>> variablesDictionary = new();", "\n ", "\n // Constructor", - "\n public ReportStorage(IWorkspace workspace, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory) {", + "\n public ReportStorage(IWorkspace workspace, ", + "\n Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory reportFactory, ", + "\n IExportVariable export) {", "\n this.workspace = workspace;", "\n this.hierarchicalDimensionCache = workspace.ToHierarchicalDimensionCache();", "\n this.reportFactory = reportFactory;", + "\n this.export = export;", "\n }", "\n ", "\n // Initializers", @@ -211,6 +216,7 @@ "\n // Other getters", "\n public IWorkspace Workspace => workspace;", "\n public Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory Report => reportFactory;", + "\n public IExportVariable Export => export;", "\n", "\n public Systemorph.Vertex.Hierarchies.IHierarchy GetHierarchy() where T : class, IHierarchicalDimension => hierarchicalDimensionCache.Get();", "\n ", From 1aa1787d7ce77981f4c833e54f0fe1807040db02 Mon Sep 17 00:00:00 2001 From: akatz Date: Wed, 1 Mar 2023 17:43:16 +0100 Subject: [PATCH 14/55] for objects: almost works, it is an advanced sketch --- ifrs17/DataModel/DataStructure.ipynb | 6 +- .../ReportMutableScopesInteractive.ipynb | 75 ++++++++++++++++++- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 38dcde94..71bcc925 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -57,10 +57,10 @@ "\n#r \"nuget:Systemorph.SharePoint,1.6.5-ci-20230222-101910\"", "\n#r \"nuget:Systemorph.OneDrive,1.6.5-ci-20230222-101910\"", "\n#r \"nuget:Systemorph.Scopes,1.6.5-ci-20230222-101910\"", - "\n#r \"nuget:Systemorph.Import,1.6.4\"", + "\n#r \"nuget:Systemorph.Import,1.6.6\"", "\n#r \"nuget:Systemorph.Test,1.6.5-ci-20230222-101910\"", - "\n#r \"nuget:Systemorph.Export,1.6.4\"", - "\n#r \"nuget:Systemorph.DataSetReader,1.6.4\"", + "\n#r \"nuget:Systemorph.Export,1.6.6\"", + "\n#r \"nuget:Systemorph.DataSetReader,1.6.6\"", "\n#r \"nuget:Systemorph.DataSource,1.6.3\"", "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.3\"", "\n#r \"nuget:Systemorph.Reporting,1.6.5-ci-20230222-101910\"", diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index bf62dd49..054ac5c8 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -150,6 +150,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "## Comparison" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -253,7 +262,6 @@ "cell_type": "code", "source": [ "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", - "\n // [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", "\n [DropdownMethod(nameof(GetFilterName))]", "\n string FilterName { get; set; }", "\n", @@ -435,6 +443,42 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "// A new scope for objects ", + "\n// No slice and dice ", + "\n// Limited filtering (date, reporting node, arg?)", + "\npublic interface FromEnumerableReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity", + "\n{", + "\n protected IPivotFactory report => GetStorage().Report;", + "\n protected IExportVariable export => GetStorage().Export;", + "\n", + "\n IEnumerable GetData() => default;", + "\n", + "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage()", + "\n .GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); ", + "\n", + "\n", + "\n async Task ToReportAsync()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n return await GetReportTaskAsync(GetData());", + "\n }", + "\n", + "\n async Task GetReportTaskAsync(IEnumerable data)", + "\n {", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -921,6 +965,28 @@ "\n return ret;", "\n }", "\n", + "\n public InteractiveObjectView GetFormsEntityFromObjects(string name = null)", + "\n where TScope : FromEnumerableReportScope", + "\n {", + "\n var key = name ?? typeof(TScope).Name;", + "\n if (!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", ", + "\n _ => GetEnumerableReportScope(key));", + "\n return ret;", + "\n }", + "\n", + "\n public InteractiveObjectView GetReportFromObject(string name = null)", + "\n where TScope : FromEnumerableReportScope", + "\n {", + "\n var key = name ?? typeof(TScope).Name;", + "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, _ => {", + "\n var scope = GetEnumerableReportScope(key);", + "\n return scope.ToReportAsync();", + "\n });", + "\n return ret;", + "\n }", + "\n", "\n public InteractiveObjectView ExportToCsv(string fileName)", "\n where T : ReportScope", "\n {", @@ -949,6 +1015,13 @@ "\n", "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n", + "\n public FromEnumerableReportScope GetEnumerableReportScope(string name = null)", + "\n where TScope : FromEnumerableReportScope", + "\n {", + "\n return interactiveObject.State.GetScope(name ?? typeof(TScope).Name, o => o.WithStorage(storage));", + "\n }", + "\n", + "\n", "\n // Keeping the old API", "\n public ReportScope PresentValues => GetReportScope();", "\n public ReportScope RiskAdjustments => GetReportScope();", From 9e98c2604b09c0149a32a23443ccf18a208d8f9d Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 3 Mar 2023 11:31:03 +0100 Subject: [PATCH 15/55] merge changes --- .../Test/MapTemplateAndImportTest.ipynb | 53 +++++-------------- .../Test/ReimportWithDifferentScopeTest.ipynb | 4 +- ifrs17-template/Test/SequenceImportTest.ipynb | 20 +++++++ 3 files changed, 34 insertions(+), 43 deletions(-) diff --git a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb index 60ac6284..dbcf479d 100644 --- a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -165,7 +165,7 @@ "\n .GroupofContractConfiguration(typeof(ReinsurancePortfolio))", "\n .GroupofContractConfiguration(typeof(InsurancePortfolio))", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog()", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -184,7 +184,7 @@ "\n .GroupofContractConfiguration(typeof(ReinsurancePortfolio))", "\n .GroupofContractConfiguration(typeof(InsurancePortfolio))", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog()", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", "\n .ExecuteAsync()" ], "metadata": {}, @@ -266,7 +266,7 @@ "\n .StateEnumConfiguration() ", "\n .DataNodeStateConfiguration(dataNodeStates)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog()", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -283,7 +283,7 @@ "\n .StateEnumConfiguration() ", "\n .DataNodeStateConfiguration(dataNodeStates)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog()", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", "\n .ExecuteAsync()" ], "metadata": {}, @@ -360,7 +360,7 @@ "\n .WithSource(Workspace)", "\n .DataNodeParameterConfiguration(dataNodeParameters)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog()", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -376,7 +376,7 @@ "\n .WithSource(Workspace)", "\n .DataNodeParameterConfiguration(dataNodeParameters)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog()", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", "\n .ExecuteAsync()" ], "metadata": {}, @@ -542,10 +542,11 @@ { "cell_type": "code", "source": [ - "public async Task CheckErrors(string inputFileName, List errorBms, IWorkspace workspace)", + "public async Task CheckErrors(string inputFileName, List errorBms)", "\n{", "\n Activity.Start();", - "\n var log = await Import.FromFile(inputFileName).WithFormat(ImportFormats.DataNodeParameter).WithTarget(workspace).ExecuteAsync();", + "\n var log = await Import.FromFile(inputFileName).WithFormat(ImportFormats.DataNodeParameter).WithTarget(Workspace).ExecuteAsync();", + "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n errorBms.Intersect(log.Errors.Select(x => x.ToString().Substring(0,x.ToString().Length-2).Substring(40)).ToArray()).Count().Should().Be(errorBms.Count());", "\n return Activity.Finish();", "\n}" @@ -554,16 +555,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "var ws1 = Workspace.CreateNew();", - "\nws1.InitializeFrom(DataSource);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -571,52 +562,32 @@ "\nvar errorsBm = new List(){Get(Error.InvalidDataNode, \"DataNodeInvalid0\"),", "\n Get(Error.InvalidDataNode, \"DataNodeInvalid1\"),", "\n Get(Error.InvalidDataNode, \"DataNodeInvalid2\")};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws1);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm);", "\nactivity" ], "metadata": {}, "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "var ws2 = Workspace.CreateNew();", - "\nws2.InitializeFrom(DataSource);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ "var inputFileName = \"Data/DataNodeParameter_Duplicate.csv\";", "\nvar errorsBm = new List(){Get(Error.DuplicateSingleDataNode, \"DT1.1\"),", "\n Get(Error.DuplicateInterDataNode, \"DT1.1\",\"DTR1.1\"),};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws2);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm);", "\nactivity" ], "metadata": {}, "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "var ws3 = Workspace.CreateNew();", - "\nws3.InitializeFrom(DataSource);" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ "var inputFileName = \"Data/DataNodeParameter_InvalidReinsCov.csv\";", "\nvar errorsBm = new List(){Get(Error.ReinsuranceCoverageDataNode, \"DT1.1\",\"DT1.1\")};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws3);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm);", "\nactivity" ], "metadata": {}, diff --git a/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb b/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb index 37e4280a..84609e9c 100644 --- a/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb +++ b/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb @@ -51,7 +51,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog()", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", "\n .ExecuteAsync()" ], "metadata": {}, @@ -86,7 +86,7 @@ "await Import.FromFile(\"Data/NominalCashflows_CH_2020_12_DT1.1NoPrem.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog()", + "\n .WithActivityLog(Session, DataSource, DataSetReader)", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Test/SequenceImportTest.ipynb b/ifrs17-template/Test/SequenceImportTest.ipynb index aef67b5e..4791c988 100644 --- a/ifrs17-template/Test/SequenceImportTest.ipynb +++ b/ifrs17-template/Test/SequenceImportTest.ipynb @@ -79,6 +79,16 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "ws1.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nws1.Initialize(x => x.FromSource(DataSource));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -143,6 +153,16 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "ws2.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\nws2.Initialize(x => x.FromSource(DataSource));" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ From 5804a76c026b329a4da9e1ddccd7530c88bde689 Mon Sep 17 00:00:00 2001 From: akatz Date: Tue, 7 Mar 2023 17:51:08 +0100 Subject: [PATCH 16/55] incorporates parameter report -- for object --- .../Report/InteractiveParameterReport.ipynb | 66 +++++ ifrs17/CalculationEngine.ipynb | 23 +- ifrs17/DataModel/DataStructure.ipynb | 18 +- ...rameterReportMutableScopeInteractive.ipynb | 234 ++++++++++++++++++ ifrs17/Report/ReportMutableScopes.ipynb | 11 +- .../ReportMutableScopesInteractive.ipynb | 22 +- 6 files changed, 342 insertions(+), 32 deletions(-) create mode 100644 ifrs17-template/Report/InteractiveParameterReport.ipynb create mode 100644 ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb diff --git a/ifrs17-template/Report/InteractiveParameterReport.ipynb b/ifrs17-template/Report/InteractiveParameterReport.ipynb new file mode 100644 index 00000000..f763051a --- /dev/null +++ b/ifrs17-template/Report/InteractiveParameterReport.ipynb @@ -0,0 +1,66 @@ +{ + "metadata": { + "authors": [], + "id": "SB2KH3IeJ0ayzI-af7eReA", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!eval-notebook \"../Import/CloseImportTemplate\"", + "\nWorkspace.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parameterInteractive.Reset(Workspace);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parameterInteractive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "parameterInteractive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/CalculationEngine.ipynb b/ifrs17/CalculationEngine.ipynb index 08ea709e..1a320c63 100644 --- a/ifrs17/CalculationEngine.ipynb +++ b/ifrs17/CalculationEngine.ipynb @@ -22,6 +22,7 @@ "#!import \"DataModel/DataStructure\"", "\n#!import \"Report/ReportMutableScopes\"", "\n#!import \"Report/ReportMutableScopesInteractive\"", + "\n#!import \"Report/ParameterReportMutableScopeInteractive\"", "\n#!import \"Import/Importers\"", "\n#!import \"Export/ExportConfiguration\"", "\n#!import \"Utils/TestHelper\"", @@ -35,7 +36,7 @@ { "cell_type": "code", "source": [ - "var ifrs17 = new Ifrs17(Workspace, Scopes, Report);" + "var ifrs17 = new Ifrs17(Workspace, Scopes, Report, Export);" ], "metadata": {}, "execution_count": 0, @@ -44,7 +45,25 @@ { "cell_type": "code", "source": [ - "var ifrs17Interactive = new Ifrs17Interactive(Workspace, Report, InteractiveObject);" + "var ifrs17Interactive = new Ifrs17Interactive(Workspace, Report, Export, InteractiveObject);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var parameterInteractive = new InteractiveParameterReports(Workspace, Report, Export, InteractiveObject);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 38dcde94..260fd2f4 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -50,21 +50,21 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Activities,1.6.5-ci-20230222-101910\"", - "\n#r \"nuget:Systemorph.Arithmetics,1.6.5-ci-20230222-101910\"", + "#r \"nuget:Systemorph.Activities,1.6.5\"", + "\n#r \"nuget:Systemorph.Arithmetics,1.6.5\"", "\n#r \"nuget:Systemorph.Workspace,1.6.3\"", - "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.5-ci-20230222-101910\"", - "\n#r \"nuget:Systemorph.SharePoint,1.6.5-ci-20230222-101910\"", - "\n#r \"nuget:Systemorph.OneDrive,1.6.5-ci-20230222-101910\"", - "\n#r \"nuget:Systemorph.Scopes,1.6.5-ci-20230222-101910\"", + "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.5\"", + "\n#r \"nuget:Systemorph.SharePoint,1.6.5\"", + "\n#r \"nuget:Systemorph.OneDrive,1.6.5\"", + "\n#r \"nuget:Systemorph.Scopes,1.6.5\"", "\n#r \"nuget:Systemorph.Import,1.6.4\"", - "\n#r \"nuget:Systemorph.Test,1.6.5-ci-20230222-101910\"", + "\n#r \"nuget:Systemorph.Test,1.6.5\"", "\n#r \"nuget:Systemorph.Export,1.6.4\"", "\n#r \"nuget:Systemorph.DataSetReader,1.6.4\"", "\n#r \"nuget:Systemorph.DataSource,1.6.3\"", "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.3\"", - "\n#r \"nuget:Systemorph.Reporting,1.6.5-ci-20230222-101910\"", - "\n#r \"nuget:Systemorph.Charting,1.6.5-ci-20230222-101910\"", + "\n#r \"nuget:Systemorph.Reporting,1.6.5\"", + "\n#r \"nuget:Systemorph.Charting,1.6.5\"", "\n#r \"nuget:Systemorph.SchemaMigrations,1.6.3\"" ], "metadata": {}, diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb new file mode 100644 index 00000000..d8ad95b8 --- /dev/null +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -0,0 +1,234 @@ +{ + "metadata": { + "authors": [], + "id": "XdWtZAfDUkKgJxSlrhCSSw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"ReportMutableScopesInteractive\"", + "\n#!import \"ParameterReportsQueries\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface RepFormsEntity : MutableScopeWithWorkspace", + "\n{", + "\n [DropdownMethod(nameof(ReportMenu))]", + "\n string ReportType{get; set;}", + "\n", + "\n IReadOnlyCollection ReportMenu() => new string[] {\"DataNodeReport\", ", + "\n \"DataNodeStateReport\", ", + "\n \"YieldCurves\", ", + "\n \"SingleDataNodeReport\", ", + "\n \"InterDataNodeParameters\", ", + "\n \"PartnerRating\", ", + "\n \"PartnerDefaultRates\"};", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "[InitializeScope(nameof(InitReportStorageScopeAsync))]", + "\npublic interface ParameterReportScope: IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, RepFormsEntity", + "\n{", + "\n protected IPivotFactory report => GetStorage().Report;", + "\n protected IExportVariable export => GetStorage().Export;", + "\n protected int headerColumnWidthValue => 250;", + "\n", + "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); ", + "\n", + "\n async Task InitializeStorageAsync()", + "\n {", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", + "\n }", + "\n", + "\n ImportArgs GetArgs() => new ImportArgs(ReportingNode, Year, Month, default, Scenario, default); ", + "\n", + "\n async Task GenerateDataNodeReport()", + "\n {", + "\n await InitializeStorageAsync();", + "\n var data = await workspace.GetDataNodeDataReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GenerateDataNodeStatesReport()", + "\n {", + "\n await InitializeStorageAsync();", + "\n var data = await workspace.GetDataNodeStateReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GenerateYieldCurvesReport()", + "\n {", + "\n await InitializeStorageAsync();", + "\n var data = await workspace.GetYieldCurveReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GenerateSingleDataNodeReport()", + "\n {", + "\n await InitializeStorageAsync();", + "\n var data = await workspace.GetSingleDataNodeReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GenerateInterDataNodeParametersReport()", + "\n {", + "\n await InitializeStorageAsync();", + "\n var data = await workspace.GetInterDataNodeParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GeneratePartnerRatingReport()", + "\n {", + "\n await InitializeStorageAsync();", + "\n var data = await workspace.GetPartnerRatingsReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task GenerateDefaultRatesReport()", + "\n {", + "\n await InitializeStorageAsync();", + "\n var data = await workspace.GetCreditDefaultRatesReportParametersAsync(GetArgs());", + "\n return await report.ForObjects(data)", + "\n .WithQuerySource(workspace)", + "\n .ToTable()", + "\n .ExecuteAsync();", + "\n }", + "\n", + "\n async Task ToReport() => ReportType switch", + "\n {", + "\n \"DataNodeReport\" => await GenerateDataNodeReport(), ", + "\n \"DataNodeStateReport\" => await GenerateDataNodeStatesReport(), ", + "\n \"YieldCurves\" => await GenerateYieldCurvesReport(), ", + "\n \"SingleDataNodeReport\" => await GenerateSingleDataNodeReport(), ", + "\n \"InterDataNodeParameters\" => await GenerateInterDataNodeParametersReport(), ", + "\n \"PartnerRating\" => await GeneratePartnerRatingReport(), ", + "\n \"PartnerDefaultRates\" => await GenerateDefaultRatesReport(),", + "\n _ => await GenerateDataNodeReport()", + "\n };", + "\n", + "\n async Task InitReportStorageScopeAsync() { ", + "\n await GetStorage().InitializeReportIndependentCacheAsync();", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "class InteractiveParameterReports", + "\n{", + "\n private IPivotFactory report;", + "\n private IExportVariable export;", + "\n private InteractiveObjectVariable interactiveObject;", + "\n private ReportStorage storage;", + "\n", + "\n private IDictionary interactiveObjectCache = new Dictionary();", + "\n ", + "\n public InteractiveParameterReports(IWorkspace workspace, ", + "\n IPivotFactory report, ", + "\n IExportVariable export, ", + "\n InteractiveObjectVariable interactiveObject)", + "\n {", + "\n this.report = report;", + "\n this.export = export;", + "\n this.interactiveObject = interactiveObject;", + "\n this.storage = new ReportStorage(workspace, report, export);", + "\n }", + "\n", + "\n public void Reset(IWorkspace workspace)", + "\n {", + "\n storage = new ReportStorage(workspace, report, export);", + "\n interactiveObjectCache = new Dictionary() {};", + "\n }", + "\n", + "\n public ParameterReportScope GetReportScope(string name = null)", + "\n where T : ParameterReportScope", + "\n {", + "\n return interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", + "\n }", + "\n", + "\n public InteractiveObjectView GetFormsEntity(string name = null)", + "\n where T : ParameterReportScope", + "\n {", + "\n var key = name ?? typeof(T).Name;", + "\n if (!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", + "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", ", + "\n _ => GetReportScope());", + "\n return ret;", + "\n }", + "\n", + "\n public InteractiveObjectView GetReport(string name = null)", + "\n where T : ParameterReportScope", + "\n {", + "\n var key = name ?? typeof(T).Name;", + "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, ", + "\n _ => {", + "\n var scope = GetReportScope();", + "\n return scope.ToReport(); ", + "\n });", + "\n return ret;", + "\n }", + "\n", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Report/ReportMutableScopes.ipynb b/ifrs17/Report/ReportMutableScopes.ipynb index 91f9faf9..b826e432 100644 --- a/ifrs17/Report/ReportMutableScopes.ipynb +++ b/ifrs17/Report/ReportMutableScopes.ipynb @@ -332,16 +332,21 @@ "\n private Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report;", "\n private ReportStorage Storage;", "\n private ReportUniverse reportUniverse;", + "\n private IExportVariable export;", "\n ", "\n //reset", - "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report);", + "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report, export);", "\n", "\n //constructor", - "\n public Ifrs17 (IWorkspace workspace, Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes, Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report)", + "\n public Ifrs17 (IWorkspace workspace, ", + "\n Systemorph.Vertex.Scopes.Proxy.IScopeFactory scopes, ", + "\n Systemorph.Vertex.Pivot.Builder.Interfaces.IPivotFactory report,", + "\n IExportVariable export)", "\n {", "\n this.scopes = scopes; ", "\n this.report = report; ", - "\n Storage = new ReportStorage(workspace, report);", + "\n this.export = export;", + "\n Storage = new ReportStorage(workspace, report, export);", "\n reportUniverse = scopes.ForSingleton().WithStorage(Storage).ToScope();", "\n }", "\n", diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index bf62dd49..b6c1fa5a 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -854,15 +854,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "markdown", - "source": [ - "# IFRS 17 Reports" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ @@ -921,17 +912,12 @@ "\n return ret;", "\n }", "\n", - "\n public InteractiveObjectView ExportToCsv(string fileName)", + "\n public async Task ExportToCsv(string fileName)", "\n where T : ReportScope", "\n {", - "\n var key = fileName + \".csv\";", - "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", - "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, _ => {", - "\n var scope = GetReportScope(key);", - "\n var filters = scope.GetFilters();", - "\n return scope.ToCsvAsync(fileName);", - "\n });", - "\n return ret;", + "\n var scope = GetReportScope();", + "\n var filters = scope.GetFilters();", + "\n return await scope.ToCsvAsync(fileName);", "\n } ", "\n", "\n public InteractiveObjectView ExportToExcel(string fileName)", From 5a801268f203f09fbef42965e598a43f00acb670 Mon Sep 17 00:00:00 2001 From: akatz Date: Thu, 9 Mar 2023 16:58:29 +0100 Subject: [PATCH 17/55] stopgap solution for csv and excel reports included. --- .../ReportMutableScopesInteractive.ipynb | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index b6c1fa5a..127bac17 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -378,7 +378,7 @@ { "cell_type": "code", "source": [ - "[InitializeScope(nameof(InitReportStorageScopeAsync))]", + "[InitializeScope(nameof(Init))]", "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, BasicSliceAndDiceFormsEntity, BasicFilterFormsEntity {", "\n protected IPivotFactory report => GetStorage().Report;", "\n protected IExportVariable export => GetStorage().Export;", @@ -400,7 +400,7 @@ "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", "\n return await export.ToCsv(fileName)", - "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", + "\n .ForDataCube(dataScope.DataCube, config => config//.WithQuerySource(workspace)", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", "\n .ExecuteAsync();", @@ -411,7 +411,7 @@ "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", "\n return await export.ToExcel(fileName)", - "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", + "\n .ForDataCube(dataScope.DataCube, config => config//.WithQuerySource(workspace) // Temporary solution to avoid a clash in DB access with the report", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", "\n .ExecuteAsync();", @@ -426,6 +426,11 @@ "\n .ExecuteAsync();", "\n }", "\n", + "\n void Init(){", + "\n var task = InitReportStorageScopeAsync();", + "\n task.Wait();", + "\n }", + "\n", "\n async Task InitReportStorageScopeAsync() { // This has the Async issue, but imo it should come in the future", "\n await GetStorage().InitializeReportIndependentCacheAsync();", "\n }", @@ -900,37 +905,34 @@ "\n return ret;", "\n }", "\n", - "\n public InteractiveObjectView GetReport(string name = null) where T : ReportScope {", + "\n public async Task GetReport(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", - "\n if(!interactiveObjectCache.TryGetValue(key, out var ret))", + "\n if(!interactiveObjectCache.TryGetValue(key, out var ret)){", "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", "\n _ => {", "\n var scope = GetReportScope(key);", "\n var filters = scope.GetFilters(); // Not used and should be improved", - "\n return scope.ToReportAsync();", - "\n });", + "\n return scope.ToReportAsync(); // Not awaited -- and causes a problem down the rode, if report and output files are needed ", + "\n }); ", + "\n }", "\n return ret;", "\n }", "\n", - "\n public async Task ExportToCsv(string fileName)", + "\n public async Task ExportToCsvAsync(string fileName)", "\n where T : ReportScope", "\n {", "\n var scope = GetReportScope();", - "\n var filters = scope.GetFilters();", + "\n var _ = scope.GetFilters();", "\n return await scope.ToCsvAsync(fileName);", "\n } ", "\n", - "\n public InteractiveObjectView ExportToExcel(string fileName)", + "\n", + "\n public async Task ExportToExcelAsync(string fileName)", "\n where T : ReportScope", "\n {", - "\n var key = fileName + \".xls\";", - "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", - "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, _ => {", - "\n var scope = GetReportScope(key);", - "\n var filters = scope.GetFilters();", - "\n return scope.ToExcelAsync(fileName);", - "\n });", - "\n return ret;", + "\n var scope = GetReportScope();", + "\n var _ = scope.GetFilters();", + "\n return await scope.ToExcelAsync(fileName);", "\n }", "\n", "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", From ac29d93c32eb05cd98be12a8bf35694472e0421b Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 10 Mar 2023 12:59:58 +0100 Subject: [PATCH 18/55] resolve merge conflict --- ifrs17/Report/ReportMutableScopes.ipynb | 1 - 1 file changed, 1 deletion(-) diff --git a/ifrs17/Report/ReportMutableScopes.ipynb b/ifrs17/Report/ReportMutableScopes.ipynb index 24004a82..c08680fe 100644 --- a/ifrs17/Report/ReportMutableScopes.ipynb +++ b/ifrs17/Report/ReportMutableScopes.ipynb @@ -333,7 +333,6 @@ "\n private IExportVariable export;", "\n private ReportStorage Storage;", "\n private ReportUniverse reportUniverse;", - "\n private IExportVariable export;", "\n ", "\n //reset", "\n public void Reset(IWorkspace workspace) => Storage = new ReportStorage(workspace, report, export);", From 2e338eb31fd527c95ed7f33527a01867f8e256d6 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 10 Mar 2023 13:00:34 +0100 Subject: [PATCH 19/55] add filters --- .../ReportMutableScopesInteractive.ipynb | 145 +++++++++++------- 1 file changed, 89 insertions(+), 56 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 127bac17..126dab36 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -253,7 +253,6 @@ "cell_type": "code", "source": [ "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", - "\n // [DropdownValues(\"\", \"GroupOfContract\", \"Novelty\", \"EconomicBasis\")]", "\n [DropdownMethod(nameof(GetFilterName))]", "\n string FilterName { get; set; }", "\n", @@ -263,7 +262,16 @@ "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", "\n string FilterAction { get; set; }", "\n", - "\n protected string[] defaultFilters => new string[] {\"\", \"GroupOfContract\", \"Portfolio\", \"LineOfBusiness\", \"AnnualCohort\"};", + "\n protected string[] defaultFilters => new string[] {", + "\n nameof(ReportVariable.GroupOfContract),", + "\n nameof(ReportVariable.Portfolio),", + "\n nameof(ReportVariable.LineOfBusiness),", + "\n nameof(ReportVariable.AnnualCohort),", + "\n nameof(ReportVariable.LiabilityType),", + "\n nameof(ReportVariable.ValuationApproach),", + "\n nameof(ReportVariable.OciType),", + "\n nameof(ReportVariable.InitialProfitability), //(\\\"Profitability\\\")", + "\n };", "\n", "\n IReadOnlyCollection GetFilterName() => defaultFilters;", "\n ", @@ -271,16 +279,33 @@ "\n new string[]{ null }.Concat(", "\n await (FilterName switch", "\n {", - "\n \"GroupOfContract\" => workspace.Query().Select(x => x.SystemName),", - "\n \"Novelty\" => workspace.Query().Select(x => x.SystemName),", - "\n \"EconomicBasis\" => workspace.Query().Select(x => x.SystemName),", - "\n _ => Enumerable.Empty().AsQueryable()", + "\n nameof(ReportVariable.GroupOfContract) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.Portfolio) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.LineOfBusiness) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.AnnualCohort) => workspace.Query()", + "\n //.Where(x => InputDataFilter.Any(x => x.filterName == nameof(ReportVariable.GroupOfContract)) ", + "\n // ? InputDataFilter.Where(x => x.filterName == nameof(ReportVariable.GroupOfContract)).filterValue == x.SystemName", + "\n // : true)", + "\n .Select(x => x.AnnualCohort.ToString()).Distinct(),", + "\n nameof(ReportVariable.LiabilityType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.ValuationApproach) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.OciType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.InitialProfitability) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n ", + "\n nameof(ReportVariable.Novelty) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)), //Not needed", + "\n nameof(ReportVariable.VariableType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)), //Not needed. Query VariableType??", + "\n nameof(ReportVariable.EconomicBasis) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.AmountType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n nameof(ReportVariable.EstimateType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", + "\n _ => Enumerable.Empty().AsQueryable()", "\n }) .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).OrderBy(x => x).ToArrayAsync()).ToArray();", "\n ", "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", "\n ", "\n // This is just a cast... do we need this?", - "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null ? Enumerable.Empty<(string, object)>() : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", + "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null ", + "\n ? Enumerable.Empty<(string, object)>() ", + "\n : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", "\n", "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", "\n {", @@ -468,11 +493,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"Novelty\", \"VariableType\", \"Currency\", \"LiabilityType\", \"GroupOfContract\"};", + "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -498,11 +524,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"VariableType\", \"Currency\"};", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -528,11 +555,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\", \"EconomicBasis\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", "\n }", "\n", - "\n new IReadOnlyCollection GitFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"VariableType\", \"Currency\"};", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -558,11 +586,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"AmountType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.AmountType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"AmountType\", \"LiabilityType\", \"Currency\"};", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -588,11 +617,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"VariableType\", \"LiabilityType\", \"Currency\"};", + "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n", "\n}" ], @@ -619,11 +649,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"VariableType\", \"Currency\", \"LiabilityType\"};", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n", "\n}" ], @@ -650,11 +681,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"EstimateType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"AmountType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.EstimateType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.AmountType) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Currency\", \"AmountType\", \"EstimateType\"};", + "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n", "\n}" ], @@ -681,11 +713,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"Currency\", \"VariableType\"};", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -711,12 +744,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"EstimateType\", \"VariableType\"};", - "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -742,12 +775,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"VariableType\", \"Currency\"};", - "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -764,12 +797,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"VariableType\", \"EstimateType\", \"Currency\"};", - "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -795,12 +828,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"Novelty\", \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Novelty\", \"VariableType\", \"EstimateType\", \"Currency\"};", - "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -817,11 +850,11 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"VariableType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"EstimateType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Currency\", \"VariableType\", \"EstimateType\"};", - "\n", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -847,12 +880,12 @@ "\n", "\n void Init() {", "\n // BasicSliceAndDiceFormsEntity", - "\n defaultRowSlices = new string[] { \"VariableType\", \"EstimateType\" };", - "\n defaultColumnSlices = new string[] { \"Currency\", \"LiabilityType\" };", + "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType), nameof(ReportVariable.EstimateType) };", + "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency)};", "\n }", - "\n", - "\n new IReadOnlyCollection GetFilterName() => new string[] {\"\", \"GroupOfContract\", \"Currency\", \"VariableType\", \"EstimateType\"};", - "\n", + "\n ", + "\n private List specificFilters => new List {};", + "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, From 9e954984fe074877e0135b441e17324a11277023 Mon Sep 17 00:00:00 2001 From: akatz Date: Fri, 10 Mar 2023 17:36:35 +0100 Subject: [PATCH 20/55] reference to disposable workspaces --- .../ReportMutableScopesInteractive.ipynb | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 126dab36..1d52d3cc 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -424,8 +424,9 @@ "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", + "\n var disposable_workspace = workspace;", "\n return await export.ToCsv(fileName)", - "\n .ForDataCube(dataScope.DataCube, config => config//.WithQuerySource(workspace)", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(disposable_workspace)", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", "\n .ExecuteAsync();", @@ -435,8 +436,9 @@ "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", + "\n var disposable_workspace = workspace; // needed to avoid two threads refering to the same data source ", "\n return await export.ToExcel(fileName)", - "\n .ForDataCube(dataScope.DataCube, config => config//.WithQuerySource(workspace) // Temporary solution to avoid a clash in DB access with the report", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(disposable_workspace) ", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", "\n .ExecuteAsync();", @@ -498,7 +500,7 @@ "\n }", "\n", "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -529,7 +531,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -560,7 +562,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -591,7 +593,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -622,7 +624,7 @@ "\n }", "\n", "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n", "\n}" ], @@ -654,7 +656,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n", "\n}" ], @@ -686,7 +688,7 @@ "\n }", "\n", "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n", "\n}" ], @@ -718,7 +720,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -749,7 +751,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -780,7 +782,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -802,7 +804,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -833,7 +835,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -854,7 +856,7 @@ "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -885,7 +887,7 @@ "\n }", "\n ", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", "\n}" ], "metadata": {}, @@ -938,7 +940,7 @@ "\n return ret;", "\n }", "\n", - "\n public async Task GetReport(string name = null) where T : ReportScope {", + "\n public InteractiveObjectView GetReport(string name = null) where T : ReportScope {", "\n var key = name ?? typeof(T).Name;", "\n if(!interactiveObjectCache.TryGetValue(key, out var ret)){", "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key,", From 545b687fbcf112b4aef859debed9ad2935727c83 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 10 Mar 2023 19:09:22 +0100 Subject: [PATCH 21/55] filters, scenario, slices --- .../Report/ReportConfigurationAndUtils.ipynb | 14 ++ .../ReportMutableScopesInteractive.ipynb | 181 ++++++++++++------ 2 files changed, 132 insertions(+), 63 deletions(-) diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index 061851c6..fc6ea7ad 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -223,6 +223,20 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "public static async Task<(IDictionary, IReadOnlyCollection)> GetAnnualCohortAutocompleteMappings (this IQuerySource querySource) {", + "\n var query = await querySource.Query().Select(x => x.AnnualCohort.ToString()).Distinct().ToArrayAsync();", + "\n var mappingDictionary = query.ToDictionary(x => x, x => x);", + "\n var orderedDropDownValues = query.Select(x => x);", + "\n return (mappingDictionary, new string[]{ null }.Concat(orderedDropDownValues).ToArray());", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 126dab36..947e7ffc 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -136,14 +136,20 @@ "\n string ScenarioControl { get; set; }", "\n", "\n [NotVisible] IDictionary ScenarioMapping { get; set; }", - "\n protected string Scenario => !string.IsNullOrWhiteSpace(ScenarioControl) && ScenarioMapping is not null && ScenarioMapping.TryGetValue(ScenarioControl, out var value) ? value : null;", + "\n protected string Scenario => !string.IsNullOrWhiteSpace(ScenarioControl) && ", + "\n ScenarioMapping is not null && ", + "\n ScenarioMapping.TryGetValue(ScenarioControl, out var value) ", + "\n ? value ", + "\n : null;", "\n ", "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", - "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", - "\n .Concat(new string[] {\"Delta\", \"All\"})", + "\n ScenarioMapping[\"Delta\"] = \"Delta\";", + "\n ScenarioMapping[\"All\"] = \"All\";", + "\n return orderedDropDownValues.Concat(new string[] {\"Delta\", \"All\"})", + "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", "\n .ToArray(); ", - "\n } ", + "\n }", "\n}" ], "metadata": {}, @@ -169,9 +175,11 @@ "\n string ReportingNodeControl { get; set; }", "\n", "\n [NotVisible] IDictionary ReportingNodeMapping { get; set; }", - "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ReportingNodeMapping is not null && ReportingNodeMapping.TryGetValue(ReportingNodeControl, out var value)", - "\n ? value", - "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", + "\n protected string ReportingNode => !string.IsNullOrWhiteSpace(ReportingNodeControl) && ", + "\n ReportingNodeMapping is not null && ", + "\n ReportingNodeMapping.TryGetValue(ReportingNodeControl, out var value)", + "\n ? value", + "\n : GetStorage().InitialReportingNode.SystemName; // Maybe these cases can be more specific", "\n", "\n async Task> GetReportingNodeAutocompleteAsync(string userInput, int page, int pageSize) {", "\n (ReportingNodeMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", @@ -252,21 +260,24 @@ { "cell_type": "code", "source": [ - "public interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", + "[InitializeScope(nameof(InitFilters))]", + "\npublic interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", "\n [DropdownMethod(nameof(GetFilterName))]", "\n string FilterName { get; set; }", "\n", "\n [DropdownMethod(nameof(GetBasicFilterAsync))]", - "\n string FilterValue { get; set; }", + "\n [Display(Name = \"Filter Value\")]", + "\n string FilterValueControl { get; set; }", "\n", "\n [DropdownValues(\"\", \"Add\", \"Remove\")]", "\n string FilterAction { get; set; }", "\n", "\n protected string[] defaultFilters => new string[] {", + "\n \"\",", "\n nameof(ReportVariable.GroupOfContract),", "\n nameof(ReportVariable.Portfolio),", "\n nameof(ReportVariable.LineOfBusiness),", - "\n nameof(ReportVariable.AnnualCohort),", + "\n //nameof(ReportVariable.AnnualCohort),", "\n nameof(ReportVariable.LiabilityType),", "\n nameof(ReportVariable.ValuationApproach),", "\n nameof(ReportVariable.OciType),", @@ -275,37 +286,53 @@ "\n", "\n IReadOnlyCollection GetFilterName() => defaultFilters;", "\n ", + "\n [NotVisible] IDictionary> FilterMapping { get; set; }", + "\n protected string FilterValue => !string.IsNullOrWhiteSpace(FilterName) && !string.IsNullOrWhiteSpace(FilterValueControl) && ", + "\n FilterMapping is not null && FilterMapping.TryGetValue(FilterName, out var inner) &&", + "\n inner.TryGetValue(FilterValueControl, out var value)", + "\n ? value", + "\n : null;", + "\n", + "\n async Task> GetFilterAutocompleteAsync() where T : KeyedDimension {", + "\n (var filterMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", + "\n FilterMapping[nameof(T)] = filterMapping;", + "\n return orderedDropDownValues;", + "\n }", + "\n", + "\n async Task> GetAnnualCohortFilterAutocompleteAsync() {", + "\n (var filterMapping, var orderedDropDownValues) = await workspace.GetAnnualCohortAutocompleteMappings();", + "\n FilterMapping[nameof(ReportVariable.AnnualCohort)] = filterMapping;", + "\n return orderedDropDownValues;", + "\n }", + "\n", "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", "\n new string[]{ null }.Concat(", - "\n await (FilterName switch", + "\n (FilterName switch", "\n {", - "\n nameof(ReportVariable.GroupOfContract) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n nameof(ReportVariable.Portfolio) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n nameof(ReportVariable.LineOfBusiness) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n nameof(ReportVariable.AnnualCohort) => workspace.Query()", - "\n //.Where(x => InputDataFilter.Any(x => x.filterName == nameof(ReportVariable.GroupOfContract)) ", - "\n // ? InputDataFilter.Where(x => x.filterName == nameof(ReportVariable.GroupOfContract)).filterValue == x.SystemName", - "\n // : true)", - "\n .Select(x => x.AnnualCohort.ToString()).Distinct(),", - "\n nameof(ReportVariable.LiabilityType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n nameof(ReportVariable.ValuationApproach) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n nameof(ReportVariable.OciType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n nameof(ReportVariable.InitialProfitability) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n ", - "\n nameof(ReportVariable.Novelty) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)), //Not needed", - "\n nameof(ReportVariable.VariableType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)), //Not needed. Query VariableType??", - "\n nameof(ReportVariable.EconomicBasis) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n nameof(ReportVariable.AmountType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n nameof(ReportVariable.EstimateType) => workspace.Query().Select(x => ParseDimensionToDisplayString(x.SystemName, x.DisplayName)),", - "\n _ => Enumerable.Empty().AsQueryable()", - "\n }) .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).OrderBy(x => x).ToArrayAsync()).ToArray();", + "\n //GetAutocompleteMappings", + "\n nameof(ReportVariable.Portfolio) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.GroupOfContract) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.LineOfBusiness) => await GetFilterAutocompleteAsync(),", + "\n //nameof(ReportVariable.AnnualCohort) => await GetAnnualCohortFilterAutocompleteAsync(),//TODO the filter is not applied because the prop is an Int", + "\n nameof(ReportVariable.LiabilityType) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.ValuationApproach) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.OciType) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.InitialProfitability) => await GetFilterAutocompleteAsync(),", + "\n", + "\n nameof(ReportVariable.Novelty) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.VariableType) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.EconomicBasis) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.AmountType) => await GetFilterAutocompleteAsync(),", + "\n nameof(ReportVariable.EstimateType) => await GetFilterAutocompleteAsync(),", + "\n _ => Enumerable.Empty().ToArray()", + "\n }).Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase)).OrderBy(x => x)).ToArray();", "\n ", "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", "\n ", - "\n // This is just a cast... do we need this?", - "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null ", - "\n ? Enumerable.Empty<(string, object)>() ", - "\n : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", + "\n //The cast is needed by the .Filter func", + "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null", + "\n ? Enumerable.Empty<(string, object)>()", + "\n : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", "\n", "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", "\n {", @@ -332,6 +359,10 @@ "\n InputDataFilter = f.ToArray();", "\n }", "\n }", + "\n", + "\n void InitFilters() {", + "\n FilterMapping = new Dictionary>() ;", + "\n }", "\n}" ], "metadata": {}, @@ -350,22 +381,47 @@ { "cell_type": "code", "source": [ - "public interface BasicSliceAndDiceFormsEntity : MutableScopeWithWorkspace {", - "\n [DropdownValues(\"\", \"GroupOfContract\")]", - "\n string SliceRowName { get; set; }", - "\n", - "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", - "\n string SliceColumnName { get; set; }", + "public interface BasicSliceAndDiceRowsFormsEntity : MutableScopeWithWorkspace {", + "\n //[DropdownValues(\"\", \"Novelty\",\"VariableType\",\"AmountType\")]", + "\n [NotVisible] string SliceRowName { get; set; }", "\n", "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", "\n [NotVisible] IReadOnlyCollection defaultRowSlices { get; set; }", "\n protected string[] rowSlices => defaultRowSlices.Union(InputRowSlices).ToArray();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public interface BasicSliceAndDiceColumnsFormsEntity : MutableScopeWithWorkspace {", + "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", + "\n string SliceColumnName { get; set; }", "\n", "\n protected IReadOnlyCollection InputColumnSlices => (SliceColumnName is null ? Enumerable.Empty() : SliceColumnName.RepeatOnce()).ToArray();", "\n [NotVisible] IReadOnlyCollection defaultColumnSlices { get; set; }", "\n protected string[] columnSlices => defaultColumnSlices.Union(InputColumnSlices).ToArray();", "\n", - "\n IReadOnlyCollection GetSliceColumnNameAutocomplete() => new [] {\"\", \"GroupOfContract\", \"AmountType\"};", + "\n IReadOnlyCollection GetSliceColumnNameAutocomplete() => new [] {\"\", ", + "\n nameof(ReportVariable.ReportingNode), ", + "\n nameof(ReportVariable.Scenario),", + "\n nameof(ReportVariable.Portfolio), ", + "\n nameof(ReportVariable.GroupOfContract), ", + "\n nameof(ReportVariable.LineOfBusiness),", + "\n nameof(ReportVariable.LiabilityType),", + "\n nameof(ReportVariable.InitialProfitability),", + "\n nameof(ReportVariable.ValuationApproach),", + "\n nameof(ReportVariable.AnnualCohort),", + "\n nameof(ReportVariable.OciType),", + "\n nameof(ReportVariable.IsReinsurance),", + "\n nameof(ReportVariable.AccidentYear),", + "\n ", + "\n nameof(ReportVariable.AmountType),", + "\n nameof(ReportVariable.EstimateType),", + "\n nameof(ReportVariable.EconomicBasis)};", "\n}" ], "metadata": {}, @@ -386,13 +442,14 @@ "source": [ "public interface Data : IMutableScope<((int year, int month) reportingPeriod, string reportingNode, string scenario, CurrencyType currencyType, (string filterName, object filterValue)[] dataFilter)> {", "\n IDataCube InputDataCube { get; set; }", - "\n", "\n IDataCube DataCube { get {", "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ? InputDataCube : InputDataCube.Filter(Identity.dataFilter); ", - "\n if(Identity.scenario != \"Delta\") return filteredDataCube;", + "\n if(Identity.scenario != \"All\" && Identity.scenario != \"Delta\") return filteredDataCube.Filter((\"Scenario\", Identity.scenario));", + "\n if(Identity.scenario == \"All\") return filteredDataCube.Select(x => x.Scenario == null ? x with {Scenario = \"Best Estimate\" } : x).ToDataCube();", "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", - "\n return filteredDataCube.Select(x => x.Scenario == null ? x : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0d) }).ToDataCube();", + "\n return filteredDataCube.Select(x => x.Scenario == null ? x with { Scenario = \"Best Estimate\" } ", + "\n : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0.0) }).ToDataCube();", "\n }}", "\n} " ], @@ -404,7 +461,8 @@ "cell_type": "code", "source": [ "[InitializeScope(nameof(Init))]", - "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, BasicSliceAndDiceFormsEntity, BasicFilterFormsEntity {", + "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, ", + "\n BasicSliceAndDiceRowsFormsEntity, BasicSliceAndDiceColumnsFormsEntity, BasicFilterFormsEntity {", "\n protected IPivotFactory report => GetStorage().Report;", "\n protected IExportVariable export => GetStorage().Export;", "\n protected int headerColumnWidthValue => 250;", @@ -498,7 +556,7 @@ "\n }", "\n", "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -529,7 +587,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -560,7 +618,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -591,7 +649,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -622,8 +680,7 @@ "\n }", "\n", "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", - "\n", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -654,8 +711,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", - "\n", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -686,8 +742,7 @@ "\n }", "\n", "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", - "\n", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -718,7 +773,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -749,7 +804,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -780,7 +835,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -802,7 +857,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -833,7 +888,7 @@ "\n }", "\n", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -854,7 +909,7 @@ "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -885,7 +940,7 @@ "\n }", "\n ", "\n private List specificFilters => new List {};", - "\n new IReadOnlyCollection GetFilterName() => Array.AsReadOnly( defaultFilters.ToList().Concat(specificFilters).ToArray() );", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, From a92660450468e014cc25173e1ee7484e7aec53aa Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 13 Mar 2023 12:26:04 +0100 Subject: [PATCH 22/55] Reports split to notebook per each report + some modifications --- .../Report/InteractiveReports.ipynb | 458 ------------------ .../SeparateInteractiveReports/Accruals.ipynb | 65 +++ .../ActualsLIC.ipynb | 56 +++ .../ActualsLRC.ipynb | 56 +++ .../SeparateInteractiveReports/CSM.ipynb | 56 +++ .../Deferrals.ipynb | 56 +++ .../ExperienceAdjustmen.ipynb | 56 +++ .../SeparateInteractiveReports/Fcf.ipynb | 65 +++ .../FinancialPerformance.ipynb | 56 +++ .../SeparateInteractiveReports/LIC.ipynb | 56 +++ .../SeparateInteractiveReports/LRC.ipynb | 65 +++ .../PresentValue.ipynb | 76 +++ .../SeparateInteractiveReports/ReadMe.ipynb | 71 +++ .../RiskAdjustment.ipynb | 65 +++ .../TechnicalMargin.ipynb | 65 +++ .../SeparateInteractiveReports/Written.ipynb | 65 +++ .../ReportMutableScopesInteractive.ipynb | 40 +- 17 files changed, 963 insertions(+), 464 deletions(-) delete mode 100644 ifrs17-template/Report/InteractiveReports.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/ReadMe.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb create mode 100644 ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb diff --git a/ifrs17-template/Report/InteractiveReports.ipynb b/ifrs17-template/Report/InteractiveReports.ipynb deleted file mode 100644 index 98231218..00000000 --- a/ifrs17-template/Report/InteractiveReports.ipynb +++ /dev/null @@ -1,458 +0,0 @@ -{ - "metadata": { - "authors": [], - "id": "wTla7_suu02MahikFpsz0A", - "kernelspec": { - "display_name": "Formula Framework", - "language": "C#", - "name": "C#" - }, - "language_info": { - "file_extension": ".cs", - "mimetype": "text/plain", - "name": "C#" - } - }, - "nbformat": 4, - "nbformat_minor": 5, - "cells": [ - { - "cell_type": "markdown", - "source": [ - "", - "\n

Interactive Reports

" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Set up data and configuration", - "\n", - "\nChoose to run the Reports notebook either with the set of Systemorph data in memory or with the data present in the Database: ", - "\n- #!eval-notebook \"../Database/Configure\" : connects to a physical Database", - "\n- #!eval-notebook \"../Import/CloseImportTemplate\" : uses the in-memory set up", - "\n", - "\nWe use here the in-memory set up." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "#!import \"../Import/CloseImportTemplate\"" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# Best Estimate", - "\n", - "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#best-estimate) future cash flows are shown here in an Analysis of Change report.", - "\n", - "\nThe granularity of the reported figures can be modified by changing the Column Slices options.", - "\nFor example one can add \"GroupOfContract\" to separate the contributions of the individual Group of Contracts.", - "\n", - "\nAggregated values are displayed when the data has a finer granularity than the one selected by the report slice options." - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - } - ] -} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb new file mode 100644 index 00000000..48a4baa0 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb @@ -0,0 +1,65 @@ +{ + "metadata": { + "authors": [], + "id": "oKYWmrRFfU2e9YTd1Vj9iw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"Accruals\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb new file mode 100644 index 00000000..e7150493 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb @@ -0,0 +1,56 @@ +{ + "metadata": { + "authors": [], + "id": "TQuldOYk4EOSd_LlOA_F9g", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"ActulasLic\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb new file mode 100644 index 00000000..5b52f65d --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb @@ -0,0 +1,56 @@ +{ + "metadata": { + "authors": [], + "id": "grGt10mtDky3n0kfGJ0_cg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"ActLrc\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb new file mode 100644 index 00000000..15afa586 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb @@ -0,0 +1,56 @@ +{ + "metadata": { + "authors": [], + "id": "YfxenPHy6ky0dq9nEONroA", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"CSM\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb new file mode 100644 index 00000000..4613327c --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb @@ -0,0 +1,56 @@ +{ + "metadata": { + "authors": [], + "id": "T4bL4ggXtUu8qf7OrBY7lg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"Deferrals\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb new file mode 100644 index 00000000..6a251229 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb @@ -0,0 +1,56 @@ +{ + "metadata": { + "authors": [], + "id": "AXPivUdMuE-lUwK-q-qUPg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"ExperienceAdjustment\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb new file mode 100644 index 00000000..31d8e2f4 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb @@ -0,0 +1,65 @@ +{ + "metadata": { + "authors": [], + "id": "SJ5ZNXF0EkSstU_pWIG2Kg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"Fcf\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb new file mode 100644 index 00000000..324195c7 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb @@ -0,0 +1,56 @@ +{ + "metadata": { + "authors": [], + "id": "AmrSZNq9YUqkLnbEjLUpkw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"FinancialPerformace\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb new file mode 100644 index 00000000..4524d888 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb @@ -0,0 +1,56 @@ +{ + "metadata": { + "authors": [], + "id": "qorXFtJ_gE2BGWjTnWDHAg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb new file mode 100644 index 00000000..989141b6 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb @@ -0,0 +1,65 @@ +{ + "metadata": { + "authors": [], + "id": "e-MbqoKGUEaq_uBz7npwPQ", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"Lrc\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb new file mode 100644 index 00000000..0a039ec8 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb @@ -0,0 +1,76 @@ +{ + "metadata": { + "authors": [], + "id": "PTEWug2t60Cim-6iwrIVGg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"../../Import/CloseImportTemplate\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"PvReport\", addDateTime : true)", + "\n/*ifrs17Interactive.ToExcelInteractive(\"PvReport\", addDateTime : true) */" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ReadMe.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/ReadMe.ipynb new file mode 100644 index 00000000..ea03fa7f --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/ReadMe.ipynb @@ -0,0 +1,71 @@ +{ + "metadata": { + "authors": [], + "id": "HX-3ABD14UaeXjlLLekeNw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Set up and configurations " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Choose to run the Report notebooks either with the set of Systemorph data in memory or with the data present in the Database:", + "\n", + "\n- #!eval-notebook \"../Database/Configure\" : connects to a physical Database", + "\n- #!eval-notebook \"../Import/CloseImportTemplate\" : uses the in-memory set up", + "\nWe use here the in-memory set up.", + "\n", + "\nNote that all these definitions are located in the PresentValue notebook, and the rest of the notebooks simply import this notebook. Change the definitions in that file.", + "\n", + "\nEach report is located in a different notebook in order to improve the performance. Location multiple interactive reports in a single notebook, though possible, might potentially decrease the performance. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Best Estimate", + "\n", + "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#best-estimate) future cash flows are shown here in an Analysis of Change report.", + "\n", + "\nThe granularity of the reported figures can be modified by changing the Column Slices options.", + "\nFor example one can add \"GroupOfContract\" to separate the contributions of the individual Group of Contracts.", + "\n", + "\nAggregated values are displayed when the data has a finer granularity than the one selected by the report slice options." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb new file mode 100644 index 00000000..5dae5de8 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb @@ -0,0 +1,65 @@ +{ + "metadata": { + "authors": [], + "id": "BBEqtQSGT0CHl8YpJC18hw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"RaReport\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb new file mode 100644 index 00000000..f533c6aa --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb @@ -0,0 +1,65 @@ +{ + "metadata": { + "authors": [], + "id": "c9ui1BTJv0-wnUoEiBU1pw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"TechMargin\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb new file mode 100644 index 00000000..775545a2 --- /dev/null +++ b/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb @@ -0,0 +1,65 @@ +{ + "metadata": { + "authors": [], + "id": "WzfGMeugkEGQTanwpQJcTg", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "code", + "source": [ + "#!import \"PresentValue\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "await ifrs17Interactive.ExportToExcelAsync(\"Written\", addDateTime : true)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 1d52d3cc..09c35b56 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -947,29 +947,57 @@ "\n _ => {", "\n var scope = GetReportScope(key);", "\n var filters = scope.GetFilters(); // Not used and should be improved", - "\n return scope.ToReportAsync(); // Not awaited -- and causes a problem down the rode, if report and output files are needed ", + "\n return scope.ToReportAsync(); ", "\n }); ", "\n }", "\n return ret;", "\n }", "\n", - "\n public async Task ExportToCsvAsync(string fileName)", + "\n public async Task ExportToCsvAsync(string fileName, bool addDateTime = false)", "\n where T : ReportScope", "\n {", + "\n var fullFileName = addDateTime ? AttachDateTime(fileName) : fileName; ", "\n var scope = GetReportScope();", "\n var _ = scope.GetFilters();", - "\n return await scope.ToCsvAsync(fileName);", + "\n return await scope.ToCsvAsync(fullFileName);", "\n } ", "\n", "\n", - "\n public async Task ExportToExcelAsync(string fileName)", + "\n public async Task ExportToExcelAsync(string fileName, bool addDateTime = false)", "\n where T : ReportScope", "\n {", + "\n var fullFileName = addDateTime ? AttachDateTime(fileName) : fileName;", "\n var scope = GetReportScope();", "\n var _ = scope.GetFilters();", - "\n return await scope.ToExcelAsync(fileName);", + "\n return await scope.ToExcelAsync(fullFileName);", "\n }", "\n", + "\n private string ToTwoDigitString(int number ) => number.ToString().Length == 1 ? \"0\" + number.ToString() : number.ToString();", + "\n", + "\n private string AttachDateTime(string fileName)", + "\n {", + "\n DateTime creationTime = DateTime.UtcNow;", + "\n return fileName + \"_\" + creationTime.Year.ToString() + ToTwoDigitString(creationTime.Month) + ToTwoDigitString(creationTime.Day) +", + "\n ToTwoDigitString(creationTime.Hour) + ToTwoDigitString(creationTime.Minute) + ToTwoDigitString(creationTime.Second);", + "\n }", + "\n", + "\n // This routine is still buggy, triggering an infinite loop. Not clear why. -- A.K.", + "\n public InteractiveObjectView ToExcelInteractive(string fileName, bool addDateTime = false, string name = null)", + "\n where T : ReportScope", + "\n {", + "\n var key = name ?? typeof(T).Name;", + "\n var fullFileName = addDateTime ? AttachDateTime(fileName) : fileName; ", + "\n if (!interactiveObjectCache.TryGetValue($\"{key}.xlsx\", out var ret))", + "\n ret = interactiveObjectCache[$\"{key}.xlsx\"] = interactiveObject.CreateView($\"{key}.xlsx\", _ => ", + "\n {", + "\n var scope = GetReportScope();", + "\n var filters = scope.GetFilters();", + "\n return scope.ToExcelAsync(fullFileName);", + "\n });", + "\n return ret;", + "\n }", + "\n ", + "\n", "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n", "\n // Keeping the old API", @@ -986,7 +1014,7 @@ "\n public ReportScope Lrc => GetReportScope();", "\n public ReportScope ActuarialLic => GetReportScope();", "\n public ReportScope Lic => GetReportScope();", - "\n public ReportScope FinancialPerformance => GetReportScope(); ", + "\n public ReportScope FinancialPerformance => GetReportScope(); ", "\n}" ], "metadata": {}, From cd047131bd02447e6d0cb7f6f4bf91b74091b111 Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 13 Mar 2023 13:40:36 +0100 Subject: [PATCH 23/55] minor fix in parameter mutable reports --- ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index d8ad95b8..1aef8cc1 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -198,7 +198,7 @@ "\n var key = name ?? typeof(T).Name;", "\n if (!interactiveObjectCache.TryGetValue($\"{key}FormsEntity\", out var ret))", "\n ret = interactiveObjectCache[$\"{key}FormsEntity\"] = interactiveObject.CreateView($\"{key}FormsEntity\", ", - "\n _ => GetReportScope());", + "\n _ => GetReportScope(name : \"ParameterReports\"));", "\n return ret;", "\n }", "\n", From c211027f6f9d116cf2be1263e939e0964f34fa1f Mon Sep 17 00:00:00 2001 From: akatz Date: Wed, 15 Mar 2023 10:54:41 +0100 Subject: [PATCH 24/55] Typos fixed, pseudo-fix for the threading issue removed and added slices to the parameter reports --- .../PresentValue.ipynb | 3 +- ifrs17/DataModel/DataStructure.ipynb | 12 ++++---- ...rameterReportMutableScopeInteractive.ipynb | 30 +++++++++++++------ .../ReportMutableScopesInteractive.ipynb | 9 +++--- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb index 0a039ec8..ec9662b1 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb @@ -56,8 +56,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"PvReport\", addDateTime : true)", - "\n/*ifrs17Interactive.ToExcelInteractive(\"PvReport\", addDateTime : true) */" + "await ifrs17Interactive.ExportToExcelAsync(\"PvReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index d07bc12f..87a2a4a0 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -52,20 +52,20 @@ "source": [ "#r \"nuget:Systemorph.Activities,1.6.5\"", "\n#r \"nuget:Systemorph.Arithmetics,1.6.5\"", - "\n#r \"nuget:Systemorph.Workspace,1.6.3\"", + "\n#r \"nuget:Systemorph.Workspace,1.6.4\"", "\n#r \"nuget:Systemorph.InteractiveObjects,1.6.5\"", "\n#r \"nuget:Systemorph.SharePoint,1.6.5\"", "\n#r \"nuget:Systemorph.OneDrive,1.6.5\"", "\n#r \"nuget:Systemorph.Scopes,1.6.5\"", - "\n#r \"nuget:Systemorph.Import,1.6.6\"", + "\n#r \"nuget:Systemorph.Import,1.6.7\"", "\n#r \"nuget:Systemorph.Test,1.6.5\"", - "\n#r \"nuget:Systemorph.Export,1.6.6\"", + "\n#r \"nuget:Systemorph.Export,1.6.7\"", "\n#r \"nuget:Systemorph.DataSetReader,1.6.6\"", - "\n#r \"nuget:Systemorph.DataSource,1.6.3\"", - "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.3\"", + "\n#r \"nuget:Systemorph.DataSource,1.6.4\"", + "\n#r \"nuget:Systemorph.DataSource.Conversions,1.6.4\"", "\n#r \"nuget:Systemorph.Reporting,1.6.5\"", "\n#r \"nuget:Systemorph.Charting,1.6.5\"", - "\n#r \"nuget:Systemorph.SchemaMigrations,1.6.3\"" + "\n#r \"nuget:Systemorph.SchemaMigrations,1.6.4\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index 1aef8cc1..aea1a9af 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -34,7 +34,7 @@ "\n [DropdownMethod(nameof(ReportMenu))]", "\n string ReportType{get; set;}", "\n", - "\n IReadOnlyCollection ReportMenu() => new string[] {\"DataNodeReport\", ", + "\n IReadOnlyCollection ReportMenu() => new string[] {\"\", \"DataNodeReport\", ", "\n \"DataNodeStateReport\", ", "\n \"YieldCurves\", ", "\n \"SingleDataNodeReport\", ", @@ -50,8 +50,7 @@ { "cell_type": "code", "source": [ - "[InitializeScope(nameof(InitReportStorageScopeAsync))]", - "\npublic interface ParameterReportScope: IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, RepFormsEntity", + "public interface ParameterReportScope: IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, RepFormsEntity", "\n{", "\n protected IPivotFactory report => GetStorage().Report;", "\n protected IExportVariable export => GetStorage().Export;", @@ -61,6 +60,7 @@ "\n", "\n async Task InitializeStorageAsync()", "\n {", + "\n await GetStorage().InitializeReportIndependentCacheAsync();", "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n }", "\n", @@ -72,6 +72,8 @@ "\n var data = await workspace.GetDataNodeDataReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.Portfolio)", + "\n .GroupRowsBy(x => x.DataNode)", "\n .ToTable()", "\n .ExecuteAsync();", "\n }", @@ -82,6 +84,8 @@ "\n var data = await workspace.GetDataNodeStateReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.GroupOfContract)", + "\n .GroupColumnsBy(x => x.Period)", "\n .ToTable()", "\n .ExecuteAsync();", "\n }", @@ -92,6 +96,9 @@ "\n var data = await workspace.GetYieldCurveReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.GroupOfContract)", + "\n .GroupColumnsBy(x => x.YieldCurveType)", + "\n .GroupColumnsBy(x => x.Period)", "\n .ToTable()", "\n .ExecuteAsync();", "\n }", @@ -102,6 +109,8 @@ "\n var data = await workspace.GetSingleDataNodeReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.GroupOfContract)", + "\n .GroupColumnsBy(x => x.Period)", "\n .ToTable()", "\n .ExecuteAsync();", "\n }", @@ -112,6 +121,9 @@ "\n var data = await workspace.GetInterDataNodeParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.GroupOfContract)", + "\n .GroupRowsBy(x => x.LinkedDataNode)", + "\n .GroupColumnsBy(x => x.Period)", "\n .ToTable()", "\n .ExecuteAsync();", "\n }", @@ -122,6 +134,8 @@ "\n var data = await workspace.GetPartnerRatingsReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.Partner)", + "\n .GroupColumnsBy(x => x.Period)", "\n .ToTable()", "\n .ExecuteAsync();", "\n }", @@ -132,6 +146,8 @@ "\n var data = await workspace.GetCreditDefaultRatesReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", + "\n .GroupRowsBy(x => x.CreditRiskRating)", + "\n .GroupColumnsBy(x => x.Period)", "\n .ToTable()", "\n .ExecuteAsync();", "\n }", @@ -145,12 +161,8 @@ "\n \"InterDataNodeParameters\" => await GenerateInterDataNodeParametersReport(), ", "\n \"PartnerRating\" => await GeneratePartnerRatingReport(), ", "\n \"PartnerDefaultRates\" => await GenerateDefaultRatesReport(),", - "\n _ => await GenerateDataNodeReport()", + "\n _ => null", "\n };", - "\n", - "\n async Task InitReportStorageScopeAsync() { ", - "\n await GetStorage().InitializeReportIndependentCacheAsync();", - "\n }", "\n}" ], "metadata": {}, @@ -209,7 +221,7 @@ "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, ", "\n _ => {", - "\n var scope = GetReportScope();", + "\n var scope = GetReportScope(name : \"ParameterReports\");", "\n return scope.ToReport(); ", "\n });", "\n return ret;", diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index afc77872..aad9fb61 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -482,9 +482,9 @@ "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", - "\n var disposable_workspace = workspace;", + "\n //var disposable_workspace = workspace;", "\n return await export.ToCsv(fileName)", - "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(disposable_workspace)", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", "\n .ExecuteAsync();", @@ -494,15 +494,16 @@ "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", - "\n var disposable_workspace = workspace; // needed to avoid two threads refering to the same data source ", + "\n //var disposable_workspace = workspace; // needed to avoid two threads refering to the same data source ", "\n return await export.ToExcel(fileName)", - "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(disposable_workspace) ", + "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace) ", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", "\n .ExecuteAsync();", "\n }", "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", + "\n //var disposable_workspace_2 = workspace;", "\n return await report.ForDataCube(data)", "\n .WithQuerySource(workspace)", "\n .SliceRowsBy(rowSlices)", From b5117ed44e7904429760d8d7b48415b63318703d Mon Sep 17 00:00:00 2001 From: akatz Date: Thu, 16 Mar 2023 15:31:15 +0100 Subject: [PATCH 25/55] filters fix --- .../SeparateInteractiveReports/Accruals.ipynb | 57 ++++++++++++++++++- .../ReportMutableScopesInteractive.ipynb | 7 ++- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb index 48a4baa0..d80af054 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb @@ -19,7 +19,17 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -52,6 +62,51 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var scope = ifrs17Interactive.GetReportScope();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "scope.GetData()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "scope.GetData().Filter((\"Scenario\", (string)null))" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "var data = scope.GetData();" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "data.Where(x => x.Scenario != null).ToDataCube()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index aad9fb61..ef918417 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -445,6 +445,7 @@ "\n IDataCube DataCube { get {", "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ? InputDataCube : InputDataCube.Filter(Identity.dataFilter); ", + "\n if(Identity.scenario == null) return filteredDataCube.Where(x => x.Scenario == null).ToDataCube();", "\n if(Identity.scenario != \"All\" && Identity.scenario != \"Delta\") return filteredDataCube.Filter((\"Scenario\", Identity.scenario));", "\n if(Identity.scenario == \"All\") return filteredDataCube.Select(x => x.Scenario == null ? x with {Scenario = \"Best Estimate\" } : x).ToDataCube();", "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", @@ -478,11 +479,12 @@ "\n return await GetReportTaskAsync(dataScope.DataCube);", "\n }", "\n", + "\n // Using this routine is highly discouraged due to the mutlithreading issue -A.K.", + "\n // Avoid using these methods if working with the DB -- it will trigger synchronization error in access to the DB", "\n async Task ToCsvAsync(string fileName){", "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", - "\n //var disposable_workspace = workspace;", "\n return await export.ToCsv(fileName)", "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", "\n .SliceRowsBy(rowSlices)", @@ -494,16 +496,15 @@ "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n dataScope.InputDataCube = GetData();", - "\n //var disposable_workspace = workspace; // needed to avoid two threads refering to the same data source ", "\n return await export.ToExcel(fileName)", "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace) ", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", "\n .ExecuteAsync();", "\n }", + "\n ", "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", - "\n //var disposable_workspace_2 = workspace;", "\n return await report.ForDataCube(data)", "\n .WithQuerySource(workspace)", "\n .SliceRowsBy(rowSlices)", From 4ba679bd81bb57619ea82b6e708c976614704ca0 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Thu, 16 Mar 2023 18:52:52 +0100 Subject: [PATCH 26/55] filter fix --- ifrs17/Report/ReportMutableScopesInteractive.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index ef918417..64b10dc7 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -295,7 +295,7 @@ "\n", "\n async Task> GetFilterAutocompleteAsync() where T : KeyedDimension {", "\n (var filterMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings();", - "\n FilterMapping[nameof(T)] = filterMapping;", + "\n FilterMapping[typeof(T).Name] = filterMapping;", "\n return orderedDropDownValues;", "\n }", "\n", From b0a6707bc240695ea2020e78383d2aa27a12a0ca Mon Sep 17 00:00:00 2001 From: akatz Date: Fri, 17 Mar 2023 09:19:21 +0100 Subject: [PATCH 27/55] some changes to the reports --- .../ActualsLIC.ipynb | 9 +++++---- .../ActualsLRC.ipynb | 9 +++++---- .../SeparateInteractiveReports/CSM.ipynb | 9 +++++---- .../SeparateInteractiveReports/Deferrals.ipynb | 9 +++++---- .../ExperienceAdjustmen.ipynb | 9 +++++---- .../SeparateInteractiveReports/Fcf.ipynb | 18 +++++------------- .../FinancialPerformance.ipynb | 9 +++++---- .../SeparateInteractiveReports/LIC.ipynb | 9 +++++---- .../SeparateInteractiveReports/LRC.ipynb | 9 +++++---- .../RiskAdjustment.ipynb | 9 +++++---- .../TechnicalMargin.ipynb | 9 +++++---- .../SeparateInteractiveReports/Written.ipynb | 9 +++++---- 12 files changed, 60 insertions(+), 57 deletions(-) diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb index e7150493..8dc9313e 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"ActulasLic\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb index 5b52f65d..45ee28ec 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"ActLrc\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb index 15afa586..c2f7408d 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"CSM\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb index 4613327c..b01f2537 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"Deferrals\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb index 6a251229..8e037829 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"ExperienceAdjustment\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb index 31d8e2f4..5c05ab82 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,16 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -46,7 +38,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"Fcf\", addDateTime : true)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -55,7 +47,7 @@ { "cell_type": "code", "source": [ - "" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb index 324195c7..96257c63 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"FinancialPerformace\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb index 4524d888..493810ca 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb index 989141b6..35297804 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"Lrc\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb index 5dae5de8..d739b9e0 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"RaReport\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb index f533c6aa..d2545dff 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"TechMargin\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb index 775545a2..bbd34739 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb +++ b/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb @@ -19,7 +19,7 @@ { "cell_type": "code", "source": [ - "#!import \"PresentValue\"" + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, @@ -28,7 +28,8 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, @@ -37,7 +38,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -46,7 +47,7 @@ { "cell_type": "code", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"Written\", addDateTime : true)" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, From e8e6cff3e6c56a1b0f8ef69a7c955d149829fe65 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 17 Mar 2023 17:50:11 +0100 Subject: [PATCH 28/55] interactive reports --- .../Report/InteractiveReports/Accruals.ipynb | 75 +++++++++++ .../Csm-Lc-LoReCo.ipynb} | 11 +- .../Deferrals.ipynb | 11 +- .../ExperienceAdjustment.ipynb} | 11 +- .../FinancialPerformance.ipynb | 11 +- .../FulfilmentCashflow.ipynb} | 11 +- .../LIC.ipynb | 11 +- .../LRC.ipynb | 11 +- .../LicActuarial.ipynb} | 13 +- .../LoadData.ipynb} | 21 +-- .../LrcActuarial.ipynb} | 13 +- .../PresentValue.ipynb | 11 +- .../RiskAdjustment.ipynb | 11 +- .../TechnicalMargin.ipynb | 11 +- .../WrittenActual.ipynb} | 11 +- .../SeparateInteractiveReports/Accruals.ipynb | 120 ------------------ 16 files changed, 214 insertions(+), 149 deletions(-) create mode 100644 ifrs17-template/Report/InteractiveReports/Accruals.ipynb rename ifrs17-template/Report/{SeparateInteractiveReports/CSM.ipynb => InteractiveReports/Csm-Lc-LoReCo.ipynb} (78%) rename ifrs17-template/Report/{SeparateInteractiveReports => InteractiveReports}/Deferrals.ipynb (80%) rename ifrs17-template/Report/{SeparateInteractiveReports/ExperienceAdjustmen.ipynb => InteractiveReports/ExperienceAdjustment.ipynb} (80%) rename ifrs17-template/Report/{SeparateInteractiveReports => InteractiveReports}/FinancialPerformance.ipynb (80%) rename ifrs17-template/Report/{SeparateInteractiveReports/Fcf.ipynb => InteractiveReports/FulfilmentCashflow.ipynb} (80%) rename ifrs17-template/Report/{SeparateInteractiveReports => InteractiveReports}/LIC.ipynb (81%) rename ifrs17-template/Report/{SeparateInteractiveReports => InteractiveReports}/LRC.ipynb (83%) rename ifrs17-template/Report/{SeparateInteractiveReports/ActualsLIC.ipynb => InteractiveReports/LicActuarial.ipynb} (78%) rename ifrs17-template/Report/{SeparateInteractiveReports/ReadMe.ipynb => InteractiveReports/LoadData.ipynb} (55%) rename ifrs17-template/Report/{SeparateInteractiveReports/ActualsLRC.ipynb => InteractiveReports/LrcActuarial.ipynb} (78%) rename ifrs17-template/Report/{SeparateInteractiveReports => InteractiveReports}/PresentValue.ipynb (84%) rename ifrs17-template/Report/{SeparateInteractiveReports => InteractiveReports}/RiskAdjustment.ipynb (82%) rename ifrs17-template/Report/{SeparateInteractiveReports => InteractiveReports}/TechnicalMargin.ipynb (82%) rename ifrs17-template/Report/{SeparateInteractiveReports/Written.ipynb => InteractiveReports/WrittenActual.ipynb} (82%) delete mode 100644 ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb diff --git a/ifrs17-template/Report/InteractiveReports/Accruals.ipynb b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb new file mode 100644 index 00000000..b6d1cf4b --- /dev/null +++ b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb @@ -0,0 +1,75 @@ +{ + "metadata": { + "authors": [], + "id": "oKYWmrRFfU2e9YTd1Vj9iw", + "kernelspec": { + "display_name": "Formula Framework", + "language": "C#", + "name": "C#" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/plain", + "name": "C#" + } + }, + "nbformat": 4, + "nbformat_minor": 5, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Accruals

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#!import \"LoadData\"" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetFormsEntity()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb similarity index 78% rename from ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb rename to ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb index c2f7408d..471692b3 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/CSM.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Contractual Service Margin / Loss Component / Loss Recovery Component

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb similarity index 80% rename from ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb rename to ifrs17-template/Report/InteractiveReports/Deferrals.ipynb index b01f2537..1929d19b 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/Deferrals.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Deferrals

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb similarity index 80% rename from ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb rename to ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb index 8e037829..7daead0d 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/ExperienceAdjustmen.ipynb +++ b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Experience Adjustment

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb similarity index 80% rename from ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb rename to ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb index 96257c63..8c87b844 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/FinancialPerformance.ipynb +++ b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Financial Performance

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb similarity index 80% rename from ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb rename to ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb index 5c05ab82..d0b7feb0 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/Fcf.ipynb +++ b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Fulfilment Cash flow

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb b/ifrs17-template/Report/InteractiveReports/LIC.ipynb similarity index 81% rename from ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb rename to ifrs17-template/Report/InteractiveReports/LIC.ipynb index 493810ca..9bf48f2c 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/LIC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LIC.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

LIC

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb b/ifrs17-template/Report/InteractiveReports/LRC.ipynb similarity index 83% rename from ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb rename to ifrs17-template/Report/InteractiveReports/LRC.ipynb index 35297804..49a962b0 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/LRC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LRC.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

LRC

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb similarity index 78% rename from ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb rename to ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb index 8dc9313e..e6dae6b0 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLIC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb @@ -1,7 +1,7 @@ { "metadata": { "authors": [], - "id": "TQuldOYk4EOSd_LlOA_F9g", + "id": "dVthm2DPB0qGOEC02sxPsA", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

LIC Actuarial

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ReadMe.ipynb b/ifrs17-template/Report/InteractiveReports/LoadData.ipynb similarity index 55% rename from ifrs17-template/Report/SeparateInteractiveReports/ReadMe.ipynb rename to ifrs17-template/Report/InteractiveReports/LoadData.ipynb index ea03fa7f..c3929052 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/ReadMe.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LoadData.ipynb @@ -19,7 +19,7 @@ { "cell_type": "markdown", "source": [ - "# Set up and configurations " + "

Set up and configurations

" ], "metadata": {}, "execution_count": 0, @@ -32,34 +32,27 @@ "\n", "\n- #!eval-notebook \"../Database/Configure\" : connects to a physical Database", "\n- #!eval-notebook \"../Import/CloseImportTemplate\" : uses the in-memory set up", - "\nWe use here the in-memory set up.", "\n", - "\nNote that all these definitions are located in the PresentValue notebook, and the rest of the notebooks simply import this notebook. Change the definitions in that file.", + "\nWe use here the in-memory set up.", "\n", - "\nEach report is located in a different notebook in order to improve the performance. Location multiple interactive reports in a single notebook, though possible, might potentially decrease the performance. " + "\nThe current notebook is used by all interactive reports and any change made here is going to affect all interactive reports.", + "\n" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ - "# Best Estimate", - "\n", - "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17/env/v1.1.0/Report/ReportScopes#best-estimate) future cash flows are shown here in an Analysis of Change report.", - "\n", - "\nThe granularity of the reported figures can be modified by changing the Column Slices options.", - "\nFor example one can add \"GroupOfContract\" to separate the contributions of the individual Group of Contracts.", - "\n", - "\nAggregated values are displayed when the data has a finer granularity than the one selected by the report slice options." + "#!import \"../../Import/CloseImportTemplate\"" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "markdown", + "cell_type": "code", "source": [ "" ], diff --git a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb similarity index 78% rename from ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb rename to ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb index 45ee28ec..ed139596 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/ActualsLRC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb @@ -1,7 +1,7 @@ { "metadata": { "authors": [], - "id": "grGt10mtDky3n0kfGJ0_cg", + "id": "6W4aDEXW4kGr7_GR8uVx6g", "kernelspec": { "display_name": "Formula Framework", "language": "C#", @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

LRC Actuarial

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb similarity index 84% rename from ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb rename to ifrs17-template/Report/InteractiveReports/PresentValue.ipynb index ec9662b1..1353b889 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/PresentValue.ipynb +++ b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Present Value of Best Estimate

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb similarity index 82% rename from ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb rename to ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb index d739b9e0..0e7b90b7 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/RiskAdjustment.ipynb +++ b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Risk Adjustment

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb similarity index 82% rename from ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb rename to ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb index d2545dff..50f45c50 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/TechnicalMargin.ipynb +++ b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Technical Margin

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb similarity index 82% rename from ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb rename to ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb index bbd34739..4c3b5827 100644 --- a/ifrs17-template/Report/SeparateInteractiveReports/Written.ipynb +++ b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb @@ -16,10 +16,19 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "

Written Actuarial

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ - "#!import \"../../Import/CloseImportTemplate\"" + "#!import \"LoadData\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb b/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb deleted file mode 100644 index d80af054..00000000 --- a/ifrs17-template/Report/SeparateInteractiveReports/Accruals.ipynb +++ /dev/null @@ -1,120 +0,0 @@ -{ - "metadata": { - "authors": [], - "id": "oKYWmrRFfU2e9YTd1Vj9iw", - "kernelspec": { - "display_name": "Formula Framework", - "language": "C#", - "name": "C#" - }, - "language_info": { - "file_extension": ".cs", - "mimetype": "text/plain", - "name": "C#" - } - }, - "nbformat": 4, - "nbformat_minor": 5, - "cells": [ - { - "cell_type": "code", - "source": [ - "#!import \"../../Import/CloseImportTemplate\"" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetFormsEntity()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "ifrs17Interactive.GetReport()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"Accruals\", addDateTime : true)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var scope = ifrs17Interactive.GetReportScope();" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "scope.GetData()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "scope.GetData().Filter((\"Scenario\", (string)null))" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "var data = scope.GetData();" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "data.Where(x => x.Scenario != null).ToDataCube()" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - } - ] -} \ No newline at end of file From 156253abd7243cf3bcddd2177adef768f1986f86 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Fri, 17 Mar 2023 17:57:18 +0100 Subject: [PATCH 29/55] solve merge conflicts in tests --- .../Test/MapTemplateAndImportTest.ipynb | 53 ++++++++++++++----- .../Test/ReimportWithDifferentScopeTest.ipynb | 4 +- ifrs17-template/Test/SequenceImportTest.ipynb | 20 ------- 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb index dbcf479d..60ac6284 100644 --- a/ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -165,7 +165,7 @@ "\n .GroupofContractConfiguration(typeof(ReinsurancePortfolio))", "\n .GroupofContractConfiguration(typeof(InsurancePortfolio))", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -184,7 +184,7 @@ "\n .GroupofContractConfiguration(typeof(ReinsurancePortfolio))", "\n .GroupofContractConfiguration(typeof(InsurancePortfolio))", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -266,7 +266,7 @@ "\n .StateEnumConfiguration() ", "\n .DataNodeStateConfiguration(dataNodeStates)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -283,7 +283,7 @@ "\n .StateEnumConfiguration() ", "\n .DataNodeStateConfiguration(dataNodeStates)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -360,7 +360,7 @@ "\n .WithSource(Workspace)", "\n .DataNodeParameterConfiguration(dataNodeParameters)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\n", "\nexportResult.ActivityLog.Status.Should().Be(ActivityLogStatus.Succeeded);" @@ -376,7 +376,7 @@ "\n .WithSource(Workspace)", "\n .DataNodeParameterConfiguration(dataNodeParameters)", "\n .MainTabConfiguration(partition)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -542,11 +542,10 @@ { "cell_type": "code", "source": [ - "public async Task CheckErrors(string inputFileName, List errorBms)", + "public async Task CheckErrors(string inputFileName, List errorBms, IWorkspace workspace)", "\n{", "\n Activity.Start();", - "\n var log = await Import.FromFile(inputFileName).WithFormat(ImportFormats.DataNodeParameter).WithTarget(Workspace).ExecuteAsync();", - "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", + "\n var log = await Import.FromFile(inputFileName).WithFormat(ImportFormats.DataNodeParameter).WithTarget(workspace).ExecuteAsync();", "\n errorBms.Intersect(log.Errors.Select(x => x.ToString().Substring(0,x.ToString().Length-2).Substring(40)).ToArray()).Count().Should().Be(errorBms.Count());", "\n return Activity.Finish();", "\n}" @@ -555,6 +554,16 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var ws1 = Workspace.CreateNew();", + "\nws1.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -562,32 +571,52 @@ "\nvar errorsBm = new List(){Get(Error.InvalidDataNode, \"DataNodeInvalid0\"),", "\n Get(Error.InvalidDataNode, \"DataNodeInvalid1\"),", "\n Get(Error.InvalidDataNode, \"DataNodeInvalid2\")};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws1);", "\nactivity" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var ws2 = Workspace.CreateNew();", + "\nws2.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ "var inputFileName = \"Data/DataNodeParameter_Duplicate.csv\";", "\nvar errorsBm = new List(){Get(Error.DuplicateSingleDataNode, \"DT1.1\"),", "\n Get(Error.DuplicateInterDataNode, \"DT1.1\",\"DTR1.1\"),};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws2);", "\nactivity" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "var ws3 = Workspace.CreateNew();", + "\nws3.InitializeFrom(DataSource);" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ "var inputFileName = \"Data/DataNodeParameter_InvalidReinsCov.csv\";", "\nvar errorsBm = new List(){Get(Error.ReinsuranceCoverageDataNode, \"DT1.1\",\"DT1.1\")};", - "\nvar activity = await CheckErrors(inputFileName, errorsBm);", + "\nvar activity = await CheckErrors(inputFileName, errorsBm, ws3);", "\nactivity" ], "metadata": {}, diff --git a/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb b/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb index 84609e9c..37e4280a 100644 --- a/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb +++ b/ifrs17-template/Test/ReimportWithDifferentScopeTest.ipynb @@ -51,7 +51,7 @@ "await Import.FromFile(\"../Files/TransactionalData/NominalCashflows_CH_2020_12.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, @@ -86,7 +86,7 @@ "await Import.FromFile(\"Data/NominalCashflows_CH_2020_12_DT1.1NoPrem.csv\")", "\n .WithFormat(ImportFormats.Cashflow)", "\n .WithTarget(DataSource)", - "\n .WithActivityLog(Session, DataSource, DataSetReader)", + "\n .WithActivityLog()", "\n .ExecuteAsync()" ], "metadata": {}, diff --git a/ifrs17-template/Test/SequenceImportTest.ipynb b/ifrs17-template/Test/SequenceImportTest.ipynb index 4791c988..aef67b5e 100644 --- a/ifrs17-template/Test/SequenceImportTest.ipynb +++ b/ifrs17-template/Test/SequenceImportTest.ipynb @@ -79,16 +79,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "ws1.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\nws1.Initialize(x => x.FromSource(DataSource));" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -153,16 +143,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "ws2.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", - "\nws2.Initialize(x => x.FromSource(DataSource));" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ From 216ae05243b2522cfcf6d27e9384e90ee8b7df40 Mon Sep 17 00:00:00 2001 From: akatz Date: Fri, 17 Mar 2023 18:55:39 +0100 Subject: [PATCH 30/55] fixes a nasty bug that shows up when there is no data. --- ifrs17/Report/ReportMutableScopesInteractive.ipynb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 64b10dc7..bcbc8887 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -475,7 +475,10 @@ "\n async Task ToReportAsync() {", "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", - "\n dataScope.InputDataCube = GetData();", + "\n var dataCube = GetData();", + "\n // Find another way to avoid nasty errors if the DC is empty - AK", + "\n if (dataCube.ToArray().Count() == 0) return null;", + "\n dataScope.InputDataCube = dataCube;", "\n return await GetReportTaskAsync(dataScope.DataCube);", "\n }", "\n", From 928e07924f6aa5c793d6f4e25203c51ea3862cc8 Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 10:56:30 +0100 Subject: [PATCH 31/55] Some comments addressed and moved the types of parameter reports into an enum --- ifrs17/Constants/Enums.ipynb | 19 ++++++++++++ ...rameterReportMutableScopeInteractive.ipynb | 30 +++++++------------ .../ReportMutableScopesInteractive.ipynb | 11 ++----- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/ifrs17/Constants/Enums.ipynb b/ifrs17/Constants/Enums.ipynb index aa5231be..a2038727 100644 --- a/ifrs17/Constants/Enums.ipynb +++ b/ifrs17/Constants/Enums.ipynb @@ -264,6 +264,25 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Parameter Reports Types " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public enum ParameterReportType {DataNodeReport, DataNodeStateReport, YieldCurves, SingleDataNodeReport, ", + "\n InterDataNodeParameters, PartnerRating, PartnerDefaultRates};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index aea1a9af..d1ceddd2 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -29,18 +29,10 @@ { "cell_type": "code", "source": [ - "public interface RepFormsEntity : MutableScopeWithWorkspace", + "public interface ParameterReportFormsEntity : MutableScopeWithWorkspace", "\n{", - "\n [DropdownMethod(nameof(ReportMenu))]", - "\n string ReportType{get; set;}", - "\n", - "\n IReadOnlyCollection ReportMenu() => new string[] {\"\", \"DataNodeReport\", ", - "\n \"DataNodeStateReport\", ", - "\n \"YieldCurves\", ", - "\n \"SingleDataNodeReport\", ", - "\n \"InterDataNodeParameters\", ", - "\n \"PartnerRating\", ", - "\n \"PartnerDefaultRates\"};", + "\n [DropdownEnum(typeof(ParameterReportType))]", + "\n ParameterReportType ReportType{get; set;}", "\n}" ], "metadata": {}, @@ -50,7 +42,7 @@ { "cell_type": "code", "source": [ - "public interface ParameterReportScope: IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, RepFormsEntity", + "public interface ParameterReportScope: IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, ParameterReportFormsEntity", "\n{", "\n protected IPivotFactory report => GetStorage().Report;", "\n protected IExportVariable export => GetStorage().Export;", @@ -154,13 +146,13 @@ "\n", "\n async Task ToReport() => ReportType switch", "\n {", - "\n \"DataNodeReport\" => await GenerateDataNodeReport(), ", - "\n \"DataNodeStateReport\" => await GenerateDataNodeStatesReport(), ", - "\n \"YieldCurves\" => await GenerateYieldCurvesReport(), ", - "\n \"SingleDataNodeReport\" => await GenerateSingleDataNodeReport(), ", - "\n \"InterDataNodeParameters\" => await GenerateInterDataNodeParametersReport(), ", - "\n \"PartnerRating\" => await GeneratePartnerRatingReport(), ", - "\n \"PartnerDefaultRates\" => await GenerateDefaultRatesReport(),", + "\n ParameterReportType.DataNodeReport => await GenerateDataNodeReport(), ", + "\n ParameterReportType.DataNodeStateReport => await GenerateDataNodeStatesReport(), ", + "\n ParameterReportType.YieldCurves => await GenerateYieldCurvesReport(), ", + "\n ParameterReportType.SingleDataNodeReport => await GenerateSingleDataNodeReport(), ", + "\n ParameterReportType.InterDataNodeParameters => await GenerateInterDataNodeParametersReport(), ", + "\n ParameterReportType.PartnerRating => await GeneratePartnerRatingReport(), ", + "\n ParameterReportType.PartnerDefaultRates => await GenerateDefaultRatesReport(),", "\n _ => null", "\n };", "\n}" diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index bcbc8887..79b12edc 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -329,10 +329,7 @@ "\n ", "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", "\n ", - "\n //The cast is needed by the .Filter func", - "\n protected (string filterName, object filterValue)[] dataFilter => (InputDataFilter is null", - "\n ? Enumerable.Empty<(string, object)>()", - "\n : InputDataFilter.Select(x => (x.filterName, (object)x.filterValue))).ToArray();", + "\n protected (string fileName, object filterValue)[] dataFilter => InputDataFilter.Select(x => (x.filterName, (object)x.filterValue)).ToArray();", "\n", "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", "\n {", @@ -345,15 +342,13 @@ "\n", "\n private void AddFilter(string filterName, string filterValue)", "\n {", - "\n if(InputDataFilter == null)", - "\n InputDataFilter = Enumerable.Empty<(string, string)>().ToArray();", "\n if(!InputDataFilter.Contains((filterName, filterValue)))", "\n InputDataFilter = InputDataFilter.Append((filterName, filterValue)).ToArray();", "\n }", "\n ", "\n private void RemoveFilter(string filterName, string filterValue)", "\n {", - "\n if(InputDataFilter != null && InputDataFilter.Contains((filterName, filterValue)))", + "\n if(InputDataFilter.Contains((filterName, filterValue)))", "\n { var f = InputDataFilter.ToList();", "\n f.Remove((filterName, filterValue));", "\n InputDataFilter = f.ToArray();", @@ -362,6 +357,7 @@ "\n", "\n void InitFilters() {", "\n FilterMapping = new Dictionary>() ;", + "\n InputDataFilter = Enumerable.Empty<(string, string)>().ToArray();", "\n }", "\n}" ], @@ -382,7 +378,6 @@ "cell_type": "code", "source": [ "public interface BasicSliceAndDiceRowsFormsEntity : MutableScopeWithWorkspace {", - "\n //[DropdownValues(\"\", \"Novelty\",\"VariableType\",\"AmountType\")]", "\n [NotVisible] string SliceRowName { get; set; }", "\n", "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", From 838aa259e85c164eb99f3b21988451c52b5cda20 Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 13:04:20 +0100 Subject: [PATCH 32/55] Changed to FirstOrDefault() / LastOrDefault() --- ifrs17/Report/ReportStorage.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ifrs17/Report/ReportStorage.ipynb b/ifrs17/Report/ReportStorage.ipynb index 4d7eed27..3af872a6 100644 --- a/ifrs17/Report/ReportStorage.ipynb +++ b/ifrs17/Report/ReportStorage.ipynb @@ -149,9 +149,9 @@ "\n await hierarchicalDimensionCache.InitializeAsync();", "\n", "\n // Initial Values", - "\n var mostRecentPartition = (await workspace.Query().Where(x => x.Scenario == null).OrderBy(x => x.Year).ThenBy(x => x.Month).ToArrayAsync()).Last();", + "\n var mostRecentPartition = (await workspace.Query().Where(x => x.Scenario == null).OrderBy(x => x.Year).ThenBy(x => x.Month).ToArrayAsync()).LastOrDefault();", "\n InitialReportingPeriod = (mostRecentPartition.Year, mostRecentPartition.Month);", - "\n var rootReportingNode = (await workspace.Query().Where(x => x.Parent == null).ToArrayAsync()).First();", + "\n var rootReportingNode = (await workspace.Query().Where(x => x.Parent == null).ToArrayAsync()).FirstOrDefault();", "\n InitialReportingNode = (rootReportingNode.DisplayName, rootReportingNode.SystemName);", "\n }", "\n ", From 03b215c2fe478b8c25f98449503ed0c29c466711 Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 13:16:16 +0100 Subject: [PATCH 33/55] syntax simplificattion --- ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index d1ceddd2..3d1d874f 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -190,11 +190,8 @@ "\n interactiveObjectCache = new Dictionary() {};", "\n }", "\n", - "\n public ParameterReportScope GetReportScope(string name = null)", - "\n where T : ParameterReportScope", - "\n {", - "\n return interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", - "\n }", + "\n public ParameterReportScope GetReportScope(string name = null) where T : ParameterReportScope => ", + "\n ginteractiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n", "\n public InteractiveObjectView GetFormsEntity(string name = null)", "\n where T : ParameterReportScope", From 845b1cdcf56aa23f7d0584fb27cf36f07bf76b1b Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 13:32:25 +0100 Subject: [PATCH 34/55] routines renamed --- ...rameterReportMutableScopeInteractive.ipynb | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index 3d1d874f..3c71b5d5 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -58,7 +58,7 @@ "\n", "\n ImportArgs GetArgs() => new ImportArgs(ReportingNode, Year, Month, default, Scenario, default); ", "\n", - "\n async Task GenerateDataNodeReport()", + "\n async Task GetDataNodeReport()", "\n {", "\n await InitializeStorageAsync();", "\n var data = await workspace.GetDataNodeDataReportParametersAsync(GetArgs());", @@ -70,7 +70,7 @@ "\n .ExecuteAsync();", "\n }", "\n", - "\n async Task GenerateDataNodeStatesReport()", + "\n async Task GetDataNodeStatesReport()", "\n {", "\n await InitializeStorageAsync();", "\n var data = await workspace.GetDataNodeStateReportParametersAsync(GetArgs());", @@ -82,7 +82,7 @@ "\n .ExecuteAsync();", "\n }", "\n", - "\n async Task GenerateYieldCurvesReport()", + "\n async Task GetYieldCurvesReport()", "\n {", "\n await InitializeStorageAsync();", "\n var data = await workspace.GetYieldCurveReportParametersAsync(GetArgs());", @@ -95,7 +95,7 @@ "\n .ExecuteAsync();", "\n }", "\n", - "\n async Task GenerateSingleDataNodeReport()", + "\n async Task GetSingleDataNodeReport()", "\n {", "\n await InitializeStorageAsync();", "\n var data = await workspace.GetSingleDataNodeReportParametersAsync(GetArgs());", @@ -107,7 +107,7 @@ "\n .ExecuteAsync();", "\n }", "\n", - "\n async Task GenerateInterDataNodeParametersReport()", + "\n async Task GetInterDataNodeParametersReport()", "\n {", "\n await InitializeStorageAsync();", "\n var data = await workspace.GetInterDataNodeParametersAsync(GetArgs());", @@ -120,7 +120,7 @@ "\n .ExecuteAsync();", "\n }", "\n", - "\n async Task GeneratePartnerRatingReport()", + "\n async Task GetPartnerRatingReport()", "\n {", "\n await InitializeStorageAsync();", "\n var data = await workspace.GetPartnerRatingsReportParametersAsync(GetArgs());", @@ -132,7 +132,7 @@ "\n .ExecuteAsync();", "\n }", "\n", - "\n async Task GenerateDefaultRatesReport()", + "\n async Task GetDefaultRatesReport()", "\n {", "\n await InitializeStorageAsync();", "\n var data = await workspace.GetCreditDefaultRatesReportParametersAsync(GetArgs());", @@ -146,13 +146,13 @@ "\n", "\n async Task ToReport() => ReportType switch", "\n {", - "\n ParameterReportType.DataNodeReport => await GenerateDataNodeReport(), ", - "\n ParameterReportType.DataNodeStateReport => await GenerateDataNodeStatesReport(), ", - "\n ParameterReportType.YieldCurves => await GenerateYieldCurvesReport(), ", - "\n ParameterReportType.SingleDataNodeReport => await GenerateSingleDataNodeReport(), ", - "\n ParameterReportType.InterDataNodeParameters => await GenerateInterDataNodeParametersReport(), ", - "\n ParameterReportType.PartnerRating => await GeneratePartnerRatingReport(), ", - "\n ParameterReportType.PartnerDefaultRates => await GenerateDefaultRatesReport(),", + "\n ParameterReportType.DataNodeReport => await GetDataNodeReport(), ", + "\n ParameterReportType.DataNodeStateReport => await GetDataNodeStatesReport(), ", + "\n ParameterReportType.YieldCurves => await GetYieldCurvesReport(), ", + "\n ParameterReportType.SingleDataNodeReport => await GetSingleDataNodeReport(), ", + "\n ParameterReportType.InterDataNodeParameters => await GetInterDataNodeParametersReport(), ", + "\n ParameterReportType.PartnerRating => await GetPartnerRatingReport(), ", + "\n ParameterReportType.PartnerDefaultRates => await GetDefaultRatesReport(),", "\n _ => null", "\n };", "\n}" From ae8babf786940a5f99b3f561bab68110b7db8a2e Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 13:40:57 +0100 Subject: [PATCH 35/55] typo fixed --- ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index 3c71b5d5..e37119e4 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -191,7 +191,7 @@ "\n }", "\n", "\n public ParameterReportScope GetReportScope(string name = null) where T : ParameterReportScope => ", - "\n ginteractiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", + "\n interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n", "\n public InteractiveObjectView GetFormsEntity(string name = null)", "\n where T : ParameterReportScope", From 7dfaa38accf68a6c5cfb08e73b1ce768da5b8c1d Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 13:50:25 +0100 Subject: [PATCH 36/55] syntax change to Any() --- ifrs17/Report/ReportMutableScopesInteractive.ipynb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 79b12edc..de5783a4 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -471,8 +471,7 @@ "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n var dataCube = GetData();", - "\n // Find another way to avoid nasty errors if the DC is empty - AK", - "\n if (dataCube.ToArray().Count() == 0) return null;", + "\n if (!dataCube.ToArray().Any()) return null;", "\n dataScope.InputDataCube = dataCube;", "\n return await GetReportTaskAsync(dataScope.DataCube);", "\n }", From c27d3cd93d5b779c763f122696c7d27341a21db8 Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 14:13:40 +0100 Subject: [PATCH 37/55] move import types and forms into the CE --- ifrs17/Constants/Enums.ipynb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ifrs17/Constants/Enums.ipynb b/ifrs17/Constants/Enums.ipynb index a2038727..eb0b4b3b 100644 --- a/ifrs17/Constants/Enums.ipynb +++ b/ifrs17/Constants/Enums.ipynb @@ -283,6 +283,33 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## Allowed Import Types and Forms" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public enum TypesAndForms {YieldCurve, ", + "\n ExchangeRate, ", + "\n PartnerRating, ", + "\n CreditDefaultRate, ", + "\n DataNode, ", + "\n DataNodeState, ", + "\n DataNodeParameter, ", + "\n Opening, ", + "\n Actual, ", + "\n Cashflow};" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file From 613666ab131360dbed1cc0e5326f4b7ada7495c2 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Mon, 20 Mar 2023 16:41:11 +0100 Subject: [PATCH 38/55] small refactor of specific filter --- .../ReportMutableScopesInteractive.ipynb | 64 ++++++------------- 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index bcbc8887..e55dc94a 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -284,8 +284,9 @@ "\n nameof(ReportVariable.InitialProfitability), //(\\\"Profitability\\\")", "\n };", "\n", - "\n IReadOnlyCollection GetFilterName() => defaultFilters;", - "\n ", + "\n [NotVisible] IReadOnlyCollection specificFilters { get; set; }", + "\n IReadOnlyCollection GetFilterName() => defaultFilters.Union(specificFilters).ToArray();", + "\n", "\n [NotVisible] IDictionary> FilterMapping { get; set; }", "\n protected string FilterValue => !string.IsNullOrWhiteSpace(FilterName) && !string.IsNullOrWhiteSpace(FilterValueControl) && ", "\n FilterMapping is not null && FilterMapping.TryGetValue(FilterName, out var inner) &&", @@ -431,7 +432,7 @@ { "cell_type": "markdown", "source": [ - "# Report Scopes" + "# Generic Report Scope and Data Scope" ], "metadata": {}, "execution_count": 0, @@ -506,7 +507,6 @@ "\n .ExecuteAsync();", "\n }", "\n ", - "\n", "\n async Task GetReportTaskAsync(IDataCube data) {", "\n return await report.ForDataCube(data)", "\n .WithQuerySource(workspace)", @@ -560,10 +560,9 @@ "\n // BasicSliceAndDiceFormsEntity", "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", + "\n // SpecificFiltersFormEntity", + "\n specificFilters = new string[] {nameof(ReportVariable.AmountType)};", "\n }", - "\n", - "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -592,9 +591,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -623,9 +619,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EconomicBasis) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -654,9 +647,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.AmountType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -684,10 +674,9 @@ "\n // BasicSliceAndDiceFormsEntity", "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", + "\n // SpecificFiltersFormEntity", + "\n specificFilters = new string[] {nameof(ReportVariable.AmountType)};", "\n }", - "\n", - "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -716,9 +705,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -746,10 +732,9 @@ "\n // BasicSliceAndDiceFormsEntity", "\n defaultRowSlices = new string[] { nameof(ReportVariable.EstimateType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.AmountType) };", + "\n // SpecificFiltersFormEntity", + "\n specificFilters = new string[] {nameof(ReportVariable.AmountType)};", "\n }", - "\n", - "\n private List specificFilters => new List {nameof(ReportVariable.AmountType)};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -778,9 +763,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -809,9 +791,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -840,9 +819,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -862,9 +838,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -893,9 +866,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.Novelty), nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", - "\n", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -915,8 +885,6 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency), nameof(ReportVariable.EstimateType) };", "\n }", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, @@ -945,15 +913,21 @@ "\n defaultRowSlices = new string[] { nameof(ReportVariable.VariableType), nameof(ReportVariable.EstimateType) };", "\n defaultColumnSlices = new string[] { nameof(ReportVariable.Currency)};", "\n }", - "\n ", - "\n private List specificFilters => new List {};", - "\n IReadOnlyCollection GetFilterName() => defaultFilters.ToList().Concat(specificFilters).ToArray();", "\n}" ], "metadata": {}, "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# IFRS 17 Interactive " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ From d8b45c79c4a977b4442d97e4955bdd7f9d7cb574 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Mon, 20 Mar 2023 16:59:50 +0100 Subject: [PATCH 39/55] fix failing tests --- ifrs17-template/Test/ReportVariablesTest.ipynb | 2 +- ifrs17/Test/ReportStorageTest.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ifrs17-template/Test/ReportVariablesTest.ipynb b/ifrs17-template/Test/ReportVariablesTest.ipynb index f447c1d4..2d6351fe 100644 --- a/ifrs17-template/Test/ReportVariablesTest.ipynb +++ b/ifrs17-template/Test/ReportVariablesTest.ipynb @@ -91,7 +91,7 @@ { "cell_type": "code", "source": [ - "var reportStorage = new ReportStorage(Workspace, Report);", + "var reportStorage = new ReportStorage(Workspace, Report, Export);", "\nawait reportStorage.InitializeReportIndependentCacheAsync();" ], "metadata": {}, diff --git a/ifrs17/Test/ReportStorageTest.ipynb b/ifrs17/Test/ReportStorageTest.ipynb index c27442c0..8d2c9414 100644 --- a/ifrs17/Test/ReportStorageTest.ipynb +++ b/ifrs17/Test/ReportStorageTest.ipynb @@ -72,7 +72,7 @@ "\n ", "\n //Create report storage", "\n var period = (year, month);", - "\n var reportStorage = new ReportStorage(Workspace, Report);", + "\n var reportStorage = new ReportStorage(Workspace, Report, Export);", "\n await reportStorage.InitializeReportIndependentCacheAsync();", "\n await reportStorage.InitializeAsync(period, \"G\", null, CurrencyType.Contractual);", "\n ", From 44d937a0f180be0adbaaf9d3fc4c593957f80055 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Mon, 20 Mar 2023 17:06:11 +0100 Subject: [PATCH 40/55] increase memory recommended --- ifrs17-template/Test/Tests.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ifrs17-template/Test/Tests.ipynb b/ifrs17-template/Test/Tests.ipynb index c70f9674..0e535198 100644 --- a/ifrs17-template/Test/Tests.ipynb +++ b/ifrs17-template/Test/Tests.ipynb @@ -29,7 +29,7 @@ "cell_type": "markdown", "source": [ "Comprehensive collection of tests executed on top of the Systemorph use cases (initialization).", - "\n
Execute this Notebook using at least 14Gb RAM." + "\n
Execute this Notebook using at least 18Gb RAM." ], "metadata": {}, "execution_count": 0, @@ -144,4 +144,4 @@ "outputs": [] } ] -} +} \ No newline at end of file From 8dd5555ac73e79ca518a0a7132f25252d0a5e69f Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 17:06:20 +0100 Subject: [PATCH 41/55] enums moved to classes + routine to query constant attributes of a class --- ifrs17/Constants/Consts.ipynb | 48 ++++++++++++++++++++++++++++++++ ifrs17/Constants/Enums.ipynb | 46 ------------------------------ ifrs17/Report/ReportScopes.ipynb | 31 +++++++++++++++++++++ 3 files changed, 79 insertions(+), 46 deletions(-) diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index b3889647..af1e0827 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -217,6 +217,28 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Import Types" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static class ImportTypes{", + "\n public const string ExchangeRate = nameof(ExchangeRate);", + "\n public const string PartnerRating = nameof(PartnerRating);", + "\n public const string CreditDefaultRate = nameof(CreditDefaultRate);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ @@ -415,6 +437,32 @@ "metadata": {}, "execution_count": 0, "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Parameter Reports" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "public static class ParameterReportType{", + "\n DataNodeReport = nameof(DataNodeReport);", + "\n DataNodeStateReport = nameof(DataNodeStateReport);", + "\n YieldCurves = nameof(YieldCurves);", + "\n SingleDataNodeReport = nameof(SingleDataNodeReport);", + "\n InterDataNodeParameters = nameof(InterDataNodeParameters);", + "\n PartnerRating = nameof(PartnerRating);", + "\n PartnerDefaultRates = nameof(PartnerDefaultRates);", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17/Constants/Enums.ipynb b/ifrs17/Constants/Enums.ipynb index eb0b4b3b..aa5231be 100644 --- a/ifrs17/Constants/Enums.ipynb +++ b/ifrs17/Constants/Enums.ipynb @@ -264,52 +264,6 @@ "metadata": {}, "execution_count": 0, "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Parameter Reports Types " - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public enum ParameterReportType {DataNodeReport, DataNodeStateReport, YieldCurves, SingleDataNodeReport, ", - "\n InterDataNodeParameters, PartnerRating, PartnerDefaultRates};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "## Allowed Import Types and Forms" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "public enum TypesAndForms {YieldCurve, ", - "\n ExchangeRate, ", - "\n PartnerRating, ", - "\n CreditDefaultRate, ", - "\n DataNode, ", - "\n DataNodeState, ", - "\n DataNodeParameter, ", - "\n Opening, ", - "\n Actual, ", - "\n Cashflow};" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] } ] } \ No newline at end of file diff --git a/ifrs17/Report/ReportScopes.ipynb b/ifrs17/Report/ReportScopes.ipynb index af7efdf7..525773c1 100644 --- a/ifrs17/Report/ReportScopes.ipynb +++ b/ifrs17/Report/ReportScopes.ipynb @@ -212,6 +212,37 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "### Retrieve constant elements from a class" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "using System.Reflection;", + "\npublic static T[] GetAllPublicConstantValues(this Type type, ", + "\n IList excludedTerms = null)", + "\n{", + "\n var selection = type", + "\n .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)", + "\n .Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(T))", + "\n .Select(x => (T)x.GetRawConstantValue())", + "\n .ToArray();", + "\n if (excludedTerms == null)", + "\n return selection;", + "\n else ", + "\n return selection.Where(x => !excludedTerms.Contains(x)).ToArray();", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ From 3994ca74c11c4701a6ebd37d2e0abbe656a2a49f Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 17:27:33 +0100 Subject: [PATCH 42/55] bug fixed + produce param reports menu from method rather than enum --- ifrs17/Constants/Consts.ipynb | 14 +++++++------- .../ParameterReportMutableScopeInteractive.ipynb | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index af1e0827..b649eafc 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -451,13 +451,13 @@ "cell_type": "code", "source": [ "public static class ParameterReportType{", - "\n DataNodeReport = nameof(DataNodeReport);", - "\n DataNodeStateReport = nameof(DataNodeStateReport);", - "\n YieldCurves = nameof(YieldCurves);", - "\n SingleDataNodeReport = nameof(SingleDataNodeReport);", - "\n InterDataNodeParameters = nameof(InterDataNodeParameters);", - "\n PartnerRating = nameof(PartnerRating);", - "\n PartnerDefaultRates = nameof(PartnerDefaultRates);", + "\n public const string DataNodeReport = nameof(DataNodeReport);", + "\n public const string DataNodeStateReport = nameof(DataNodeStateReport);", + "\n public const string YieldCurves = nameof(YieldCurves);", + "\n public const string SingleDataNodeReport = nameof(SingleDataNodeReport);", + "\n public const string InterDataNodeParameters = nameof(InterDataNodeParameters);", + "\n public const string PartnerRating = nameof(PartnerRating);", + "\n public const string PartnerDefaultRates = nameof(PartnerDefaultRates);", "\n}" ], "metadata": {}, diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index e37119e4..6c51ec95 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -31,8 +31,10 @@ "source": [ "public interface ParameterReportFormsEntity : MutableScopeWithWorkspace", "\n{", - "\n [DropdownEnum(typeof(ParameterReportType))]", - "\n ParameterReportType ReportType{get; set;}", + "\n [DropdownMethod(nameof(GetParameterReportTypes))]", + "\n string ReportType{get; set;}", + "\n", + "\n string[] GetParameterReportTypes() => typeof(ParameterReportType).GetAllPublicConstantValues();", "\n}" ], "metadata": {}, From 5c39529c427f55459d120e1dacf3e6b22d38cf58 Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 18:12:32 +0100 Subject: [PATCH 43/55] Added a comment about null reports --- ifrs17/Report/ReportMutableScopesInteractive.ipynb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 7b6f56e5..047d8fca 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -472,6 +472,8 @@ "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var dataScope = GetScope(((Year, Month), ReportingNode, Scenario, CurrencyType, dataFilter));", "\n var dataCube = GetData();", + "\n // This is a temporary solution to avoid an error from the empty report", + "\n // Remove when the issue is solved on the platform - A.K.", "\n if (!dataCube.ToArray().Any()) return null;", "\n dataScope.InputDataCube = dataCube;", "\n return await GetReportTaskAsync(dataScope.DataCube);", From 3fe878e21bbf00f56a1b7038086151537eee648c Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 19:26:37 +0100 Subject: [PATCH 44/55] Generalization of the interactive mutable scopes --- .../ReportMutableScopesInteractive.ipynb | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 047d8fca..7adcf592 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -89,7 +89,9 @@ { "cell_type": "code", "source": [ - "public interface MutableScopeWithWorkspace : IMutableScopeWithStorage {", + "public interface MutableScopeWithWorkspace : IMutableScopeWithStorage ", + "\nwhere TStorage : ReportStorage", + "\n{", "\n protected IWorkspace workspace => GetStorage().Workspace; ", "\n}" ], @@ -130,7 +132,9 @@ { "cell_type": "code", "source": [ - "public interface ScenarioFormsEntity : MutableScopeWithWorkspace {", + "public interface ScenarioFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage ", + "\n{", "\n [DropdownMethod(nameof(GetScenarioAutocompleteAsync))]", "\n [Display(Name = \"Scenario\")]", "\n string ScenarioControl { get; set; }", @@ -169,7 +173,9 @@ "cell_type": "code", "source": [ "[InitializeScope(nameof(InitReportingNode))]", - "\npublic interface ReportingNodeFormsEntity : MutableScopeWithWorkspace {", + "\npublic interface ReportingNodeFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage", + "\n{", "\n [DropdownMethod(nameof(GetReportingNodeAutocompleteAsync))]", "\n [Display(Name = \"ReportingNode\")]", "\n string ReportingNodeControl { get; set; }", @@ -217,7 +223,9 @@ "cell_type": "code", "source": [ "[InitializeScope(nameof(InitReportingPeriod))]", - "\npublic interface MonthlyPeriodFormsEntity : MutableScopeWithWorkspace {", + "\npublic interface MonthlyPeriodFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage", + "\n{", "\n [DropdownMethod(nameof(GetReportingPeriodAutocompleteAsync))]", "\n string ReportingPeriod { get; set; }", "\n", @@ -261,7 +269,9 @@ "cell_type": "code", "source": [ "[InitializeScope(nameof(InitFilters))]", - "\npublic interface BasicFilterFormsEntity : MutableScopeWithWorkspace {", + "\npublic interface BasicFilterFormsEntity : MutableScopeWithWorkspace", + "\nwhere TStorage : ReportStorage", + "\n{", "\n [DropdownMethod(nameof(GetFilterName))]", "\n string FilterName { get; set; }", "\n", @@ -378,7 +388,9 @@ { "cell_type": "code", "source": [ - "public interface BasicSliceAndDiceRowsFormsEntity : MutableScopeWithWorkspace {", + "public interface BasicSliceAndDiceRowsFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage", + "\n{", "\n [NotVisible] string SliceRowName { get; set; }", "\n", "\n protected IReadOnlyCollection InputRowSlices => (SliceRowName is null ? Enumerable.Empty() : SliceRowName.RepeatOnce()).ToArray();", @@ -393,7 +405,9 @@ { "cell_type": "code", "source": [ - "public interface BasicSliceAndDiceColumnsFormsEntity : MutableScopeWithWorkspace {", + "public interface BasicSliceAndDiceColumnsFormsEntity : MutableScopeWithWorkspace ", + "\nwhere TStorage : ReportStorage", + "\n{", "\n [DropdownMethod(nameof(GetSliceColumnNameAutocomplete))]", "\n string SliceColumnName { get; set; }", "\n", @@ -458,8 +472,14 @@ "cell_type": "code", "source": [ "[InitializeScope(nameof(Init))]", - "\npublic interface ReportScope : IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, ", - "\n BasicSliceAndDiceRowsFormsEntity, BasicSliceAndDiceColumnsFormsEntity, BasicFilterFormsEntity {", + "\npublic interface ReportScope : IMutableScope, ", + "\n ReportingNodeFormsEntity, ", + "\n MonthlyPeriodFormsEntity, ", + "\n ScenarioFormsEntity, ", + "\n CurrencyFormsEntity, ", + "\n BasicSliceAndDiceRowsFormsEntity, ", + "\n BasicSliceAndDiceColumnsFormsEntity, ", + "\n BasicFilterFormsEntity {", "\n protected IPivotFactory report => GetStorage().Report;", "\n protected IExportVariable export => GetStorage().Export;", "\n protected int headerColumnWidthValue => 250;", From 2d4512d906bf65ddc073dddb91f36b36b5756bfd Mon Sep 17 00:00:00 2001 From: akatz Date: Mon, 20 Mar 2023 19:51:02 +0100 Subject: [PATCH 45/55] Align with the API --- .../ParameterReportMutableScopeInteractive.ipynb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index 6c51ec95..0942b5ff 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -29,7 +29,8 @@ { "cell_type": "code", "source": [ - "public interface ParameterReportFormsEntity : MutableScopeWithWorkspace", + "public interface ParameterReportFormsEntity : MutableScopeWithWorkspace", + "\nwhere TStorage : ReportStorage", "\n{", "\n [DropdownMethod(nameof(GetParameterReportTypes))]", "\n string ReportType{get; set;}", @@ -44,7 +45,12 @@ { "cell_type": "code", "source": [ - "public interface ParameterReportScope: IMutableScope, ReportingNodeFormsEntity, MonthlyPeriodFormsEntity, ScenarioFormsEntity, CurrencyFormsEntity, ParameterReportFormsEntity", + "public interface ParameterReportScope: IMutableScope, ", + "\n ReportingNodeFormsEntity, ", + "\n MonthlyPeriodFormsEntity, ", + "\n ScenarioFormsEntity, ", + "\n CurrencyFormsEntity, ", + "\n ParameterReportFormsEntity", "\n{", "\n protected IPivotFactory report => GetStorage().Report;", "\n protected IExportVariable export => GetStorage().Export;", From 726896b44ac84549e2d4b7914f5b39cf62b87599 Mon Sep 17 00:00:00 2001 From: akatz Date: Tue, 21 Mar 2023 10:15:13 +0100 Subject: [PATCH 46/55] Move initializations to the LoadData and add exports to excel --- .../Report/InteractiveReports/Accruals.ipynb | 11 +++++------ .../InteractiveReports/Csm-Lc-LoReCo.ipynb | 16 ++++++++++++---- .../Report/InteractiveReports/Deferrals.ipynb | 16 ++++++++++++---- .../ExperienceAdjustment.ipynb | 16 ++++++++++++---- .../FinancialPerformance.ipynb | 16 ++++++++++++---- .../InteractiveReports/FulfilmentCashflow.ipynb | 16 ++++++++++++---- .../Report/InteractiveReports/LIC.ipynb | 16 ++++++++++++---- .../Report/InteractiveReports/LRC.ipynb | 11 +++++------ .../Report/InteractiveReports/LicActuarial.ipynb | 16 ++++++++++++---- .../Report/InteractiveReports/LoadData.ipynb | 3 ++- .../Report/InteractiveReports/LrcActuarial.ipynb | 16 ++++++++++++---- .../Report/InteractiveReports/PresentValue.ipynb | 16 +++------------- .../InteractiveReports/RiskAdjustment.ipynb | 11 +++++------ .../InteractiveReports/TechnicalMargin.ipynb | 11 +++++------ .../InteractiveReports/WrittenActual.ipynb | 11 +++++------ 15 files changed, 126 insertions(+), 76 deletions(-) diff --git a/ifrs17-template/Report/InteractiveReports/Accruals.ipynb b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb index b6d1cf4b..4cea9c66 100644 --- a/ifrs17-template/Report/InteractiveReports/Accruals.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,16 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ifrs17Interactive.GetReport()" + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -65,7 +64,7 @@ { "cell_type": "code", "source": [ - "" + "await ifrs17Interactive.ExportToExcelAsync(\"Accruals\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb index 471692b3..ecb71e6d 100644 --- a/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,7 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -56,7 +64,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "await ifrs17Interactive.ExportToExcelAsync(\"CsmLcLorecoReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb index 1929d19b..abbcd2e1 100644 --- a/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,7 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -56,7 +64,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "await ifrs17Interactive.ExportToExcelAsync(\"DeferralsReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb index 7daead0d..d8db727b 100644 --- a/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb +++ b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,7 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -56,7 +64,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "await ifrs17Interactive.ExportToExcelAsync(\"ExpAdjReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb index 8c87b844..c45fee90 100644 --- a/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb +++ b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,7 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -56,7 +64,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "await ifrs17Interactive.ExportToExcelAsync(\"FpReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb index d0b7feb0..04687fde 100644 --- a/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb +++ b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,7 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -56,7 +64,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "await ifrs17Interactive.ExportToExcelAsync(\"FcfReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LIC.ipynb b/ifrs17-template/Report/InteractiveReports/LIC.ipynb index 9bf48f2c..df287a38 100644 --- a/ifrs17-template/Report/InteractiveReports/LIC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LIC.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,7 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -56,7 +64,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "await ifrs17Interactive.ExportToExcelAsync(\"LicReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LRC.ipynb b/ifrs17-template/Report/InteractiveReports/LRC.ipynb index 49a962b0..1bd0478f 100644 --- a/ifrs17-template/Report/InteractiveReports/LRC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LRC.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,16 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ifrs17Interactive.GetReport()" + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -65,7 +64,7 @@ { "cell_type": "code", "source": [ - "" + "await ifrs17Interactive.ExportToExcelAsync(\"LrcReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb index e6dae6b0..060ea4ae 100644 --- a/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,7 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -56,7 +64,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "await ifrs17Interactive.ExportToExcelAsync(\"LicActualReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LoadData.ipynb b/ifrs17-template/Report/InteractiveReports/LoadData.ipynb index c3929052..0b97f90a 100644 --- a/ifrs17-template/Report/InteractiveReports/LoadData.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LoadData.ipynb @@ -54,7 +54,8 @@ { "cell_type": "code", "source": [ - "" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Interactive.Reset(Workspace)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb index ed139596..e68465c4 100644 --- a/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,7 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -56,7 +64,7 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetReport()" + "await ifrs17Interactive.ExportToExcelAsync(\"LrcActualReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb index 1353b889..a0a192a0 100644 --- a/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb +++ b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb @@ -34,16 +34,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "code", "source": [ @@ -63,9 +53,9 @@ "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "await ifrs17Interactive.ExportToExcelAsync(\"PvReport\", addDateTime : true)" + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -74,7 +64,7 @@ { "cell_type": "code", "source": [ - "" + "await ifrs17Interactive.ExportToExcelAsync(\"PvReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb index 0e7b90b7..911db35a 100644 --- a/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb +++ b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,16 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ifrs17Interactive.GetReport()" + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -65,7 +64,7 @@ { "cell_type": "code", "source": [ - "" + "await ifrs17Interactive.ExportToExcelAsync(\"RiskAdjReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb index 50f45c50..a785b7d9 100644 --- a/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb +++ b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,16 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ifrs17Interactive.GetReport()" + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -65,7 +64,7 @@ { "cell_type": "code", "source": [ - "" + "await ifrs17Interactive.ExportToExcelAsync(\"TmReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb index 4c3b5827..a9e3cc21 100644 --- a/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb +++ b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb @@ -37,8 +37,7 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);", - "\nifrs17Interactive.Reset(Workspace)" + "ifrs17Interactive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -47,16 +46,16 @@ { "cell_type": "code", "source": [ - "ifrs17Interactive.GetFormsEntity()" + "ifrs17Interactive.GetReport()" ], "metadata": {}, "execution_count": 0, "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "ifrs17Interactive.GetReport()" + "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " ], "metadata": {}, "execution_count": 0, @@ -65,7 +64,7 @@ { "cell_type": "code", "source": [ - "" + "await ifrs17Interactive.ExportToExcelAsync(\"WrittenReport\", addDateTime : true)" ], "metadata": {}, "execution_count": 0, From 80783492c1b061ead0fd6473003b6f3d4572f907 Mon Sep 17 00:00:00 2001 From: akatz Date: Tue, 21 Mar 2023 11:56:41 +0100 Subject: [PATCH 47/55] Initialization to ParameterReportScope --- ...rameterReportMutableScopeInteractive.ipynb | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index 0942b5ff..2fce6bec 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -45,7 +45,8 @@ { "cell_type": "code", "source": [ - "public interface ParameterReportScope: IMutableScope, ", + "[InitializeScope(nameof(Init))]", + "\npublic interface ParameterReportScope: IMutableScope, ", "\n ReportingNodeFormsEntity, ", "\n MonthlyPeriodFormsEntity, ", "\n ScenarioFormsEntity, ", @@ -58,17 +59,12 @@ "\n", "\n HashSet<(ReportIdentity, CurrencyType)> GetDataIdentities() => GetStorage().GetIdentities((Year, Month), ReportingNode, Scenario, CurrencyType); ", "\n", - "\n async Task InitializeStorageAsync()", - "\n {", - "\n await GetStorage().InitializeReportIndependentCacheAsync();", - "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", - "\n }", "\n", "\n ImportArgs GetArgs() => new ImportArgs(ReportingNode, Year, Month, default, Scenario, default); ", "\n", "\n async Task GetDataNodeReport()", "\n {", - "\n await InitializeStorageAsync();", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var data = await workspace.GetDataNodeDataReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", @@ -80,7 +76,7 @@ "\n", "\n async Task GetDataNodeStatesReport()", "\n {", - "\n await InitializeStorageAsync();", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var data = await workspace.GetDataNodeStateReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", @@ -92,7 +88,7 @@ "\n", "\n async Task GetYieldCurvesReport()", "\n {", - "\n await InitializeStorageAsync();", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var data = await workspace.GetYieldCurveReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", @@ -105,7 +101,7 @@ "\n", "\n async Task GetSingleDataNodeReport()", "\n {", - "\n await InitializeStorageAsync();", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var data = await workspace.GetSingleDataNodeReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", @@ -117,7 +113,7 @@ "\n", "\n async Task GetInterDataNodeParametersReport()", "\n {", - "\n await InitializeStorageAsync();", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var data = await workspace.GetInterDataNodeParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", @@ -130,7 +126,7 @@ "\n", "\n async Task GetPartnerRatingReport()", "\n {", - "\n await InitializeStorageAsync();", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var data = await workspace.GetPartnerRatingsReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", @@ -142,7 +138,7 @@ "\n", "\n async Task GetDefaultRatesReport()", "\n {", - "\n await InitializeStorageAsync();", + "\n await GetStorage().InitializeAsync((Year, Month), ReportingNode, Scenario, CurrencyType);", "\n var data = await workspace.GetCreditDefaultRatesReportParametersAsync(GetArgs());", "\n return await report.ForObjects(data)", "\n .WithQuerySource(workspace)", @@ -163,6 +159,15 @@ "\n ParameterReportType.PartnerDefaultRates => await GetDefaultRatesReport(),", "\n _ => null", "\n };", + "\n", + "\n void Init(){", + "\n var task = InitReportStorageScopeAsync();", + "\n task.Wait();", + "\n }", + "\n", + "\n async Task InitReportStorageScopeAsync() { ", + "\n await GetStorage().InitializeReportIndependentCacheAsync();", + "\n }", "\n}" ], "metadata": {}, @@ -177,7 +182,7 @@ "\n private IPivotFactory report;", "\n private IExportVariable export;", "\n private InteractiveObjectVariable interactiveObject;", - "\n private ReportStorage storage;", + "\n public ReportStorage storage;", "\n", "\n private IDictionary interactiveObjectCache = new Dictionary();", "\n ", From cb170d3644899fb588d35acac6a02d620fb353cf Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Tue, 21 Mar 2023 17:15:19 +0100 Subject: [PATCH 48/55] parameter interactive some refinement --- .../Report/InteractiveParameterReport.ipynb | 48 +++++++++++++++++-- ...rameterReportMutableScopeInteractive.ipynb | 43 +++++++++++++++-- .../ReportMutableScopesInteractive.ipynb | 17 +++++++ 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/ifrs17-template/Report/InteractiveParameterReport.ipynb b/ifrs17-template/Report/InteractiveParameterReport.ipynb index f763051a..82c1d443 100644 --- a/ifrs17-template/Report/InteractiveParameterReport.ipynb +++ b/ifrs17-template/Report/InteractiveParameterReport.ipynb @@ -16,6 +16,46 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "", + "\n

Interactive Parameter Reports

" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "This notebook is the interactive version of [Parameter Reports](./ParameterReports). For demonstration purposes we import here data for some *Group of Insurance Contract* (GIC) and *Group of Reinsurance Contract* (GRIC) - the import is triggered in the [Set up data and configuration](#set-up-data-and-configuration) section.", + "\n
The imported data set consists of cash flows, actuals, and parameters.", + "\n
Input files can be found in the **File** directory. You are invited to change them or upload your own or add new data in the [CloseImportTemplate](../Import/CloseImportTemplate) notebook. ", + "\n", + "\nIn this notebook we show the parameters (provided to the calculation engine as inputs) used to performe the calculation of the reports shown in [Reports](Reports) notebook.", + "\n", + "\nSelect from the dropdown which *Report Type* you are interested in and the report adjust to the desired selection. " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Set up data and configuration", + "\n", + "\nChoose to run the Reports notebook either with the set of Systemorph data in memory or with the data present in the Database: ", + "\n- #!eval-notebook \"../Database/Configure\" : connects to a physical Database", + "\n- #!eval-notebook \"../Import/CloseImportTemplate\" : uses the in-memory set up", + "\n", + "\nWe use here the in-memory set up." + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -36,9 +76,9 @@ "outputs": [] }, { - "cell_type": "code", + "cell_type": "markdown", "source": [ - "parameterInteractive.GetFormsEntity()" + "# Interactive view" ], "metadata": {}, "execution_count": 0, @@ -47,7 +87,7 @@ { "cell_type": "code", "source": [ - "parameterInteractive.GetReport()" + "parameterInteractive.GetFormsEntity()" ], "metadata": {}, "execution_count": 0, @@ -56,7 +96,7 @@ { "cell_type": "code", "source": [ - "" + "parameterInteractive.GetReport()" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb index 2fce6bec..199703ff 100644 --- a/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb +++ b/ifrs17/Report/ParameterReportMutableScopeInteractive.ipynb @@ -16,6 +16,15 @@ "nbformat": 4, "nbformat_minor": 5, "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Import References" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -26,6 +35,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Parameter Forms Entity" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -42,6 +60,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Parameter Report Scope" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -49,7 +76,7 @@ "\npublic interface ParameterReportScope: IMutableScope, ", "\n ReportingNodeFormsEntity, ", "\n MonthlyPeriodFormsEntity, ", - "\n ScenarioFormsEntity, ", + "\n ScenarioParameterFormsEntity,", "\n CurrencyFormsEntity, ", "\n ParameterReportFormsEntity", "\n{", @@ -174,6 +201,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive Parameter " + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -222,10 +258,7 @@ "\n var key = name ?? typeof(T).Name;", "\n if (!interactiveObjectCache.TryGetValue(key, out var ret))", "\n ret = interactiveObjectCache[key] = interactiveObject.CreateView(key, ", - "\n _ => {", - "\n var scope = GetReportScope(name : \"ParameterReports\");", - "\n return scope.ToReport(); ", - "\n });", + "\n _ => GetReportScope(name : \"ParameterReports\").ToReport());", "\n return ret;", "\n }", "\n", diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 7adcf592..56a641d8 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -160,6 +160,23 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "source": [ + "public interface ScenarioParameterFormsEntity : ScenarioFormsEntity", + "\nwhere TStorage : ReportStorage ", + "\n{", + "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", + "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", + "\n return orderedDropDownValues.Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", + "\n .ToArray(); ", + "\n }", + "\n}" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "source": [ From e836edd6832058a34195537aea98ff78f08427b6 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Tue, 21 Mar 2023 17:19:11 +0100 Subject: [PATCH 49/55] export description --- ifrs17-template/Report/InteractiveReports/Accruals.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/Deferrals.ipynb | 2 +- .../Report/InteractiveReports/ExperienceAdjustment.ipynb | 2 +- .../Report/InteractiveReports/FinancialPerformance.ipynb | 2 +- .../Report/InteractiveReports/FulfilmentCashflow.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/LIC.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/LRC.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/PresentValue.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb | 2 +- ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ifrs17-template/Report/InteractiveReports/Accruals.ipynb b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb index 4cea9c66..ff1f5a82 100644 --- a/ifrs17-template/Report/InteractiveReports/Accruals.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb index ecb71e6d..101520af 100644 --- a/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb index abbcd2e1..f2dd7b0a 100644 --- a/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb index d8db727b..2d5d4798 100644 --- a/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb +++ b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb index c45fee90..24ddd2ee 100644 --- a/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb +++ b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb index 04687fde..2aa980ed 100644 --- a/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb +++ b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LIC.ipynb b/ifrs17-template/Report/InteractiveReports/LIC.ipynb index df287a38..33a19d3a 100644 --- a/ifrs17-template/Report/InteractiveReports/LIC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LIC.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LRC.ipynb b/ifrs17-template/Report/InteractiveReports/LRC.ipynb index 1bd0478f..139a2143 100644 --- a/ifrs17-template/Report/InteractiveReports/LRC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LRC.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb index 060ea4ae..2b4b4022 100644 --- a/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb index e68465c4..64f66725 100644 --- a/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb index a0a192a0..99c82692 100644 --- a/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb +++ b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb index 911db35a..0ea71e16 100644 --- a/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb +++ b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb index a785b7d9..288489e9 100644 --- a/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb +++ b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb index a9e3cc21..3a4fbc4b 100644 --- a/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb +++ b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb @@ -55,7 +55,7 @@ { "cell_type": "markdown", "source": [ - "The following row will output the report into excel. To change the name of the file, please change the string in the argument. The program will automatically attach the UTC creation date and time to the name that you chose. If you don not want the date and time to be attached, please change the addDataTime to false. " + "Export the report to excel format using the next cell. Change the file name using the input string and disable appending UTC export time by chaging true to false. " ], "metadata": {}, "execution_count": 0, From 8e51d6e06e70e84594912751610214398df76e38 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Tue, 21 Mar 2023 17:27:27 +0100 Subject: [PATCH 50/55] report markdown --- .../Report/InteractiveReports/Accruals.ipynb | 18 ++++++++++++++++++ .../InteractiveReports/Csm-Lc-LoReCo.ipynb | 18 ++++++++++++++++++ .../Report/InteractiveReports/Deferrals.ipynb | 18 ++++++++++++++++++ .../ExperienceAdjustment.ipynb | 18 ++++++++++++++++++ .../FinancialPerformance.ipynb | 18 ++++++++++++++++++ .../FulfilmentCashflow.ipynb | 18 ++++++++++++++++++ .../Report/InteractiveReports/LIC.ipynb | 18 ++++++++++++++++++ .../Report/InteractiveReports/LRC.ipynb | 18 ++++++++++++++++++ .../InteractiveReports/LicActuarial.ipynb | 18 ++++++++++++++++++ .../InteractiveReports/LrcActuarial.ipynb | 18 ++++++++++++++++++ .../InteractiveReports/PresentValue.ipynb | 18 ++++++++++++++++++ .../InteractiveReports/RiskAdjustment.ipynb | 18 ++++++++++++++++++ .../InteractiveReports/TechnicalMargin.ipynb | 18 ++++++++++++++++++ .../InteractiveReports/WrittenActual.ipynb | 18 ++++++++++++++++++ 14 files changed, 252 insertions(+) diff --git a/ifrs17-template/Report/InteractiveReports/Accruals.ipynb b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb index ff1f5a82..c2b3eb39 100644 --- a/ifrs17-template/Report/InteractiveReports/Accruals.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Accruals.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb index 101520af..605fccf9 100644 --- a/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Csm-Lc-LoReCo.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb index f2dd7b0a..74ed4bbe 100644 --- a/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb +++ b/ifrs17-template/Report/InteractiveReports/Deferrals.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb index 2d5d4798..bca1a5d0 100644 --- a/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb +++ b/ifrs17-template/Report/InteractiveReports/ExperienceAdjustment.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb index 24ddd2ee..f6d93cd9 100644 --- a/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb +++ b/ifrs17-template/Report/InteractiveReports/FinancialPerformance.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb index 2aa980ed..e9eb2257 100644 --- a/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb +++ b/ifrs17-template/Report/InteractiveReports/FulfilmentCashflow.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/LIC.ipynb b/ifrs17-template/Report/InteractiveReports/LIC.ipynb index 33a19d3a..e7080f53 100644 --- a/ifrs17-template/Report/InteractiveReports/LIC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LIC.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/LRC.ipynb b/ifrs17-template/Report/InteractiveReports/LRC.ipynb index 139a2143..b33382f5 100644 --- a/ifrs17-template/Report/InteractiveReports/LRC.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LRC.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb index 2b4b4022..a7ceb1a8 100644 --- a/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LicActuarial.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb index 64f66725..760172db 100644 --- a/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb +++ b/ifrs17-template/Report/InteractiveReports/LrcActuarial.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb index 99c82692..8695c9e8 100644 --- a/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb +++ b/ifrs17-template/Report/InteractiveReports/PresentValue.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb index 0ea71e16..c34ad162 100644 --- a/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb +++ b/ifrs17-template/Report/InteractiveReports/RiskAdjustment.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb index 288489e9..62b7e671 100644 --- a/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb +++ b/ifrs17-template/Report/InteractiveReports/TechnicalMargin.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ diff --git a/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb index 3a4fbc4b..b03d6226 100644 --- a/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb +++ b/ifrs17-template/Report/InteractiveReports/WrittenActual.ipynb @@ -25,6 +25,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Load Data" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ @@ -34,6 +43,15 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "markdown", + "source": [ + "# Interactive report and export" + ], + "metadata": {}, + "execution_count": 0, + "outputs": [] + }, { "cell_type": "code", "source": [ From 69efe32d6e1273ecb26057ec1a97045f19a5aa16 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Tue, 21 Mar 2023 17:29:43 +0100 Subject: [PATCH 51/55] comment ToExcelInteractive --- .../ReportMutableScopesInteractive.ipynb | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 56a641d8..8df76c95 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -1048,21 +1048,21 @@ "\n ToTwoDigitString(creationTime.Hour) + ToTwoDigitString(creationTime.Minute) + ToTwoDigitString(creationTime.Second);", "\n }", "\n", - "\n // This routine is still buggy, triggering an infinite loop. Not clear why. -- A.K.", - "\n public InteractiveObjectView ToExcelInteractive(string fileName, bool addDateTime = false, string name = null)", - "\n where T : ReportScope", - "\n {", - "\n var key = name ?? typeof(T).Name;", - "\n var fullFileName = addDateTime ? AttachDateTime(fileName) : fileName; ", - "\n if (!interactiveObjectCache.TryGetValue($\"{key}.xlsx\", out var ret))", - "\n ret = interactiveObjectCache[$\"{key}.xlsx\"] = interactiveObject.CreateView($\"{key}.xlsx\", _ => ", - "\n {", - "\n var scope = GetReportScope();", - "\n var filters = scope.GetFilters();", - "\n return scope.ToExcelAsync(fullFileName);", - "\n });", - "\n return ret;", - "\n }", + "\n // This routine is still buggy, triggering an infinite loop. -- A.K.", + "\n // public InteractiveObjectView ToExcelInteractive(string fileName, bool addDateTime = false, string name = null)", + "\n // where T : ReportScope", + "\n // {", + "\n // var key = name ?? typeof(T).Name;", + "\n // var fullFileName = addDateTime ? AttachDateTime(fileName) : fileName; ", + "\n // if (!interactiveObjectCache.TryGetValue($\"{key}.xlsx\", out var ret))", + "\n // ret = interactiveObjectCache[$\"{key}.xlsx\"] = interactiveObject.CreateView($\"{key}.xlsx\", _ => ", + "\n // {", + "\n // var scope = GetReportScope();", + "\n // var filters = scope.GetFilters();", + "\n // return scope.ToExcelAsync(fullFileName);", + "\n // });", + "\n // return ret;", + "\n // }", "\n ", "\n", "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", From 3b00166ba99da35c66d549b410ac7c05ad09c52d Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Wed, 22 Mar 2023 11:33:28 +0100 Subject: [PATCH 52/55] switch case in the data scope --- .../ReportMutableScopesInteractive.ipynb | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 8df76c95..05e85833 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -148,7 +148,7 @@ "\n ", "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", - "\n ScenarioMapping[\"Delta\"] = \"Delta\";", + "\n ScenarioMapping[\"Delta\"] = \"Delta\"; //TODO this behavior needs to be updated. PR#217", "\n ScenarioMapping[\"All\"] = \"All\";", "\n return orderedDropDownValues.Concat(new string[] {\"Delta\", \"All\"})", "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", @@ -357,7 +357,7 @@ "\n ", "\n [NotVisible] IReadOnlyCollection<(string filterName, string filterValue)> InputDataFilter { get; set; }", "\n ", - "\n protected (string fileName, object filterValue)[] dataFilter => InputDataFilter.Select(x => (x.filterName, (object)x.filterValue)).ToArray();", + "\n protected (string fileName, object filterValue)[] dataFilter => InputDataFilter.Select(x => (x.filterName, (object)x.filterValue)).ToArray(); //TODO this cast is needed by the Filter func", "\n", "\n IReadOnlyCollection<(string filterName, string filterValue)> GetFilters()", "\n {", @@ -471,13 +471,20 @@ "\n IDataCube InputDataCube { get; set; }", "\n IDataCube DataCube { get {", "\n if(InputDataCube is null) return Enumerable.Empty().ToDataCube();", - "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ? InputDataCube : InputDataCube.Filter(Identity.dataFilter); ", - "\n if(Identity.scenario == null) return filteredDataCube.Where(x => x.Scenario == null).ToDataCube();", - "\n if(Identity.scenario != \"All\" && Identity.scenario != \"Delta\") return filteredDataCube.Filter((\"Scenario\", Identity.scenario));", - "\n if(Identity.scenario == \"All\") return filteredDataCube.Select(x => x.Scenario == null ? x with {Scenario = \"Best Estimate\" } : x).ToDataCube();", - "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", - "\n return filteredDataCube.Select(x => x.Scenario == null ? x with { Scenario = \"Best Estimate\" } ", - "\n : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0.0) }).ToDataCube();", + "\n var filteredDataCube = (Identity.dataFilter is null || Identity.dataFilter.Length == 0) ", + "\n ? InputDataCube ", + "\n : InputDataCube.Filter(Identity.dataFilter); ", + "\n switch (Identity.scenario)", + "\n {", + "\n case null : return filteredDataCube.Where(x => x.Scenario == null).ToDataCube();", + "\n case Scenarios.All : return filteredDataCube.Select(x => x.Scenario == null ? x with {Scenario = Scenarios.Default } : x).ToDataCube();", + "\n case Scenarios.Delta : ", + "\n var bestEstimateById = filteredDataCube.Where(x => x.Scenario == null).ToDictionary(x => x.ToIdentityString());", + "\n return filteredDataCube.Select(x => x.Scenario == null ", + "\n ? x with { Scenario = Scenarios.Default } ", + "\n : x with { Value = x.Value - (bestEstimateById.TryGetValue((x with {Scenario = null}).ToIdentityString(), out var be)? be.Value : 0.0) }).ToDataCube(); ", + "\n default : return filteredDataCube.Filter((nameof(ReportVariable.Scenario), Identity.scenario));", + "\n }", "\n }}", "\n} " ], From 915f04c238ec77fdd2873152db52ff86657edf28 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Wed, 22 Mar 2023 14:15:57 +0100 Subject: [PATCH 53/55] remove treatment of annual cohort --- ifrs17/Report/ReportConfigurationAndUtils.ipynb | 14 -------------- ifrs17/Report/ReportMutableScopesInteractive.ipynb | 8 +------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index fc6ea7ad..061851c6 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -223,20 +223,6 @@ "execution_count": 0, "outputs": [] }, - { - "cell_type": "code", - "source": [ - "public static async Task<(IDictionary, IReadOnlyCollection)> GetAnnualCohortAutocompleteMappings (this IQuerySource querySource) {", - "\n var query = await querySource.Query().Select(x => x.AnnualCohort.ToString()).Distinct().ToArrayAsync();", - "\n var mappingDictionary = query.ToDictionary(x => x, x => x);", - "\n var orderedDropDownValues = query.Select(x => x);", - "\n return (mappingDictionary, new string[]{ null }.Concat(orderedDropDownValues).ToArray());", - "\n}" - ], - "metadata": {}, - "execution_count": 0, - "outputs": [] - }, { "cell_type": "markdown", "source": [ diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 05e85833..a7560232 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -327,12 +327,6 @@ "\n return orderedDropDownValues;", "\n }", "\n", - "\n async Task> GetAnnualCohortFilterAutocompleteAsync() {", - "\n (var filterMapping, var orderedDropDownValues) = await workspace.GetAnnualCohortAutocompleteMappings();", - "\n FilterMapping[nameof(ReportVariable.AnnualCohort)] = filterMapping;", - "\n return orderedDropDownValues;", - "\n }", - "\n", "\n async Task> GetBasicFilterAsync(string userInput, int page, int pageSize) =>", "\n new string[]{ null }.Concat(", "\n (FilterName switch", @@ -341,7 +335,7 @@ "\n nameof(ReportVariable.Portfolio) => await GetFilterAutocompleteAsync(),", "\n nameof(ReportVariable.GroupOfContract) => await GetFilterAutocompleteAsync(),", "\n nameof(ReportVariable.LineOfBusiness) => await GetFilterAutocompleteAsync(),", - "\n //nameof(ReportVariable.AnnualCohort) => await GetAnnualCohortFilterAutocompleteAsync(),//TODO the filter is not applied because the prop is an Int", + "\n //nameof(ReportVariable.AnnualCohort) => //TODO the filter is not applied because the prop is an Int", "\n nameof(ReportVariable.LiabilityType) => await GetFilterAutocompleteAsync(),", "\n nameof(ReportVariable.ValuationApproach) => await GetFilterAutocompleteAsync(),", "\n nameof(ReportVariable.OciType) => await GetFilterAutocompleteAsync(),", From 6afcbbeb611197bb9a3df10418c7344ed43ce896 Mon Sep 17 00:00:00 2001 From: akatz Date: Thu, 23 Mar 2023 11:41:34 +0100 Subject: [PATCH 54/55] with activity log --- ifrs17/Report/ReportConfigurationAndUtils.ipynb | 3 ++- ifrs17/Report/ReportMutableScopesInteractive.ipynb | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index 061851c6..2a93bd7a 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -29,7 +29,8 @@ "cell_type": "code", "source": [ "#!import \"../Utils/EqualityComparers\"", - "\n#!import \"../Utils/Queries\"" + "\n#!import \"../Utils/Queries\"", + "\n#!import \"../Utils/ActivityLog\"" ], "metadata": {}, "execution_count": 0, diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index a7560232..9c9d7b31 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -527,6 +527,7 @@ "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace)", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\n }", "\n", @@ -538,6 +539,7 @@ "\n .ForDataCube(dataScope.DataCube, config => config.WithQuerySource(workspace) ", "\n .SliceRowsBy(rowSlices)", "\n .SliceColumnsBy(columnSlices))", + "\n .WithActivityLog()", "\n .ExecuteAsync();", "\n }", "\n ", @@ -1065,7 +1067,7 @@ "\n // return ret;", "\n // }", "\n ", - "\n", + "\n ", "\n public ReportScope GetReportScope(string name = null) where T : ReportScope => interactiveObject.State.GetScope(name ?? typeof(T).Name, o => o.WithStorage(storage));", "\n", "\n // Keeping the old API", From 497db1bfc00497ce092b1964c155c8cf3cfe8187 Mon Sep 17 00:00:00 2001 From: Davide Colleoni Date: Thu, 23 Mar 2023 17:36:13 +0100 Subject: [PATCH 55/55] remove hardcoded --- ifrs17/Report/ReportMutableScopesInteractive.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ifrs17/Report/ReportMutableScopesInteractive.ipynb b/ifrs17/Report/ReportMutableScopesInteractive.ipynb index 9c9d7b31..26fb0f69 100644 --- a/ifrs17/Report/ReportMutableScopesInteractive.ipynb +++ b/ifrs17/Report/ReportMutableScopesInteractive.ipynb @@ -148,9 +148,9 @@ "\n ", "\n async Task> GetScenarioAutocompleteAsync(string userInput, int page, int pageSize) {", "\n (ScenarioMapping, var orderedDropDownValues) = await workspace.GetAutocompleteMappings(true);", - "\n ScenarioMapping[\"Delta\"] = \"Delta\"; //TODO this behavior needs to be updated. PR#217", - "\n ScenarioMapping[\"All\"] = \"All\";", - "\n return orderedDropDownValues.Concat(new string[] {\"Delta\", \"All\"})", + "\n ScenarioMapping[Scenarios.Delta] = Scenarios.Delta; //TODO this behavior needs to be updated. PR#217", + "\n ScenarioMapping[Scenarios.All] = Scenarios.All;", + "\n return orderedDropDownValues.Concat(new string[] {Scenarios.Delta, Scenarios.All})", "\n .Where(x => userInput == null || x.Contains(userInput, StringComparison.OrdinalIgnoreCase))", "\n .ToArray(); ", "\n }",