Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
corr tariff interfaces & calculators
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfliegner committed Apr 5, 2023
1 parent 61f6b7c commit 97a4e7b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
14 changes: 13 additions & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions src/DDL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/InsuranceContracts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
10 changes: 4 additions & 6 deletions src/InsuranceTariffs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/LifeInsuranceDataModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 97a4e7b

Please sign in to comment.