export function willTestamentCalculator(form: FormTs) {
// Will types and base fees
const willTypes: Record<string, { baseFee: number, hours: number }> = {
'simple-single': { baseFee: 350, hours: 1.5 },
'simple-couple': { baseFee: 550, hours: 2.5 },
'standard-single': { baseFee: 650, hours: 3 },
'standard-couple': { baseFee: 950, hours: 4 },
'complex-single': { baseFee: 1200, hours: 5 },
'complex-couple': { baseFee: 1800, hours: 7 },
'high-net-worth': { baseFee: 3500, hours: 12 },
'business-owner': { baseFee: 2500, hours: 10 }
};
// Attorney rates
const attorneyRates: Record<string, number> = {
'associate': 250,
'senior-associate': 350,
'partner': 450,
'estate-specialist': 550
};
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Will & Testament Preparation Calculator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Will Type Section
const willSection = form.addSubform('willType', { title: '๐ Will Type' });
willSection.addRow(row => {
row.addDropdown('type', {
label: 'Will Package',
options: [
{ id: 'simple-single', name: 'Simple Will - Single Person' },
{ id: 'simple-couple', name: 'Simple Wills - Couple' },
{ id: 'standard-single', name: 'Standard Will - Single Person' },
{ id: 'standard-couple', name: 'Standard Wills - Couple' },
{ id: 'complex-single', name: 'Complex Will - Single Person' },
{ id: 'complex-couple', name: 'Complex Wills - Couple' },
{ id: 'high-net-worth', name: 'High Net Worth Estate Plan' },
{ id: 'business-owner', name: 'Business Owner Estate Plan' }
],
defaultValue: 'standard-single',
isRequired: true
}, '1fr');
row.addDropdown('attorneyLevel', {
label: 'Attorney Level',
options: [
{ id: 'associate', name: 'Associate ($250/hr)' },
{ id: 'senior-associate', name: 'Senior Associate ($350/hr)' },
{ id: 'partner', name: 'Partner ($450/hr)' },
{ id: 'estate-specialist', name: 'Estate Planning Specialist ($550/hr)' }
],
defaultValue: 'senior-associate',
isRequired: true
}, '1fr');
});
// Estate Details Section
const estateSection = form.addSubform('estate', { title: '๐ฐ Estate Details' });
estateSection.addRow(row => {
row.addDropdown('estateValue', {
label: 'Estimated Estate Value',
options: [
{ id: 'under-500k', name: 'Under $500,000' },
{ id: '500k-1m', name: '$500,000 - $1 million' },
{ id: '1m-3m', name: '$1 - $3 million' },
{ id: '3m-5m', name: '$3 - $5 million (+15%)' },
{ id: 'over-5m', name: 'Over $5 million (+30%)' }
],
defaultValue: '500k-1m',
isRequired: true
}, '1fr');
row.addDropdown('beneficiaries', {
label: 'Number of Beneficiaries',
options: [
{ id: '1-2', name: '1-2 Beneficiaries' },
{ id: '3-5', name: '3-5 Beneficiaries' },
{ id: '6-10', name: '6-10 Beneficiaries (+$200)' },
{ id: '10+', name: '10+ Beneficiaries (+$400)' }
],
defaultValue: '3-5',
isRequired: true
}, '1fr');
});
estateSection.addRow(row => {
row.addCheckbox('minorChildren', {
label: 'Minor Children (Guardian provisions) (+$200)',
defaultValue: false
}, '1fr');
row.addCheckbox('specialNeeds', {
label: 'Special Needs Beneficiary (+$500)',
defaultValue: false
}, '1fr');
});
estateSection.addRow(row => {
row.addCheckbox('blendedFamily', {
label: 'Blended Family Provisions (+$350)',
defaultValue: false
}, '1fr');
row.addCheckbox('charityBequest', {
label: 'Charitable Bequests (+$150)',
defaultValue: false
}, '1fr');
});
// Additional Documents Section
const documentsSection = form.addSubform('documents', { title: '๐ Additional Documents' });
documentsSection.addRow(row => {
row.addCheckbox('livingWill', {
label: 'Living Will / Advance Directive (+$150)',
defaultValue: true
}, '1fr');
row.addCheckbox('healthcarePoa', {
label: 'Healthcare Power of Attorney (+$150)',
defaultValue: true
}, '1fr');
});
documentsSection.addRow(row => {
row.addCheckbox('financialPoa', {
label: 'Financial Power of Attorney (+$200)',
defaultValue: true
}, '1fr');
row.addCheckbox('hipaaAuth', {
label: 'HIPAA Authorization (+$50)',
defaultValue: false
}, '1fr');
});
documentsSection.addRow(row => {
row.addCheckbox('digitalAssets', {
label: 'Digital Assets Directive (+$100)',
defaultValue: false
}, '1fr');
row.addCheckbox('petTrust', {
label: 'Pet Trust (+$300)',
defaultValue: false
}, '1fr');
});
// Trust Options Section
const trustSection = form.addSubform('trusts', { title: '๐๏ธ Trust Options' });
trustSection.addRow(row => {
row.addCheckbox('revocableTrust', {
label: 'Revocable Living Trust (+$1,500-2,500)',
defaultValue: false
}, '1fr');
row.addCheckbox('irrevocableTrust', {
label: 'Irrevocable Trust (+$2,500-5,000)',
defaultValue: false
}, '1fr');
});
trustSection.addRow(row => {
row.addCheckbox('specialNeedsTrust', {
label: 'Special Needs Trust (+$2,000)',
defaultValue: false
}, '1fr');
row.addCheckbox('spendthriftTrust', {
label: 'Spendthrift Trust (+$1,500)',
defaultValue: false
}, '1fr');
});
trustSection.addRow(row => {
row.addCheckbox('estateTaxPlanning', {
label: 'Estate Tax Planning (+$1,000-3,000)',
defaultValue: false,
isVisible: () => {
const value = estateSection.dropdown('estateValue')?.value();
return ['3m-5m', 'over-5m'].includes(value || '');
}
}, '1fr');
row.addCheckbox('assetProtection', {
label: 'Asset Protection Planning (+$1,500)',
defaultValue: false
}, '1fr');
});
// Service Options Section
const serviceSection = form.addSubform('service', { title: 'โ๏ธ Service Options' });
serviceSection.addRow(row => {
row.addDropdown('urgency', {
label: 'Timeline',
options: [
{ id: 'standard', name: 'Standard (2-3 weeks)' },
{ id: 'expedited', name: 'Expedited (1 week) (+25%)' },
{ id: 'rush', name: 'Rush (2-3 days) (+50%)' }
],
defaultValue: 'standard',
isRequired: true
}, '1fr');
row.addCheckbox('witnessNotary', {
label: 'Witness & Notary Services (+$75)',
defaultValue: true
}, '1fr');
});
serviceSection.addRow(row => {
row.addCheckbox('fundingGuidance', {
label: 'Trust Funding Guidance (+$300)',
defaultValue: false,
isVisible: () => {
return (trustSection.checkbox('revocableTrust')?.value() ||
trustSection.checkbox('irrevocableTrust')?.value()) ?? false;
}
}, '1fr');
row.addCheckbox('annualReview', {
label: 'Annual Review Service (+$200/year)',
defaultValue: false
}, '1fr');
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Summary Section
const summarySection = form.addSubform('summary', { title: '๐ฐ Cost Estimate', isCollapsible: false });
summarySection.addRow(row => {
row.addPriceDisplay('willFee', {
label: 'Will Preparation',
computedValue: () => {
const type = willSection.dropdown('type')?.value() || 'standard-single';
const estateValue = estateSection.dropdown('estateValue')?.value() || '500k-1m';
let fee = willTypes[type]?.baseFee ?? 0;
// Estate value adjustment
const valueMultipliers: Record<string, number> = {
'under-500k': 1.0, '500k-1m': 1.0, '1m-3m': 1.1,
'3m-5m': 1.15, 'over-5m': 1.3
};
fee *= valueMultipliers[estateValue] || 1.0;
return Math.round(fee);
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('estateFee', {
label: 'Estate Provisions',
computedValue: () => {
let total = 0;
const beneficiaries = estateSection.dropdown('beneficiaries')?.value() || '3-5';
if (beneficiaries === '6-10') total += 200;
if (beneficiaries === '10+') total += 400;
if (estateSection.checkbox('minorChildren')?.value()) total += 200;
if (estateSection.checkbox('specialNeeds')?.value()) total += 500;
if (estateSection.checkbox('blendedFamily')?.value()) total += 350;
if (estateSection.checkbox('charityBequest')?.value()) total += 150;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('documentsFee', {
label: 'Additional Documents',
computedValue: () => {
let total = 0;
if (documentsSection.checkbox('livingWill')?.value()) total += 150;
if (documentsSection.checkbox('healthcarePoa')?.value()) total += 150;
if (documentsSection.checkbox('financialPoa')?.value()) total += 200;
if (documentsSection.checkbox('hipaaAuth')?.value()) total += 50;
if (documentsSection.checkbox('digitalAssets')?.value()) total += 100;
if (documentsSection.checkbox('petTrust')?.value()) total += 300;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
row.addPriceDisplay('trustFee', {
label: 'Trust Planning',
computedValue: () => {
let total = 0;
if (trustSection.checkbox('revocableTrust')?.value()) total += 2000;
if (trustSection.checkbox('irrevocableTrust')?.value()) total += 3500;
if (trustSection.checkbox('specialNeedsTrust')?.value()) total += 2000;
if (trustSection.checkbox('spendthriftTrust')?.value()) total += 1500;
if (trustSection.checkbox('estateTaxPlanning')?.value()) total += 2000;
if (trustSection.checkbox('assetProtection')?.value()) total += 1500;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('serviceFee', {
label: 'Services & Urgency',
computedValue: () => {
const type = willSection.dropdown('type')?.value() || 'standard-single';
const urgency = serviceSection.dropdown('urgency')?.value() || 'standard';
const baseFee = willTypes[type]?.baseFee ?? 0;
let total = 0;
// Urgency
const urgencyMultipliers: Record<string, number> = {
'standard': 0, 'expedited': 0.25, 'rush': 0.50
};
total += baseFee * (urgencyMultipliers[urgency] || 0);
// Services
if (serviceSection.checkbox('witnessNotary')?.value()) total += 75;
if (serviceSection.checkbox('fundingGuidance')?.value()) total += 300;
if (serviceSection.checkbox('annualReview')?.value()) total += 200;
return Math.round(total);
},
variant: 'default',
prefix: '+'
});
});
const finalSection = form.addSubform('final', {
title: '๐งพ Total Estimate',
isCollapsible: false,
sticky: 'bottom'
});
finalSection.addRow(row => {
row.addPriceDisplay('totalFee', {
label: 'Estimated Total',
computedValue: () => {
const type = willSection.dropdown('type')?.value() || 'standard-single';
const estateValue = estateSection.dropdown('estateValue')?.value() || '500k-1m';
const beneficiaries = estateSection.dropdown('beneficiaries')?.value() || '3-5';
const urgency = serviceSection.dropdown('urgency')?.value() || 'standard';
// Base will fee
let total = willTypes[type]?.baseFee ?? 0;
// Estate value multiplier
const valueMultipliers: Record<string, number> = {
'under-500k': 1.0, '500k-1m': 1.0, '1m-3m': 1.1,
'3m-5m': 1.15, 'over-5m': 1.3
};
total *= valueMultipliers[estateValue] || 1.0;
// Beneficiaries
if (beneficiaries === '6-10') total += 200;
if (beneficiaries === '10+') total += 400;
// Estate provisions
if (estateSection.checkbox('minorChildren')?.value()) total += 200;
if (estateSection.checkbox('specialNeeds')?.value()) total += 500;
if (estateSection.checkbox('blendedFamily')?.value()) total += 350;
if (estateSection.checkbox('charityBequest')?.value()) total += 150;
// Documents
if (documentsSection.checkbox('livingWill')?.value()) total += 150;
if (documentsSection.checkbox('healthcarePoa')?.value()) total += 150;
if (documentsSection.checkbox('financialPoa')?.value()) total += 200;
if (documentsSection.checkbox('hipaaAuth')?.value()) total += 50;
if (documentsSection.checkbox('digitalAssets')?.value()) total += 100;
if (documentsSection.checkbox('petTrust')?.value()) total += 300;
// Trusts
if (trustSection.checkbox('revocableTrust')?.value()) total += 2000;
if (trustSection.checkbox('irrevocableTrust')?.value()) total += 3500;
if (trustSection.checkbox('specialNeedsTrust')?.value()) total += 2000;
if (trustSection.checkbox('spendthriftTrust')?.value()) total += 1500;
if (trustSection.checkbox('estateTaxPlanning')?.value()) total += 2000;
if (trustSection.checkbox('assetProtection')?.value()) total += 1500;
// Urgency
const urgencyMultipliers: Record<string, number> = {
'standard': 1.0, 'expedited': 1.25, 'rush': 1.50
};
total *= urgencyMultipliers[urgency] || 1.0;
// Services
if (serviceSection.checkbox('witnessNotary')?.value()) total += 75;
if (serviceSection.checkbox('fundingGuidance')?.value()) total += 300;
if (serviceSection.checkbox('annualReview')?.value()) total += 200;
return Math.round(total);
},
variant: 'large'
});
});
finalSection.addRow(row => {
row.addTextPanel('packageNote', {
computedValue: () => {
const type = willSection.dropdown('type')?.value() || 'standard-single';
if (type.includes('couple')) {
return 'Price includes wills for both spouses';
}
return 'Individual estate planning package';
},
customStyles: { 'font-size': '0.9rem', 'color': '#059669', 'text-align': 'center' }
});
});
finalSection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => 'This estimate is for planning purposes. Actual fees depend on estate complexity and specific requirements. A consultation will determine the optimal estate planning strategy for your situation.',
customStyles: { 'font-size': '0.8rem', 'color': '#64748b', 'font-style': 'italic' }
});
});
form.configureSubmitButton({
label: 'Schedule Estate Planning Consultation'
});
}