Skip to content

Instantly share code, notes, and snippets.

@noff
Created February 19, 2015 08:06
Show Gist options
  • Save noff/bdeb94b82e691c322dc9 to your computer and use it in GitHub Desktop.
Save noff/bdeb94b82e691c322dc9 to your computer and use it in GitHub Desktop.
calculate = (valid = true) ->
# процент первого взноса от стоимости
calc_out.paid_pct = Math.round(100 * calc_in.paid / calc_in.total) + '%'
# подключаем библиотеку
calFinance = new Finance()
if calc_in.increase != null
# стоимость юнита минус предоплата
principal = calc_in.total - calc_in.paid
per_month = - Math.round( pmt(0.01 * calc_in.rate, calc_in.time, principal) / 12 )
per_month_profit = calc_in.rent - per_month
calc_out.price = Math.round( calc_in.total * Math.pow((1 + calc_in.increase * 0.01), 10) )
# calc_out.profit = Math.round( rate(calc_in.time * 12, per_month_profit, - calc_in.paid, calc_out.price) * 1200 )
# calc_out.profit = Math.round( rate(calc_in.time, per_month_profit * 12, - calc_in.paid, calc_out.price) * 100 )
if valid == true
# Получаем ежегодный платеж.
need_pay_per_year = calFinance.AM(principal, calc_in.rate, calc_in.time, 0) * 12;
# Теперь делаем введенную сумму аренды минус ежегодный платеж = чистый ежегодный платеж (ЧЕП).
clear_plus_per_year = ( calc_in.rent * 12 ) - need_pay_per_year;
profit = calFinance.IRR(-calc_in.paid, clear_plus_per_year, clear_plus_per_year, clear_plus_per_year, clear_plus_per_year, clear_plus_per_year, clear_plus_per_year, clear_plus_per_year, clear_plus_per_year, clear_plus_per_year, clear_plus_per_year + calc_out.price)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment