1+ @(contextPath = "SalesTransaction.UserProfile", attributeSource = "ST")
2+ extern string UserProfile;
3+
4+ type AutoSilver {
5+ @(closeRelation = true, propagateUp = true, sequence = 1)
6+ relation auto : Vehicle {
7+ @(defaultValue = 0)
8+ maxAutoValue = max(Auto_Value);
9+ @(defaultValue = 0)
10+ minAutoYear = min(Year);
11+ @(defaultValue = 0)
12+ aggDriverAccPoint = max(maxDriverAccPoint);
13+ @(defaultValue = 0)
14+ autoHasAntiTheft = count(Has_Anti_Theft > 0);
15+ }
16+
17+ @(sequence = 2)
18+ relation bodilyinjurypropertydamage : BodilyInjuryPropertyDamage[0..1];
19+
20+ @(sequence = 3)
21+ relation medicalpayments : MedicalPayments[0..1] {
22+ medicalLimit = Limit;
23+ medicalDeductible = Deductible;
24+ }
25+
26+ @(defaultValue = 0, tagName = "NetUnitPrice")
27+ decimal(2) unitPrice;
28+
29+ boolean autoCondition = auto[Vehicle] > 0 && !auto.autoHasAntiTheft;
30+
31+ boolean driverCondition = auto.aggDriverAccPoint > 5;
32+
33+ boolean unitPriceCondition = unitPrice > 100;
34+
35+ boolean condition5 = autoCondition && driverCondition && unitPriceCondition;
36+
37+ // constraint #1
38+
39+ require(auto.maxAutoValue >= 50000 && auto.minAutoYear < 2020, medicalpayments[MedicalPayments], "Auto add Medical Payments");
40+ constraint(auto.maxAutoValue >= 50000 && auto.minAutoYear < 2020 -> medicalpayments[MedicalPayments].Limit == 2000);
41+
42+ // constraint #5
43+ require(condition5, bodilyinjurypropertydamage[BodilyInjuryPropertyDamage], "BIPD is required when Auto IsElectricVehicle and Antitheft is false and Driver accident points > 5 and Collision is selected and MedicalPayments is NOT selected");
44+
45+ // constraint #6
46+ require(medicalpayments[MedicalPayments] == 1 && medicalpayments.medicalDeductible == 500 && UserProfile == "Custom Standard User", bodilyinjurypropertydamage[BodilyInjuryPropertyDamage] { Bodily_Injury_Per_Person_Limit = 1000 }, "BIPD is required when MedicalPayments is selected at 1k limit");
47+
48+
49+ }
50+
51+ type Auto {
52+ @(configurable = false)
53+ int Auto_Value;
54+
55+ @(configurable = false)
56+ int Year;
57+
58+ string Colour;
59+
60+ @(configurable = "false")
61+ string Make;
62+
63+ string License_State;
64+
65+ @(configurable = "false")
66+ string Model;
67+
68+ @(configurable = false)
69+ boolean Is_Electric_Vehicle;
70+
71+ @(configurable = false)
72+ boolean Has_Anti_Theft;
73+
74+ string AssetRecordName;
75+
76+
77+ }
78+
79+ type Vehicle : Auto {
80+ @(sequence = 1)
81+ relation collision : Collision[0..1];
82+
83+ @(sequence = 2)
84+ relation comprehensive : Comprehensive[0..1];
85+
86+ @(sequence = 3)
87+ relation uninsuredMotorist : UninsuredMotorist[0..1];
88+
89+ @(closeRelation = true, propagateUp = true, sequence = 1)
90+ relation driver : AutoDriver[0..5] {
91+ @(defaultValue = 0)
92+ maxDriverAccPoint = max(Driver_Accident_Points);
93+ }
94+
95+ int maxDriverAccPoint = driver.maxDriverAccPoint;
96+
97+ // constraint #2
98+ require(Year > 2023, collision[Collision], "auto add collision coverage if year > 2023");
99+ constraint(collision[Collision] > 0 && Year > 2023 -> collision[Collision].Limit == 5000);
100+
101+ // constraint #3
102+ exclude(collision[Collision] > 0 && collision[Collision].Deductible == 200 && Year < 2020, uninsuredMotorist[UninsuredMotorist]);
103+
104+ }
105+
106+ type Driver {
107+ @(configurable = false)
108+ int Driver_Accident_Points = [0..10];
109+
110+ @(configurable = false)
111+ int Driver_MVR_Points = [0..10];
112+
113+ string Driving_License;
114+
115+ @(configurable = false)
116+ int Age_First_Licensed = [0..100];
117+
118+ @(configurable = false)
119+ string E_Mail;
120+
121+ @(configurable = false)
122+ string State;
123+
124+ @(configurable = false)
125+ int Age = [0..100];
126+
127+ @(configurable = false)
128+ string First_Name;
129+
130+ @(configurable = false)
131+ string Last_Name;
132+
133+ // constraint #4
134+ message(Age_First_Licensed != 0 && Age_First_Licensed < 16, "Warning: Age First License can't be lower than 16", "Warning");
135+ message(Age != 0 && Age < 16, "Driver is underaged to be added to the quote", "Error");
136+
137+ }
138+
139+ type AutoDriver : Driver;
140+
141+ @(split = false)
142+ type UninsuredMotorist {
143+ int Deductible = [0, 50, 100, 200, 500];
144+
145+ int Property_Damage_Per_Accident_Limit = [500, 1000, 1500, 2000];
146+
147+ int Bodily_Injury_Per_Person_Limit = [500, 1000, 1500, 2000];
148+
149+ int Bodily_Injury_Per_Accident_Limit = [500, 1000, 1500, 2000];
150+
151+ int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
152+
153+
154+ }
155+
156+ @(split = false)
157+ type Collision {
158+ @(domainComputation = "false")
159+ int Deductible = [0, 50, 100, 200, 500];
160+
161+ @(defaultValue = "1000", domainComputation = "false")
162+ int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
163+
164+
165+ }
166+
167+ @(split = false)
168+ type BodilyInjuryPropertyDamage {
169+ @(defaultValue = "100", domainComputation = "false")
170+ int Deductible = [0, 50, 100, 200, 500];
171+
172+ @(defaultValue = "1000", domainComputation = "false")
173+ int Bodily_Injury_Per_Person_Limit = [500, 1000, 1500, 2000];
174+
175+ @(defaultValue = "1000", domainComputation = "false")
176+ int Property_Damage_Per_Accident_Limit = [500, 1000, 1500, 2000];
177+
178+ @(defaultValue = "1000", domainComputation = "false")
179+ int Bodily_Injury_Per_Accident_Limit = [500, 1000, 1500, 2000];
180+
181+ @(defaultValue = "1000", domainComputation = "false")
182+ int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
183+
184+
185+ boolean rootCondition5 = parent(condition5);
186+
187+ rule(rootCondition5, "hide", "attribute", "Property_Damage_Per_Accident_Limit");
188+
189+ rule(rootCondition5, "hide", "attribute", "Bodily_Injury_Per_Accident_Limit", "value", 2000);
190+
191+ }
192+
193+ @(split = false)
194+ type MedicalPayments {
195+ @(defaultValue = "100", domainComputation = "false")
196+ int Deductible = [0, 50, 100, 200, 500];
197+
198+ int Property_Damage_Per_Accident_Limit = [500, 1000, 1500, 2000];
199+
200+ int Bodily_Injury_Per_Person_Limit = [500, 1000, 1500, 2000];
201+
202+ int Bodily_Injury_Per_Accident_Limit = [500, 1000, 1500, 2000];
203+
204+ @(defaultValue = "1000", domainComputation = "false")
205+ int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
206+
207+
208+ }
209+
210+ @(split = false)
211+ type Comprehensive {
212+ @(defaultValue = "100", domainComputation = "false")
213+ int Deductible = [0, 50, 100, 200, 500];
214+
215+ @(defaultValue = "1000", domainComputation = "false")
216+ int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
217+
218+ }
0 commit comments