Calculations are single-line statements that return a numeric result.
In BriteLines, there are four types of calculations:
Important information about calculations:
- Variable calculations simply perform the calculation and store it in the reference name. The result can then be used by other calculations.
- All shared calculations are variable calculations.
- Premium, limit, and deductible calculations result in the item’s premium, limit, and deductible respectively.
baseRate * rateFactorTable * seniorDiscount
This calculation says to take the
baseRate and multiply it by the
rateFactorTable and the
Each field, item, rate table, and calculation has a reference name. Calculations use this reference name to refer to the fields, items, rate tables, and calculations. This allows information about these entities to change (like updating a label or default value) without affecting rating logic.
Note: Reference names can’t contain any spaces.
Valid reference names
A reference name must be a valid Python identifier. This means a reference name can only start with a letter or underscore and can only contain letters, numbers, and underscores.
The following are valid reference names:
The following are invalid reference names:
$value(contains a dollar sign)
1stdriver(starts with a number)
Reserved reference names
Some reference names are already reserved by BriteLines. These reference names are unavailable to be used by any field, rate table, calculation, or item.
The following reference names are reserved by BriteLines along with other Python built-ins:
The following arithmetic operations can be performed on references that return numbers (fields of type number, rate tables, and calculations).
+ character is used to add numbers together.
baseRateTable + numberField + otherCalculation
- character is used to subtract one number from another number.
baseRateTable - numberField
* character is used to multiply numbers together.
baseRateTable * rateTableFactor
/ character is used to divide one number by another number.
baseRateTable / 2
Comparison operations compare values and return either true or false according to the condition.
True if the left operand is greater than the right.
numOfDrivers > numOfVehicles
True if the left operand is less than the right.
numOfDrivers < numOfVehicles
True if both operands are equal.
numOfDrivers == numOfVehicles
Not equal to
True if operands aren’t equal.
numOfDrivers != numOfVehicles
Greater than or equal to
True if the left operand is greater than or equal to the right.
numOfDrivers >= numOfVehicles
Less than or equal to
True if the left operand is less than or equal to the right.
numOfDrivers <= numOfVehicles
Scopes determine which references are available for calculation. Shared calculations and item calculations have different scopes.
Shared calculations have a scope that can reference all fields, rate tables, and other shared calculations. They can’t reference specific item calculations.
Item calculations have a scope that can reference all fields, rate tables, shared calculations, and the other calculations for that item.
Because of these rules, shared calculation reference names must be unique across all fields, items, rate tables, and calculations. Item calculations reference names, however, only need to be unique across fields, items, rate tables, shared calculations, and the current item’s calculations.
comprehensive could both have calculations called
baseRate, because the names wouldn’t clash. You couldn’t, however, have a shared calculation called
baseRate, because when rating the
bodilyInjury item, the rating engine wouldn’t know if it should use the value from the item’s
baseRate calculation or the risk type’s
baseRate shared calculation.
Circular reference errors
Calculations must not reference each other.
You couldn’t have the two calculations below. They would result in a circular reference error because
baseRate refers to
rateCalc refers to
baseRate. The rating engine wouldn’t have any way of determining the value for either one.
rateCalc * seniorDiscount
baseRate * otherFactor