/* js code */ // Credit calculator function elems_summ(arr) { var total = 0; for (var i=1; i < arr.length; i++) { total += arr[i]; } return total.toPrecision(7); } function calculate() { // datas for calculation var price = $("input#price").val(); var vznos = $("input#vznos").val(); var period = $("select#period").val(); var stavka = $("input#stavka").val(); var percents = new Array(); var m = ''; var html = ''; var price_glob = price; var credit_summ = price; if (vznos != 0) { price -= vznos; credit_summ = price; } var f1 = $("input#forma1:checked").val(); if (f1 == 1) { // anual credit var mounthly = price * (((stavka/100)/12)/(1-(Math.pow(1+((stavka/100)/12), -period)))); m = mounthly.toPrecision(7) for (var i=1; i <= period; i++) { var percent = (price * (stavka/12) / 100); percents[i] = percent; var body = m - percent; html += ''+i+''+parseFloat(price).toPrecision(7)+''+body.toPrecision(7)+''+percent.toPrecision(7)+''+m+''; price -= body; } } else { // standart credit var body = price / period; var average_pay = 0; for (var i=1; i <= period; i++) { var percent = (price * (stavka/12) / 100); var mounthly = body + percent; average_pay += mounthly; percents[i] = percent; html += ''+i+''+parseFloat(price).toPrecision(7)+''+body.toPrecision(7)+''+percent.toPrecision(7)+''+mounthly.toPrecision(7)+''; price -= body; } m = average_pay / period; } var percents_summ = elems_summ(percents); var full_summ = parseFloat(credit_summ) + parseFloat(percents_summ); $("div#result").html("
Цена автомобиля, USD: "+price_glob+ "
Сумма кредита, USD: "+credit_summ+ "
Сумма выплаченных процентов за весь срок, USD: "+percents_summ+ "
Среднемесячный полный платеж, USD: "+m+ "
Полная стоимость с учетом выплаченных процентов, USD: "+full_summ+"
") var tbl = $("input#table:checked").length; if (tbl) { $("div#estimate").after(""+html+"
МесяцОстаток кредитаТело кредитаНачислено процентовВсего к оплате
"); } $("#clean").click(function () { $("div#estimate").remove(); $("table#est").remove(); }) } /* template */ {% extends "base.html" %} {% load i18n %} {% block title %} {% trans "Credit calculator" %} {% endblock %} {% block scripts %} {% endblock %} {% block content %}

{% trans "Credit calculator" %}

{% trans "Price of auto in USD" %}: $
{% trans "Start payment" %}: $
{% trans "Credit period" %}:
{% trans "Annual bank salary" %}: %
 {% trans "Form of credit repayment" %}:  
   
{% trans "calculate monthly instalments" %}

 
{% endblock %}