This repository has been archived by the owner on Aug 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestAPI.jl
309 lines (251 loc) · 8.73 KB
/
testAPI.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
using BitemporalPostgres
using LifeInsuranceDataModel, LifeInsuranceProduct
using SearchLight
using TimeZones
SearchLight.Configuration.load() |> SearchLight.connect
SearchLight.query("DROP SCHEMA public CASCADE")
SearchLight.query("CREATE SCHEMA public")
LifeInsuranceDataModel.load_model()
# Creating Tariffs
using LifeInsuranceDataModel, LifeInsuranceProduct, SearchLight
import SearchLight: Serializer.serialize
tif = get_tariff_interface(1)
ProfitParticipationTariff = create_tariff("Profit participation", 1, serialize(tif.parameters), serialize(tif.contract_attributes))
tif = get_tariff_interface(2)
PensionTariff = create_tariff("Pension Insurance", 2, serialize(tif.parameters), serialize(tif.contract_attributes))
tif = get_tariff_interface(3)
SingleLifeRiskTariff = create_tariff("Single Life Risk Insurance", 3, serialize(tif.parameters), serialize(tif.contract_attributes))
tif = get_tariff_interface(4)
JointLifeRiskTariff = create_tariff("Joint Life Risk Insurance", 4, serialize(tif.parameters), serialize(tif.contract_attributes), [1, 2])
cpRole = Dict{String,Int64}()
map(find(LifeInsuranceDataModel.ContractPartnerRole)) do entry
cpRole[entry.value] = entry.id.value
end
tiprRole = Dict{String,Int64}()
map(find(LifeInsuranceDataModel.TariffItemPartnerRole)) do entry
tiprRole[entry.value] = entry.id.value
end
titrRole = Dict{String,Int64}()
map(find(LifeInsuranceDataModel.TariffItemRole)) do entry
titrRole[entry.value] = entry.id.value
end
ppRole = Dict{String,Int64}()
map(find(LifeInsuranceDataModel.ProductPartRole)) do entry
ppRole[entry.value] = entry.id.value
end
# Pension Insurance Product
pensionInsurance = Product()
pr = ProductRevision(description="Pension", interface_id=1)
pp = ProductPart()
ppr = ProductPartRevision(
ref_tariff=PensionTariff,
ref_role=ppRole["Main Coverage - Life"],
description="Main Coverage - Life",
)
pp2 = ProductPart()
ppr2 = ProductPartRevision(
ref_tariff=ProfitParticipationTariff,
ref_role=ppRole["Profit participation"],
description="Profit participation Life Risk",
)
w0 = Workflow(
type_of_entity="Product",
tsw_validfrom=ZonedDateTime(2000, 1, 1, 0, 0, 0, 0, tz"UTC"),
)
create_entity!(w0)
create_component!(pensionInsurance, pr, w0)
create_subcomponent!(pensionInsurance, pp, ppr, w0)
create_subcomponent!(pensionInsurance, pp2, ppr2, w0)
commit_workflow!(w0)
# Single Life Risk Insurance Product
singlelifeRiskInsurance = Product()
pr = ProductRevision(description="Single Life Risk", interface_id=2)
pp = ProductPart()
ppr = ProductPartRevision(
ref_tariff=SingleLifeRiskTariff,
ref_role=ppRole["Main Coverage - Life"],
description="Main Coverage - Life",
)
pp2 = ProductPart()
ppr2 = ProductPartRevision(
ref_tariff=ProfitParticipationTariff,
ref_role=ppRole["Profit participation"],
description="Profit participation Life Risk",
)
w0 = Workflow(
type_of_entity="Product",
tsw_validfrom=ZonedDateTime(2000, 1, 1, 0, 0, 0, 0, tz"UTC"),
)
create_entity!(w0)
create_component!(singlelifeRiskInsurance, pr, w0)
create_subcomponent!(singlelifeRiskInsurance, pp, ppr, w0)
create_subcomponent!(singlelifeRiskInsurance, pp2, ppr2, w0)
commit_workflow!(w0)
# A Joint Life Risk Insurance Product
jointlifeRiskInsurance = Product()
pr = ProductRevision(description="Joint Life Risk", interface_id=3)
pp = ProductPart()
ppr = ProductPartRevision(
ref_tariff=JointLifeRiskTariff,
ref_role=ppRole["Main Coverage - Life"],
description="Main Coverage - Life",
)
pp2 = ProductPart()
ppr2 = ProductPartRevision(
ref_tariff=ProfitParticipationTariff,
ref_role=ppRole["Profit participation"],
description="Profit participation Life Risk",
)
w0 = Workflow(
type_of_entity="Product",
tsw_validfrom=ZonedDateTime(2000, 1, 1, 0, 0, 0, 0, tz"UTC"),
)
create_entity!(w0)
create_component!(jointlifeRiskInsurance, pr, w0)
create_subcomponent!(jointlifeRiskInsurance, pp, ppr, w0)
create_subcomponent!(jointlifeRiskInsurance, pp2, ppr2, w0)
commit_workflow!(w0)
prs = prsection(1, now(tz"UTC"), ZonedDateTime(2023, 4, 1, 21, 0, 1, 1, tz"UTC"), 0)
rolesTariffItemPartner = load_role(TariffItemPartnerRole)
# create partner woman1 nonsmoker
woman1 = LifeInsuranceDataModel.Partner()
pr = LifeInsuranceDataModel.PartnerRevision(description="woman 1", sex="f", smoker=false)
w = Workflow(type_of_entity="Partner",
tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC"),
)
create_entity!(w)
create_component!(woman1, pr, w)
commit_workflow!(w)
# create partner woman2 smoker
woman2 = LifeInsuranceDataModel.Partner()
pr = LifeInsuranceDataModel.PartnerRevision(description="woman 2", sex="f", smoker=true)
w = Workflow(type_of_entity="Partner",
tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC"),
)
create_entity!(w)
create_component!(woman2, pr, w)
commit_workflow!(w)
# create partner man1 nonsmoker
man1 = LifeInsuranceDataModel.Partner()
pr = LifeInsuranceDataModel.PartnerRevision(description="man 1", sex="m", smoker=false)
w = Workflow(type_of_entity="Partner",
tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC"),
)
create_entity!(w)
create_component!(man1, pr, w)
commit_workflow!(w)
man1
# create partner man2 smoker
man2 = LifeInsuranceDataModel.Partner()
pr = LifeInsuranceDataModel.PartnerRevision(description="man 2", sex="m", smoker=true)
w = Workflow(type_of_entity="Partner",
tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC"),
)
create_entity!(w)
create_component!(man2, pr, w)
commit_workflow!(w)
# Contract woman nonsmoker pension
w1 = Workflow(
type_of_entity="Contract",
tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC"),
)
create_entity!(w1)
c = Contract()
cr = ContractRevision(description="contract creation properties")
create_component!(c, cr, w1)
cpr = ContractPartnerRef(ref_super=c.id)
cprr = ContractPartnerRefRevision(
ref_partner=woman1.id,
ref_role=cpRole["Policy Holder"],
description="policiyholder ref properties",
)
create_subcomponent!(c, cpr, cprr, w1)
# pi 1
PartnerRole = tiprRole["Insured Person"]
PartnerroleMap = Dict{Integer,PartnerSection}()
PartnerroleMap[PartnerRole] = psection(woman1.id.value, now(tz"UTC"), w1.tsw_validfrom, 0)
cpi = ProductItem(ref_super=c.id)
cpir = ProductItemRevision(
ref_product=pensionInsurance.id,
description="from contract creation",
)
create_subcomponent!(c, cpi, cpir, w1)
LifeInsuranceDataModel.create_product_instance(
w1,
cpi,
pensionInsurance.id.value,
PartnerroleMap
)
commit_workflow!(w1)
# Contract man smoker woman nonsmoker joint life
w1 = Workflow(
type_of_entity="Contract",
tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC"),
)
create_entity!(w1)
c = Contract()
cr = ContractRevision(description="contract creation properties")
create_component!(c, cr, w1)
cpr = ContractPartnerRef(ref_super=c.id)
cprr = ContractPartnerRefRevision(
ref_partner=woman2.id,
ref_role=cpRole["Policy Holder"],
description="policyholder ref properties",
)
create_subcomponent!(c, cpr, cprr, w1)
# pi 1
PartnerroleMap = Dict{Integer,PartnerSection}()
PartnerRole = tiprRole["Insured Person"]
PartnerroleMap[PartnerRole] = psection(woman1.id.value, now(tz"UTC"), w1.tsw_validfrom, 0)
PartnerRole = tiprRole["2nd Insured Person"]
PartnerroleMap[PartnerRole] = psection(man1.id.value, now(tz"UTC"), w1.tsw_validfrom, 0)
cpi = ProductItem(ref_super=c.id)
cpir = ProductItemRevision(
ref_product=jointlifeRiskInsurance.id.value,
description="from contract creation",
)
create_subcomponent!(c, cpi, cpir, w1)
LifeInsuranceDataModel.create_product_instance(
w1,
cpi,
jointlifeRiskInsurance.id.value,
PartnerroleMap,
)
commit_workflow!(w1)
# contract man smoker single life risk
w1 = Workflow(
type_of_entity="Contract",
tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC"),
)
create_entity!(w1)
c = Contract()
cr = ContractRevision(description="contract creation properties")
create_component!(c, cr, w1)
cpr = ContractPartnerRef(ref_super=c.id)
cprr = ContractPartnerRefRevision(
ref_partner=man2.id,
ref_role=cpRole["Policy Holder"],
description="policiyholder ref properties",
)
create_subcomponent!(c, cpr, cprr, w1)
# pi 1
PartnerRole = tiprRole["Insured Person"]
PartnerroleMap = Dict{Integer,PartnerSection}()
PartnerroleMap[PartnerRole] = psection(man2.id.value, now(tz"UTC"), w1.tsw_validfrom, 0)
cpi = ProductItem(ref_super=c.id)
cpir = ProductItemRevision(
ref_product=singlelifeRiskInsurance.id,
description="from contract creation",
)
create_subcomponent!(c, cpi, cpir, w1)
LifeInsuranceDataModel.create_product_instance(
w1,
cpi,
singlelifeRiskInsurance.id.value,
PartnerroleMap
)
commit_workflow!(w1)
include("testCalcPEN.jl")
include("testCalcSLR.jl")
include("testCalcJLR.jl")
include("testValidate.jl")