The evaluation rate object allows for the assignment of variables and use of math via python. A knowledge of data structures and calling functions in python is helpful.

Core Concepts

Running Total

The purpose of the rate chain is to serve as a running total for premium calculation. Any given step can be hidden from the user when viewing the rate chain calculation on a policy by breaking the chain during the build. Doing so also breaks the premium from the running total concept.

Master Premium

If checked, uses the result of the evaluation in the total premium for the line item, ignoring any other rate objects assigned to premium.

Variables

Each step in the chain can be set to a variable (numbers or dictionaries) for later reference or a premium calculation.


BriteCore Setup

Syntax for Calculating Premium

The evaluation line item can calculate premium through various references.

Referencing the Line Item Itself

Limits

this.limit references the line item's own limit.

Premium

this.premium references the line item's own premium. It is the rate chain premium of the item up to the point of the this.premium evaluation.

Deductible

this.deductible references the line item’s own deductible.

Categories

this.categories references the line item's own categories.

Miscellaneous

  • this.policy_inception_date.year references the inception date of the policy
  • this.policy_term_effective_date.year references the effective date of the current term


Referencing Another Line Item

Limits

  • items[“line item name”].limit references another item’s limit
    limit(items["Coverage A - Dwelling"]) cannot be used as it can with premium, as the function is not currently supported
  • limit([items.get("line item name", 0), items.get("line item name", 0), items.get ("line item name", 0)]) will return the limit of identified line items. If a line item is not on the policy then 0 will be returned

Premium

  • items["line item name"].premium or premium(items["line item name"]) references the premium of the specified line item. If the line item’s premium is referenced, BriteCore will rate the referenced item in order to get its premium
  • premium(this.property) calculates the premium for all coverages (policy_type_items.type = ‘coverage’) in the Primary Exposures section. As this function rates numerous coverages, it should be used sparingly to avoid extended processing time
    As this function rates all coverage line items, no other line items can reference the line item with this evaluation; otherwise a loop will occur. This is because premium(this.property) requires every other item (except this) on the property to be rated to return the right amount. If the function runs into an item that hasn’t been rated, it tries to rate it. So if item A runs premium(this.property) and item B looks at item A’s premium, Item B won’t ever be able to rate
  • premium(items['line item name'], items['line item name']) returns the sum of the premiums of all identified line items
  • premium([items.get("line item name", 0), items.get("line item name", 0), items.get("line item name", 0)]) returns the premium of identified line items. If a line item is not on the policy, 0 will be returned

Deductible

items[“line item name”].deductible references another line item’s deductible.

Categories

  • items[“line item name”].categories[“category name”] references a category within another line item
  • items['line item name'].categories[“category name”] in [“cat1 name”, “cat 2 name”] references multiple categories within another line item


Referencing a Subline

Premium

premium([item for item in this.property.all_items() if item.sub_line_name == "My Special SubLine and not item.is_a_calculation"]) references the premium of all items in a subline that are not calculation items.


Referencing Properties

  • this.stage_properties()
  • premium(this.properties)

Miscellaneous Syntax

Decimals

d() accepts a string data type. The syntax d(1.5) will not work because 1.5 is a float. To process decimals without floating point rounding errors, use a string.

Rounding

  • round(d(“3.5”))
  • Since a float cannot be rounded, use round() with decimals

Ifs

Multiple if-else statements may be written but can quickly become hard to read. It is recommended to break up statements when possible.

Examples
Single if statement:

(this.premium * 3) if this.premium < 100 else 220

Single if statement with defined value range:

this.variableName1 if this.variableName2 >= 1000000 and
this.variableName2 <= 5000000 else 0

Multiple if-else statements:

d("140.00")
if this.limit == 300000 else
d("165.00")
if this.limit == 500000 else
d("190.00")
if this.limit == 1000000 else
d("1000000.00")

Get

get() is a method for retrieving data from a dictionary.

Interpolate Between Values

interpolate(this.limit, the thing you want to interpolate)

Dictionaries

  • {"Owner": 1, "Tenant": d("1.2"), "Seasonal": d("1.4")}
  • {"Frame":{"1": 1, "2": 2},"Masonry":{"1": 3, "2": 4}}

How-Tos

Assign a Variable

  1. Create a line item
  2. Click the gray arrow of the Setup box
  3. Check the Line item has a rate and/or a deductible box
  4. Scroll down to the Rating box
  5. Click the gray arrow
  6. Click + Add to Chain. For any rate object, you can set a variable
  7. On the rate object in the Chain Details section, click + No Variable Set
  8. Name the variable

Important notes

  • Use camel case when defining variable. With camel case, the first word is lower-case, there are no spaces between words, and each word after the first is capitalized
    • My variable becomes myVariable
    • This is my variable becomes thisIsMyVariable
  • Do not assign a variable the names limit or premium since those are specific functions. A variable name containing the words limit or premium is acceptable, for example runningLimit or premiumCalculation
  • Do not use a number in the variable name

Customize Evaluation Error Message

Custom error messages are built using the evaluation rate object.

  1. Navigate to Lines
  2. Select effective date
  3. Select policy type
  4. Click pencil icon to edit line item
  5. Click Rating
  6. Click Evaluation
  7. In the Python Code to Evaluate textbox, add error function with custom message. See image below
  8. Click Save and Exit

FAQs

Does the Evaluation Rate Object support case/swich operations?

  • Python does not have a concept of case/switch. It does support mutliple if statements. Depending upon the need, it might be cleaner to create a dictionary rather than multiple ifs. If multiple ifs are needed, it is recommended to break the multiple ifs into separate evaluations
  • Example
    Multiple ifs:
    if test_value == 'something':
      other_value = 'result1'
    elif test_value == 'something else':
      other_value = 'result2'
    elif test_value == 'last value':
      other_value = 'final result'
    else:
      other_value = 'default'
    Dictionary:
    other_value = {
      "something": "result1",
      "something else": "result2",
      "last value": "final result",
    }.get(test_value, "default)

As python is used, what resources will help me troubleshoot the errors?

What does the error File "", line 1 indicate?
This typically means there is a syntax error.

What does the error InvalidOperation: Invalid literal for decimal indicate?
This means you used a comma in your number (e.g., 1,500 instead of 1500). Remove the comma.


More Information

Reference the ScopedRateItem class in /lib/policies/rengine.py.



Feedback

Report unclear or missing documentation.