|
@@ -1,11 +1,11 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div> |
|
|
|
|
|
|
|
|
<div v-if="downpayment && totalMonthly > 0"> |
|
|
|
|
|
|
|
|
<section class="form inputs"> |
|
|
<section class="form inputs"> |
|
|
<h3>Monthly Payment - ${{totalMonthly}}</h3> |
|
|
<h3>Monthly Payment - ${{totalMonthly}}</h3> |
|
|
<label>Loan payment: ${{loanPayment.toFixed(2)}}</label> |
|
|
<label>Loan payment: ${{loanPayment.toFixed(2)}}</label> |
|
|
<label v-if="loan.mi.monthly"> |
|
|
<label v-if="loan.mi.monthly"> |
|
|
Mortgage insurance: ${{(loanPayment*loan.mi.rate/100).toFixed(2)}} |
|
|
|
|
|
|
|
|
Mortgage insurance: ${{(loan.amount*loan.mi.rate/100/12).toFixed(2)}} |
|
|
</label> |
|
|
</label> |
|
|
<label>Property taxes: ${{loan.tax}}</label> |
|
|
<label>Property taxes: ${{loan.tax}}</label> |
|
|
</section> |
|
|
</section> |
|
@@ -13,10 +13,10 @@ |
|
|
<section class="form inputs"> |
|
|
<section class="form inputs"> |
|
|
<h3>Cash to Close - ${{totalMonthly}}</h3> |
|
|
<h3>Cash to Close - ${{totalMonthly}}</h3> |
|
|
<label>Closing costs: ${{fees}}</label> |
|
|
<label>Closing costs: ${{fees}}</label> |
|
|
<label>Credits: ${{credits}}</label> |
|
|
|
|
|
<label>Downpayment: ${{downpayment.toFixed(2)}}</label> |
|
|
|
|
|
|
|
|
<label v-if="credits">Credits: ${{credits}}</label> |
|
|
|
|
|
<label>Down payment: ${{downpayment.toFixed(2)}}</label> |
|
|
<label v-if="!loan.mi.monthly"> |
|
|
<label v-if="!loan.mi.monthly"> |
|
|
Mortgage insurance: ${{(loanPayment*loan.mi.rate).toFixed(2)}} |
|
|
|
|
|
|
|
|
Mortgage insurance: ${{(loanPayment*loan.mi.rate/100).toFixed(2)}} |
|
|
</label> |
|
|
</label> |
|
|
</section> |
|
|
</section> |
|
|
|
|
|
|
|
@@ -30,16 +30,20 @@ |
|
|
|
|
|
|
|
|
<script setup> |
|
|
<script setup> |
|
|
import { ref, computed } from 'vue' |
|
|
import { ref, computed } from 'vue' |
|
|
const props = defineProps(['downpayment', 'loan']) |
|
|
|
|
|
|
|
|
const props = defineProps(['downpayment', 'loan', 'valid']) |
|
|
|
|
|
|
|
|
function amortize(principle, rate, periods) { |
|
|
function amortize(principle, rate, periods) { |
|
|
return principle * rate*(1+rate)**periods / ((1+rate)**periods - 1) |
|
|
return principle * rate*(1+rate)**periods / ((1+rate)**periods - 1) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const loanPayment = computed(() => amortize(props.loan.amount, |
|
|
|
|
|
|
|
|
const loanPayment = computed(() => { |
|
|
|
|
|
let amount = props.loan.amount |
|
|
|
|
|
if (!props.loan.mi.monthly) amount = |
|
|
|
|
|
amount + props.loan.mi.rate/100*(amount+props.downpayment) |
|
|
|
|
|
return amortize(props.loan.amount, |
|
|
props.loan.interest / 100 / 12, |
|
|
props.loan.interest / 100 / 12, |
|
|
props.loan.term*12) |
|
|
props.loan.term*12) |
|
|
) |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
const totalMonthly = computed ( |
|
|
const totalMonthly = computed ( |
|
|
() => (loanPayment.value + |
|
|
() => (loanPayment.value + |
|
@@ -48,6 +52,12 @@ const totalMonthly = computed ( |
|
|
props.loan.hazard).toFixed(2) |
|
|
props.loan.hazard).toFixed(2) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const totalCash = computed ( |
|
|
|
|
|
() => (fees.value + |
|
|
|
|
|
credits.value + |
|
|
|
|
|
props.downpayment).toFixed(2) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// Closing costs |
|
|
// Closing costs |
|
|
const fees = computed(() => { |
|
|
const fees = computed(() => { |
|
|
return props.loan.fees.reduce((total, x) => { |
|
|
return props.loan.fees.reduce((total, x) => { |
|
@@ -66,5 +76,4 @@ const credits = computed(() => { |
|
|
const cashToClose = computed(() => { |
|
|
const cashToClose = computed(() => { |
|
|
return fees + credits + downpayment |
|
|
return fees + credits + downpayment |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |