generated from joaocaram/template_tiawSG_2022
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5308f0
commit 03ea420
Showing
3 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<!DOCTYPE html> | ||
<html lang="pt-BR"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Alugar ou Financiar</title> | ||
<link rel="stylesheet" href="/style.css"> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> | ||
</head> | ||
<body> | ||
<header> | ||
<nav class="navbar navbar-expand-lg navbar-light bg-light bb-1"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" href="#">Logo</a> | ||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" | ||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarNav"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item"> | ||
<a class="nav-link active" aria-current="page" href="#">Página Inicial</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="#">Perguntas Frequentes</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="#">Contato</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
</header> | ||
<main> | ||
<h1></h1> | ||
<div class="container"> | ||
<div class="form-section"> | ||
<h2>Informações sobre o imóvel</h2> | ||
<label for="valorCompra">Valor de compra</label> | ||
<input type="number" id="valorCompra" placeholder="R$"> | ||
<label for="valorAluguel">Valor do Aluguel</label> | ||
<input type="number" id="valorAluguel" placeholder="R$"> | ||
<label for="valorizacaoAnual">Valorização Anual</label> | ||
<input type="number" id="valorizacaoAnual" placeholder="média: 3% a 5%" step="0.01"> | ||
<label for="valorIGPM">Valor do IGPM</label> | ||
<input type="number" id="valorIGPM" placeholder="média: 8,63%" step="0.01"> | ||
</div> | ||
|
||
<div class="form-section"> | ||
<h2>Financiamento</h2> | ||
<label for="entrada">Entrada</label> | ||
<input type="number" id="entrada" placeholder="R$"> | ||
<label for="outrosCustos">Outros custos com o financiamento</label> | ||
<input type="number" id="outrosCustos" placeholder="R$"> | ||
<label for="prazoFinanciamento">Prazo de financiamento (meses)</label> | ||
<input type="number" id="prazoFinanciamento" placeholder="0" step="1"> | ||
<label for="cet">Custo Efetivo Total (CET)</label> | ||
<input type="number" id="cet" placeholder="0,00%" step="0.01"> | ||
</div> | ||
|
||
<div class="form-section"> | ||
<button id="buttonCalcular" onclick="calcularResultados()">Calcular</button> | ||
</div> | ||
|
||
<div class="results-section"> | ||
<h2>Financiando</h2> | ||
<label for="patrimonioTotalFinanciando">Patrimônio total</label> | ||
<input type="text" id="patrimonioTotalFinanciando" readonly> | ||
<label for="totalPagoFinanciando">Total pago financiando</label> | ||
<input type="text" id="totalPagoFinanciando" readonly> | ||
<label for="totalAportadoFinanciando">Total aportado</label> | ||
<input type="text" id="totalAportadoFinanciando" readonly> | ||
</div> | ||
|
||
<div class="results-section"> | ||
<h2>Alugando e Investindo</h2> | ||
<label for="patrimonioTotalAlugInvestindo">Patrimônio total *considerando investimentos iguais ou acima da Valorização*</label> | ||
<input type="text" id="patrimonioTotalAlugInvestindo" readonly> | ||
<label for="totalPagoAluguel">Total pago de aluguel</label> | ||
<input type="text" id="totalPagoAluguel" readonly> | ||
<label for="totalAportadoAlugInvestindo">Total aportado</label> | ||
<input type="text" id="totalAportadoAlugInvestindo" readonly> | ||
</div> | ||
</div> | ||
</main> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" | ||
integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+" | ||
crossorigin="anonymous"></script> | ||
<script src="/script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function calcularResultados() { | ||
const valorCompra = parseFloat(document.getElementById('valorCompra').value); | ||
const valorAluguel = parseFloat(document.getElementById('valorAluguel').value); | ||
const valorizacaoAnual = parseFloat(document.getElementById('valorizacaoAnual').value) / 100; | ||
const valorIGPM = parseFloat(document.getElementById('valorIGPM').value) / 100; | ||
const entrada = parseFloat(document.getElementById('entrada').value); | ||
const outrosCustos = parseFloat(document.getElementById('outrosCustos').value); | ||
const prazoFinanciamento = parseInt(document.getElementById('prazoFinanciamento').value); | ||
const cet = parseFloat(document.getElementById('cet').value) / 100; | ||
|
||
const valorFinanciado = valorCompra - entrada + outrosCustos; | ||
const jurosMensal = cet / 12; | ||
|
||
const mensalidade = valorFinanciado * jurosMensal / (1 - Math.pow(1 + jurosMensal, -prazoFinanciamento)); | ||
const totalPagoFinanciamento = mensalidade * prazoFinanciamento; | ||
|
||
const patrimonioTotalFinanciando = valorCompra * Math.pow(1 + valorizacaoAnual, prazoFinanciamento / 12); | ||
const totalAportadoFinanciando = entrada; | ||
|
||
let valorTotalAluguel = 0; | ||
let aluguelAtual = valorAluguel; | ||
for (let i = 0; i < prazoFinanciamento; i++) { | ||
valorTotalAluguel += aluguelAtual; | ||
if ((i + 1) % 12 === 0) { | ||
aluguelAtual *= 1 + valorIGPM; | ||
} | ||
} | ||
|
||
let totalAportadoAlugInvestindo = entrada; | ||
let saldoInvestimento = 0; | ||
|
||
for (let i = 0; i < prazoFinanciamento; i++) { | ||
saldoInvestimento += (mensalidade - valorAluguel) * Math.pow(1 + valorizacaoAnual / 12, prazoFinanciamento - i); | ||
} | ||
totalAportadoAlugInvestindo += saldoInvestimento; | ||
const patrimonioTotalAlugInvestindo = totalAportadoAlugInvestindo * Math.pow(1 + valorizacaoAnual, prazoFinanciamento / 12); | ||
|
||
document.getElementById('patrimonioTotalFinanciando').value = patrimonioTotalFinanciando.toFixed(2); | ||
document.getElementById('totalPagoFinanciando').value = totalPagoFinanciamento.toFixed(2); | ||
document.getElementById('totalAportadoFinanciando').value = totalAportadoFinanciando.toFixed(2); | ||
|
||
document.getElementById('patrimonioTotalAlugInvestindo').value = patrimonioTotalAlugInvestindo.toFixed(2); | ||
document.getElementById('totalPagoAluguel').value = valorTotalAluguel.toFixed(2); | ||
document.getElementById('totalAportadoAlugInvestindo').value = totalAportadoAlugInvestindo.toFixed(2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.container { | ||
max-width: 1200px; | ||
margin: 0 auto; | ||
padding: 20px; | ||
background-color: white; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
border-radius: 8px; | ||
} | ||
|
||
.navbar { | ||
border-bottom: 1px solid; | ||
} | ||
|
||
.nav-item { | ||
padding-left: 30px; | ||
} | ||
|
||
.form-section { | ||
margin-bottom: 20px; | ||
} | ||
|
||
label { | ||
display: block; | ||
margin-bottom: 5px; | ||
font-weight: bold; | ||
} | ||
|
||
input[type="number"], input[type="text"] { | ||
width: 100%; | ||
padding: 8px; | ||
margin-bottom: 10px; | ||
border: 1px solid #ddd; | ||
border-radius: 4px; | ||
box-sizing: border-box; | ||
} | ||
|
||
#buttonCalcular { | ||
width: 100%; | ||
padding: 10px; | ||
background-color: #494949; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
#buttonCalcular:hover { | ||
background-color: #000000; | ||
} | ||
|
||
.results-section { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.results-section h2 { | ||
color: #444; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.results-section label { | ||
color: #444; | ||
} | ||
|
||
.results-section input { | ||
font-weight: bold; | ||
} | ||
|
||
/* Responsividade */ | ||
@media (max-width: 768px) { | ||
.form-section, .results-section { | ||
padding: 10px; | ||
} | ||
} |