Mortgage/Loan Overpayment Calculator
A few weeks back I was talking with someone who was looking into over-paying a loan. The premise is that, provided your lender allows overpayments, by over-paying you can save a fortune in interest payments.
The amount you can save isn't all that straight-forward to work out, due to the miracle that is compound interest. I knocked up a quick overpayment calculator using gwt.progressive
, which I'm hosting at Amazon S3 with a registered domain name.
Here's one of the classes that's being bound - or "activated" if you like - by gwt.progressive:
public class OverpaymentSummary extends Composite {
interface MyActivator extends WidgetActivator<OverpaymentSummary>{}
MyActivator activator = GWT.create(MyActivator.class);
@RuntimeUiWidget(id="saving") InlineLabel saving;
@RuntimeUiWidget(id="years") InlineLabel years;
@RuntimeUiWidget(id="months") InlineLabel months;
public OverpaymentSummary(Element anElement) {
initWidget(activator.activate(this, anElement));
}
public void setResults(
Money aStandardTotal, int aStandardMonths,
Money anOverpaidTotal, int anOverMonths) {
saving.setText(aStandardTotal.minus(anOverpaidTotal).toString());
int _monthsSaved = aStandardMonths - anOverMonths;
setYears(_monthsSaved/12);
setMonths(_monthsSaved - ((_monthsSaved/12)*12));
removeStyleName("hidden");
}
private void setYears(int aYears) {
years.setText(""+aYears);
}
private void setMonths(int aMonths) {
months.setText(""+aMonths);
}
}
Which is bound onto html that looks like this:
<div class="summary hidden">By overpaying you could save
<span id="saving">???</span>, and reduce your mortgage
term by <span id="years">?</span> years and
<span id="months">?</span> months!</div>
Notice the <span>
elements with the id's "saving", "years", and "months" - these are bound automatically to the three InlineLabel
's annotated with @RuntimeUiWidget
.