Creating new cost data objects in your rating engine
The main task of your line rating engine is to create new cost data objects and set the rating-related properties.
For this task, wherever your rating code lives, use the new operator with the appropriate CostData subclass. Be sure to use the constructor with individual properties, not the constructor that takes an entire Cost. In other words, use the constructor that looks like the following code from the personal auto rating engine.
var cost = new PersonalAutoCovCostData(start, end, vehicle.FixedId, cov.FixedId)Next, your rating engine must set all the rating-related properties on new cost data objects.
If PolicyCenter is configured to support multicurrency, you must call the alternate constructor that contains a financial exchange rate cache object.
var cd = new MyCostData(cost, RateCache)In addition to creating an
entirely new cost data objects from your main rating algorithm, a rating
engine subclass must override the createCostDataForCost
method. This method takes the cost as a parameter. The method must create
and return a new instance of the appropriate subclass of CostData.
The built-in rating code only calls this method when rating from the slice date forward.
override function createCostDataForCost(c : Cost) : CostData {
switch (typeof c) {
case PersonalAutoCovCost: return new PersonalAutoCovCostData(c, RateCache)
case PersonalVehicleCovCost: return new PersonalVehicleCovCostData(c, RateCache)
case PersonalAutoPIPCovCost : return new PersonalAutoPIPCovCostData(c, RateCache)
default : throw "Unknown cost type ${(typeof c).Name}"
}
}
