export function companyFormationCalculator(form: FormTs) {
// State filing fees (representative sample - actual fees vary)
const stateFees: Record<string, { llc: number, corp: number, expedite: number }> = {
'delaware': { llc: 90, corp: 89, expedite: 50 },
'wyoming': { llc: 100, corp: 100, expedite: 50 },
'nevada': { llc: 425, corp: 725, expedite: 125 },
'california': { llc: 70, corp: 100, expedite: 350 },
'texas': { llc: 300, corp: 300, expedite: 25 },
'florida': { llc: 125, corp: 70, expedite: 50 },
'new-york': { llc: 200, corp: 125, expedite: 75 },
'other': { llc: 150, corp: 150, expedite: 50 }
};
// Entity type base service fees
const entityFees: Record<string, number> = {
'llc': 500,
'c-corp': 750,
's-corp': 800,
'partnership': 600,
'lp': 650,
'non-profit': 1000,
'sole-prop': 200
};
// Document fees
const documentFees: Record<string, number> = {
'operating-agreement': 350,
'bylaws': 400,
'partnership-agreement': 500,
'shareholder-agreement': 600,
'minutes': 200,
'resolutions': 150,
'ein': 0,
'banking-resolution': 100
};
// Registered agent annual fees by state type
const agentFees: Record<string, number> = {
'basic': 99,
'premium': 199,
'self': 0
};
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Company Formation Cost Calculator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Entity Selection Section
const entitySection = form.addSubform('entity', { title: '๐ข Business Entity' });
entitySection.addRow(row => {
row.addDropdown('entityType', {
label: 'Entity Type',
options: [
{ id: 'llc', name: 'Limited Liability Company (LLC)' },
{ id: 'c-corp', name: 'C-Corporation' },
{ id: 's-corp', name: 'S-Corporation' },
{ id: 'partnership', name: 'General Partnership' },
{ id: 'lp', name: 'Limited Partnership (LP)' },
{ id: 'non-profit', name: 'Non-Profit Organization' },
{ id: 'sole-prop', name: 'Sole Proprietorship (DBA)' }
],
defaultValue: 'llc',
isRequired: true
}, '1fr');
row.addDropdown('state', {
label: 'Formation State',
options: [
{ id: 'delaware', name: 'Delaware (Most popular)' },
{ id: 'wyoming', name: 'Wyoming (Low fees)' },
{ id: 'nevada', name: 'Nevada (Privacy)' },
{ id: 'california', name: 'California' },
{ id: 'texas', name: 'Texas' },
{ id: 'florida', name: 'Florida' },
{ id: 'new-york', name: 'New York' },
{ id: 'other', name: 'Other State' }
],
defaultValue: 'delaware',
isRequired: true
}, '1fr');
});
entitySection.addRow(row => {
row.addDropdown('members', {
label: 'Number of Owners/Members',
options: [
{ id: '1', name: 'Single Member / Owner' },
{ id: '2-5', name: '2-5 Members / Shareholders' },
{ id: '6-10', name: '6-10 Members / Shareholders' },
{ id: '10+', name: '10+ Members / Shareholders' }
],
defaultValue: '1',
isRequired: true
}, '1fr');
row.addDropdown('processing', {
label: 'Processing Speed',
options: [
{ id: 'standard', name: 'Standard (5-10 business days)' },
{ id: 'expedited', name: 'Expedited (2-3 business days)' },
{ id: 'rush', name: 'Rush / Same Day (if available)' }
],
defaultValue: 'standard',
isRequired: true
}, '1fr');
});
// Services Section
const servicesSection = form.addSubform('services', { title: 'โ๏ธ Formation Services' });
servicesSection.addRow(row => {
row.addDropdown('registeredAgent', {
label: 'Registered Agent Service',
options: [
{ id: 'basic', name: 'Basic Agent ($99/year)' },
{ id: 'premium', name: 'Premium Agent ($199/year)' },
{ id: 'self', name: 'Self (I\'ll be my own agent)' }
],
defaultValue: 'basic',
isRequired: true
}, '1fr');
row.addDropdown('agentYears', {
label: 'Agent Service Duration',
options: [
{ id: '1', name: '1 Year' },
{ id: '2', name: '2 Years (5% discount)' },
{ id: '3', name: '3 Years (10% discount)' }
],
defaultValue: '1',
isVisible: () => {
const agent = servicesSection.dropdown('registeredAgent')?.value();
return agent !== 'self';
}
}, '1fr');
});
servicesSection.addRow(row => {
row.addCheckbox('einApplication', {
label: 'EIN / Tax ID Application (Included)',
defaultValue: true
}, '1fr');
row.addCheckbox('foreignQualification', {
label: 'Foreign Qualification (if doing business in another state)',
defaultValue: false
}, '1fr');
});
// Documents Section
const documentsSection = form.addSubform('documents', { title: '๐ Legal Documents' });
documentsSection.addRow(row => {
row.addCheckbox('operatingAgreement', {
label: 'Operating Agreement / Bylaws',
defaultValue: true
}, '1fr');
row.addDropdown('agreementType', {
label: 'Document Complexity',
options: [
{ id: 'basic', name: 'Basic Template' },
{ id: 'standard', name: 'Standard (+$200)' },
{ id: 'custom', name: 'Fully Custom (+$500)' }
],
defaultValue: 'basic',
isVisible: () => documentsSection.checkbox('operatingAgreement')?.value() === true
}, '1fr');
});
documentsSection.addRow(row => {
row.addCheckbox('shareholderAgreement', {
label: 'Shareholder / Member Agreement',
defaultValue: false,
isVisible: () => {
const members = entitySection.dropdown('members')?.value();
return members !== '1';
}
}, '1fr');
row.addCheckbox('minutes', {
label: 'Initial Minutes & Resolutions',
defaultValue: false
}, '1fr');
});
documentsSection.addRow(row => {
row.addCheckbox('bankingResolution', {
label: 'Banking Resolution',
defaultValue: false
}, '1fr');
row.addCheckbox('companyKit', {
label: 'Physical Company Kit (binder, seal)',
defaultValue: false
}, '1fr');
});
// Compliance Section
const complianceSection = form.addSubform('compliance', { title: 'โจ Ongoing Compliance' });
complianceSection.addRow(row => {
row.addCheckbox('annualReport', {
label: 'Annual Report Filing Service',
defaultValue: false
}, '1fr');
row.addCheckbox('complianceReminders', {
label: 'Compliance Calendar & Reminders',
defaultValue: true
}, '1fr');
});
complianceSection.addRow(row => {
row.addCheckbox('boiReport', {
label: 'BOI Report Filing (FinCEN)',
defaultValue: true
}, '1fr');
row.addCheckbox('bookkeepingSetup', {
label: 'Bookkeeping Setup Consultation',
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('stateFees', {
label: 'State Filing Fees',
computedValue: () => {
const entityType = entitySection.dropdown('entityType')?.value() || 'llc';
const state = entitySection.dropdown('state')?.value() || 'delaware';
const processing = entitySection.dropdown('processing')?.value() || 'standard';
const stateData = stateFees?.[state] ?? stateFees['other'];
let fee = (entityType.includes('corp') || entityType === 's-corp' ? stateData?.corp : stateData?.llc) ?? 0;
// Expedite fees
if (processing === 'expedited') fee += stateData?.expedite ?? 0;
else if (processing === 'rush') fee += stateData?.expedite ?? 0 * 2;
// Foreign qualification
if (servicesSection.checkbox('foreignQualification')?.value()) {
fee += 250;
}
return fee;
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('serviceFees', {
label: 'Formation Service Fee',
computedValue: () => {
const entityType = entitySection.dropdown('entityType')?.value() || 'llc';
const members = entitySection.dropdown('members')?.value() || '1';
let baseFee = entityFees?.[entityType] ?? 500;
// Multiple members complexity
if (members === '2-5') baseFee *= 1.1;
else if (members === '6-10') baseFee *= 1.2;
else if (members === '10+') baseFee *= 1.4;
return Math.round(baseFee);
},
variant: 'default'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('agentFees', {
label: 'Registered Agent',
computedValue: () => {
const agentType = servicesSection.dropdown('registeredAgent')?.value() || 'basic';
const years = parseInt(servicesSection.dropdown('agentYears')?.value() || '1');
const baseFee = agentFees?.[agentType] ?? 99;
let total = baseFee * years;
// Multi-year discounts
if (years === 2) total *= 0.95;
else if (years === 3) total *= 0.90;
return Math.round(total);
},
variant: 'default'
}, '1fr');
row.addPriceDisplay('documentFees', {
label: 'Legal Documents',
computedValue: () => {
const entityType = entitySection.dropdown('entityType')?.value() || 'llc';
let total = 0;
if (documentsSection.checkbox('operatingAgreement')?.value()) {
const isCorpType = entityType.includes('corp') || entityType === 's-corp';
let baseDoc = isCorpType ? (documentFees['bylaws'] || 400) : (documentFees['operating-agreement'] || 350);
const agreementType = documentsSection.dropdown('agreementType')?.value() || 'basic';
if (agreementType === 'standard') baseDoc += 200;
else if (agreementType === 'custom') baseDoc += 500;
total += baseDoc;
}
if (documentsSection.checkbox('shareholderAgreement')?.value()) {
total += documentFees['shareholder-agreement'] || 600;
}
if (documentsSection.checkbox('minutes')?.value()) {
total += (documentFees['minutes'] || 200) + (documentFees['resolutions'] || 150);
}
if (documentsSection.checkbox('bankingResolution')?.value()) {
total += documentFees['banking-resolution'] || 100;
}
if (documentsSection.checkbox('companyKit')?.value()) {
total += 75;
}
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
summarySection.addRow(row => {
row.addPriceDisplay('complianceFees', {
label: 'Compliance Services',
computedValue: () => {
let total = 0;
if (complianceSection.checkbox('annualReport')?.value()) total += 150;
if (complianceSection.checkbox('boiReport')?.value()) total += 100;
if (complianceSection.checkbox('bookkeepingSetup')?.value()) total += 200;
return total;
},
variant: 'default',
prefix: '+'
}, '1fr');
});
const finalSection = form.addSubform('final', {
title: '๐งพ Total Investment',
isCollapsible: false,
sticky: 'bottom'
});
finalSection.addRow(row => {
row.addPriceDisplay('totalCost', {
label: 'Total Formation Cost',
computedValue: () => {
const entityType = entitySection.dropdown('entityType')?.value() || 'llc';
const state = entitySection.dropdown('state')?.value() || 'delaware';
const processing = entitySection.dropdown('processing')?.value() || 'standard';
const members = entitySection.dropdown('members')?.value() || '1';
// State fees
const stateData = stateFees?.[state] ?? stateFees['other'];
let stateFee = (entityType.includes('corp') || entityType === 's-corp' ? stateData?.corp : stateData?.llc) ?? 0;
if (processing === 'expedited') stateFee += stateData?.expedite ?? 0;
else if (processing === 'rush') stateFee += stateData?.expedite ?? 0 * 2;
if (servicesSection.checkbox('foreignQualification')?.value()) stateFee += 250;
// Service fees
let serviceFee = entityFees?.[entityType] ?? 500;
if (members === '2-5') serviceFee *= 1.1;
else if (members === '6-10') serviceFee *= 1.2;
else if (members === '10+') serviceFee *= 1.4;
// Agent fees
const agentType = servicesSection.dropdown('registeredAgent')?.value() || 'basic';
const years = parseInt(servicesSection.dropdown('agentYears')?.value() || '1');
let agentFee = (agentFees?.[agentType] ?? 99) * years;
if (years === 2) agentFee *= 0.95;
else if (years === 3) agentFee *= 0.90;
// Document fees
let docFee = 0;
if (documentsSection.checkbox('operatingAgreement')?.value()) {
const isCorpType = entityType.includes('corp') || entityType === 's-corp';
let baseDoc = isCorpType ? (documentFees['bylaws'] || 400) : (documentFees['operating-agreement'] || 350);
const agreementType = documentsSection.dropdown('agreementType')?.value() || 'basic';
if (agreementType === 'standard') baseDoc += 200;
else if (agreementType === 'custom') baseDoc += 500;
docFee += baseDoc;
}
if (documentsSection.checkbox('shareholderAgreement')?.value()) docFee += documentFees['shareholder-agreement'] || 600;
if (documentsSection.checkbox('minutes')?.value()) docFee += (documentFees['minutes'] || 200) + (documentFees['resolutions'] || 150);
if (documentsSection.checkbox('bankingResolution')?.value()) docFee += documentFees['banking-resolution'] || 100;
if (documentsSection.checkbox('companyKit')?.value()) docFee += 75;
// Compliance fees
let compFee = 0;
if (complianceSection.checkbox('annualReport')?.value()) compFee += 150;
if (complianceSection.checkbox('boiReport')?.value()) compFee += 100;
if (complianceSection.checkbox('bookkeepingSetup')?.value()) compFee += 200;
return Math.round(stateFee + serviceFee + agentFee + docFee + compFee);
},
variant: 'large'
});
});
finalSection.addRow(row => {
row.addTextPanel('timeline', {
computedValue: () => {
const processing = entitySection.dropdown('processing')?.value() || 'standard';
if (processing === 'rush') return 'Estimated Timeline: 1-2 business days';
if (processing === 'expedited') return 'Estimated Timeline: 2-3 business days';
return 'Estimated Timeline: 5-10 business days';
},
customStyles: { 'font-size': '0.9rem', 'color': '#64748b', 'text-align': 'center' }
});
});
finalSection.addRow(row => {
row.addTextPanel('disclaimer', {
computedValue: () => 'This estimate is for planning purposes only. State fees are subject to change. Actual formation time varies by state and processing volume.',
customStyles: { 'font-size': '0.8rem', 'color': '#64748b', 'font-style': 'italic' }
});
});
form.configureSubmitButton({
label: 'Start Formation Process'
});
}