From ec0b8feac597d969057cee0d5ce8785eb5c9c0c0 Mon Sep 17 00:00:00 2001 From: olsch01 Date: Wed, 11 Mar 2026 11:06:47 -0400 Subject: [PATCH] Fix AI prompt ambiguity around annual dues income vs. collection frequency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clarify that annualIncome is the total per year, and payment frequency describes the cash flow timing of installments — not a multiplier on income. Include per-installment dollar amount so the model understands cash float correctly. Co-Authored-By: Claude Sonnet 4.6 --- server.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index db2f759..b567922 100644 --- a/server.js +++ b/server.js @@ -207,21 +207,24 @@ app.post('/api/calculate', async (req, res) => { return res.status(400).json({ error: 'homesites and annualIncome are required.' }); } - const fmt = n => '$' + Math.round(n).toLocaleString(); - const freqLabel = { monthly: 'monthly', quarterly: 'quarterly', annually: 'annual' }[paymentFreq] || 'monthly'; - const typeLabel = { sfh: 'single-family home', townhomes: 'townhome', condos: 'condo', mixed: 'mixed-use' }[propertyType] || ''; + const fmt = n => '$' + Math.round(n).toLocaleString(); + const typeLabel = { sfh: 'single-family home', townhomes: 'townhome', condos: 'condo', mixed: 'mixed-use' }[propertyType] || ''; + const freqDivisor = { monthly: 12, quarterly: 4, annually: 1 }[paymentFreq] || 12; + const installmentAmt = annualIncome / freqDivisor; + const freqDesc = { monthly: 'monthly installments', quarterly: 'quarterly installments', annually: 'one lump-sum annual payment' }[paymentFreq] || 'monthly installments'; const prompt = `You are a conservative HOA financial advisor. Given the following community data, provide a brief (3-4 sentence) plain-English investment income recommendation. Use only conservative, realistic estimates. Do not speculate beyond what the data supports. Community: ${homesites}-unit ${typeLabel} association -Annual dues income: ${fmt(annualIncome)} (collected ${freqLabel}) +Total annual dues income: ${fmt(annualIncome)} per year +Dues collection schedule: collected in ${freqDesc} of approximately ${fmt(installmentAmt)} per cycle (this affects operating cash flow timing, not the total annual amount) Reserve fund balance: ${fmt(reserveFunds || 0)} Interest income earned in 2025: ${fmt(interest2025 || 0)} Provide a recommendation focused on: 1. How much of the reserve funds could conservatively be invested and in what vehicle (e.g. CD ladder, money market, T-bills) -2. How much operating cash could earn interest between collection and expense periods -3. A realistic estimated annual interest income potential +2. How much operating cash float could earn interest between each collection cycle and upcoming expenses, given the ${freqDesc} schedule +3. A realistic estimated annual interest income potential based on the full ${fmt(annualIncome)} annual dues total 4. A single sentence comparing that to their 2025 actual if provided Keep the tone professional and factual. No bullet points — flowing paragraph only.`;