KJE.Default.TaxRate=29;KJE.Default.TaxRateRetire=15;KJE.Default.TaxRateCapGain=14.5;KJE.Default.StateTaxRate=0;KJE.Default.IncomeTaxTableCurrent="";KJE.Default.IncomeTaxTableTaxYear=KJE.Default.IncomeTaxTableCurrent;KJE.definitions.set("**TAXTABLE_CURRENT_DEFINITION**",KJE.Default.IncomeTaxTableCurrent);KJE.definitions.set("**TAXTABLE_TAXYEAR_DEFINITION**",KJE.Default.IncomeTaxTableCurrent);KJE.Default.InflationRate=3;KJE.Default.TaxRate=40;KJE.Default.TaxRateRetire=15;KJE.definitions.set("**INFLATION_DEFINITION**","What you expect for the average long-term inflation rate.");KJE.definitions.set("**ROR_DEFINITION**","The actual rate of return is largely dependent on the type of investments you select. For example, for the last thirty years the average annual rate of return for the TSX is about 10%. Savings accounts at a bank or credit union may pay as little as 2% or less. It is important to remember that future rates of return can't be predicted with certainty and that investments that pay higher rates of return are generally subject to higher risk and volatility. The actual rate of return on investments can vary widely over time, especially for long-term investments. This includes the potential loss of principal on your investment.");KJE.ExistingLoanCalc=function(){this.MONTHS_LEFT=0;this.MONTHLY_PAYMENT=0;this.LOAN_AMOUNT=0;this.INTEREST_RATE=0;this.CURRENT_BALANCE=0;this.TERM=0;this.TOTAL_OF_PAYMENTS=0;this.TOTAL_OF_REMAINING=0;this.INTEREST_PAID=0;this.INTEREST_REMAINING=0;this.DS_BALANCE=null;this.DS_BALANCE2=null;this.cats=null;this.LNW_ERROR=KJE.parameters.get("ARRAY_MSG_ERROR",["payment must be greater than zero.","balance must be greater than zero.","term must be greater than zero.","interest exceeds 100%.","interest is less than 0%.","Payment is less than interest due"]);this.MSG_SUMMARY=KJE.parameters.get("MSG_SUMMARY","You have paid a total of CALC_TOTAL_PAYMENT after CALC_MONTHS_TODATE monthly payments. This includes CALC_INTEREST in interest. If you continue to make your regular monthly payments you will pay an additional CALC_REMAINING_INTEREST in interest over the next CALC_MONTHS_LEFT months.");this.MSG_GRAPH_REPORT_TITLE=KJE.parameters.get("MSG_GRAPH_REPORT_TITLE","Current outstanding balance is CURRENT_BALANCE.");this.sSchedule=new KJE.Repeating()};KJE.ExistingLoanCalc.prototype.clear=function(){};KJE.ExistingLoanCalc.prototype.calculate=function(t){var e=KJE;var g=this.MONTHLY_PAYMENT;var o=this.LOAN_AMOUNT;var w=this.TERM;var u=this.MONTHS_LEFT;var c=0;if((g+w+o)<=0){this.CURRENT_BALANCE=0;u=0;c=0}else{if(g<=0){throw new (this.LNW_ERROR[0])}if(o<=0){throw new (this.LNW_ERROR[1])}if(w<=0){throw new (this.LNW_ERROR[2])}c=KJE.RATE(w,g,o);this.SEMI_ANNUAL_INTEREST_RATE=(Math.pow(1+(c),6)-1)*(200)}this.INTEREST_RATE=c*1200;var a=o;var k=0;var v=0;if(u<=0){u=0;this.CURRENT_BALANCE=0}else{if(u>w){u=w}for(var p=1;p<=(w-u);p++){k=(a*(c));v=g-k;a-=v}this.CURRENT_BALANCE=a}this.TOTAL_OF_PAYMENTS=0;this.INTEREST_PAID=0;this.INTEREST_REMAINING=0;this.TOTAL_OF_REMAINING=0;var j=Math.round(this.TERM);var r=0;var h=j;if(j>120){h=Math.ceil(j/12)}else{if(j>48){h=Math.ceil(j/2)}else{h=j}}this.DS_BALANCE=KJE.FloatArray(h+1);this.DS_BALANCE2=KJE.FloatArray(h+1);this.cats=new Array(h+1);if(t){var f=this.sSchedule;f.clearRepeat();f.addHeader(f.sReportCol("#",1),f.sReportCol("Payment",2),f.sReportCol("Principal",3),f.sReportCol("Interest",4),f.sReportCol("Loan balance",5));f.addRepeat(" "," "," "," ",e.dollars(this.LOAN_AMOUNT))}var b=this.LOAN_AMOUNT;var s=0;var x=0;var d=this.MONTHLY_PAYMENT;if(this.TERM==this.MONTHS_LEFT){this.DS_BALANCE[0]=(this.LOAN_AMOUNT);this.DS_BALANCE2[0]=0}else{this.DS_BALANCE[0]=(this.LOAN_AMOUNT);this.DS_BALANCE2[0]=0}this.cats[0]="0";var l=0;var m=true;for(var p=1;p<=j;p++){r=p-1;if(j>120){m=((r%12)==0)}else{if(j>48){m=((r%2)==0)}else{m=true}}s=e.round(c*b,2);x=this.MONTHLY_PAYMENT-s;b-=x;if(b<0){d+=b;b=0;x=d-s}else{d=this.MONTHLY_PAYMENT}if(j==p){if(b>0.005){d+=b;b=0;x=d-s}else{b=0}}if(p>this.TERM-this.MONTHS_LEFT){this.INTEREST_REMAINING+=s;this.TOTAL_OF_REMAINING+=d}else{this.INTEREST_PAID+=s;this.TOTAL_OF_PAYMENTS+=d}if(m){if(j>120){this.cats[l+1]=""+Math.floor((p+12)/12)}else{this.cats[l+1]=""+p}if(p>this.TERM-this.MONTHS_LEFT){this.DS_BALANCE[l+1]=0;this.DS_BALANCE2[l+1]=(b)}else{this.DS_BALANCE[l+1]=(b);this.DS_BALANCE2[l+1]=0}l+=1}if(t){f.addRepeat(e.number(p),e.dollars(d,2),e.dollars(x,2),e.dollars(s,2),e.dollars(b,2))}}};KJE.ExistingLoanCalc.prototype.formatReport=function(b){var c=KJE;var a=this.iDecimal;var d=b;d=KJE.replace("CURRENT_BALANCE",c.dollars(this.CURRENT_BALANCE),d);d=KJE.replace("MONTHS_LEFT",c.number(this.MONTHS_LEFT),d);d=KJE.replace("MONTHLY_PAYMENT",c.dollars(this.MONTHLY_PAYMENT,2),d);d=KJE.replace("INTEREST_RATE",c.percent(this.INTEREST_RATE/100,2),d);d=KJE.replace("TERM",c.number(this.TERM),d);d=KJE.replace("LOAN_AMOUNT",c.dollars(this.LOAN_AMOUNT),d);d=KJE.replace("INTEREST_PAID",c.dollars(this.INTEREST_PAID,2),d);d=KJE.replace("INTEREST_REMAINING",c.dollars(this.INTEREST_REMAINING,2),d);d=KJE.replace("TOTAL_OF_PAYMENTS",c.dollars(this.TOTAL_OF_PAYMENTS,2),d);d=KJE.replace("TOTAL_OF_REMAINING",c.dollars(this.TOTAL_OF_REMAINING,2),d);d=KJE.replace("MONTHS_TODATE",c.number(this.TERM-this.MONTHS_LEFT),d);d=d.replace("**REPEATING GROUP**",this.sSchedule.getRepeat());this.sSchedule.clearRepeat();return d};KJE.ExistingLoanCalc.prototype.formatGraph=function(a,b){b[0].setTitle("");b[0].setTitleGraph("");b[0].show(true);b[0].paint()};KJE.ExistingLoanCalc.prototype.getGraphTitle=function(b){var a=this.MSG_GRAPH_REPORT_TITLE+"
Monthly payment | MONTHLY_PAYMENT |
---|---|
Loan amount | LOAN_AMOUNT |
Interest rate | INTEREST_RATE |
Term | TERM months |
Payments left | MONTHS_LEFT monthly payments |
Current balance | CURRENT_BALANCE |
Interest paid | INTEREST_PAID |