From d2c3f981fd449db0ca15b66bc960a89c7d11015f Mon Sep 17 00:00:00 2001 From: kawaiipunk Date: Mon, 15 Jun 2026 00:31:35 +0100 Subject: [PATCH] Fix simple-at-maturity payout bug and minor issues - Fix: simple-at-maturity final payout now includes total interest (was only paying one year's interest due to dead ternary) - Fix: add type='button' to prevent form submission in WordPress - Fix: add radix 10 to parseInt - Fix: remove misleading tilde on exact average income calculation --- calc.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/calc.html b/calc.html index d7a20b8..0216318 100644 --- a/calc.html +++ b/calc.html @@ -77,7 +77,7 @@ - @@ -210,7 +210,7 @@ /* --- Read raw inputs --- */ var a=parseFloat(document.getElementById('scd-amt').value), /* Investment amount (£) */ r=parseFloat(document.getElementById('scd-rate').value), /* Annual interest rate (%) */ - t=parseInt(document.getElementById('scd-term').value), /* Bond term (years) */ + t=parseInt(document.getElementById('scd-term').value,10), /* Bond term (years) */ mEl=document.querySelector('input[name="scd-m"]:checked'), /* Selected payout method */ m=mEl?mEl.value:'cm', /* Default to compound-at-maturity */ e=document.getElementById('scd-err'), /* Error container */ @@ -245,7 +245,7 @@ if(ann){ p=i; /* yearly payout = this year's interest */ }else if(y===t){ /* final year for at-maturity modes */ - p=cmp?bal+i:bal+i; /* pay out current balance + final interest */ + p=cmp?bal+i:a+totI; /* cm: full accumulated balance; sm: principal + total simple interest */ } totP+=p; @@ -281,7 +281,7 @@ /* --- Populate summary cards --- */ document.getElementById('scd-r-total').textContent=g(total); document.getElementById('scd-r-interest').textContent=g(netI); - document.getElementById('scd-r-annual').textContent=(ann?'':'~')+g(yrInc)+(ann?'/yr':'/yr avg'); + document.getElementById('scd-r-annual').textContent=g(yrInc)+(ann?'/yr':'/yr avg'); document.getElementById('scd-r-eff').textContent=eff.toFixed(2)+'%'; /* --- Update security tier display --- */