aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/Constraints/CaseA_1.ocl
diff options
context:
space:
mode:
authorLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2020-04-26 18:23:13 -0400
committerLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2020-04-26 18:23:13 -0400
commitc0a758eedd457a5d8eb9f1a6c17fc24143aabb3e (patch)
tree0c2e212e4e95c1d2311629128641d5cd561210f3 /Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/Constraints/CaseA_1.ocl
parentMerge branch 'Attribute-Solver' (diff)
downloadVIATRA-Generator-c0a758eedd457a5d8eb9f1a6c17fc24143aabb3e.tar.gz
VIATRA-Generator-c0a758eedd457a5d8eb9f1a6c17fc24143aabb3e.tar.zst
VIATRA-Generator-c0a758eedd457a5d8eb9f1a6c17fc24143aabb3e.zip
Add PLEDGE case study files
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/Constraints/CaseA_1.ocl')
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/Constraints/CaseA_1.ocl281
1 files changed, 281 insertions, 0 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/Constraints/CaseA_1.ocl b/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/Constraints/CaseA_1.ocl
new file mode 100644
index 00000000..0dd083b5
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/Constraints/CaseA_1.ocl
@@ -0,0 +1,281 @@
1import 'file:/Users/Aren Babikian/git/VIATRA-Attributes/original.PLEDGE.case.studies/model/CD_Case_A.uml'
2--e.g., import 'file:/Users/User_X/CD_Case_A.uml'
3
4package Taxation
5
6
7context External_Allowance inv inv1:
8let currentYear: Integer = 2018 in
9let origin: Physical_Person = self.reciver in
10let union:Legal_Union_Record=origin.getLegalUnionRecord(currentYear) in
11let house: Household = if(not union.oclIsUndefined()) then union.household else invalid endif in
12let children:Set(Dependent)= house.children->select(d:Dependent| d.allowances->select(ext| ext.reciver=origin)->size()>0) in
13let eligible_children:Set(Dependent) = children->select( birth_year >=currentYear - 6) in
14let is_disabled:Boolean = self.person.disability_type<>Disability_Types::NONE and self.person.disability_percentage>0.5 in
15let age5:Integer = currentYear - self.person.birth_year in
16let base:Real = if(age5>6 and eligible_children->size()<=1) then 185.60 else if(age5>6 and eligible_children->size()=2) then 220.36 else if(age5>6 and eligible_children->size()=2) then 267.59 else 361.83 endif endif endif in
17
18if(age5<=6) then self.amount = 580
19else
20if(age5>=6 and age5<=11)then
21self.amount = ((base.toString().toReal() + 16.17).round())
22 else
23 self.amount = base.round()
24 endif endif
25
26context Tax_Card inv inv2:
27let classe: Tax_Class_Category = self.income.taxPayer.getTaxClass(2018) in
28let amount:Real = self.income.income_per_year() in
29
30if(income.income_type.oclIsTypeOf(Employment_Income)) then
31let a:Real = if(classe=Tax_Class_Category::One_A) then self.income.taxPayer.from_law.get_A_for_salary_class_1A(amount) else if(classe=Tax_Class_Category::Two) then self.income.taxPayer.from_law.get_A_for_salary_class_2(amount) else self.income.taxPayer.from_law.get_A_for_salary_class_1(amount) endif endif in
32let b:Real = if(classe=Tax_Class_Category::One_A) then self.income.taxPayer.from_law.get_B_for_salary_class_1A(amount) else if(classe=Tax_Class_Category::Two) then self.income.taxPayer.from_law.get_B_for_salary_class_2(amount) else self.income.taxPayer.from_law.get_B_for_salary_class_1(amount) endif endif in
33 let res:Real = self.income.taxPayer.from_law.round_ten_cent(a * amount - b) in
34 let max:Real = if(classe=Tax_Class_Category::Two) then 25085 else 12585 endif in
35
36 if(amount<max) then
37 let final_res:Real= self.income.taxPayer.from_law.round_ten_cent(res*1.07) in
38 self.income.taxPayer.taxesDue = final_res.max(100000)
39 else
40 let adjustement:Real= if(classe=Tax_Class_Category::One_A) then 81.906 else if(classe=Tax_Class_Category::Two) then 165.74 else 82.87 endif endif in
41 let final_res:Real= self.income.taxPayer.from_law.round_ten_cent(res + (res*0.09-adjustement)) in
42 self.income.taxPayer.taxesDue = final_res.max(100000)
43 endif
44
45else
46if(income.income_type.oclIsTypeOf(Pensions_and_Annuities_Income)) then
47let a:Real = if(classe=Tax_Class_Category::One_A) then self.income.taxPayer.from_law.get_A_for_pension_class_1A(amount) else if(classe=Tax_Class_Category::Two) then self.income.taxPayer.from_law.get_A_for_pension_class_2(amount) else self.income.taxPayer.from_law.get_A_for_pension_class_1(amount) endif endif in
48let b:Real = if(classe=Tax_Class_Category::One_A) then self.income.taxPayer.from_law.get_B_for_pension_class_1A(amount) else if(classe=Tax_Class_Category::Two) then self.income.taxPayer.from_law.get_B_for_pension_class_2(amount) else self.income.taxPayer.from_law.get_B_for_pension_class_1(amount) endif endif in
49 let res:Real = self.income.taxPayer.from_law.round_ten_cent(a * amount - b) in
50 let max:Real = if(classe=Tax_Class_Category::Two) then 25065 else 12565 endif in
51
52 if(amount<max) then
53 let final_res:Real= self.income.taxPayer.from_law.round_ten_cent(res*1.07) in
54 self.income.taxPayer.taxesDue = final_res.max(100000)
55 else
56 let adjustement:Real= if(classe=Tax_Class_Category::One_A) then 81.906 else if(classe=Tax_Class_Category::Two) then 165.74 else 82.87 endif endif in
57 let final_res:Real= self.income.taxPayer.from_law.round_ten_cent(res + (res*0.09-adjustement)) in
58 self.income.taxPayer.taxesDue = final_res.max(100000)
59 endif
60else
61self.income.taxPayer.taxesDue = -1
62endif
63endif
64
65
66context Dependent inv inv3:
67if((self.getAge(2018) <=21) or (self.continued_studies = true)) then
68self.allowances->size()=1
69else
70self.allowances->size()=0
71endif
72
73context Income inv inv5:
74if(not self.income_type.oclIsTypeOf(Employment_Income)) then
75self.details->forAll(d|d.worked_days = 0)
76else
77self.details->forAll(d|d.worked_days >= 1 and d.worked_days<=25)
78endif
79
80context Tax_Payer inv inv6:
81let val:Integer = self.getAge(2018) - 16 in
82self.dependents->forAll( d:Dependent| d.getAge(2018) > val)
83
84context Income inv inv7:
85let val:Real =self.details->asOrderedSet()->first().distance in
86self.details->forAll(d: Income_Detail|d.distance = val)
87
88--context Income inv user_complete_details:
89--self.details->forAll(d: Income_Detail|d.month = self.details->asOrderedSet()->indexOf(d))
90
91context Income inv inv8:
92if(not self.income_type.oclIsTypeOf(Employment_Income)) then
93self.details->forAll(d| d.distance = 0)
94else
95self.details->forAll(d| d.distance >= 0.0 and d.distance <= 100)
96endif
97
98--context Income inv inv9:
99--if(self.income_type.oclIsTypeOf(Pensions_and_Annuities_Income)) then
100--self.details->forAll(d| not d.is_contributing_pension)
101--else
102--self.details->forAll(d| d.is_contributing_pension)
103--endif
104
105context Income inv inv10:
106let val:Real =self.details->asOrderedSet()->first().amount in
107self.details->forAll(d: Income_Detail|d.amount = val)
108
109
110
111context Expense inv inv11:
112let max:Real = if((self.income.income_amount / 2)>50) then self.income.income_amount / 2 else 50 endif in
113self.declared_amount >= 50 and self.declared_amount <= max
114
115context Tax_Payer inv inv12:
116 self.addresses->exists( hab_add:Address | hab_add.oclIsTypeOf(Habitual_Address) = true and hab_add.country<>Country::ZZ) and
117 self.incomes->exists(inc | inc.oclIsTypeOf(Local_Income) = true)
118 implies
119 self.oclIsTypeOf(Non_Resident_Tax_Payer)
120
121context Tax_Payer inv inv13:
122 self.addresses->exists( hab_add:Address | hab_add.oclIsTypeOf(Habitual_Address) = true and hab_add.country=Country::ZZ)
123implies
124 self.oclIsTypeOf(Resident_Tax_Payer)
125
126--context Tax_Payer inv inv14:
127--self.dependents->size() >= 0 and self.dependents->size()<= 6
128
129context External_Allowance inv inv15:
130let child:Dependent = self.person in
131let h:Household = Household.allInstances()->select(children->includes(child))->asOrderedSet()->first() in
132let t1:Set(Physical_Person) = Set{h.parents.individual_A,h.parents.individual_B}->select(oclIsKindOf(Tax_Payer)) in
133if(t1->size()=1) then
134self.reciver = t1->asOrderedSet()->first()
135else
136self.reciver = t1->asOrderedSet()->at(2) or self.reciver = t1->asOrderedSet()->at(1)
137endif
138
139context Tax_Card inv inv16:
140if(self.income.taxPayer.incomes->size()=1) then
141self.tax_card_type=Tax_Card_Type::Principal
142else
143let all_incomes:OrderedSet(Income)=self.income.taxPayer.incomes->select(inc:Income| inc.income_amount= self.income.taxPayer.incomes.income_amount->max())->asOrderedSet() in
144let bigest_income:Income= all_incomes->first() in
145if(bigest_income=self.income) then
146self.tax_card_type=Tax_Card_Type::Principal
147else
148self.tax_card_type=Tax_Card_Type::Additional
149endif
150endif
151
152
153context Legal_Union_Record inv inv17:
154self.start_year <=2018 and self.start_year >=1950
155
156
157--context Household inv inv18:
158--not self.parents.oclIsUndefined()
159
160--context Legal_Union_Record inv inv19:
161--not self.household.oclIsUndefined()
162
163context Legal_Union_Record inv inv20:
164self.individual_B <> self.individual_A
165and
166not self.individual_A.oclIsUndefined()
167and
168not self.individual_B.oclIsUndefined()
169
170--context Legal_Union_Record inv inv21:
171--self.properties->size() >= 1
172
173--context Tax_Payer inv inv22:
174--self.incomes->size() >= 1
175
176--context Tax_Payer inv inv23:
177--not self.from_law.oclIsUndefined()
178
179--context Tax_Payer inv inv24:
180--not self.from_agent.oclIsUndefined()
181
182--context Income inv inv25:
183--not self.income_type.oclIsUndefined()
184
185--context Income inv inv26:
186--self.details->size() = 12
187
188
189--context Tax_Payer inv inv27:
190--not self.from_agent.oclIsUndefined()
191
192
193--context Tax_Payer inv inv28:
194--not self.from_law.oclIsUndefined()
195
196--context Legal_Union_Record inv inv29:
197--self.properties->size()=1
198
199--context Tax_Payer inv inv30:
200--self.AEP_deduction = 0
201
202--context Physical_Person inv inv31:
203--self.last_start_year_widower = -1
204
205--context Physical_Person inv inv32:
206--self.name = 'Not important'
207
208context Physical_Person inv inv33:
209self.getAge(2018) >= 0 and self.getAge(2018) <= 100
210
211context Physical_Person inv inv34:
212self.birth_month >= 1 and self.birth_month <= 12
213
214context Physical_Person inv inv35:
215self.birth_day >= 1 and self.birth_day <= 28
216
217--context FromAgent inv inv36:
218--self.taxation_year = 2018
219
220--context Income inv inv37:
221--self.year = 2018
222
223--context Income inv inv38:
224--self.start_year = 2018
225
226--context Tax_Card inv inv39:
227--self.deduction_FD_yearly = 0
228
229--context Tax_Card inv inv40:
230--self.credit_CIS_yearly = 0
231
232--context Tax_Card inv inv40:
233--self.credit_CIS_monthly = 0
234
235--context Tax_Card inv inv41:
236--self.credit_CIP_yearly = 0
237
238--context Tax_Card inv inv42:
239--self.credit_CIP_monthly = 0
240
241--context Tax_Card inv inv43:
242--self.deduction_CE_invalidity_yearly = 0
243
244--context Tax_Card inv inv44:
245--self.deduction_DS_Debt_yearly = 0
246
247
248--context Expense inv inv45:
249--self.year_expense_was_incurred_in = 2018
250
251--context Tax_Property inv inv46:
252--self.taxed_jointly = true
253
254context Legal_Union_Record inv inv47:
255(self.separation_cause=Separation_Causes::NONE and self.end_year = -1)
256or(self.end_year>self.start_year)
257
258
259context Physical_Person inv inv48:
260(self.disability_type = Disability_Types::NONE and self.disability_percentage = 0) or
261(self.disability_type <> Disability_Types::NONE and self.disability_percentage > 0 and self.disability_percentage <= 1)
262
263context Legal_Union_Record inv inv49:
264self.individual_A.oclIsKindOf(Tax_Payer) and
265self.individual_B.oclIsKindOf(Physical_Person) and
266not self.individual_B.oclIsTypeOf(Dependent) and
267self.individual_A <> self.individual_B
268
269--context Income inv inv50:
270--not self.income_type.oclIsUndefined()
271
272--context Income inv inv51:
273--not self.taxPayer.oclIsUndefined()
274
275--context Tax_Card inv inv52:
276--not self.income.oclIsUndefined()
277
278--context Legal_Union_Record inv inv53:
279--not self.household.oclIsUndefined()
280
281endpackage \ No newline at end of file