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
- 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
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
let finalStatus = QuoteStatus; // "Declined", "Referred", or "Valid"
// QuotePublicData now contains the status and all decisions
let quoteData = QuotePublicData;
$Log("Quote Status: " + quoteData.status);
// Display underwriter decisions
for (let decision in quoteData.underwriterDecisions) {
$Log("[" + decision.code + "] " + decision.message);
}
Integration Example
fn 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
};
}
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
let 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
fn 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¶
let quoteData = QuotePublicData;
// Quote identification
let quoteId = quoteData.quoteId; // Unique quote identifier (GUID)
let reference = quoteData.reference; // Quote reference number
let status = quoteData.status; // "Valid", "Referred", or "Declined"
// Product information
let productId = quoteData.productId; // Product GUID
let productName = quoteData.productName; // Product display name
let productBrand = quoteData.productBrand; // Brand name
Policy Dates¶
// Date information (set by $CalculatePolicyDates)
let inceptionDate = quoteData.inceptionDate; // ISO 8601 UTC
let expiryDate = quoteData.expiryDate; // ISO 8601 UTC
let inceptionFormatted = quoteData.inceptionDateFormatted; // Display format
let expiryFormatted = quoteData.expiryDateFormatted; // Display format
let policyPeriod = quoteData.policyPeriod; // e.g., "12 months"
let duration = quoteData.policyDurationInDays; // Number of days
let timeZone = quoteData.timeZoneId; // Timezone identifier
Financial Information¶
// Premium and costs (set by $CalculatePremiumAdditive)
let annualPremium = quoteData.annualPremium; // { amount, currency }
let monthlyPremium = quoteData.monthlyPremium; // { amount, currency, ... }
let fee = quoteData.fee; // { amount, currency }
let feeTax = quoteData.feeTax; // { amount, currency }
let taxDuty = quoteData.taxDuty; // { amount, currency }
let totalTax = quoteData.tax; // { amount, currency }
let taxPercentage = quoteData.taxPercentage; // Decimal (e.g., 0.12)
Features and Decisions¶
// Features collection
let features = quoteData.features;
let featureTitle = features.title;
let featureItems = features.items; // Array of feature objects
// Underwriter decisions and endorsements (set by $CheckQuote)
let decisions = quoteData.underwriterDecisions; // Array
let endorsements = quoteData.endorsements; // Array
Complete Quote Workflow¶
fn 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
};
}
let result = ProcessCompleteQuote();
Accessing QuotePublicData¶
// Access quote data structure
let quote = QuotePublicData;
// Display quote summary
fn 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: " + $ToString(quote.policyDurationInDays) + " days");
$Log("");
$Log("Annual Premium: £" + $ToString(quote.annualPremium.amount));
if (quote.monthlyPremium.amount > 0) {
$Log("Monthly Payment: £" + $ToString(quote.monthlyPremium.amount));
}
// Display features
if (quote.features.items.length > 0) {
$Log("");
$Log("=== " + quote.features.title + " ===");
for (let feature in quote.features.items) {
let valueStr = "";
if (feature.value != null) {
valueStr = " - " + feature.value.currency + " " + $ToString(feature.value.amount);
}
let keyStr = feature.isKey ? " [KEY]" : "";
$Log(feature.name + valueStr + keyStr);
$Log(" " + feature.description);
}
}
// Display underwriter decisions
if (quote.underwriterDecisions.length > 0) {
$Log("");
$Log("=== Underwriter Decisions ===");
for (let decision in quote.underwriterDecisions) {
$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 |
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