File size: 43,668 Bytes
c6af477 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 | """Quote-application wizard views.
SOURCE NOTE. The public marketing capture could not enter the wizard, but a
headed browser handoff on 2026-08-26 reached `ua.apps.insureon.com` and directly
observed the step names, order, conditional workers' compensation step, and
the opening Company Information controls. The remaining detailed field copy
uses the local deterministic application model. Evidence-backed inputs include:
* the business-class taxonomy and its ids (first-party endpoint, HTTP 200),
* the product names, coverage descriptions and average premiums (captured
`/small-business-insurance/*` and `/small-business-insurance/*/cost`),
* the carrier names (captured home page),
* the site chrome, typography and palette (captured stylesheet).
Later step field sets and control shapes remain a bounded reconstruction; they
do not claim a pixel-level visual contract. See `KNOWN_DIFFERENCES.md` and
`scope/claims.jsonl`.
"""
from __future__ import annotations
from typing import Any, Mapping, Sequence
import render as R
from content import professions as P
STEPS: list[tuple[str, str]] = [
("company", "Company Information"),
("protection", "Protection Options"),
("contact", "Contact Information"),
("business", "Business Details"),
("locations", "Locations"),
("sales", "Sales & Operations"),
("workers", "Workers’ Compensation"),
("practices", "Business Operations & Practices"),
]
ENTITY_TYPES = [
("sole-proprietorship", "Sole proprietorship"),
("llc", "LLC"),
("s-corporation", "S corporation"),
("c-corporation", "C corporation"),
("partnership", "Partnership"),
("nonprofit", "Nonprofit"),
]
ENTITY_TYPE_LABELS = dict(ENTITY_TYPES)
YEARS_OPTIONS = [
("0", "Less than 1 year"),
("1", "1 year"),
("2", "2 years"),
("3", "3 years"),
("5", "5 years"),
("10", "10 or more years"),
]
US_STATES = [
("AL", "Alabama"), ("AK", "Alaska"), ("AZ", "Arizona"), ("AR", "Arkansas"),
("CA", "California"), ("CO", "Colorado"), ("CT", "Connecticut"),
("DE", "Delaware"), ("DC", "District of Columbia"), ("FL", "Florida"),
("GA", "Georgia"), ("HI", "Hawaii"), ("ID", "Idaho"), ("IL", "Illinois"),
("IN", "Indiana"), ("IA", "Iowa"), ("KS", "Kansas"), ("KY", "Kentucky"),
("LA", "Louisiana"), ("ME", "Maine"), ("MD", "Maryland"),
("MA", "Massachusetts"), ("MI", "Michigan"), ("MN", "Minnesota"),
("MS", "Mississippi"), ("MO", "Missouri"), ("MT", "Montana"),
("NE", "Nebraska"), ("NV", "Nevada"), ("NH", "New Hampshire"),
("NJ", "New Jersey"), ("NM", "New Mexico"), ("NY", "New York"),
("NC", "North Carolina"), ("ND", "North Dakota"), ("OH", "Ohio"),
("OK", "Oklahoma"), ("OR", "Oregon"), ("PA", "Pennsylvania"),
("RI", "Rhode Island"), ("SC", "South Carolina"), ("SD", "South Dakota"),
("TN", "Tennessee"), ("TX", "Texas"), ("UT", "Utah"), ("VT", "Vermont"),
("VA", "Virginia"), ("WA", "Washington"), ("WV", "West Virginia"),
("WI", "Wisconsin"), ("WY", "Wyoming"),
]
def _shell(inner: str, *, step: str, title: str, app: Mapping[str, Any] | None = None,
logged_in: bool = False, description: str = "",
steps: Sequence[tuple[str, str]] | None = None) -> str:
ref = ""
if app and app.get("reference"):
ref = (f'<p style="text-align:center;color:var(--ion-muted);font-size:.82rem">'
f'Application {R.esc(app["reference"])}</p>')
visible_steps = list(steps or STEPS)
body = f"""<section class="section section--tint" style="padding:2.5rem 0">
<div class="wrap">{R.stepper(visible_steps, step)}{ref}</div>
</section>
<section class="section"><div class="wrap">{inner}</div></section>"""
return R.page(body, title=title, description=description, logged_in=logged_in)
# --------------------------------------------------------------------------- #
# step 1: business class
# --------------------------------------------------------------------------- #
def start_quote(query: str = "", product: str = "", error: str = "",
logged_in: bool = False) -> str:
"""T03 entry: the business-class picker that the source renders as a modal."""
from content import site as S
# The source filters the class list as the user types. Offline we render the
# whole captured taxonomy and filter it client-side, so typing behaves the
# same way with no request; `query` additionally narrows it server-side so
# the step still works without JavaScript and stays deep-linkable.
rows = P.search(query, limit=len(P.all_services()))
options = "".join(
f'<li data-class-option data-label="{R.esc(r["name"])} {R.esc(r["industry_name"])}">'
f'<button class="btn btn--ghost btn--block" type="submit" name="profession_id"'
f' value="{r["id"]}" style="text-align:left;border-color:var(--ion-border)">'
f'{R.esc(r["name"])}'
f'<span style="display:block;font-size:.75rem;color:var(--ion-muted)">'
f'{R.esc(r["industry_name"])}</span></button></li>'
for r in rows
)
empty = "" if rows else (
'<p style="padding:1rem;color:var(--ion-muted)">No business type matches '
f'“{R.esc(query)}”. Try a broader keyword.</p>')
inner = f"""<div class="form-card" style="max-width:44rem">
<h1 style="font-size:1.9rem;text-align:center">{R.esc(S.QUOTE_MODAL["heading"])}</h1>
<p style="text-align:center;color:var(--ion-muted)">{R.esc(S.QUOTE_MODAL["subheading"])}</p>
{R.error_summary({"class": error} if error else {})}
<form method="get" action="/start-quote" class="search-form" style="margin-bottom:1rem">
<input type="hidden" name="product" value="{R.esc(product)}">
<label for="class-search" style="position:absolute;left:-9999px">
{R.esc(S.QUOTE_MODAL["placeholder"])}</label>
<input id="class-search" type="search" name="q" data-class-search
placeholder="{R.esc(S.QUOTE_MODAL["placeholder"])}"
autocomplete="off" value="{R.esc(query)}">
<button class="btn btn--ghost" type="submit">Search</button>
</form>
<form method="post" action="/app/quote/new">
<input type="hidden" name="product" value="{R.esc(product)}">
<ul data-class-list style="list-style:none;padding:0;margin:0;max-height:26rem;
overflow-y:auto;border:1px solid var(--ion-border);border-radius:.5rem">
{options}
</ul>
{empty}
<p data-class-empty hidden style="padding:1rem;color:var(--ion-muted)">
No business type matches that search. Try a broader keyword.</p>
</form>
<p style="text-align:center;margin-top:1.5rem;color:var(--ion-muted)">
{R.esc(S.QUOTE_MODAL["call_prompt"])}</p>
</div>"""
return _shell(inner, step="class",
title="Small Business Insurance Quotes | Insureon",
description="Get the right coverage from top insurance companies.",
logged_in=logged_in)
def source_steps(app: Mapping[str, Any]) -> list[tuple[str, str]]:
products = list(app.get("requested_products") or [])
return [row for row in STEPS if row[0] != "workers" or "workers-compensation" in products]
def company_information(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""<div class="form-card">
<h1 style="font-size:1.7rem">Your Company Information</h1>
<p style="color:var(--ion-muted)">Tell us about the company you want to insure.</p>
{R.error_summary(errors)}
<form method="post" action="/app/quote/{R.esc(app['id'])}/company-information">
{R.field("business_name", "What's the name of your business?", value=app.get("business_name") or "", error=errors.get("business_name", ""), required=True, attrs='autocomplete="organization"')}
{R.field("zip_code", "What is the zip code of your primary business location?", value=app.get("zip_code") or "", error=errors.get("zip_code", ""), required=True, attrs='inputmode="numeric" maxlength="5" autocomplete="postal-code"')}
<fieldset class="field"><legend>When did you start your business?</legend><div class="field-row">
{R.field("start_month", "Month", kind="select", value="", error=errors.get("start_month", ""), required=True, options=[("", "Select month")] + [(str(i), str(i)) for i in range(1, 13)])}
{R.field("start_year", "Year", kind="number", value="", error=errors.get("start_year", ""), required=True, attrs='min="1900" max="2026" inputmode="numeric"')}
</div></fieldset>
<div class="btn-row" style="justify-content:flex-end"><button class="btn btn--primary" type="submit">Save and Continue</button></div>
</form>
</div>"""
return _shell(inner, step="company", title="Company Information | Insureon", app=app, logged_in=logged_in, steps=source_steps(app))
def protection_options(app: Mapping[str, Any], catalog: Mapping[str, Mapping[str, Any]],
selected: Sequence[str], limits: Mapping[str, Any],
errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
boxes = []
for slug, prod in catalog.items():
boxes.append(f'<label class="tile"><input type="checkbox" name="products" value="{R.esc(slug)}"{" checked" if slug in selected else ""}> <strong>{R.esc(prod["name"])}</strong><p>{R.esc(prod.get("short_description", ""))}</p></label>')
inner = f"""<div class="form-card" style="max-width:50rem"><h1 style="font-size:1.7rem">Protection Options</h1><p style="color:var(--ion-muted)">Choose the policies and limits you want Insureon to compare.</p>{R.error_summary(errors)}
<form method="post" action="/app/quote/{R.esc(app['id'])}/protection-options"><div class="tile-grid protection-grid">{''.join(boxes)}</div><div class="field-row">
{R.field("limit", "Liability limits", kind="select", value=str(limits.get("limit") or ""), options=limits.get("limit_options") or [])}
{R.field("deductible", "Deductible", kind="select", value=str(limits.get("deductible") or ""), options=limits.get("deductible_options") or [])}</div>
<div class="btn-row" style="justify-content:space-between"><a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/company-information">Back</a><button class="btn btn--primary" type="submit">Save and Continue</button></div></form></div>"""
return _shell(inner, step="protection", title="Protection Options | Insureon", app=app, logged_in=logged_in, steps=source_steps(dict(app, requested_products=list(selected))))
def contact_information(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""<div class="form-card"><h1 style="font-size:1.7rem">Contact Information</h1><p style="color:var(--ion-muted)">Where should we attach this local quote application?</p>{R.error_summary(errors)}<form method="post" action="/app/quote/{R.esc(app['id'])}/contact-information"><div class="field-row">
{R.field("contact_first", "First name", value=app.get("contact_first") or "", error=errors.get("contact_first", ""), required=True, attrs='autocomplete="given-name"')}
{R.field("contact_last", "Last name", value=app.get("contact_last") or "", error=errors.get("contact_last", ""), required=True, attrs='autocomplete="family-name"')}</div>
{R.field("email", "Email", kind="email", value=app.get("email") or "", error=errors.get("email", ""), required=True, attrs='autocomplete="email"')}
{R.field("phone", "Phone", kind="tel", value=app.get("phone") or "", error=errors.get("phone", ""), required=True, attrs='autocomplete="tel"')}
<div class="btn-row" style="justify-content:space-between"><a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/protection-options">Back</a><button class="btn btn--primary" type="submit">Save and Continue</button></div></form></div>"""
return _shell(inner, step="contact", title="Contact Information | Insureon", app=app, logged_in=logged_in, steps=source_steps(app))
def source_business_details(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""<div class="form-card"><h1 style="font-size:1.7rem">Business Details</h1><p><strong>{R.esc(app.get('profession_name', ''))}</strong> · {R.esc(app.get('industry_name', ''))}</p>{R.error_summary(errors)}<form method="post" action="/app/quote/{R.esc(app['id'])}/business-details">
{R.field("entity_type", "Business structure", kind="select", value=app.get("entity_type") or "llc", error=errors.get("entity_type", ""), required=True, options=ENTITY_TYPES)}
<div class="btn-row" style="justify-content:space-between"><a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/contact-information">Back</a><button class="btn btn--primary" type="submit">Save and Continue</button></div></form></div>"""
return _shell(inner, step="business", title="Business Details | Insureon", app=app, logged_in=logged_in, steps=source_steps(app))
def locations(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""<div class="form-card"><h1 style="font-size:1.7rem">Locations</h1><p style="color:var(--ion-muted)">Confirm the primary location for this company.</p>{R.error_summary(errors)}<form method="post" action="/app/quote/{R.esc(app['id'])}/locations">
{R.field("zip_code", "ZIP code", value=app.get("zip_code") or "", error=errors.get("zip_code", ""), required=True, attrs='inputmode="numeric" maxlength="5"')}
<div class="field-row">{R.field("state", "State", kind="select", value=app.get("state") or "", error=errors.get("state", ""), required=True, options=[("", "Select a state")] + list(US_STATES))}{R.field("city", "City", value=app.get("city") or "", error=errors.get("city", ""), required=True)}</div>
<div class="btn-row" style="justify-content:space-between"><a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/business-details">Back</a><button class="btn btn--primary" type="submit">Save and Continue</button></div></form></div>"""
return _shell(inner, step="locations", title="Locations | Insureon", app=app, logged_in=logged_in, steps=source_steps(app))
def sales_operations(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
revenue = app.get("annual_revenue") or ""
inner = f"""<div class="form-card"><h1 style="font-size:1.7rem">Sales & Operations</h1><p style="color:var(--ion-muted)">Annual sales help carriers estimate the scale of your operations.</p>{R.error_summary(errors)}<form method="post" action="/app/quote/{R.esc(app['id'])}/sales-operations">{R.field("annual_revenue", "Estimated annual sales (USD)", kind="number", value=str(revenue), error=errors.get("annual_revenue", ""), required=True, attrs='min="0" step="1000" inputmode="numeric"')}<div class="btn-row" style="justify-content:space-between"><a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/locations">Back</a><button class="btn btn--primary" type="submit">Save and Continue</button></div></form></div>"""
return _shell(inner, step="sales", title="Sales & Operations | Insureon", app=app, logged_in=logged_in, steps=source_steps(app))
def workers_compensation(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""<div class="form-card"><h1 style="font-size:1.7rem">Workers’ Compensation</h1><p style="color:var(--ion-muted)">This step appears because workers’ compensation was selected.</p>{R.error_summary(errors)}<form method="post" action="/app/quote/{R.esc(app['id'])}/workers-compensation">{R.field("employees", "How many employees do you have?", kind="number", value=str(app.get("employees") or ""), error=errors.get("employees", ""), required=True, attrs='min="0" max="500" inputmode="numeric"')}<div class="btn-row" style="justify-content:space-between"><a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/sales-operations">Back</a><button class="btn btn--primary" type="submit">Save and Continue</button></div></form></div>"""
return _shell(inner, step="workers", title="Workers’ Compensation | Insureon", app=app, logged_in=logged_in, steps=source_steps(app))
def business_practices(app: Mapping[str, Any], logged_in: bool = False) -> str:
claims = bool(app.get("has_prior_claims")); cert = bool(app.get("needs_certificate"))
back = "workers-compensation" if "workers-compensation" in list(app.get("requested_products") or []) else "sales-operations"
inner = f"""<div class="form-card"><h1 style="font-size:1.7rem">Business Operations & Practices</h1><p style="color:var(--ion-muted)">A final set of questions helps match your company with eligible carriers.</p><form method="post" action="/app/quote/{R.esc(app['id'])}/business-operations-practices"><div class="field"><label>Any insurance claims in the last three years?</label><label><input type="radio" name="has_prior_claims" value="0"{"" if claims else " checked"}> No</label> <label><input type="radio" name="has_prior_claims" value="1"{" checked" if claims else ""}> Yes</label></div><label><input type="checkbox" name="needs_certificate" value="1"{" checked" if cert else ""}> I need a certificate of insurance</label><div class="btn-row" style="justify-content:space-between"><a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/{back}">Back</a><button class="btn btn--primary" type="submit">See my quotes</button></div></form></div>"""
return _shell(inner, step="practices", title="Business Operations & Practices | Insureon", app=app, logged_in=logged_in, steps=source_steps(app))
# --------------------------------------------------------------------------- #
# step 2: location
# --------------------------------------------------------------------------- #
def location(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""<div class="form-card">
<h1 style="font-size:1.7rem">Where is your business located?</h1>
<p style="color:var(--ion-muted)">Insurance requirements and rates vary by state,
so we start with your business address.</p>
<p><strong>{R.esc(app.get("profession_name", ""))}</strong>
<span style="color:var(--ion-muted)">— {R.esc(app.get("industry_name", ""))}</span>
<a href="/start-quote" style="margin-left:.5rem;font-size:.85rem">Change</a></p>
{R.error_summary(errors)}
<form method="post" action="/app/quote/{R.esc(app['id'])}/location">
{R.field("zip_code", "ZIP code", value=app.get("zip_code") or "",
error=errors.get("zip_code", ""), required=True,
placeholder="60601", hint="5-digit US ZIP code",
attrs='inputmode="numeric" maxlength="10" autocomplete="postal-code"')}
{R.field("state", "State", kind="select", value=app.get("state") or "",
error=errors.get("state", ""), required=True,
options=[("", "Select a state")] + list(US_STATES))}
{R.field("city", "City", value=app.get("city") or "",
error=errors.get("city", ""), placeholder="Chicago")}
<div class="btn-row" style="justify-content:space-between">
<a class="btn btn--ghost" href="/start-quote">Back</a>
<button class="btn btn--primary" type="submit">Continue</button>
</div>
</form>
</div>"""
return _shell(inner, step="location", title="Business location | Insureon",
app=app, logged_in=logged_in)
# --------------------------------------------------------------------------- #
# step 3: business details
# --------------------------------------------------------------------------- #
def business(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
revenue = app.get("annual_revenue")
employees = app.get("employees")
inner = f"""<div class="form-card">
<h1 style="font-size:1.7rem">Tell us about your business</h1>
<p style="color:var(--ion-muted)">Carriers price your policy from these details.</p>
{R.error_summary(errors)}
<form method="post" action="/app/quote/{R.esc(app['id'])}/business">
{R.field("business_name", "Business name", value=app.get("business_name") or "",
error=errors.get("business_name", ""), required=True,
placeholder="Northside Consulting LLC", attrs='autocomplete="organization"')}
<div class="field-row">
{R.field("employees", "Number of employees",
value="" if employees is None else str(employees),
error=errors.get("employees", ""), required=True,
kind="number", placeholder="5",
hint="Include owners and part-time staff",
attrs='min="0" max="500" inputmode="numeric"')}
{R.field("annual_revenue", "Annual revenue (USD)",
value="" if revenue is None else str(revenue),
error=errors.get("annual_revenue", ""), required=True,
kind="number", placeholder="200000",
hint="Gross revenue for the last 12 months",
attrs='min="0" step="1000" inputmode="numeric"')}
</div>
<div class="field-row">
{R.field("years_in_business", "Years in business", kind="select",
value=str(app.get("years_in_business") or ""),
error=errors.get("years_in_business", ""),
options=[("", "Select")] + list(YEARS_OPTIONS))}
{R.field("entity_type", "Business structure", kind="select",
value=app.get("entity_type") or "",
error=errors.get("entity_type", ""),
options=[("", "Select")] + list(ENTITY_TYPES))}
</div>
<div class="btn-row" style="justify-content:space-between">
<a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/location">Back</a>
<button class="btn btn--primary" type="submit">Continue</button>
</div>
</form>
</div>"""
return _shell(inner, step="business", title="Business details | Insureon",
app=app, logged_in=logged_in)
# --------------------------------------------------------------------------- #
# step 4: risk profile
# --------------------------------------------------------------------------- #
def risk(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
claims = bool(app.get("has_prior_claims"))
cert = bool(app.get("needs_certificate"))
inner = f"""<div class="form-card">
<h1 style="font-size:1.7rem">A few risk questions</h1>
<p style="color:var(--ion-muted)">These answers affect which carriers can quote
your business and what they charge.</p>
{R.error_summary(errors)}
<form method="post" action="/app/quote/{R.esc(app['id'])}/risk">
<div class="field">
<label>Have you had any insurance claims in the last 3 years?</label>
<label style="font-weight:400"><input type="radio" name="has_prior_claims"
value="0"{"" if claims else " checked"}> No claims</label><br>
<label style="font-weight:400"><input type="radio" name="has_prior_claims"
value="1"{" checked" if claims else ""}> Yes, one or more claims</label>
</div>
<div class="field">
<label>Do you need a certificate of insurance for a client or landlord?</label>
<label style="font-weight:400"><input type="checkbox" name="needs_certificate"
value="1"{" checked" if cert else ""}> Yes, I need a certificate of insurance</label>
</div>
{R.field("operations", "Briefly describe what your business does",
kind="textarea", value=app.get("operations") or "",
error=errors.get("operations", ""),
placeholder="Management consulting for small manufacturers",
hint="Optional. Helps carriers classify your operations.")}
<div class="btn-row" style="justify-content:space-between">
<a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/business">Back</a>
<button class="btn btn--primary" type="submit">Continue</button>
</div>
</form>
</div>"""
return _shell(inner, step="risk", title="Risk profile | Insureon",
app=app, logged_in=logged_in)
# --------------------------------------------------------------------------- #
# step 5: coverage
# --------------------------------------------------------------------------- #
def coverage(app: Mapping[str, Any], catalog: Mapping[str, Mapping[str, Any]],
selected: Sequence[str], limits: Mapping[str, Any],
errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
boxes = []
for slug, prod in catalog.items():
checked = " checked" if slug in selected else ""
boxes.append(f"""<label class="tile" style="display:block;cursor:pointer">
<input type="checkbox" name="products" value="{R.esc(slug)}"{checked}>
<strong style="margin-left:.4rem">{R.esc(prod["name"])}</strong>
<p style="margin:.5rem 0 0;font-size:.88rem;color:var(--ion-muted)">
{R.esc(prod.get("short_description", ""))}</p>
</label>""")
limit_opts = limits.get("limit_options") or []
ded_opts = limits.get("deductible_options") or []
inner = f"""<div class="form-card" style="max-width:48rem">
<h1 style="font-size:1.7rem">Choose your coverage</h1>
<p style="color:var(--ion-muted)">Select the policies you want quoted, then set
your limits and deductible.</p>
{R.error_summary(errors)}
<form method="post" action="/app/quote/{R.esc(app['id'])}/coverage">
<div class="tile-grid" style="grid-template-columns:1fr 1fr;margin-bottom:1.5rem">
{''.join(boxes)}
</div>
<div class="field-row">
{R.field("limit", "Liability limits", kind="select",
value=str(limits.get("limit") or ""),
error=errors.get("limit", ""), options=limit_opts)}
{R.field("deductible", "Deductible", kind="select",
value=str(limits.get("deductible") or ""),
error=errors.get("deductible", ""), options=ded_opts)}
</div>
<div class="btn-row" style="justify-content:space-between">
<a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/risk">Back</a>
<button class="btn btn--primary" type="submit">Get my quotes</button>
</div>
</form>
</div>"""
return _shell(inner, step="coverage", title="Choose your coverage | Insureon",
app=app, logged_in=logged_in)
# --------------------------------------------------------------------------- #
# step 6: compare quotes
# --------------------------------------------------------------------------- #
def _quote_card(app_id: str, q: Mapping[str, Any], chosen: bool) -> str:
badge = ('<span class="quote-card__badge">RECOMMENDED</span>'
if q.get("recommended") else "")
return f"""<div class="quote-card{' quote-card--recommended' if q.get('recommended') else ''}">
<div>
{badge}
<div class="quote-card__carrier">{R.esc(q["carrier_name"])}</div>
<div class="quote-card__meta">{R.esc(q["product_name"])} ·
AM Best {R.esc(q.get("rating", ""))}</div>
<div class="quote-card__meta">
{R.money(q["per_occurrence_limit_cents"])} per occurrence /
{R.money(q["aggregate_limit_cents"])} aggregate ·
{R.money(q["deductible_cents"])} deductible</div>
</div>
<div class="quote-card__price">
<b>{R.money(q["monthly_premium_cents"])}</b>
<span>per month · {R.money(q["annual_premium_cents"])} annually</span>
</div>
<div style="display:flex;flex-direction:column;gap:.5rem">
<form method="post" action="/app/quote/{R.esc(app_id)}/select">
<input type="hidden" name="option_id" value="{R.esc(q["id"])}">
<button class="btn {'btn--ghost' if chosen else 'btn--primary'} btn--sm" type="submit">
{"Selected" if chosen else "Select"}</button>
</form>
<a class="btn btn--ghost btn--sm" href="/app/quote/{R.esc(app_id)}/quotes/{R.esc(q['id'])}">
View details</a>
</div>
</div>"""
def quotes(app: Mapping[str, Any], options: Sequence[Mapping[str, Any]],
selected_ids: Sequence[str], notice: str = "",
logged_in: bool = False) -> str:
if not options:
listing = ('<div class="empty-state">No quotes have been generated for this '
'application yet. <a href="/app/quote/'
+ R.esc(app["id"]) + '/coverage">Choose your coverage</a> to continue.</div>')
else:
listing = ('<div class="quote-list">'
+ "".join(_quote_card(app["id"], q, q["id"] in selected_ids)
for q in options)
+ "</div>")
save = ""
if not logged_in:
save = ('<p style="color:var(--ion-muted);font-size:.9rem">'
'<a href="/account/register?next=/app/quote/' + R.esc(app["id"])
+ '/quotes">Create an account</a> to save these quotes and come '
'back to them later.</p>')
else:
save = f"""<form method="post" action="/app/quote/{R.esc(app['id'])}/save"
style="display:inline">
<button class="btn btn--ghost btn--sm" type="submit">Save this quote</button>
</form>"""
inner = f"""<h1 style="font-size:1.8rem">Compare your quotes</h1>
<p style="color:var(--ion-muted)">
{R.esc(app.get("business_name") or "Your business")} ·
{R.esc(app.get("profession_name", ""))} ·
{R.esc(app.get("city") or "")} {R.esc(app.get("state") or "")}
{R.esc(app.get("zip_code") or "")}</p>
{R.notice(notice)}
{listing}
<div style="margin-top:1.5rem">{save}</div>
<div class="btn-row" style="justify-content:space-between">
<a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/coverage">Edit coverage</a>
<a class="btn btn--primary" href="/app/quote/{R.esc(app['id'])}/review">Continue to review</a>
</div>"""
return _shell(inner, step="quotes", title="Compare quotes | Insureon",
app=app, logged_in=logged_in)
def quote_detail(app: Mapping[str, Any], q: Mapping[str, Any],
product: Mapping[str, Any] | None, chosen: bool,
logged_in: bool = False) -> str:
"""T08: plan detail with limits, benefits, exclusions and policy terms."""
def _bullets(entries: Any) -> str:
rows = []
for e in entries or []:
if isinstance(e, Mapping):
t, b = e.get("title", ""), e.get("body", "")
else:
t, b = str(e), ""
rows.append(f"<li><strong>{R.esc(t)}</strong>"
+ (f"<br>{R.esc(b)}" if b else "") + "</li>")
return "".join(rows)
covers = _bullets((product or {}).get("covers"))
excl = _bullets((product or {}).get("not_covered"))
inner = f"""<a href="/app/quote/{R.esc(app['id'])}/quotes"
style="font-size:.85rem">← Back to all quotes</a>
<h1 style="font-size:1.8rem;margin-top:1rem">{R.esc(q["carrier_name"])} —
{R.esc(q["product_name"])}</h1>
<div class="two-col" style="margin-top:1.5rem">
<div>
<table class="summary-table">
<tr><th>Carrier</th><td>{R.esc(q["carrier_name"])}</td></tr>
<tr><th>AM Best rating</th><td>{R.esc(q.get("rating", ""))}</td></tr>
<tr><th>Policy</th><td>{R.esc(q["product_name"])}</td></tr>
<tr><th>Per occurrence limit</th><td>{R.money(q["per_occurrence_limit_cents"])}</td></tr>
<tr><th>Aggregate limit</th><td>{R.money(q["aggregate_limit_cents"])}</td></tr>
<tr><th>Deductible</th><td>{R.money(q["deductible_cents"])}</td></tr>
<tr><th>Monthly premium</th><td>{R.money(q["monthly_premium_cents"])}</td></tr>
<tr class="total"><th>Annual premium</th><td>{R.money(q["annual_premium_cents"])}</td></tr>
</table>
<form method="post" action="/app/quote/{R.esc(app['id'])}/select" style="margin-top:1.5rem">
<input type="hidden" name="option_id" value="{R.esc(q["id"])}">
<button class="btn {'btn--ghost' if chosen else 'btn--primary'}" type="submit">
{"Selected for this application" if chosen else "Select this quote"}</button>
</form>
</div>
<div class="prose">
{f"<h3>What this policy covers</h3><ul>{covers}</ul>" if covers else ""}
{f"<h3>What this policy does not cover</h3><ul>{excl}</ul>" if excl else ""}
<h3>Policy terms</h3>
<ul>
<li>12-month policy term, effective the day coverage is bound.</li>
<li>Premium shown is for the limits and deductible selected on this application.</li>
<li>Final terms are subject to carrier underwriting review.</li>
</ul>
</div>
</div>"""
return _shell(inner, step="quotes",
title=f"{q['carrier_name']} {q['product_name']} quote | Insureon",
app=app, logged_in=logged_in)
# --------------------------------------------------------------------------- #
# step 7: review (T02 / T23 acceptance surface)
# --------------------------------------------------------------------------- #
def review(app: Mapping[str, Any], selected: Sequence[Mapping[str, Any]],
totals: Mapping[str, int], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
if not selected:
inner = f"""<h1 style="font-size:1.8rem">Review your application</h1>
<div class="empty-state">You have not selected a quote yet.
<a href="/app/quote/{R.esc(app['id'])}/quotes">Compare your quotes</a> and select
at least one policy to continue.</div>"""
return _shell(inner, step="review", title="Review your application | Insureon",
app=app, logged_in=logged_in)
rows = "".join(
f'<tr><th>{R.esc(q["product_name"])} — {R.esc(q["carrier_name"])}</th>'
f'<td>{R.money(q["annual_premium_cents"])} / year'
f'<span style="display:block;font-weight:400;color:var(--ion-muted);font-size:.85rem">'
f'{R.money(q["monthly_premium_cents"])} per month · '
f'{R.money(q["per_occurrence_limit_cents"])} per occurrence / '
f'{R.money(q["aggregate_limit_cents"])} aggregate · '
f'{R.money(q["deductible_cents"])} deductible</span></td></tr>'
for q in selected
)
revenue = app.get("annual_revenue")
revenue_txt = f"${int(revenue):,}" if revenue not in (None, "") else "—"
inner = f"""<h1 style="font-size:1.8rem">Review your application</h1>
<p style="color:var(--ion-muted)">Check that everything below is correct before
you continue to enrollment.</p>
{R.error_summary(errors)}
<div class="two-col" style="align-items:start">
<div>
<h3>Your business</h3>
<table class="summary-table">
<tr><th>Business name</th><td>{R.esc(app.get("business_name") or "—")}</td></tr>
<tr><th>Business type</th><td>{R.esc(app.get("profession_name") or "—")}</td></tr>
<tr><th>Industry</th><td>{R.esc(app.get("industry_name") or "—")}</td></tr>
<tr><th>Number of employees</th><td>{R.esc(app.get("employees"))}</td></tr>
<tr><th>Annual revenue</th><td>{revenue_txt}</td></tr>
<tr><th>Years in business</th><td>{R.esc(app.get("years_in_business") or "—")}</td></tr>
<tr><th>Business structure</th><td>{R.esc(ENTITY_TYPE_LABELS.get(app.get("entity_type") or "", app.get("entity_type") or "—"))}</td></tr>
<tr><th>Location</th><td>{R.esc(app.get("city") or "")}
{R.esc(app.get("state") or "")} {R.esc(app.get("zip_code") or "")}</td></tr>
<tr><th>Prior claims</th><td>{"Yes" if app.get("has_prior_claims") else "No"}</td></tr>
</table>
<p style="margin-top:1rem">
<a href="/app/quote/{R.esc(app['id'])}/business" style="font-size:.9rem">
Edit business details</a></p>
</div>
<div>
<h3>Your selected coverage</h3>
<table class="summary-table">
{rows}
<tr class="total"><th>Total annual premium</th>
<td>{R.money(totals["annual_cents"])}</td></tr>
<tr class="total"><th>Total monthly premium</th>
<td>{R.money(totals["monthly_cents"])}</td></tr>
</table>
<p style="margin-top:1rem">
<a href="/app/quote/{R.esc(app['id'])}/quotes" style="font-size:.9rem">
Change selected quotes</a></p>
</div>
</div>
<div class="btn-row" style="justify-content:space-between;margin-top:2.5rem">
<a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/quotes">Back</a>
<a class="btn btn--primary btn--lg" href="/app/quote/{R.esc(app['id'])}/enroll">
Continue to enrollment</a>
</div>"""
return _shell(inner, step="review", title="Review your application | Insureon",
app=app, logged_in=logged_in)
# --------------------------------------------------------------------------- #
# enrollment / payment / confirmation
# --------------------------------------------------------------------------- #
def enroll(app: Mapping[str, Any], totals: Mapping[str, int],
errors: Mapping[str, str] | None = None, logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""<div class="form-card">
<h1 style="font-size:1.7rem">Enrollment details</h1>
<p style="color:var(--ion-muted)">We use these details to issue your policy
documents and certificate of insurance.</p>
{R.error_summary(errors)}
<form method="post" action="/app/quote/{R.esc(app['id'])}/enroll">
<div class="field-row">
{R.field("contact_first", "First name", value=app.get("contact_first") or "",
error=errors.get("contact_first", ""), required=True,
attrs='autocomplete="given-name"')}
{R.field("contact_last", "Last name", value=app.get("contact_last") or "",
error=errors.get("contact_last", ""), required=True,
attrs='autocomplete="family-name"')}
</div>
{R.field("email", "Email address", kind="email", value=app.get("email") or "",
error=errors.get("email", ""), required=True,
placeholder="owner@example.com", attrs='autocomplete="email"')}
{R.field("phone", "Phone number", kind="tel", value=app.get("phone") or "",
error=errors.get("phone", ""), required=True,
placeholder="(312) 555-0142", attrs='autocomplete="tel"')}
{R.field("effective_date", "Requested coverage start date", kind="date",
value=app.get("effective_date") or "",
error=errors.get("effective_date", ""), required=True)}
<table class="summary-table" style="margin:1.5rem 0">
<tr class="total"><th>Total annual premium</th>
<td>{R.money(totals["annual_cents"])}</td></tr>
</table>
<div class="btn-row" style="justify-content:space-between">
<a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/review">Back</a>
<button class="btn btn--primary" type="submit">Continue to payment</button>
</div>
</form>
</div>"""
return _shell(inner, step="review", title="Enrollment | Insureon",
app=app, logged_in=logged_in)
def payment(app: Mapping[str, Any], totals: Mapping[str, int],
errors: Mapping[str, str] | None = None, effective_date: str = "",
logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""<div class="form-card">
<h1 style="font-size:1.7rem">Payment</h1>
{R.notice("Offline demonstration site. This is a local sandbox payment step: "
"no card is charged, no payment processor is contacted, and no card "
"number is stored. Enter any placeholder values.")}
{R.error_summary(errors)}
<form method="post" action="/app/quote/{R.esc(app['id'])}/payment">
<input type="hidden" name="effective_date" value="{R.esc(effective_date)}">
{R.field("billing_name", "Name on account", value="",
error=errors.get("billing_name", ""), required=True,
placeholder="Business owner name")}
{R.field("method_label", "Payment method", kind="select", value="card-sandbox",
error=errors.get("method_label", ""),
options=[("card-sandbox", "Sandbox card"),
("ach-sandbox", "Sandbox bank transfer")])}
{R.field("billing_zip", "Billing ZIP code", value=app.get("zip_code") or "",
error=errors.get("billing_zip", ""), required=True,
attrs='inputmode="numeric" maxlength="10"')}
<table class="summary-table" style="margin:1.5rem 0">
<tr><th>Total annual premium</th><td>{R.money(totals["annual_cents"])}</td></tr>
<tr class="total"><th>Due today</th><td>{R.money(totals["annual_cents"])}</td></tr>
</table>
<div class="btn-row" style="justify-content:space-between">
<a class="btn btn--ghost" href="/app/quote/{R.esc(app['id'])}/enroll">Back</a>
<button class="btn btn--primary btn--lg" type="submit">Complete purchase</button>
</div>
</form>
</div>"""
return _shell(inner, step="review", title="Payment | Insureon",
app=app, logged_in=logged_in)
def confirmation(app: Mapping[str, Any], policies: Sequence[Mapping[str, Any]],
totals: Mapping[str, int], documents: Sequence[Mapping[str, Any]],
logged_in: bool = False) -> str:
rows = "".join(
f'<tr><th>{R.esc(p["product_name"])} — {R.esc(p["carrier_name"])}</th>'
f'<td>Policy {R.esc(p["number"])}<span style="display:block;font-weight:400;'
f'color:var(--ion-muted);font-size:.85rem">Effective {R.esc(p["effective_date"])} '
f'to {R.esc(p["expiration_date"])} · {R.money(p["annual_premium_cents"])} / year'
f"</span></td></tr>"
for p in policies
)
docs = "".join(
f'<li><a href="/account/documents/{R.esc(d["id"])}">{R.esc(d["title"])}</a></li>'
for d in documents
)
revenue = app.get("annual_revenue")
revenue_txt = f"${int(revenue):,}" if revenue not in (None, "") else "—"
inner = f"""<div style="max-width:44rem;margin:0 auto">
<h1 style="font-size:1.9rem">You're covered.</h1>
<p style="color:var(--ion-muted)">Application {R.esc(app.get("reference", ""))} is
complete. A confirmation was recorded for
{R.esc(app.get("email") or "your account")}.</p>
<h3 style="margin-top:2rem">Your business</h3>
<table class="summary-table">
<tr><th>Business name</th><td>{R.esc(app.get("business_name") or "—")}</td></tr>
<tr><th>Business type</th><td>{R.esc(app.get("profession_name") or "—")}</td></tr>
<tr><th>Number of employees</th><td>{R.esc(app.get("employees"))}</td></tr>
<tr><th>Annual revenue</th><td>{revenue_txt}</td></tr>
</table>
<h3 style="margin-top:2rem">Your policies</h3>
<table class="summary-table">
{rows}
<tr class="total"><th>Total annual premium</th>
<td>{R.money(totals["annual_cents"])}</td></tr>
</table>
{f'<h3 style="margin-top:2rem">Your documents</h3><ul class="prose">{docs}</ul>' if docs else ''}
<div class="btn-row" style="justify-content:flex-start;margin-top:2rem">
<a class="btn btn--primary" href="/account/policies">Manage my policies</a>
<a class="btn btn--ghost" href="/account/documents">View documents</a>
</div>
</div>"""
return _shell(inner, step="review", title="Purchase confirmed | Insureon",
app=app, logged_in=logged_in)
|