您位於此處:
AutoSilver 的限制範例
檢閱針對 AutoSilver 產品模型設計的範例限制,以支援複雜的汽車保險邏輯。
使用這些限制範例瞭解如何在車輛特性、涵蓋範圍選擇和跨產品互動之間套用條件邏輯。
如需完整參考,您可以檢閱 完整的 AutoSilver CML 檔案。
為高價值的舊車要求醫療保險
如果最貴的汽車超過 $50,000,且最舊的汽車是 2020 年之前的,則需要具有 $2000 限制的醫療保險。
涵蓋的內容
- 多例項限制
- 需要涵蓋範圍限制
- 跨產品限制
CML 範例
type AutoSilver {
@(closeRelation = true, propagateUp = true, sequence = 1)
relation auto : Vehicle {
maxAutoValue = max(Auto_Value);
minAutoYear = min(Year);
}
boolean constraint1 = auto.maxAutoValue >= 50000 && auto.minAutoYear < 2020;
require(constraint1, medicalpayments[MedicalPayments], "Auto add Medical Payments");
constraint(constraint1 && medicalpayments[MedicalPayments] > 0 -> medicalpayments[MedicalPayments].Limit == 2000, "Medical coverage set to $2000 for older high-value vehicles");
}
type Auto {
@(configurable = false)
decimal(2) Auto_Value;
int Year = [1980..2026];
}
type MedicalPayments {
@(defaultValue = "1000", domainComputation = false)
int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
}
要求較新車輛的碰撞涵蓋範圍
針對 2023 年以後的車輛,新增具有 $5000 限制的「碰撞」涵蓋範圍。
什麼是涵蓋
- 需要涵蓋範圍限制
- 跨產品限制
CML 範例
type Auto {
int Year = [1980..2026];
}
type Vehicle : Auto {
relation collision : Collision[0..1];
boolean constraint2 = Year > 2023;
constraint(constraint2 -> collision[Collision], "auto add collision coverage");
constraint(constraint2 && collision[Collision] > 0 -> collision[Collision].Limit == 5000, "set collision limit to 5000");
}
@(split = false)
type Collision {
@(defaultValue = "1000", domainComputation = false)
int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
} 排除舊車輛的未受保駕駛涵蓋範圍
當車輛超過 2020 年且已選取可扣除 $200 美元的「碰撞涵蓋範圍」時,無法選取「未保險駕駛人」涵蓋範圍。
涵蓋的內容
- 排除涵蓋範圍限制
- 跨產品限制
CML 範例
type Auto {
int Year = [1980..2026];
}
type Vehicle : Auto {
@(sequence = 4)
relation comprehensive : Comprehensive[0..1];
@(sequence = 3)
relation uninsuredMotorist : UninsuredMotorist[0..1];
boolean constraint3 = collision[Collision] > 0 && collision[Collision].Deductible == 200 && Year < 2020;
exclude(constraint3, uninsuredMotorist[UninsuredMotorist]);
}
@(split = false)
type Collision {
@(defaultValue = "1000", domainComputation = false)
int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
@(domainComputation = false)
int Deductible = [0, 50, 100, 200, 500];
}
@(split = false)
type UninsuredMotorist;
駕照年齡驗證
確保第一個授權的駕駛年齡和年齡皆大於 16。
涵蓋的內容
- 基本限制
CML 範例
type Driver {
@(configurable = false)
int Age = [0..100];
int Age_First_Licensed = [0..100];
message(Age_First_Licensed < 16, "Don’t know who gave you license to driver before 16, legally!", "Warning");
message(Age < 16, "Error”: Driver is underaged to be added to the quote", "Error");
}
符合特定條件時要求 BIPD
當符合特定車輛、駕駛人和價格條件且未選取「醫療付款」時,此限制需要 BIPD 涵蓋範圍。它也會隱藏 BIPD 涵蓋範圍中的屬性和值。
涵蓋的內容
- 多例項限制
- 需要涵蓋範圍限制
- 基數限制
- 父系基數限制
- 跨產品限制
- 孫系產品限制
- 同層級產品限制
CML 範例
type AutoSilver {
@(closeRelation = true, propagateUp = true, sequence = 1)
relation auto : Vehicle {
maxDriverAccPoint1 = max(maxDriverAccPoint);
autoHasAntiTheft = count(Has_Anti_Theft > 0);
}
@(sequence = 2)
relation bodilyinjurypropertydamage : BodilyInjuryPropertyDamage[0..1];
@(sequence = 3)
relation medicalpayments : MedicalPayments[0..1] {
medicalLimit = Limit;
medicalDeductible = Deductible;
}
@(tagName = "ItemTotalPrice")
decimal(2) totalPrice;
boolean autoCondition = auto[Vehicle] > 0 && !auto.autoHasAntiTheft;
boolean driverCondition = auto.maxDriverAccPoint1 > 5;
boolean totalPriceCondition = totalPrice > 10;
boolean constraint5 = autoCondition && driverCondition && totalPriceCondition && medicalpayments[MedicalPayments] == 0;
@(abort = true)
require(constraint5, 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");
}
type Auto {
boolean Has_Anti_Theft;
}
type Vehicle : Auto {
int maxDriverAccPoint = driver.maxDriverAccPoint;
@(closeRelation = true, propagateUp = true, sequence = 1)
relation driver : AutoDriver[0..5] {
maxDriverAccPoint = max(Driver_Accident_Points);
}
type Driver {
int Driver_Accident_Points = [0..10];
}
type MedicalPayments {
@(defaultValue = "1000", domainComputation = false)
int Limit = [1000, 2000, 5000, 10000, 25000, 50000];
}
@(split = false)
type BodilyInjuryPropertyDamage {
@(defaultValue = "1000", domainComputation = false)
int Property_Damage_Per_Accident_Limit = [500, 1000, 1500, 2000];
@(defaultValue = "1000", domainComputation = false)
int Bodily_Injury_Per_Accident_Limit = [500, 1000, 1500, 2000];
boolean rootconstraint5 = parent(constraint5);
rule(rootconstraint5, "hide", "attribute", "Property_Damage_Per_Accident_Limit");
rule(rootconstraint5, "hide", "attribute", "Bodily_Injury_Per_Accident_Limit","value", 2000);
}透過醫療付款要求標準使用者 BIPD
當標準使用者選取具有 $1000 限制且高單價的「醫療付款」涵蓋範圍時,新增具有 $1000 每個人身體傷害限制的 BIPD 涵蓋範圍。
涵蓋的內容
- 需要涵蓋範圍限制
- 基數限制
- 跨產品限制
- 同層級產品限制
CML 範例
@(contextPath = "SalesTransaction.UserProfile", attributeSource = "ST")
extern string UserProfile;
type AutoSilver {
@(sequence = 3)
relation medicalpayments : MedicalPayments[0..1] {
medicalLimit = Limit;
medicalDeductible = Deductible;
medicalInputUnitPrice = inputUnitPrice;
}
@(sequence = 2)
relation bodilyinjurypropertydamage : BodilyInjuryPropertyDamage[0..1];
boolean constraint6 = medicalpayments[MedicalPayments] == 1 && medicalpayments.medicalDeductible == 500 && UserProfile == "Standard User" && medicalpayments.medicalInputUnitPrice > 220;
require(constraint6, bodilyinjurypropertydamage[BodilyInjuryPropertyDamage], "BIPD is required when MedicalPayments is selected at 1k limit");
constraint(constraint6 && bodilyinjurypropertydamage[BodilyInjuryPropertyDamage] -> bodilyinjurypropertydamage[BodilyInjuryPropertyDamage].Bodily_Injury_Per_Person_Limit == 1000);
}
@(split = false)
type BodilyInjuryPropertyDamage {
@(defaultValue = "1000", domainComputation = false)
int Bodily_Injury_Per_Person_Limit = [500, 1000, 1500, 2000];
}
@(split = false)
type MedicalPayments {
@(defaultValue = "100", domainComputation = false)
int Deductible = [0, 50, 100, 200, 500];
@(tagName = "InputUnitPrice")
decimal(2) inputUnitPrice;
}
