Quote Functions¶
Functions for managing quote public data, features, and quote status validation.
Overview¶
The Quote Functions subsystem manages:
- Quote Public Data - Centralized quote information structure for external consumption, including cover details, vouchers, deep links, tax messages and calculated answers
- Features - Key selling points and policy features with optional monetary values
- Quote Status - Validation and status management based on underwriter decisions
- Integration - Bridges internal calculations with external quote representation
These functions work with the QuotePublicData environment variable, which serves as the primary data contract between the quoting engine and external systems.
Quote Status Functions¶
$CheckQuote¶
Validates the quote and sets the appropriate quote status based on underwriter decisions. This function examines all underwriting decisions and determines the final quote status.
Signature
Parameters
- None (uses
UnderwriterDecisionsfrom environment)
Returns
- null
Environment Variables Used
UnderwriterDecisions- Array of underwriter decisionsQuotePublicData- Quote data structure (input)
Environment Variables Updated
QuoteStatus- Final quote status: "Valid", "Referred", or "Declined"QuotePublicData- Updated with quote status and underwriter decisions
Status Priority
The function applies the following priority (most restrictive wins):
- "Declined" - If any decision has type "Declined"
- "Referred" - If any decision has type "Referred" (and none declined)
- "Valid" - If no declined or referred decisions exist
Invalid quotes: If
QuoteStatusis already"Invalid"(set by$InvalidateQuote),$CheckQuotedoes nothing and the quote stays Invalid. Script errors no longer mark a quote as Invalid automatically. Call$InvalidateQuote()when the quote should be invalid.
Example
// Run underwriting rules
if (customer.Age < 18) {
$Decline("AGE-MIN", "Applicant must be 18 or older");
}
if (itemValue > 10000) {
$Level1Referral("VAL-HIGH", "High value item requires review");
}
// Check quote status based on decisions
$CheckQuote();
// Access the final status
finalStatus = QuoteStatus; // "Declined", "Referred", or "Valid"
// QuotePublicData now contains the status and all decisions
quoteData = QuotePublicData;
$Log("Quote Status: " + quoteData.status);
// Display underwriter decisions
decisionIndex = 0;
while (decisionIndex < quoteData.underwriterDecisions.Length) {
decision = quoteData.underwriterDecisions[decisionIndex];
decisionIndex++;
$Log("[" + decision.code + "] " + decision.message);
}
Integration Example
function CompleteQuote() {
// Calculate premium
$CalculatePremiumAdditive("NewBusiness");
// Run underwriting
UnderwriteCustomer();
// Validate and set quote status
$CheckQuote();
// Return based on status
if (QuoteStatus == "Declined") {
return {
"Success": false,
"Status": "Declined",
"QuoteData": QuotePublicData
};
}
if (QuoteStatus == "Referred") {
return {
"Success": true,
"Status": "Referred",
"RequiresReview": true,
"QuoteData": QuotePublicData
};
}
// Valid quote
return {
"Success": true,
"Status": "Valid",
"QuoteData": QuotePublicData
};
}
$InvalidateQuote¶
Marks the quote as Invalid. Use it when the quote cannot be offered for reasons that are not an underwriting decision, such as missing or inconsistent input data.
Signature
Parameters
- None
Returns
- null
Environment Variables Updated
QuoteStatus- Set to"Invalid"QuotePublicData.status- Set to"Invalid"
Behaviour
- Once the quote is Invalid, later calls to
$CheckQuoteleave the status unchanged, so the quote cannot be turned back into Valid, Referred or Declined.
Example
if (Answers.ItemValue == null) {
$InvalidateQuote();
}
$CheckQuote(); // Keeps "Invalid" if $InvalidateQuote was called
Quote Public Data Functions¶
These functions add display and integration data to QuotePublicData. Each one reads QuotePublicData from the environment, updates it, and writes it back.
$AddCoverDetail¶
Adds a cover detail (a named, typed value such as a cover limit or excess) to the quote.
Signature
Parameters
coverDetailObject(object) - Object with the following properties:name(string) - Display name of the cover detailvalueType(string) - One of"String","Number","Boolean"or"Money"value- The value, matchingvalueType. For"Money", an object{ "amount": number, "currency": string }formattedValue(string) - Value formatted for display
Returns
- null
Environment Variables Updated
QuotePublicData.coverDetails- Cover detail appended to the array
Errors
- Throws if called with anything other than exactly one object argument.
Example
$AddCoverDetail({
"name": "Excess",
"valueType": "Money",
"value": { "amount": 100, "currency": "GBP" },
"formattedValue": "£100"
});
$AddCoverDetail({
"name": "Cover Level",
"valueType": "String",
"value": "Comprehensive",
"formattedValue": "Comprehensive"
});
$AddDeepLink¶
Adds an aggregator deep link to the quote.
Signature
Parameters
aggregator(string) - Aggregator nameurl(string) - Deep link URL
Returns
- null
Environment Variables Updated
QuotePublicData.deepLinks-{ aggregator, url }appended to the array
Example
$SetVoucherData¶
Records the voucher applied to the quote. The voucher discount itself is added to the pricing matrix separately, as a gross or net discount whose name matches voucherName.
Signature
Parameters
voucherName(string) - Voucher name. Must match the name of the discount added to the pricing matrixvoucherMessage(string) - Message to show the customervoucherPercentage(number) - Voucher discount percentage, stored as supplied (for display only; it does not apply a discount)
Returns
- null
Environment Variables Updated
QuotePublicData.voucherName,QuotePublicData.voucherMessage,QuotePublicData.voucherPercentage
Behaviour
- When
QuotePublicDatais next updated from the pricing matrix (for example by$CalculatePremiumAdditive),annualPremiumBeforeVoucherDiscountis set to the premium recalculated without the discount namedvoucherName. With no voucher, it equalsannualPremium.
Example
$AddGrossDiscountToPricingMatrix("SUMMER10", 0.10);
$SetVoucherData("SUMMER10", "10% summer discount applied", 10);
$CalculatePremiumAdditive("Regular");
// QuotePublicData.annualPremiumBeforeVoucherDiscount = premium without SUMMER10
$SetTaxMessage¶
Sets a tax message to show alongside the premium.
Signature
Parameters
message(string) - Tax message text
Returns
- null
Environment Variables Updated
QuotePublicData.taxMessage
Example
$AddCalculatedAnswer¶
Stores a value calculated by the script so that it is returned with the quote.
Signature
Parameters
name(string) - Answer namevalue(any) - Answer value
Returns
- null
Environment Variables Updated
QuotePublicData.calculatedAnswers- Dictionary keyed byname. Calling it again with the same name overwrites the earlier value
Example
Feature Management Functions¶
Features represent key selling points or policy characteristics that should be displayed prominently to customers. They can optionally include monetary values.
$AddFeatureCollectionTitle¶
Sets the title for the feature collection. This is typically a heading like "Key Benefits" or "What's Included".
Signature
Parameters
title(string) - Title for the feature collection
Returns
- null
Environment Variables Updated
QuotePublicData.features.title- Set to the provided title
Example
// Set a title for the features
$AddFeatureCollectionTitle("Key Policy Benefits");
// Or use different titles based on product type
if (productType == "Premium") {
$AddFeatureCollectionTitle("Premium Coverage Includes");
} else {
$AddFeatureCollectionTitle("Standard Coverage Includes");
}
$AddFeature¶
Adds a feature to the quote. Features can represent coverage items, benefits, or policy characteristics. Supports both object notation and individual parameters.
Signature
Parameters
Option 1: Feature Object
featureObject(object) - Object with feature properties
Option 2: Individual Parameters
id(string) - Unique feature identifiername(string) - Display name of the featuredescription(string) - Detailed description of the featureamount(number, optional) - Monetary value (use null for non-monetary features)currency(string, optional) - Currency code (use null for non-monetary features)isKey(boolean) - Whether this is a key/highlighted feature
Returns
- null
Environment Variables Updated
QuotePublicData.features.items- Feature added to collection
Example
// Add features using individual parameters
// Key feature with monetary value
$AddFeature(
"contents-cover",
"Contents Cover",
"Full replacement value for contents up to the insured amount",
50000.00,
"GBP",
true
);
// Key feature without monetary value
$AddFeature(
"accidental-damage",
"Accidental Damage",
"Cover for accidental damage to contents",
null,
null,
true
);
// Standard (non-key) feature
$AddFeature(
"personal-liability",
"Personal Liability",
"£2 million personal liability protection",
2000000.00,
"GBP",
false
);
// Using object notation
feature = {
"id": "legal-expenses",
"name": "Legal Expenses",
"description": "Up to £50,000 for legal costs",
"value": {
"amount": 50000.00,
"currency": "GBP"
},
"isKey": false
};
$AddFeature(feature);
Building a Feature List
function BuildPolicyFeatures(coverLevel) {
// Set collection title
$AddFeatureCollectionTitle("What's Covered");
// Add key features
$AddFeature(
"build-cover",
"Buildings Cover",
"Full rebuild cost covered",
rebuildValue,
"GBP",
true
);
$AddFeature(
"contents-cover",
"Contents Cover",
"All household contents protected",
contentsValue,
"GBP",
true
);
// Add standard features based on cover level
if (coverLevel == "Comprehensive" || coverLevel == "Premium") {
$AddFeature(
"accidental-damage",
"Accidental Damage",
"Accidents happen - you're covered",
null,
null,
true
);
$AddFeature(
"home-emergency",
"Home Emergency Cover",
"24/7 emergency assistance",
null,
null,
false
);
}
// Add premium-only features
if (coverLevel == "Premium") {
$AddFeature(
"legal-protection",
"Legal Protection",
"Comprehensive legal expense cover",
100000.00,
"GBP",
false
);
$AddFeature(
"family-personal-liability",
"Family Personal Liability",
"£10 million family liability protection",
10000000.00,
"GBP",
false
);
}
}
BuildPolicyFeatures(Customer.CoverLevel);
QuotePublicData Structure¶
The QuotePublicData environment variable contains all externally-facing quote information:
Core Quote Information¶
quoteData = QuotePublicData;
// Quote identification
quoteId = quoteData.quoteId; // Unique quote identifier (GUID)
reference = quoteData.reference; // Quote reference number
status = quoteData.status; // "Valid", "Referred", "Declined" or "Invalid"
// Product information
productId = quoteData.productId; // Product GUID
productName = quoteData.productName; // Product display name
productBrand = quoteData.productBrand; // Brand name
Policy Dates¶
// Date information (set by $CalculatePolicyDates)
inceptionDate = quoteData.inceptionDate; // ISO 8601 UTC
expiryDate = quoteData.expiryDate; // ISO 8601 UTC
inceptionFormatted = quoteData.inceptionDateFormatted; // Display format
expiryFormatted = quoteData.expiryDateFormatted; // Display format
policyPeriod = quoteData.policyPeriod; // e.g., "12 months"
duration = quoteData.policyDurationInDays; // Number of days
timeZone = quoteData.timeZoneId; // Timezone identifier
Financial Information¶
// Premium and costs (set by $CalculatePremiumAdditive)
annualPremium = quoteData.annualPremium; // { amount, currency }
monthlyPremium = quoteData.monthlyPremium; // { amount, currency, ... }
gross = quoteData.gross; // { amount, currency } - pricing matrix gross
fee = quoteData.fee; // { amount, currency }
feeTax = quoteData.feeTax; // { amount, currency }
taxDuty = quoteData.taxDuty; // { amount, currency }
totalTax = quoteData.tax; // { amount, currency }
taxPercentage = quoteData.taxPercentage; // Decimal (e.g., 0.12)
taxMessage = quoteData.taxMessage; // Set by $SetTaxMessage
Vouchers, Cover Details and Integration Data¶
// Voucher (set by $SetVoucherData)
voucherName = quoteData.voucherName;
voucherMessage = quoteData.voucherMessage;
voucherPercentage = quoteData.voucherPercentage;
beforeVoucher = quoteData.annualPremiumBeforeVoucherDiscount; // { amount, currency }
// Cover details (set by $AddCoverDetail)
coverDetails = quoteData.coverDetails; // Array of { name, valueType, value, formattedValue }
// Aggregator deep links (set by $AddDeepLink)
deepLinks = quoteData.deepLinks; // Array of { aggregator, url }
// Script-calculated answers (set by $AddCalculatedAnswer)
answers = quoteData.calculatedAnswers; // Dictionary keyed by name
Features and Decisions¶
// Features collection
features = quoteData.features;
featureTitle = features.title;
featureItems = features.items; // Array of feature objects
// Underwriter decisions and endorsements (set by $CheckQuote)
decisions = quoteData.underwriterDecisions; // Array
endorsements = quoteData.endorsements; // Array
Complete Quote Workflow¶
function ProcessCompleteQuote() {
// 1. Calculate policy dates
$CalculatePolicyDates();
// 2. Build pricing matrix
$SetCurrencyToPricingMatrix("GBP");
$SetCommissionRateToPricingMatrix(0.15);
$SetIptRateToPricingMatrix(0.12);
// Add items and calculate
$AddItemToPricingMatrix("Base Premium", 500.00, 1.0);
$AddFactorToPricingMatrix("Risk Factor", 1.25, true, 0);
$CalculatePremiumAdditive("NewBusiness");
// 3. Add features
$AddFeatureCollectionTitle("Your Policy Benefits");
$AddFeature(
"replacement-cover",
"New-for-Old Replacement",
"All items replaced as new",
null,
null,
true
);
$AddFeature(
"public-liability",
"Public Liability",
"£5 million public liability cover included",
5000000.00,
"GBP",
true
);
// 4. Run underwriting
if (Customer.Age < 18) {
$Decline("AGE-MIN", "Minimum age requirement not met");
} else if (Customer.Age > 75) {
$Level1Referral("AGE-MAX", "Age over standard limit");
}
if (PricingMatrix.Premium > 5000) {
$Level1Referral("PREM-HIGH", "Premium exceeds auto-acceptance limit");
}
// 5. Finalize quote status
$CheckQuote();
// 6. Return quote data
return {
"Status": QuoteStatus,
"Quote": QuotePublicData,
"Premium": PricingMatrix.Premium
};
}
result = ProcessCompleteQuote();
Accessing QuotePublicData¶
// Access quote data structure
quote = QuotePublicData;
// Display quote summary
function DisplayQuoteSummary() {
$Log("== Quote Summary ==");
$Log("Reference: " + quote.reference);
$Log("Status: " + quote.status);
$Log("Product: " + quote.productName);
$Log("");
$Log("Policy Period: " + quote.inceptionDateFormatted + " to " + quote.expiryDateFormatted);
$Log("Duration: " + quote.policyDurationInDays.ToString() + " days");
$Log("");
$Log("Annual Premium: £" + quote.annualPremium.amount.ToString());
if (quote.monthlyPremium.amount > 0) {
$Log("Monthly Payment: £" + quote.monthlyPremium.amount.ToString());
}
// Display features
if (quote.features.items.length > 0) {
$Log("");
$Log("== " + quote.features.title + " ==");
featureIndex = 0;
while (featureIndex < quote.features.items.Length) {
feature = quote.features.items[featureIndex];
featureIndex++;
valueStr = "";
if (feature.value != null) {
valueStr = " - " + feature.value.currency + " " + feature.value.amount.ToString();
}
keyStr = feature.isKey ? " [KEY]" : "";
$Log(feature.name + valueStr + keyStr);
$Log(" " + feature.description);
}
}
// Display underwriter decisions
if (quote.underwriterDecisions.length > 0) {
$Log("");
$Log("== Underwriter Decisions ==");
decisionIndex = 0;
while (decisionIndex < quote.underwriterDecisions.Length) {
decision = quote.underwriterDecisions[decisionIndex];
decisionIndex++;
$Log("[" + decision.code + "] " + decision.decision + ": " + decision.message);
}
}
}
DisplayQuoteSummary();
Best Practices¶
1. Always Call $CheckQuote¶
Finalize the quote by calling $CheckQuote after all underwriting decisions:
// ✅ Good - status properly set
RunUnderwriting();
$CheckQuote();
return QuotePublicData;
// ❌ Poor - status might be incorrect
RunUnderwriting();
return QuotePublicData; // Status not validated!
2. Add Features Early¶
Add features before finalizing the quote:
// ✅ Good - features available in final quote
$AddFeatureCollectionTitle("Key Benefits");
$AddFeature("feature-1", "Feature 1", "Description", null, null, true);
$CheckQuote();
// ❌ Poor - features added after validation
$CheckQuote();
$AddFeature("feature-1", "Feature 1", "Description", null, null, true);
3. Use Meaningful Feature IDs¶
Use consistent, descriptive feature identifiers:
// ✅ Good - clear, consistent IDs
$AddFeature("accidental-damage", "Accidental Damage", "...", null, null, true);
$AddFeature("public-liability", "Public Liability", "...", 5000000, "GBP", false);
// ❌ Poor - generic, unclear IDs
$AddFeature("f1", "Feature", "...", null, null, true);
$AddFeature("123", "Thing", "...", 5000000, "GBP", false);
4. Mark Key Features Appropriately¶
Only mark the most important features as key:
// ✅ Good - selective key features (2-3 key features)
$AddFeature("id1", "Buildings Cover", "...", 300000, "GBP", true);
$AddFeature("id2", "Contents Cover", "...", 50000, "GBP", true);
$AddFeature("id3", "Accidental Damage", "...", null, null, true);
$AddFeature("id4", "Personal Liability", "...", 2000000, "GBP", false);
$AddFeature("id5", "Legal Expenses", "...", 50000, "GBP", false);
// ❌ Poor - everything marked as key
$AddFeature("id1", "Feature 1", "...", null, null, true);
$AddFeature("id2", "Feature 2", "...", null, null, true);
$AddFeature("id3", "Feature 3", "...", null, null, true);
$AddFeature("id4", "Feature 4", "...", null, null, true);
5. Provide Clear Feature Descriptions¶
Write customer-friendly feature descriptions:
// ✅ Good - customer-friendly, clear
$AddFeature(
"accidental-damage",
"Accidental Damage Cover",
"We'll repair or replace items damaged by accident in your home",
null,
null,
true
);
// ❌ Poor - technical jargon
$AddFeature(
"ad",
"AD Cover",
"Policy extension AD-01 activated",
null,
null,
true
);
Environment Variables¶
| Variable | Type | Description |
|---|---|---|
QuotePublicData |
Object | Complete quote data structure (input/output) |
QuoteStatus |
String | Final quote status after validation (input for $CheckQuote: "Invalid" is preserved) |
UnderwriterDecisions |
Array | Underwriter decisions (input for $CheckQuote) |
InceptionDate |
String | Policy inception date (from $CalculatePolicyDates) |
ExpiryDate |
String | Policy expiry date (from $CalculatePolicyDates) |
PricingMatrix |
Object | Financial calculations (from premium functions) |
Next Steps¶
- Underwriter Functions - Create decisions that affect quote status
- Quote Calculation Functions - Calculate premiums and populate financial data
- Time Functions - Calculate policy dates for QuotePublicData
- Examples - Complete quote workflow examples