Rating

Overview

Socotra can persist premium and other charges on any element within a policy’s schema.

Rating is the process of calculating these charges on Quotes and across the suite of other Policy Transactions. This logic is implemented in the rating plugin, following the same override method approach as described in the plugin overview

The charge types that can be implemented in the rating plugin must be defined in the ChargeRef section of the configuration.

Note

Currently, any charge type can be associated with any element type in the rating plugin response. A later release will add a requirement that such associations be declared in config.

Configuration

The rating plugin requires that an interface be implemented for both Quotes and Policy Transactions of each Product defined in the configuration.

Interfaces:

  • Configuration has a top-level config.json shown below

  • Configuration has a top-level plugins/java folder containing RatingPluginImpl.java

Sample contents of the top-level config.json file defining various entity types:

{
    "products": {
        "personalAuto": {
            "eligibleAccountTypes": ["consumerAccount"]
            "data": {}
    }
        "termLife": {
            "eligibleAccountTypes": ["consumerAccount"]
            "data": {}
    }
}

Example interface declarations the RatingPluginImpl.java file:

package com.socotra.deployment.customer; // Must include

// Must implement RatePlugin, which defines interfaces and default method implementations for override
public class RatingPluginImpl implements RatePlugin {

    // Method for rating quotes based on the personalAuto product
    @Override
    public RatingSet rate(PersonalAutoQuoteRequest personalAutoQuoteRequest) {

        return RatingSet.builder().ok(true).build();
    }

    // Method for rating policy transactions based on the personalAuto product
    @Override
    public RatingSet rate(PersonalAutoRequest personalAutoRequest) {

        return RatingSet.builder().ok(true).build();
    }

    // Method for rating quotes based on the termLife product
    @Override
    public RatingSet rate(TermLifeQuoteRequest termLifeQuoteRequest) {

        return RatingSet.builder().ok(true).build();
    }

    // Method for rating policy transactions based on the termLife product
    @Override
    public RatingSet rate(TermLifeRequest termLifeRequest) {

        return RatingSet.builder().ok(true).build();
    }
}

Return Object

Rating plugin methods must return a RatingSet object, which contains individual rating items.

The example below shows how a RatingItem can be constructed, what properties it should have, and, in the context of rating a quote based on a personalAuto product, how it can be added to and returned as part of a RatingSet:

package com.socotra.deployment.customer; // Must include

// Must implement RatePlugin
public class RatingPluginImpl implements RatePlugin {

    // Method for rating quotes based on the personalAuto product
    @Override
    public RatingSet rate(PersonalAutoQuoteRequest personalAutoQuoteRequest) {

        PersonalAutoQuote personalAutoQuote = personalAutoQuoteRequest.quote();
        List<RatingItem> ratingItems = new ArrayList<>();

        double rate = 0.003 * vehicle.data().value().doubleValue() + 50;

        ratingItems.add(RatingItem.builder()
            .elementLocator(vehicle.bodilyInjuryCoverage().locator())
            .chargeType(ChargeType.premium)
            .rate(BigDecimal.valueOf(rate))
            .build());

        return RatingSet.builder().ok(true).build();
    }
}