Requote hook

How to implement requote functionality on a product module

❗️

Deprecation warning

Requote functionality has been deprecated in favour of the more flexible alteration hooks. Please do not use this on new product modules and migrate existing product modules to alteration hooks.

Overview

Requoting is a way of changing the data saved to an existing policy without issuing a new policy. This is achieved by by creating a new quote and application using updated information, which calls the getQuote() and getApplication() functions defined as part of the quote hook and application hook in the product module code. The existing policy data is then replaced by the data from the newly created application.

The policy being requoted is specified in the URL of the requote endpoint, and the body of the requote request contains only the application_id of the newly created application to be applied to the existing policy.

Requote functionality can be enabled or disabled in the general product settings. If it is enabled for your product module, you will need to define a requotePolicy() function in your product module code. This function is analogous to the getPolicy() function (read more).

Defining the requotePolicy() function

Below is an example of a requotePolicy() function. It accepts as arguments the existing policy, the policyholder linked to the new application, and the newly created application itself. It returns a RequotePolicy() object, which is analogous to a new policy.

const requotePolicy = (policy, policyholder, application) => {

  return new RequotePolicy({
    package_name: application.package_name,
    sum_assured: application.sum_assured,
    base_premium: application.base_premium,
    monthly_premium: application.monthly_premium,
    end_date: moment(policy.end_date),
    module: { ...application.module },
  });
}

As the example illustrates, the requotePolicy() function specifies which fields on the existing policy are retained on the requoted policy, and which fields are replaced by the newly created application data. In this example, all fields are replaced by the newly created application data, except the end_date field, where the existing policy end date is retained.