1function Affordability(){this._goGetRates=function(e){$.ajax({dataType:"json",url:"/ajax/get_interest_rates.php",context:{calculatorObject:e}}).done(function(t){var n=[];$.each(t,function(t,e){null==n[e.loan_type]&&(n[e.loan_type]={}),null==n[e.loan_type][e.loan_purpose]&&(n[e.loan_type][e.loan_purpose]={}),null==n[e.loan_type][e.loan_purpose][e.credit_rating]&&(n[e.loan_type][e.loan_purpose][e.credit_rating]={}),null==n[e.loan_type][e.loan_purpose][e.credit_rating][e.term]&&(n[e.loan_type][e.loan_purpose][e.credit_rating][e.term]={}),n[e.loan_type][e.loan_purpose][e.credit_rating][e.term][e.loan_amount]=parseFloat(e.interest_rate).toFixed(3)}),e.set("rateTable",n),$(document).trigger("ratesLoaded")})},this._goGetRates(this),this.set=function(t,e,n){if(void 0===this.set[t]){this[t]=e;return/^_.*/g.test(t)||this._calculateDerived.call(this),{action:"set",field:t,value:e}}this.set[t].call(this,e,n)},this.set.downPaymentPercent=function(t,e){this.downPaymentPercent=parseFloat(t)/100},this.set.interestRate=function(t,e){return 10<t&&(t=10),t/=100,this.interestRate=t,this._calculateDerived.call(this),{action:"set",field:"interestRate",value:t}},this.set.insuranceRate=function(t,e){return.5<t&&(t=.5),t/=100,this.insuranceRate=t,this._calculateDerived.call(this),{action:"set",field:"insuranceRate",value:t}},this.set.propertyTaxRate=function(t,e){return 2.5<t&&(t=2.5),t/=100,this.propertyTaxRate=t,this._calculateDerived.call(this),{action:"set",field:"propertyTaxRate",value:t}},this.get=function(t){return this[t]},this._calculateDerived=function(t){var e=this.get("annualIncome")/12;this.set("_monthlyIncome",e);var n=12*this.get("loanTermInYears");this.set("_loanTermInMonths",n);var a=e*this.get("recommendedIncomeRatio")-this.get("monthlyDebts");this.set("_recommendedTotalMonthlyPayment",a);this.get("recommendedIncomeRatio");e=0;180==n&&(e=33);a*=n/2.2+e;this.set("_reasonableStartingPointForPurchasePrice",a);n=this.get("downPayment"),e=this.get("downPaymentPercent");void 0===n&&-1<e&&(n=a*parseFloat(e));n=a-n;this.set("_reasonableAmountFinanced",n)},this._calculateMonthlyPrincipleAndInterestPayment=function(t,e,n,a){return 0==t?(e-n)/a:(t=t/12,(e-n)*Math.pow(1+t,a)*t/(Math.pow(1+t,a)-1))},this._r_calculateAffordability=function(t,e,n,a,i,r,s,o,l,c,u,h){if(s<0)return{status:"failure",reason:"recommended payment is negative"};void 0!==h&&null!=h?i=t*(b=h):b=i/t*100;var d,m=this._calculateFundingFeeRate(u,c,l,b,o),p=m/100*(t-i),y=t-i,_=p/r,f=t*e/12,g=t*n/12,P=this._calculateMonthlyPrincipleAndInterestPayment(a,t,i,r),v=f+g+P+_,R=s-(f+g+P+_),b=Math.abs(R)<.05,_=1+a+n+e;if(b)return d={status:"success",recommendedMonthyPayment:s,purchasePrice:t,monthlyTaxes:f,monthlyInsurance:g,monthlyPrincipleAndInterestPayment:P,monthlyPaymentWithThisPrice:v,fundingFeeRate:m,fundingFee:p,financedAmount:y,downPaymentPercent:h,downPayment:i,downPaymentPercentPretty:100*h,totalAmountPaid:v*r,totalInterestPaid:r*P-y};if(0!=R){if(t+=r/(2.2*_)*R,d=this._r_calculateAffordability.call(this,t,e,n,a,i,r,s,o,l,c,u,h))return d}else console.log("unknown condition? abort.")},this.calculate=function(){var t=this.get("_reasonableStartingPointForPurchasePrice"),e=this.get("propertyTaxRate"),n=this.get("insuranceRate"),a=this.get("interestRate"),i=this.get("downPayment"),r=parseFloat(this.get("downPaymentPercent")),s=this.get("_loanTermInMonths"),o=this.get("loanTermInYears"),l=this.get("_recommendedTotalMonthlyPayment"),c=this.get("vaPreviousUse"),u=this.get("loanType"),h=this.get("militaryStatus"),d=this.get("vaDisabled"),m=(this.get("rateTable"),this.get("monthlyDebts"));isNaN(r)&&(r=null);r=this._r_calculateAffordability.call(this,t,e,n,a,i,s,l,c,u,h,d,r),s=this.calculateAPR(r.financedAmount,s,a,r.fundingFee);return r.apr=s,r.interestRate=a,r.loanTermInYears=o,l=(l=this.get("_monthlyIncome")-l)-m-m,r.leftOver=l,r},this.formatCurrency=function(t,e){return(""===t||t<0)&&(t=0),e||0==e||(e=2),"$"+(t=(t=parseFloat(t).toFixed(e)).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,"))},this.calculateAPR=function(t,e,n,a,i){var r=t,s=e,a=a||0;"excellent"!=(i||"good")&&(a+=.01*r);for(var o,n=n/12,l=(r+a)*n*Math.pow(1+n,s)/(Math.pow(1+n,s)-1),c=n,u=1,h=c;u<=100&&(o=c*Math.pow(1+c,s)/(Math.pow(1+c,s)-1)-l/r,!(Math.abs(o)<1e-7));)o<0?c+=h:c-=h,h/=2,u++;return(c*=1200)<0&&(c=0),Number(c.toFixed(3))},this._calculateFundingFeeRate=function(t,e,n,a,i){var r;return!0===t||"spouse"===e?r=0:"purchase"===n||"p"===n?(a<5&&(r=!1===i?2.15:3.3),5<=a&&a<=10&&(r=1.5),10<=a&&(r=1.25)):r="cashout"===n?!1===i?2.15:3.3:(n="irrrl",.5),r},this.lookupRate=function(t,e,n,a,i){if(a=a<1e5?5e4:a<2e5?15e4:a<3e5?25e4:a<4e5?35e4:75e4,void 0===i)return!1;if(i.va&&i.va[t]&&i.va[t][e]&&i.va[t][e][n]&&i.va[t][e][n][a]){a=i.va[t][e][n][a];return(a=Number(a))<10&&0<a&&a}return!1}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.