From 97a4e7b4fc18179cfc4a612f5a3323104c2d1b82 Mon Sep 17 00:00:00 2001 From: michaelfliegner Date: Wed, 5 Apr 2023 18:58:40 +0200 Subject: [PATCH] corr tariff interfaces & calculators --- Manifest.toml | 14 +++++++++++++- Project.toml | 1 + src/DDL.jl | 4 +--- src/InsuranceContracts.jl | 2 +- src/InsuranceTariffs.jl | 10 ++++------ src/LifeInsuranceDataModel.jl | 10 +++++----- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index 254cedc..a3124bb 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -2,7 +2,7 @@ julia_version = "1.8.2" manifest_format = "2.0" -project_hash = "e0c2fdcaf25efdae016cbb3abaec66081ee08149" +project_hash = "e0fd419df8a0accf902eeff713836a935c69f767" [[deps.AbstractTrees]] git-tree-sha1 = "faa260e4cb5aba097a73fab382dd4b5819d8ec8c" @@ -360,6 +360,12 @@ version = "0.7.5" uuid = "14a3606d-f60d-562e-9121-12d972cd8159" version = "2022.2.1" +[[deps.NBInclude]] +deps = ["JSON", "Markdown", "SoftGlobalScope"] +git-tree-sha1 = "ae1ca609f7a3eb019412e8bee12663e48188f1a9" +uuid = "0db19996-df87-5ea3-a455-e3a50d440464" +version = "2.3.0" + [[deps.NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" version = "1.2.0" @@ -500,6 +506,12 @@ version = "1.0.3" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" +[[deps.SoftGlobalScope]] +deps = ["REPL"] +git-tree-sha1 = "986ec2b6162ccb95de5892ed17832f95badf770c" +uuid = "b85f4697-e234-5449-a836-ec8e2f98b302" +version = "1.1.0" + [[deps.SortingAlgorithms]] deps = ["DataStructures"] git-tree-sha1 = "a4ada03f999bd01b3a25dcaa30b2d929fe537e00" diff --git a/Project.toml b/Project.toml index 3359b99..06c50fc 100644 --- a/Project.toml +++ b/Project.toml @@ -13,6 +13,7 @@ Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" LibPQ = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" +NBInclude = "0db19996-df87-5ea3-a455-e3a50d440464" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" SearchLight = "340e8cb6-72eb-11e8-37ce-c97ebeb32050" diff --git a/src/DDL.jl b/src/DDL.jl index c3bc8b2..5bf2a71 100644 --- a/src/DDL.jl +++ b/src/DDL.jl @@ -105,8 +105,6 @@ function up() column(:ref_valid, :int8range) column(:description, :string) column(:interface_id, :bigint) - column(:mortality_table, :string) - column(:interest_rate, :float) column(:parameters, :string) column(:contract_attributes, :string)] end @@ -314,7 +312,7 @@ function up() column(:ref_valid, :int8range) column(:description, :string) column(:ref_tariff, :bigint, "REFERENCES tariffs(id) ON DELETE CASCADE") - column(:parameters, :string) + column(:contract_attributes, :string) ] end diff --git a/src/InsuranceContracts.jl b/src/InsuranceContracts.jl index 1ddccf8..4c0206f 100644 --- a/src/InsuranceContracts.jl +++ b/src/InsuranceContracts.jl @@ -217,7 +217,7 @@ TariffItemRevision ref_invalidfrom::DbId = InfinityKey description::String = "" ref_tariff::DbId = DbId() - parameters::String = "" + contract_attributes::String = "{}" end """ BitemporalPostgres.get_typeof_revision(component::TariffItem) :: Type{TariffItemRevision} diff --git a/src/InsuranceTariffs.jl b/src/InsuranceTariffs.jl index f83836b..2fa073d 100644 --- a/src/InsuranceTariffs.jl +++ b/src/InsuranceTariffs.jl @@ -30,18 +30,16 @@ Tariff_Revision ref_invalidfrom::DbId = InfinityKey description::String = "" interface_id::Integer = 0 - parameters::String = "" - contract_attributes::String = "" - mortality_table::String = "description=src.description," - interest_rate::Float64 = 0.0 + parameters::String = "{}" + contract_attributes::String = "{}" end Base.copy(src::TariffRevision) = TariffRevision( ref_component=src.ref_component, interface_id=src.interface_id, - mortality_table=src.mortality_table, description=src.description, - parameters=src.parameters) + parameters=src.parameters, + contract_attributes=src.contract_attributes) # """ TariffPartnerRole diff --git a/src/LifeInsuranceDataModel.jl b/src/LifeInsuranceDataModel.jl index 9f44698..e485862 100644 --- a/src/LifeInsuranceDataModel.jl +++ b/src/LifeInsuranceDataModel.jl @@ -185,7 +185,7 @@ function create_product_instance(wf::Workflow, pi::ProductItem, p::Integer, part println(ppr.description) tr = find(TariffRevision, SQLWhereExpression("ref_component=?", ppr.ref_tariff))[1] ti = TariffItem(ref_super=pi.id) - tir = TariffItemRevision(ref_role=ppr.ref_role, ref_tariff=ppr.ref_tariff, description=ppr.description, parameters=tr.parameters) + tir = TariffItemRevision(ref_role=ppr.ref_role, ref_tariff=ppr.ref_tariff, description=ppr.description, contract_attributes=tr.contract_attributes) create_subcomponent!(pi, ti, tir, wf) for role in keys(partnerrolemap) tip = TariffItemPartnerRef(ref_super=ti.id) @@ -221,7 +221,7 @@ function pisection(history_id::Integer, version_id::Integer, tsdb_validfrom, tsw end end)) - ca = JSON.parse(trr.parameters) + ca = JSON.parse(trr.contract_attributes) TariffItemSection(tariff_ref=TariffItemTariffReference(trr, ts), partner_refs=pitrprrs, contract_attributes=ca) end end @@ -364,15 +364,15 @@ function get_products() end """ -create_tariff(dsc::String, interface::Integer, i::Float64, parameters::String, contract_attributes::String, tariffpartnerroles::Vector{Int}=[1]) +create_tariff(dsc::String, interface::Integer, parameters::String, contract_attributes::String, tariffpartnerroles::Vector{Int}=[1]) create a tariff, default partnerroles :[1] """ -function create_tariff(dsc::String, interface::Integer, i::Float64, parameters::String, contract_attributes::String, tariffpartnerroles::Vector{Int}=[1]) +function create_tariff(dsc::String, interface::Integer, parameters::String, contract_attributes::String, tariffpartnerroles::Vector{Int}=[1]) t = LifeInsuranceDataModel.Tariff() - tr = LifeInsuranceDataModel.TariffRevision(description=dsc, interface_id=interface, interest_rate=i, parameters=parameters, contract_attributes=contract_attributes) + tr = LifeInsuranceDataModel.TariffRevision(description=dsc, interface_id=interface, parameters=parameters, contract_attributes=contract_attributes) w = Workflow( type_of_entity="Tariff", tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC"),