-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
182 lines (139 loc) · 5.66 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name=”keywords” content="Taxa de DARF FII, Imposto de Fundo Imobiliario, Real Estate Fund, DARF de FII, Jaime Dantas"/>
<meta name="description" content="Tax calculator for Real Estate Funds (FII) in the B3 (Brazil)">
<meta name="author" content="Jaime Cristalino Jales Dantas">
<title>FII Tax Calculator</title>
<style>
form {
margin: 0 auto;
width: 450px;
padding: 1em;
border: 1px solid #ccc;
border-radius: 1em;
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
form li + li {
margin-top: 1em;
}
label {
display: inline-block;
width: 110px;
text-align: right;
}
input,
textarea {
font: 1em sans-serif;
width: 300px;
box-sizing: border-box;
border: 1px solid #999;
}
input:focus,
textarea:focus {
border-color: #000;
}
.button {
padding-left: 90px;
}
button {
margin-left: 7.9em;
}
.aligncenter {
text-align: center;
}
</style>
</head>
<body>
<p class="aligncenter">
<img src="documentation/images/logo.png" alt="FII Tax Calculator for BM&FBOVESPA" style="width:300px;height:150px;">
</p>
<form id="postData" method="post">
<p class="aligncenter">
<select>
<option value="FII">Real Estate Fund (B3: FII)</option>
<option value="STOCK">Stock (B3: Ação)</option>
</select>
</p>
<p align="center">Please fill the form and click in Calculate</p>
<ul>
<li>
<label for="name">FII Name:</label>
<input type="text" id="name" name="name" />
</li>
<li>
<label for="totalValueBought">Purchase Value:</label>
<input type="number" step="0.01" id="totalValueBought" name="totalValueBought" />
</li>
<li>
<label for="totalValueSold">Sold Value:</label>
<input type="number" step="0.01" id="totalValueSold" name="totalValueSold" />
</li>
<li class="button">
<!-- <input value="Submit" type="submit" onclick="function()">-->
<button type="submit">Calculate Taxes</button>
</li>
<h3 align="center">Profit:</h3>
<ul id="profit-percentage"></ul>
<ul id="profit-total"></ul>
<h3 align="center">Taxes:</h3>
<ul id="darf-value"></ul>
<ul id="liquidacao-fee"></ul>
<ul id="emolumentos-fee"></ul>
<ul id="irrf-fee"></ul>
<p align="center"><a href="http://servicos.receita.fazenda.gov.br/Servicos/sicalcweb/default.asp?TipTributo=1&FormaPagto=1" target="_blank" > Issue Boleto</a></p>
</ul>
</form>
<p align="center">© Jaime Dantas | <a href="https://github.com/jaimedantas/fii-tax-calculator" target="_blank" >B3 Tax Calculator</a></p>
<script>
document.getElementById('postData').addEventListener('submit', postData);
function createNode(element) {
return document.createElement(element); // Create the type of element you pass in the parameters
}
function append(parent, el) {
return parent.appendChild(el); // Append the second parameter(element) to the first one
}
const ul = document.getElementById('authors'); // Get the list where we will place our authors
function postData(event){
event.preventDefault();
let nameValue = document.getElementById('name').value;
let totalValueBoughtValue = document.getElementById('totalValueBought').value;
let totalValueSoldValue = document.getElementById('totalValueSold').value;
fetch('http://jaimedantas.ddns.net:8081/tax/fii/manual', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body:JSON.stringify({name:nameValue, totalValueBought:totalValueBoughtValue, totalValueSold:totalValueSoldValue})
}).then((res) => res.json())
.then(res => {
const DARF_KEY = document.querySelector('#darf-value');
const PROFIT_PERCENTAGE_KEY = document.querySelector('#profit-percentage');
const PROFIT_TOTAL_KEY = document.querySelector('#profit-total');
const LIQUIDACAO_KEY = document.querySelector('#liquidacao-fee');
const EMOLUMENTOS_KEY = document.querySelector('#emolumentos-fee');
const IRRF_KEY = document.querySelector('#irrf-fee');
const DARF_temp = '<p>DARF Value: $' + res.fixedTax + '</p>';
const TOTAL_PROFIT_P_temp = '<p>Profit (%) : ' + res.totalProfitPercentage*100 + '%</p>';
const TOTAL_PROFIT_T_temp = '<p>Total Profit : $' + res.totalProfitValue + '</p>';
const LIQUIDACAO_temp = '<p>Liquidacao Fee: $' + res.liquidacaoFee + '</p>';
const EMOLUMENTOS_temp = '<p>Emolumentos Fee: $' + res.emolumentosFee + '</p>';
const IRRF_temp = '<p>IRRF fee: $' + res.irrffee + '</p>';
DARF_KEY.innerHTML = DARF_temp;
PROFIT_PERCENTAGE_KEY.innerHTML = TOTAL_PROFIT_P_temp;
PROFIT_TOTAL_KEY.innerHTML = TOTAL_PROFIT_T_temp;
LIQUIDACAO_KEY.innerHTML = LIQUIDACAO_temp;
EMOLUMENTOS_KEY.innerHTML = EMOLUMENTOS_temp;
IRRF_KEY.innerHTML = IRRF_temp;
console.log(DARF_KEY);
})
.catch(err => console.log(err));
}
</script>
</body>
</html>