diff --git a/full-ifrs17-template/Database/Configure.ipynb b/full-ifrs17-template/Database/Configure.ipynb index b332a43c..cbe56388 100644 --- a/full-ifrs17-template/Database/Configure.ipynb +++ b/full-ifrs17-template/Database/Configure.ipynb @@ -27,7 +27,8 @@ { "cell_type": "code", "source": [ - "#!import \"//ifrs17ce/dev/CalculationEngine\"" + "#!import \"../Constants/Consts\"", + "\n#!eval calculationEngine" ] }, { diff --git a/full-ifrs17-template/Files/DimensionsAndPartitions.csv b/full-ifrs17-template/Files/DimensionsAndPartitions.csv index bcfe9d1d..4f648680 100644 --- a/full-ifrs17-template/Files/DimensionsAndPartitions.csv +++ b/full-ifrs17-template/Files/DimensionsAndPartitions.csv @@ -228,9 +228,6 @@ CH,00000000-0000-0000-0000-000000000001,,,,,,,,,, ReportingNode,Year,Month,Id,,,,,,,, CH,2020,12,10000000-0000-0000-0000-000000000000,,,,,,,, CH,2021,3,20000000-0000-0000-0000-000000000000,,,,,,,, -CH,2021,9,30000000-0000-0000-0000-000000000000,,,,,,,, -CH,2021,12,35000000-0000-0000-0000-000000000000,,,,,,,, -CH,2022,3,40000000-0000-0000-0000-000000000000,,,,,,,, ,,,,,,,,,,, @@ProjectionConfiguration,,,,,,,,,,, SystemName,DisplayName,Shift,TimeStep,,,,,,,, diff --git a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb index 1dc82a4e..e910c089 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphBaseToMemory.ipynb @@ -128,25 +128,25 @@ { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/YieldCurve.csv\")" + "await Import.FromFile(\"../Files/800.Parameters/YieldCurve.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/ExchangeRate.csv\")" + "await Import.FromFile(\"../Files/800.Parameters/ExchangeRate.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/PartnerRating.csv\")" + "await Import.FromFile(\"../Files/800.Parameters/PartnerRating.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/CreditDefaultRate.csv\")" + "await Import.FromFile(\"../Files/800.Parameters/CreditDefaultRate.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" ] }, { @@ -158,19 +158,19 @@ { "cell_type": "code", "source": [ - "await UploadDataNodesAsync(\"../Files/700.DataNodes/DataNodes_CH.csv\")" + "await Import.FromFile(\"../Files/700.DataNodes/DataNodes_CH.csv\").WithFormat(ImportFormats.DataNode).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDataNodeStateAsync(\"../Files/700.DataNodes/DataNodeStates_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/700.DataNodes/DataNodeStates_CH_2020_12.csv\").WithFormat(ImportFormats.DataNodeState).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDataNodeParameterAsync(\"../Files/700.DataNodes/DataNodeParameters_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/700.DataNodes/DataNodeParameters_CH_2020_12.csv\").WithFormat(ImportFormats.DataNodeParameter).WithTarget(DataSource).ExecuteAsync()" ] }, { diff --git a/full-ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb b/full-ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb index 9b7b5ab5..cc45633d 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphToDatabase.ipynb @@ -106,25 +106,25 @@ { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/YieldCurve.csv\")" + "await Import.FromFile(\"../Files/800.Parameters/YieldCurve.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/ExchangeRate.csv\")" + "await Import.FromFile(\"../Files/800.Parameters/ExchangeRate.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/PartnerRating.csv\")" + "await Import.FromFile(\"../Files/800.Parameters/PartnerRating.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDimensionsAsync(\"../Files/800.Parameters/CreditDefaultRate.csv\")" + "await Import.FromFile(\"../Files/800.Parameters/CreditDefaultRate.csv\").WithType().SnapshotMode().WithTarget(DataSource).ExecuteAsync()" ] }, { @@ -136,19 +136,19 @@ { "cell_type": "code", "source": [ - "await UploadDataNodesAsync(\"../Files/700.DataNodes/DataNodes_CH.csv\")" + "await Import.FromFile(\"../Files/700.DataNodes/DataNodes_CH.csv\").WithFormat(ImportFormats.DataNode).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDataNodeStateAsync(\"../Files/700.DataNodes/DataNodeStates_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/700.DataNodes/DataNodeStates_CH_2020_12.csv\").WithFormat(ImportFormats.DataNodeState).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadDataNodeParameterAsync(\"../Files/700.DataNodes/DataNodeParameters_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/700.DataNodes/DataNodeParameters_CH_2020_12.csv\").WithFormat(ImportFormats.DataNodeParameter).WithTarget(DataSource).ExecuteAsync()" ] }, { @@ -160,31 +160,31 @@ { "cell_type": "code", "source": [ - "await UploadOpeningAsync(\"../Files/900.TransactionalData/Openings_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/Openings_CH_2020_12.csv\").WithFormat(ImportFormats.Opening).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2021_3.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2021_3.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2021_3.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2021_3.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync()" ] }, { diff --git a/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb b/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb index c9eb277e..1685c887 100644 --- a/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb +++ b/full-ifrs17-template/Initialization/InitSystemorphToMemory.ipynb @@ -52,31 +52,31 @@ { "cell_type": "code", "source": [ - "await UploadOpeningAsync(\"../Files/900.TransactionalData/Openings_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/Openings_CH_2020_12.csv\").WithFormat(ImportFormats.Opening).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2020_12.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2020_12.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadCashflowsAsync(\"../Files/900.TransactionalData/NominalCashflows_CH_2021_3.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/NominalCashflows_CH_2021_3.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" ] }, { "cell_type": "code", "source": [ - "await UploadActualAsync(\"../Files/900.TransactionalData/Actuals_CH_2021_3.csv\")" + "await Import.FromFile(\"../Files/900.TransactionalData/Actuals_CH_2021_3.csv\").WithFormat(ImportFormats.Actual).WithTarget(DataSource).ExecuteAsync()" ] }, { diff --git a/full-ifrs17-template/Report/Reports.ipynb b/full-ifrs17-template/Report/Reports.ipynb index 4caa201d..23a3804b 100644 --- a/full-ifrs17-template/Report/Reports.ipynb +++ b/full-ifrs17-template/Report/Reports.ipynb @@ -28,26 +28,18 @@ { "cell_type": "markdown", "source": [ - "This is the notebook to be run for the production of all the reports." - ] - }, - { - "cell_type": "markdown", - "source": [ - "# Infrastructure and Configuration" + "For demonstration purposes we import here data for 7 *Group of Insurance Contract* (GIC) and 4 *Group of Reinsurance Contract* (GRIC) - the import is triggered in the [Set up data and configuration](#set-up-data-and-configuration).", + "\n
The imported data set consists of cashflows, actuals, and parameters for two consecutive periods (Year 2020-Quarter 4 and Year 2021-Quarter 1)", + "\n
Input files can be found in the **File** directory. You are invited to change them or upload your own. ", + "\n
For simplicity, we import the same transactional data for all GICs and GRICs. Each *Group of Contracts* produces different figures due to differences in parameters such as *Liability Type*, *Oci type* or *Premium allocation factor* to Contractual Service Margin.", + "\n", + "\nFollow the instructions below for a guided interaction with the reports." ] }, { "cell_type": "markdown", "source": [ - "## Initialize data" - ] - }, - { - "cell_type": "code", - "source": [ - "/* DataSource is configured and connected to real database */", - "\n//#!eval-notebook \"../Database/Configure\"" + "# Set up data and configuration" ] }, { @@ -59,77 +51,18 @@ { "cell_type": "code", "source": [ - "Workspace.InitializeFrom(DataSource);" - ] - }, - { - "cell_type": "markdown", - "source": [ - "## Imports and Configurations" - ] - }, - { - "cell_type": "code", - "source": [ - "var reportStorage = new ReportStorage(Workspace, Report);", - "\nawait reportStorage.InitializeReportIndependentCacheAsync();", - "\nvar mostRecentPartition = (await Workspace.Query().Where(x => x.Scenario == null).OrderBy(x => x.Year).ThenBy(x => x.Month).ToArrayAsync()).Last();", - "\nvar reportingNodeRoot = (await Workspace.Query().Where(x => x.Parent == null).ToArrayAsync()).First().SystemName;", - "\nawait reportStorage.InitializeAsync((mostRecentPartition.Year, mostRecentPartition.Month), reportingNodeRoot, null, CurrencyType.Contractual);", - "\nvar identities = reportStorage.GetIdentities((mostRecentPartition.Year, mostRecentPartition.Month), reportingNodeRoot, null, CurrencyType.Contractual);" - ] - }, - { - "cell_type": "markdown", - "source": [ - "## Calling Scope" - ] - }, - { - "cell_type": "code", - "source": [ - "var universe = Scopes.ForSingleton().WithStorage(reportStorage).ToScope();" - ] - }, - { - "cell_type": "markdown", - "source": [ - "# Report Settings and Storage Update" - ] - }, - { - "cell_type": "code", - "source": [ - "((int Year, int Month) Period, string ReportingNode, string Scenario, CurrencyType CurrencyType) Args =", - "\n //((2020, 12), reportingNodeRoot, null,CurrencyType.Contractual)", - "\n ((2021, 3), reportingNodeRoot, null,CurrencyType.Contractual)", - "\n //((2021, 3), reportingNodeRoot, null,CurrencyType.Functional)", - "\n //((2021, 3), reportingNodeRoot, null,CurrencyType.Group)", - "\n ;", - "\n", - "\nawait reportStorage.InitializeAsync(Args.Period, Args.ReportingNode, Args.Scenario, Args.CurrencyType);", - "\nidentities = reportStorage.GetIdentities(Args.Period, Args.ReportingNode, Args.Scenario, Args.CurrencyType);" - ] - }, - { - "cell_type": "markdown", - "source": [ - "# Use cases", - "\n", - "\nFor demonstration purposes we import data for 7 *Group of Insurance Contract* (GIC) and 4 *Group of Reinsurance Contract* (GRIC). ", - "\n
The data set consists of cashflows, actuals, and parameters.", - "\n", - "\n" + "Workspace.InitializeFrom(DataSource);", + "\nifrs17Report.Reset(Workspace)" ] }, { "cell_type": "markdown", "source": [ - "# Present Value", + "# Best Estimate", "\n", - "\nPresent values of the best-estimate future cashflows are shown here in an Analysis of Change report.", + "\nPresent values of the [best-estimate](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#best-estimate) future cashflows are shown here in an Analysis of Change report.", "\n", - "\nThe report view can be modified with the Slice options for the columns by changing the SliceColumnBy inputs in the next command cell.", + "\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
We suggest to add this slice between the \"LiabilityType\" and the \"EconomicBasis\" as the order of the inputs corresponds to the order of the columns shown in the report to expand the data.", "\n", @@ -139,166 +72,157 @@ { "cell_type": "code", "source": [ - "Report.ForDataCube((universe.GetScopes(identities).Aggregate().LockedBestEstimate + universe.GetScopes(identities).Aggregate().CurrentBestEstimate)", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"Novelty\",\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"LiabilityType\", \"EconomicBasis\") //\"GroupOfContract\"", - "\n .ReportGridOptions()", - "\n .ToReport()" + "var pvReport = ifrs17Report.PresentValues;", + "\npvReport.ReportingNode = \"CH\";", + "\npvReport.ReportingPeriod = (2021, 3);", + "\npvReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\npvReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.2\"),(\"LiabilityType\", \"LIC\") }", + "\n(await pvReport.ToReportAsync) with {Height = 720}" ] }, { "cell_type": "markdown", "source": [ - "# Risk Adjustment" + "# Risk Adjustment", + "\n", + "\nPresent values of the [risk adjustment](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#risk-adjustment) future cashflows are shown here.", + "\n", + "\nFilters can be applied to report to isolate a sub-set of the data. They can be used in conjuction to the Slice options. For example, filtering **EconomicBasis** Locked-in together with a slice on the **GroupOfContract** allows to analyse the risk adjustment figures computed with the yield curve at inception for all Group of Contracts." ] }, { "cell_type": "code", "source": [ - "Report.ForDataCube((universe.GetScopes(identities).Aggregate().LockedRiskAdjustment + universe.GetScopes(identities).Aggregate().CurrentRiskAdjustment)", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"Novelty\",\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"EconomicBasis\", \"LiabilityType\",\"GroupOfContract\")", - "\n .ReportGridOptions()", - "\n .ToReport()" + "var raReport = ifrs17Report.RiskAdjustments;", + "\nraReport.ColumnSlices = new string[]{};//\"GroupOfContract\"", + "\nraReport.DataFilter = null;//new [] {(\"GroupOfContract\", \"DT1.2\")};", + "\n(await raReport.ToReportAsync) with {Height = 800}" ] }, { "cell_type": "markdown", "source": [ - "# Actuals" + "# Written Actuals", + "\n", + "\n[Written Actuals](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#written-accrual-deferral) are shown here. ", + "\n", + "\nIn this case, the analysis of change view is replaced with a default slice by the **AmountTypes**. Only the amount type with non zero value are displayed. " ] }, { "cell_type": "code", "source": [ - "Report.ForDataCube(universe.GetScopes(identities).Aggregate().Written", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"AmountType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"LiabilityType\",\"GroupOfContract\")", - "\n .ReportGridOptions(reportHeight: 450)", - "\n .ToReport()" + "var writtenActualReport = ifrs17Report.WrittenActuals;", + "\nwrittenActualReport.ColumnSlices = new string[]{};//\"GroupOfContract\"", + "\nwrittenActualReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await writtenActualReport.ToReportAsync) with {Height = 400}" ] }, { "cell_type": "markdown", "source": [ - "## Advance, Overdue Actuals" + "## Advance, Overdue Actuals", + "\n", + "\nActuals payed in [Advance](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#written-accrual-deferral)", + "\nor [Overdue](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#written-accrual-deferral) are shown here together in a simplified Analysis of Change. " ] }, { "cell_type": "code", "source": [ - "Report.ForDataCube((universe.GetScopes(identities).Aggregate().Advance + universe.GetScopes(identities).Aggregate().Overdue)", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"LiabilityType\",\"GroupOfContract\", \"EstimateType\")", - "\n .ReportGridOptions(reportHeight: 400)", - "\n .ToReport()" + "var accrualActualReport = ifrs17Report.AccrualActuals;", + "\naccrualActualReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\naccrualActualReport.DataFilter = null;//new [] {(\"GroupOfContract\", \"DT2.1\")};", + "\n(await accrualActualReport.ToReportAsync) with {Height = 400}" ] }, { "cell_type": "markdown", "source": [ - "## Deferrable Actuals" + "## Deferrable Actuals", + "\n", + "\n[Deferrable Actuals](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#written-accrual-deferral) are shown here. Amortization of the deferrable amount is computed using the Coverage Unit pattern. " ] }, { "cell_type": "code", "source": [ - "Report.ForDataCube(universe.GetScopes(identities).Aggregate().Deferrals", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"LiabilityType\",\"GroupOfContract\")", - "\n .ReportGridOptions(reportHeight: 400)", - "\n .ToReport()" + "var deferrableActualReport = ifrs17Report.DeferralActuals;", + "\ndeferrableActualReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\ndeferrableActualReport.DataFilter = null;//new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await deferrableActualReport.ToReportAsync) with {Height = 400}" ] }, { "cell_type": "markdown", "source": [ - "# Fulfilment Cashflow" + "# Fulfilment Cashflow", + "\n", + "\nPresent Value of the [Fulfilment Cashflow](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#fulfillment-cashflows) are shown here. ", + "\n
The individual contributions from Best Estimate and Risk Adjustment can be visualized slicing by **EstimateType**" ] }, { "cell_type": "code", "source": [ - "Report.ForDataCube(universe.GetScopes(identities).Aggregate().Fcf ", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"Novelty\",\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"LiabilityType\",\"GroupOfContract\", \"EconomicBasis\")//, \"EstimateType\")//, \"AmountType\")", - "\n .ReportGridOptions()", - "\n .ToReport()" + "var fulfillmentCashflowsReport = ifrs17Report.FulfillmentCashflows;", + "\nfulfillmentCashflowsReport.ColumnSlices = new string[]{};//\"EstimateType\"", + "\nfulfillmentCashflowsReport.DataFilter = null;// new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await fulfillmentCashflowsReport.ToReportAsync) with {Height = 750}" ] }, { "cell_type": "markdown", "source": [ - "# Actuarial Experience Adjustment" + "# Actuarial Experience Adjustment", + "\n", + "\nA comparison between [Written Actual](#written-actual) and the Releases of the [Best Estimate](#present-value) is reported in the [Actuarial Experience Adjustment](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#experience-adjustment)." ] }, { "cell_type": "code", "source": [ - "Report.ForDataCube(universe.GetScopes(identities).Aggregate().ActuarialExperienceAdjustment", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"EstimateType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"GroupOfContract\", \"AmountType\" )//\"LiabilityType\", \"EstimateType\")", - "\n .ReportGridOptions(reportHeight: 300, headerColumnWidth: 300)", - "\n .ToReport() " + "var experienceAdjustmentsReport = ifrs17Report.ExperienceAdjustments;", + "\nexperienceAdjustmentsReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\nexperienceAdjustmentsReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await experienceAdjustmentsReport.ToReportAsync) with {Height = 300}" ] }, { "cell_type": "markdown", "source": [ - "# LRC Technical Margin" + "# LRC Technical Margin", + "\n", + "\nIn the [Technical Margin](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#technical-margin) report we present a unified view on the figures that are allocated to either Contractual Service Margin or to Loss Component. ", + "\n
The Analysis of Change is expanded with few more steps such as **Experience Adjustment** and **Amortization**." ] }, { "cell_type": "code", "source": [ - "Report.ForDataCube(universe.GetScopes(identities).Aggregate().LrcTechnicalMargin", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"Novelty\",\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"GroupOfContract\")", - "\n .ReportGridOptions(reportHeight: 600)", - "\n .ToReport()" + "var technicalMarginsReport = ifrs17Report.TechnicalMargins;", + "\ntechnicalMarginsReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\ntechnicalMarginsReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await technicalMarginsReport.ToReportAsync) with {Height = 600}" ] }, { "cell_type": "markdown", "source": [ - "# Contractual Service Margin / Loss Component / Loss Recovery Component" + "# Contractual Service Margin / Loss Component / Loss Recovery Component", + "\n", + "\nThe Contractual Service Margin (CSM) / Loss Component (LC) / Loss Recovery Component (LR) [report](https://portal.systemorph.cloud/project/ifrs17ce/env/dev/Report/ReportScopes#technical-margin) are here shown side by side as the allocation to profit or loss is done at each step of the Analysis of Change. ", + "\n", + "\nA default slice by EstimateType - which distinguish between CSM, LC and LR contributions - is automatically enforced. " ] }, { "cell_type": "code", "source": [ - "Report.ForDataCube((universe.GetScopes(identities).Aggregate().Csm + universe.GetScopes(identities).Aggregate().Lc + universe.GetScopes(identities).Aggregate().Loreco)", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"Novelty\",\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"GroupOfContract\", \"EstimateType\")", - "\n .ReportGridOptions()", - "\n .ToReport()" + "var allocatedTechnicalMarginsReport = ifrs17Report.AllocatedTechnicalMargins;", + "\nallocatedTechnicalMarginsReport.ColumnSlices = new string[]{\"GroupOfContract\", \"EstimateType\"};//\"GroupOfContract\", \"AmountType\"", + "\nallocatedTechnicalMarginsReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await allocatedTechnicalMarginsReport.ToReportAsync) with {Height = 700}" ] }, { @@ -310,14 +234,10 @@ { "cell_type": "code", "source": [ - "Report.ForDataCube((universe.GetScopes(identities).Aggregate().LrcActuarial)", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"Novelty\",\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), /*\"LiabilityType\",\"GroupOfContract\",*/ \"EstimateType\")", - "\n .ReportGridOptions()", - "\n .ToReport()" + "var actuarialLrcReport = ifrs17Report.ActuarialLrc;", + "\nactuarialLrcReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\nactuarialLrcReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await actuarialLrcReport.ToReportAsync) with {Height = 750}" ] }, { @@ -329,14 +249,10 @@ { "cell_type": "code", "source": [ - "Report.ForDataCube((universe.GetScopes(identities).Aggregate().Lrc)", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType),\"GroupOfContract\", \"EstimateType\")", - "\n .ReportGridOptions(300)", - "\n .ToReport()" + "var lrcReport = ifrs17Report.Lrc;", + "\nlrcReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\nlrcReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await lrcReport.ToReportAsync) with {Height = 250}" ] }, { @@ -348,14 +264,10 @@ { "cell_type": "code", "source": [ - "Report.ForDataCube((universe.GetScopes(identities).Aggregate().LicActuarial)", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"Novelty\",\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), /*\"GroupOfContract\",*/ \"EstimateType\")", - "\n .ReportGridOptions()", - "\n .ToReport()" + "var actuarialLicReport = ifrs17Report.ActuarialLic;", + "\nactuarialLicReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\nactuarialLicReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await actuarialLicReport.ToReportAsync) with {Height = 750}" ] }, { @@ -367,14 +279,10 @@ { "cell_type": "code", "source": [ - "Report.ForDataCube((universe.GetScopes(identities).Aggregate().Lic)", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"VariableType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), /*\"GroupOfContract\",*/ \"EstimateType\")", - "\n .ReportGridOptions(300)", - "\n .ToReport()" + "var licReport = ifrs17Report.Lic;", + "\nlicReport.ColumnSlices = new string[]{};//\"GroupOfContract\", \"AmountType\"", + "\nlicReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await licReport.ToReportAsync) with {Height = 250}" ] }, { @@ -388,14 +296,10 @@ { "cell_type": "code", "source": [ - "Report.ForDataCube(universe.GetScopes(identities).Aggregate().FinancialPerformance", - "\n //.Filter((\"GroupOfContract\", \"DT1.1\"))", - "\n )", - "\n .WithQuerySource(DataSource)", - "\n .SliceRowsBy(\"VariableType\", \"EstimateType\")", - "\n .SliceColumnsBy(CurrencyGrouper(Args.CurrencyType), \"LiabilityType\",\"GroupOfContract\")", - "\n .ReportGridOptions(reportHeight: 900, headerColumnWidth: 500, groupDefaultExpanded: 3)", - "\n .ToReport()" + "var financialPerformanceReport = ifrs17Report.FinancialPerformance;", + "\nfinancialPerformanceReport.ColumnSlices = new string[]{};//\"GroupOfContract\"", + "\nfinancialPerformanceReport.DataFilter = null; //new [] {(\"GroupOfContract\", \"DT1.1\")};", + "\n(await financialPerformanceReport.ToReportAsync) with { Height = 900, GroupDefaultExpanded = 3}" ] }, { diff --git a/full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb b/full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb index e0b58e97..69f8137a 100644 --- a/full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb +++ b/full-ifrs17-template/Test/MapTemplateAndImportTest.ipynb @@ -443,8 +443,7 @@ "source": [ "public async Task CheckErrors(string inputFileName, List errorBms)", "\n{", - "\n var partitionId = new Guid();", - "\n var log = await UploadDataNodeParameterToWorkspaceAsync(inputFileName, partitionId);", + "\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}" diff --git a/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb b/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb index 12b9fc30..d75b5206 100644 --- a/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb +++ b/full-ifrs17-template/Test/SpecificationsImportCashflows.ipynb @@ -116,7 +116,7 @@ "cell_type": "code", "source": [ "var groupOfContract = \"GricComplex\";", - "\nawait UploadCashflowsAsync(\"Data/CashflowComplex.csv\")" + "\nawait Import.FromFile(\"Data/CashflowComplex.csv\").WithFormat(ImportFormats.Cashflow).WithTarget(DataSource).ExecuteAsync()" ] }, { diff --git a/full-ifrs17-template/Test/SpecificationsSetup.ipynb b/full-ifrs17-template/Test/SpecificationsSetup.ipynb index 335f1ca3..b9f1e2f4 100644 --- a/full-ifrs17-template/Test/SpecificationsSetup.ipynb +++ b/full-ifrs17-template/Test/SpecificationsSetup.ipynb @@ -90,7 +90,7 @@ "\n Value = scope.Value,", "\n Partition = scope.GetStorage().TargetPartition };", "\n", - "\npublic static IfrsVariable FromCsmToIfrsVariable(this ContractualServiceMaring scope)", + "\npublic static IfrsVariable FromCsmToIfrsVariable(this ContractualServiceMargin scope)", "\n => new IfrsVariable{ EstimateType = scope.EstimateType, ", "\n DataNode = scope.Identity.DataNode, ", "\n AocType = scope.Identity.AocType, ", diff --git a/full-ifrs17-template/Test/SpecificationsTechnicalMargin.ipynb b/full-ifrs17-template/Test/SpecificationsTechnicalMargin.ipynb index 43191eec..f8cc0f73 100644 --- a/full-ifrs17-template/Test/SpecificationsTechnicalMargin.ipynb +++ b/full-ifrs17-template/Test/SpecificationsTechnicalMargin.ipynb @@ -1121,7 +1121,7 @@ { "cell_type": "code", "source": [ - "var computedCSM_BoP_I = Test.GetScope(id_BoP_I).Value;", + "var computedCSM_BoP_I = Test.GetScope(id_BoP_I).Value;", "\nvar computedLC_BoP_I = Test.GetScope(id_BoP_I).Value;" ] }, @@ -1196,7 +1196,7 @@ { "cell_type": "code", "source": [ - "var computedCSM_MC_I = Test.GetScope(id_MC_I).Value;", + "var computedCSM_MC_I = Test.GetScope(id_MC_I).Value;", "\nvar computedLC_MC_I = Test.GetScope(id_MC_I).Value;" ] }, @@ -1447,7 +1447,7 @@ { "cell_type": "code", "source": [ - "var computedCSM_CL_C = Test.GetScope(id_CL_C).Value;", + "var computedCSM_CL_C = Test.GetScope(id_CL_C).Value;", "\nvar computedLC_CL_C = Test.GetScope(id_CL_C).Value;" ] }, @@ -1644,7 +1644,7 @@ { "cell_type": "code", "source": [ - "var computedCSM_EoP_C = Test.GetScope(id_EoP_C).Value;", + "var computedCSM_EoP_C = Test.GetScope(id_EoP_C).Value;", "\nvar computedLC_EoP_C = Test.GetScope(id_EoP_C).Value;" ] }, @@ -1694,7 +1694,7 @@ { "cell_type": "code", "source": [ - "var csm = allIdentitiesWoLic.SelectMany(id => Test.GetScope(id).RepeatOnce()", + "var csm = allIdentitiesWoLic.SelectMany(id => Test.GetScope(id).RepeatOnce()", "\n .Where(x => Math.Abs(x.Value) >= Precision)", "\n .Select(x => x.FromCsmToIfrsVariable())).ToArray();" ] diff --git a/ifrs17/CalculationEngine.ipynb b/ifrs17/CalculationEngine.ipynb index d6a34d5e..0936fa66 100644 --- a/ifrs17/CalculationEngine.ipynb +++ b/ifrs17/CalculationEngine.ipynb @@ -19,12 +19,18 @@ "cell_type": "code", "source": [ "#!import \"DataModel/DataStructure\"", - "\n#!import \"Report/ReportScopes\"", + "\n#!import \"Report/ReportMutableScopes\"", "\n#!import \"Import/Importers\"", "\n#!import \"Export/ExportConfiguration\"", "\n#!import \"Utils/TestHelper\"", "\n#!import \"Utils/ImportCalculationMethods\"" ] + }, + { + "cell_type": "code", + "source": [ + "var ifrs17Report = new Ifrs17Reports(Workspace, Scopes, Report);" + ] } ] } \ No newline at end of file diff --git a/ifrs17/Constants/Consts.ipynb b/ifrs17/Constants/Consts.ipynb index 8c67e92e..d5dafed5 100644 --- a/ifrs17/Constants/Consts.ipynb +++ b/ifrs17/Constants/Consts.ipynb @@ -138,7 +138,9 @@ "public static class ImportFormats{", "\n public const string Cashflow = nameof(Cashflow);", "\n public const string Actual = nameof(Actual);", + "\n public const string DataNode = nameof(DataNode);", "\n public const string DataNodeParameter = nameof(DataNodeParameter);", + "\n public const string DataNodeState = nameof(DataNodeState);", "\n public const string SimpleValue = nameof(SimpleValue);", "\n public const string Opening = nameof(Opening);", "\n public const string AocConfiguration = nameof(AocConfiguration);", diff --git a/ifrs17/DataModel/DataStructure.ipynb b/ifrs17/DataModel/DataStructure.ipynb index 78851b13..2c3fac39 100644 --- a/ifrs17/DataModel/DataStructure.ipynb +++ b/ifrs17/DataModel/DataStructure.ipynb @@ -43,17 +43,18 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Arithmetics,1.5.4\"", - "\n#r \"nuget:Systemorph.Workspace,1.5.0\"", - "\n#r \"nuget:Systemorph.Scopes,1.5.2\"", - "\n#r \"nuget:Systemorph.Import,1.5.0\"", - "\n#r \"nuget:Systemorph.Test,1.5.2\"", - "\n#r \"nuget:Systemorph.Export,1.5.0\"", - "\n#r \"nuget:Systemorph.DataSetReader,1.5.0\"", - "\n#r \"nuget:Systemorph.DataSource,1.5.0\"", - "\n#r \"nuget:Systemorph.DataSource.Conversions,1.5.0\"", - "\n#r \"nuget:Systemorph.Reporting,1.5.2\"", - "\n#r \"nuget:Systemorph.DomainDesigner,1.5.0\"" + "#r \"nuget:Systemorph.Arithmetics,1.5.5\"", + "\n#r \"nuget:Systemorph.Workspace,1.5.3\"", + "\n#r \"nuget:Systemorph.Scopes,1.5.5\"", + "\n#r \"nuget:Systemorph.Import,1.5.1\"", + "\n#r \"nuget:Systemorph.Test,1.5.5\"", + "\n#r \"nuget:Systemorph.Export,1.5.1\"", + "\n#r \"nuget:Systemorph.DataSetReader,1.5.1\"", + "\n#r \"nuget:Systemorph.DataSource,1.5.3\"", + "\n#r \"nuget:Systemorph.DataSource.Conversions,1.5.3\"", + "\n#r \"nuget:Systemorph.Reporting,1.5.5\"", + "\n#r \"nuget:Systemorph.DomainDesigner,1.5.1\"", + "\n#r \"nuget:Systemorph.SharePoint,1.5.6\"" ] }, { @@ -1056,15 +1057,6 @@ "\n- OCI Type" ] }, - { - "cell_type": "markdown", - "source": [ - "TODOs:", - "\n
    ", - "\n
  • Remove Scenario from Partition and include it as simple property (see Year, Month). Introduce concept of Priority in LoadCurrentAndPreviousParameterAsync query (see ParameterResultsEntityQueryExtensions in IfrsGeneric).
  • ", - "\n
" - ] - }, { "cell_type": "code", "source": [ diff --git a/ifrs17/Import/ImportScopeCalculation.ipynb b/ifrs17/Import/ImportScopeCalculation.ipynb index f172092b..629d2d40 100644 --- a/ifrs17/Import/ImportScopeCalculation.ipynb +++ b/ifrs17/Import/ImportScopeCalculation.ipynb @@ -1784,7 +1784,7 @@ { "cell_type": "code", "source": [ - "public interface ContractualServiceMaring : IScope", + "public interface ContractualServiceMargin : IScope", "\n{", "\n [NotVisible]string EstimateType => EstimateTypes.C;", "\n ", @@ -1951,7 +1951,7 @@ "\n ", "\n IEnumerable Csms => GetStorage().DataNodeDataBySystemName[Identity.DataNode].LiabilityType == LiabilityTypes.LIC", "\n ? Enumerable.Empty()", - "\n : GetScope(Identity).RepeatOnce()", + "\n : GetScope(Identity).RepeatOnce()", "\n .Where(x => Math.Abs(x.Value) >= Precision)", "\n .Select(x => new IfrsVariable{ EstimateType = x.EstimateType,", "\n DataNode = x.Identity.DataNode,", diff --git a/ifrs17/Import/Importers.ipynb b/ifrs17/Import/Importers.ipynb index 6be43097..8a499aa5 100644 --- a/ifrs17/Import/Importers.ipynb +++ b/ifrs17/Import/Importers.ipynb @@ -266,16 +266,14 @@ { "cell_type": "code", "source": [ - "public async Task DataNodeFactoryAsync(string file, string tab, ImportArgs args)", + "public async Task DataNodeFactoryAsync(IDataSet dataSet, string tableName, ImportArgs args)", "\n{", "\n var partition = (await DataSource.Query().Where(p => p.ReportingNode == args.ReportingNode && p.Scenario == null).ToArrayAsync()).SingleOrDefault();", "\n if(partition == null) { ApplicationMessage.Log(Error.ParsedPartitionNotFound); return; }", "\n", - "\n var extension = System.IO.Path.GetExtension(file);", - "\n var stream = await Project.FileStorage.ReadAsync(file);", - "\n var target = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet.Tables[tab];", + "\n var table = dataSet.Tables[tableName];", "\n", - "\n var dataNodesImported = target.Rows.Select(x => x.Field(nameof(RawVariable.DataNode))).ToHashSet();", + "\n var dataNodesImported = table.Rows.Select(x => x.Field(nameof(RawVariable.DataNode))).ToHashSet();", "\n var dataNodesDefined = await DataSource.Query().Where(x => dataNodesImported.Contains(x.SystemName)).ToArrayAsync();", "\n var dataNodeStatesDefined = await DataSource.Query().Select(x => x.DataNode).ToArrayAsync();", "\n var dataNodeParametersDefined = await DataSource.Query().Select(x => x.DataNode).ToArrayAsync(); ", @@ -304,24 +302,7 @@ { "cell_type": "markdown", "source": [ - "## Parse and Upload: Dimensions" - ] - }, - { - "cell_type": "code", - "source": [ - "public async Task UploadDimensionsAsync (string fileName) where T: class ", - "\n{", - "\n await CleanDatabaseAsync();", - "\n var importLog = await Import.FromFile(fileName).WithType().WithTarget(DataSource).ExecuteAsync();", - "\n return importLog;", - "\n}" - ] - }, - { - "cell_type": "markdown", - "source": [ - "### Analysis of Change Configuration" + "## Analysis of Change Configuration" ] }, { @@ -430,11 +411,9 @@ { "cell_type": "code", "source": [ - "public async Task GetArgsFromMainAsync(string file)", + "public async Task GetArgsFromMainAsync(IDataSet dataSet)", "\n{", - "\n var extension = System.IO.Path.GetExtension(file);", - "\n var stream = await Project.FileStorage.ReadAsync(file);", - "\n var mainTab = (await DataSetReader.ReadFromStream(stream).WithContentType(extension).ExecuteAsync()).DataSet.Tables[Main];", + "\n var mainTab = dataSet.Tables[Main];", "\n ", "\n if(mainTab == null) ApplicationMessage.Log(Error.NoMainTab);", "\n if(mainTab.Rows.Count() == 0) ApplicationMessage.Log(Error.IncompleteMainTab);", @@ -471,7 +450,7 @@ { "cell_type": "markdown", "source": [ - "### Parse and Upload: Data Nodes" + "## Parse and Upload: Data Nodes" ] }, { @@ -483,7 +462,7 @@ { "cell_type": "code", "source": [ - "public async Task UploadDataNodesToWorkspaceAsync(string fileName)", + "public async Task UploadDataNodesToWorkspaceAsync(IDataSet dataSet)", "\n{", "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n Workspace.Initialize(x => x.FromSource(DataSource)", @@ -493,7 +472,7 @@ "\n .DisableInitialization());", "\n ", "\n Activity.Start();", - "\n var args = await GetArgsFromMainAsync(fileName);", + "\n var args = await GetArgsFromMainAsync(dataSet);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n var storage = new ParsingStorage(args, DataSource, Workspace);", @@ -501,7 +480,7 @@ "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n var errors = new List();", - "\n var importLogPortfolios = await Import.FromFile(fileName)", + "\n var importLogPortfolios = await Import.FromDataSet(dataSet)", "\n .WithType((dataset, datarow) => new InsurancePortfolio {", "\n SystemName = datarow.Field(nameof(DataNode.SystemName)),", "\n DisplayName = datarow.Field(nameof(DataNode.DisplayName)),", @@ -526,7 +505,7 @@ "\n .ExecuteAsync();", "\n ", "\n var portfolios = await Workspace.Query().ToDictionaryAsync(x => x.SystemName);", - "\n var importLogGroupOfContracts = await Import.FromFile(fileName)", + "\n var importLogGroupOfContracts = await Import.FromDataSet(dataSet)", "\n .WithType((dataset, datarow) => {", "\n var gicSystemName = datarow.Field(nameof(DataNode.SystemName));", "\n var pf = datarow.Field(nameof(InsurancePortfolio));", @@ -586,16 +565,15 @@ { "cell_type": "code", "source": [ - "public async Task UploadDataNodesAsync(string fileName)", - "\n{", - "\n var log = await UploadDataNodesToWorkspaceAsync(fileName);", + "Import.DefineFormat(ImportFormats.DataNode, async (options, dataSet) => {", + "\n var log = await UploadDataNodesToWorkspaceAsync(dataSet);", "\n var partition = (Guid)Workspace.Partition.GetCurrent(nameof(PartitionByReportingNode));", "\n await CommitToDatabase(partition);", "\n await CommitToDatabase(partition);", "\n await CommitToDatabase(partition);", "\n await CommitToDatabase(partition);", "\n return log;", - "\n}" + "\n});" ] }, { @@ -628,7 +606,7 @@ { "cell_type": "code", "source": [ - "public async Task UploadDataNodeStateToWorkspaceAsync(string fileName)", + "public async Task UploadDataNodeStateToWorkspaceAsync(IDataSet dataSet)", "\n{", "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n Workspace.Initialize(x => x.FromSource(DataSource)", @@ -639,14 +617,14 @@ "\n await Workspace.DeleteAsync(await Workspace.Query().ToArrayAsync() );", "\n ", "\n Activity.Start();", - "\n var args = await GetArgsFromMainAsync(fileName);", + "\n var args = await GetArgsFromMainAsync(dataSet);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n var storage = new ParsingStorage(args, DataSource, Workspace);", "\n await storage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", - "\n var importLog = await Import.FromFile(fileName).WithType(", + "\n var importLog = await Import.FromDataSet(dataSet).WithType(", "\n (dataset, datarow) => new DataNodeState {", "\n DataNode = datarow.Field(nameof(DataNodeState.DataNode)),", "\n State = (State)Enum.Parse(typeof(State), datarow.Field(nameof(DataNodeState.State))),", @@ -664,12 +642,11 @@ { "cell_type": "code", "source": [ - "public async Task UploadDataNodeStateAsync(string fileName)", - "\n{", - "\n var log = await UploadDataNodeStateToWorkspaceAsync(fileName);", + "Import.DefineFormat(ImportFormats.DataNodeState, async (options, dataSet) => {", + "\n var log = await UploadDataNodeStateToWorkspaceAsync(dataSet);", "\n await CommitToDatabase((Guid)Workspace.Partition.GetCurrent(nameof(PartitionByReportingNode)), snapshot: false); ", "\n return log;", - "\n}" + "\n});" ] }, { @@ -681,7 +658,7 @@ { "cell_type": "code", "source": [ - "public async Task UploadDataNodeParameterToWorkspaceAsync(string fileName, Guid targetPartitionByReportingNodeId)", + "public async Task UploadDataNodeParameterToWorkspaceAsync(IDataSet dataSet, Guid targetPartitionByReportingNodeId)", "\n{", "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n Workspace.Initialize(x => x.FromSource(DataSource)", @@ -692,7 +669,7 @@ "\n await Workspace.DeleteAsync(await Workspace.Query().ToArrayAsync() );", "\n ", "\n Activity.Start();", - "\n var args = await GetArgsFromMainAsync(fileName) with {ImportFormat = ImportFormats.DataNodeParameter};", + "\n var args = await GetArgsFromMainAsync(dataSet) with {ImportFormat = ImportFormats.DataNodeParameter};", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", "\n var storage = new ParsingStorage(args, DataSource, Workspace);", @@ -702,7 +679,7 @@ "\n var singleDataNode = new List();", "\n var interDataNode = new List<(string,string)>();", "\n ", - "\n var importLog = await Import.FromFile(fileName)", + "\n var importLog = await Import.FromDataSet(dataSet)", "\n .WithType( (dataset, datarow) => {", "\n", "\n //read and validate DataNodes", @@ -769,16 +746,15 @@ { "cell_type": "code", "source": [ - "public async Task UploadDataNodeParameterAsync(string fileName)", - "\n{", + "Import.DefineFormat(ImportFormats.DataNodeParameter, async (options, dataSet) => {", "\n Guid partitionId = new Guid();", - "\n var log = await UploadDataNodeParameterToWorkspaceAsync(fileName, partitionId);", + "\n var log = await UploadDataNodeParameterToWorkspaceAsync(dataSet, partitionId);", "\n ", "\n await CommitToDatabase(partitionId, snapshot: false);", "\n await CommitToDatabase(partitionId, snapshot: false); ", "\n ", "\n return log;", - "\n}" + "\n});" ] }, { @@ -813,7 +789,7 @@ { "cell_type": "code", "source": [ - "public async Task ParseCashflowsToWorkspaceAsync(string fileName, ImportArgs args)", + "public async Task ParseCashflowsToWorkspaceAsync(IDataSet dataSet, ImportArgs args)", "\n{", "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n Workspace.Initialize(x => x.FromSource(DataSource)", @@ -825,7 +801,7 @@ "\n await parsingStorage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", - "\n var importLog = await Import.FromFile(fileName)", + "\n var importLog = await Import.FromDataSet(dataSet)", "\n .WithType ( (dataset, datarow) => {", "\n var aocType = datarow.Field(nameof(RawVariable.AocType));", "\n var novelty = datarow.Field(nameof(RawVariable.Novelty));", @@ -881,14 +857,13 @@ { "cell_type": "code", "source": [ - "public async Task UploadCashflowsAsync(string fileName)", - "\n{", + "Import.DefineFormat(ImportFormats.Cashflow, async (options, dataSet) => {", "\n Activity.Start();", - "\n var args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Cashflow};", - "\n await DataNodeFactoryAsync(fileName, ImportFormats.Cashflow, args);", + "\n var args = (await GetArgsFromMainAsync(dataSet)) with {ImportFormat = ImportFormats.Cashflow};", + "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Cashflow, args);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", - "\n var parsingLog = await ParseCashflowsToWorkspaceAsync(fileName, args);", + "\n var parsingLog = await ParseCashflowsToWorkspaceAsync(dataSet, args);", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n var storage = new ImportStorage(args, DataSource, Workspace);", @@ -910,7 +885,7 @@ "\n filter : x => storage.DataNodesByImportScope[ImportScope.Primary].Contains(x.DataNode));", "\n", "\n return Activity.Finish().Merge(parsingLog); ", - "\n}" + "\n});" ] }, { @@ -922,7 +897,7 @@ { "cell_type": "code", "source": [ - "public async Task ParseActualsToWorkspaceAsync(string fileName, ImportArgs args)", + "public async Task ParseActualsToWorkspaceAsync(IDataSet dataSet, ImportArgs args)", "\n{", "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n Workspace.Initialize(x => x.FromSource(DataSource)", @@ -934,7 +909,7 @@ "\n await parsingStorage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", - "\n var importLog = await Import.FromFile(fileName)", + "\n var importLog = await Import.FromDataSet(dataSet)", "\n .WithType ( (dataset, datarow) => {", "\n var dataNode = datarow.Field(nameof(DataNode));", "\n if(!parsingStorage.DataNodeDataBySystemName.TryGetValue(dataNode, out var dataNodeData)) {", @@ -985,14 +960,13 @@ { "cell_type": "code", "source": [ - "public async Task UploadActualAsync(string fileName)", - "\n{", + "Import.DefineFormat(ImportFormats.Actual, async (options, dataSet) => {", "\n Activity.Start();", - "\n var args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Actual};", - "\n await DataNodeFactoryAsync(fileName, ImportFormats.Actual, args);", + "\n var args = (await GetArgsFromMainAsync(dataSet)) with {ImportFormat = ImportFormats.Actual};", + "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Actual, args);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n", - "\n var parsingLog = await ParseActualsToWorkspaceAsync(fileName, args);", + "\n var parsingLog = await ParseActualsToWorkspaceAsync(dataSet, args);", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n", "\n var storage = new ImportStorage(args, DataSource, Workspace);", @@ -1011,7 +985,7 @@ "\n storage.DataNodesByImportScope[ImportScope.Primary].Contains(x.DataNode));", "\n", "\n return Activity.Finish().Merge(parsingLog);", - "\n}" + "\n});" ] }, { @@ -1029,7 +1003,7 @@ { "cell_type": "code", "source": [ - "public async Task ParseSimpleValueToWorkspaceAsync(string fileName, ImportArgs args, Guid targetPartitionByReportingNodeAndPeriodId)", + "public async Task ParseSimpleValueToWorkspaceAsync(IDataSet dataSet, ImportArgs args, Guid targetPartitionByReportingNodeAndPeriodId)", "\n{", "\n Workspace.Reset(x => x.ResetInitializationRules().ResetCurrentPartitions());", "\n Workspace.Initialize(x => x.FromSource(DataSource)", @@ -1042,7 +1016,7 @@ "\n await parsingStorage.InitializeAsync();", "\n if(Activity.HasErrors()) return Activity.Finish(); ", "\n", - "\n var importLog = await Import.FromFile(fileName)", + "\n var importLog = await Import.FromDataSet(dataSet)", "\n .WithType ( (dataset, datarow) => {", "\n var dataNode = parsingStorage.ValidateDataNode(datarow.Field(nameof(DataNode)));", "\n var amountType = parsingStorage.ValidateAmountType(datarow.Field(nameof(IfrsVariable.AmountType)));", @@ -1101,15 +1075,14 @@ { "cell_type": "code", "source": [ - "public async Task UploadSimpleValueAsync(string fileName)", - "\n{", + "Import.DefineFormat(ImportFormats.SimpleValue, async (options, dataSet) => {", "\n Activity.Start();", - "\n var args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.SimpleValue};", - "\n await DataNodeFactoryAsync(fileName, ImportFormats.SimpleValue, args);", + "\n var args = (await GetArgsFromMainAsync(dataSet)) with {ImportFormat = ImportFormats.SimpleValue};", + "\n await DataNodeFactoryAsync(dataSet, ImportFormats.SimpleValue, args);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n Guid partitionId = new Guid();", - "\n var parsingLog = await ParseSimpleValueToWorkspaceAsync(fileName, args, partitionId);", + "\n var parsingLog = await ParseSimpleValueToWorkspaceAsync(dataSet, args, partitionId);", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n Workspace.Query().Select(v => new {v.DataNode, v.AccidentYear}).Distinct();", @@ -1119,7 +1092,7 @@ "\n filter : x => Workspace.Query().Select(v => v.DataNode).Distinct().Contains(x.DataNode));", "\n ", "\n return Activity.Finish().Merge(parsingLog);", - "\n}" + "\n});" ] }, { @@ -1131,15 +1104,14 @@ { "cell_type": "code", "source": [ - "public async Task UploadOpeningAsync(string fileName)", - "\n{", + "Import.DefineFormat(ImportFormats.Opening, async (options, dataSet) => {", "\n Activity.Start();", - "\n var args = (await GetArgsFromMainAsync(fileName)) with {ImportFormat = ImportFormats.Opening};", - "\n await DataNodeFactoryAsync(fileName, ImportFormats.Opening, args);", + "\n var args = (await GetArgsFromMainAsync(dataSet)) with {ImportFormat = ImportFormats.Opening};", + "\n await DataNodeFactoryAsync(dataSet, ImportFormats.Opening, args);", "\n if(Activity.HasErrors()) return Activity.Finish();", "\n ", "\n Guid partitionId = new Guid();", - "\n var parsingLog = await ParseSimpleValueToWorkspaceAsync(fileName, args, partitionId);", + "\n var parsingLog = await ParseSimpleValueToWorkspaceAsync(dataSet, args, partitionId);", "\n if(parsingLog.Errors.Any()) return Activity.Finish().Merge(parsingLog);", "\n ", "\n var storage = new ImportStorage(args, DataSource, Workspace);", @@ -1158,7 +1130,7 @@ "\n storage.DataNodesByImportScope[ImportScope.Primary].Contains(x.DataNode ));", "\n", "\n return Activity.Finish().Merge(parsingLog);", - "\n}" + "\n});" ] }, { diff --git a/ifrs17/Report/ReportConfigurationAndUtils.ipynb b/ifrs17/Report/ReportConfigurationAndUtils.ipynb index 39128784..e380125c 100644 --- a/ifrs17/Report/ReportConfigurationAndUtils.ipynb +++ b/ifrs17/Report/ReportConfigurationAndUtils.ipynb @@ -102,7 +102,6 @@ "source": [ "public static async Task> QueryReportVariablesAsync(this IWorkspace workspace, (int Year, int Month, string ReportingNode, string Scenario) args ) {", "\n ", - "\n await workspace.Partition.SetAsync(new { ReportingNode = args.ReportingNode, Scenario = args.Scenario });", "\n await workspace.Partition.SetAsync(new { ReportingNode = args.ReportingNode, Scenario = args.Scenario, Year = args.Year, Month = args.Month });", "\n ", "\n return await workspace.Query()", @@ -146,6 +145,12 @@ "\n .ToArrayAsync();", "\n}" ] + }, + { + "cell_type": "code", + "source": [ + "" + ] } ] } \ No newline at end of file diff --git a/ifrs17/Report/ReportMutableScopes.ipynb b/ifrs17/Report/ReportMutableScopes.ipynb new file mode 100644 index 00000000..2cd03b41 --- /dev/null +++ b/ifrs17/Report/ReportMutableScopes.ipynb @@ -0,0 +1,311 @@ +{ + "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

" + ] + }, + { + "cell_type": "markdown", + "source": [ + "This notebook contains the set up of mutable scopes used to achieve high interactivity with reports." + ] + }, + { + "cell_type": "markdown", + "source": [ + "# References", + "\nLibraries and other notebooks which are needed for this notebook are imported below." + ] + }, + { + "cell_type": "code", + "source": [ + "#!import \"ReportScopes\"" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Mutable Scope" + ] + }, + { + "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)" + ] + }, + { + "cell_type": "code", + "source": [ + "public interface ReportUniverse : IMutableScopeWithStorage{}" + ] + }, + { + "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; }", + "\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 IEnumerable RowSlices { get; set; }", + "\n protected string[] defaultRowSlices => new string[] { };", + "\n protected string[] rowSlices => RowSlices is null ? defaultRowSlices : defaultRowSlices.Concat(RowSlices).ToArray();", + "\n", + "\n IEnumerable ColumnSlices { get; set; }", + "\n protected string[] defaultColumnSlices => new string[] { };", + "\n protected string[] columnSlices => ColumnSlices is null ? defaultColumnSlices : defaultColumnSlices.Where(cs => !ColumnSlices.Contains(cs)).Concat(ColumnSlices).ToArray(); //I can't put a slice before defaultSlices !!!", + "\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 ", + "\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 public IDataCube GetDataCube() => default;", + "\n protected int headerColumnWidthValue => 250;", + "\n private async Task GetReportTaskAsync() {", + "\n await GetStorage().InitializeAsync(ReportingPeriod, ReportingNode, Scenario, CurrencyType);", + "\n ", + "\n return report.ForDataCube(GetDataCube())", + "\n .WithQuerySource(workspace)", + "\n .SliceRowsBy(rowSlices)", + "\n .SliceColumnsBy(columnSlices)", + "\n .ReportGridOptions(headerColumnWidth: headerColumnWidthValue)", + "\n .ToReport();", + "\n }", + "\n", + "\n Task ToReportAsync => GetReportTaskAsync();", + "\n}", + "\n", + "\npublic interface PvReport : IIfrs17Report {", + "\n string[] IIfrs17Report.defaultRowSlices => new string[] { \"Novelty\", \"VariableType\" };", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType), \"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.defaultRowSlices => new string[] { \"Novelty\", \"VariableType\" };", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType), \"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.defaultRowSlices => new string[] {\"AmountType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType), \"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[] { CurrencyGrouper(CurrencyType), \"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[] { CurrencyGrouper(CurrencyType), \"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[] { CurrencyGrouper(CurrencyType), \"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[] { CurrencyGrouper(CurrencyType), \"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.defaultRowSlices => new string[] {\"Novelty\", \"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType) };", + "\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.defaultRowSlices => new string[] {\"Novelty\", \"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType), \"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.defaultRowSlices => new string[] {\"Novelty\",\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType), \"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.defaultRowSlices => new string[] {\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType), \"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.defaultRowSlices => new string[] {\"Novelty\",\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType), \"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.defaultRowSlices => new string[] {\"VariableType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType), \"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.defaultRowSlices => new string[] {\"VariableType\", \"EstimateType\"};", + "\n string[] IIfrs17Report.defaultColumnSlices => new string[] { CurrencyGrouper(CurrencyType),\"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}" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# IFRS 17 Reports" + ] + }, + { + "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." + ] + }, + { + "cell_type": "code", + "source": [ + "public class Ifrs17Reports ", + "\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 Ifrs17Reports (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(nameof(PvReport));", + "\n public IIfrs17Report RiskAdjustments => reportUniverse.GetScope(nameof(RaReport));", + "\n public IIfrs17Report WrittenActuals => reportUniverse.GetScope(nameof(WrittenReport));", + "\n public IIfrs17Report AccrualActuals => reportUniverse.GetScope(nameof(AccrualReport));", + "\n public IIfrs17Report DeferralActuals => reportUniverse.GetScope(nameof(DeferralReport));", + "\n public IIfrs17Report FulfillmentCashflows => reportUniverse.GetScope(nameof(FcfReport));", + "\n public IIfrs17Report ExperienceAdjustments => reportUniverse.GetScope(nameof(ExpAdjReport));", + "\n public IIfrs17Report TechnicalMargins => reportUniverse.GetScope(nameof(TmReport));", + "\n public IIfrs17Report AllocatedTechnicalMargins => reportUniverse.GetScope(nameof(CsmReport));", + "\n public IIfrs17Report ActuarialLrc => reportUniverse.GetScope(nameof(ActLrcReport));", + "\n public IIfrs17Report Lrc => reportUniverse.GetScope(nameof(LrcReport));", + "\n public IIfrs17Report ActuarialLic => reportUniverse.GetScope(nameof(ActLicReport));", + "\n public IIfrs17Report Lic => reportUniverse.GetScope(nameof(LicReport));", + "\n public IIfrs17Report FinancialPerformance => reportUniverse.GetScope(nameof(FpReport));", + "\n}" + ] + }, + { + "cell_type": "code", + "source": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/ifrs17/Report/ReportScopes.ipynb b/ifrs17/Report/ReportScopes.ipynb index d9344d3c..b6fd584d 100644 --- a/ifrs17/Report/ReportScopes.ipynb +++ b/ifrs17/Report/ReportScopes.ipynb @@ -21,9 +21,13 @@ "cell_type": "markdown", "source": [ "", - "\n

Report Scopes (IFRS17 Methodology Business Logic)

", - "\n", - "\nThis notebook contains the logic used to perform calculations upon reporting of data." + "\n

Report Scopes (IFRS17 Methodology Business Logic)

" + ] + }, + { + "cell_type": "markdown", + "source": [ + "This notebook contains the logic used to perform calculations upon reporting of data." ] }, { @@ -375,7 +379,8 @@ { "cell_type": "markdown", "source": [ - "## LIC (Liability for Incurred Claims)", + "", + "\n## LIC (Liability for Incurred Claims)", "\n", "\nLiability of Incurred Claims (LIC) report includes the contributions from [Lic Actuarial](#lic-actuarial) (Fullfilment Cashflow), [Advance](#written-accrual-deferral) Actual, and [Overdue](#written-accrual-deferral) Actual." ] @@ -423,7 +428,8 @@ { "cell_type": "markdown", "source": [ - "## LRC (Liability for Remaining Coverage)", + "", + "\n## LRC (Liability for Remaining Coverage)", "\n", "\nLiability for Remaining Coverage (LRC) report includes all the contributions from [LRC Actuarial](#lrc-actuarial) (Fulfillment Cashflow, Contructual Sevice Margin, Loss Component, Loss Recovery Component) and, [Advance](#written-accrual-deferral) Actual, and [Overdue](#written-accrual-deferral) Actual." ] diff --git a/ifrs17/Utils/ApplicationMessage.ipynb b/ifrs17/Utils/ApplicationMessage.ipynb index f2253bd6..e55e688c 100644 --- a/ifrs17/Utils/ApplicationMessage.ipynb +++ b/ifrs17/Utils/ApplicationMessage.ipynb @@ -27,7 +27,7 @@ { "cell_type": "code", "source": [ - "#r \"nuget:Systemorph.Activities,1.5.1\"" + "#r \"nuget:Systemorph.Activities,1.5.5\"" ] }, {