-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
81 lines (72 loc) · 2.89 KB
/
index.js
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
(function() {
$("form").submit(function(event){
$(this).blur();
return false;
});
$("form :input").bind("change keyup click", function(event){
var InvestCalc = {};
InvestCalc.impostoRenda = ($("input[name='imposto-renda']:checked").val() == true);
InvestCalc.prazo = parseInt($("input[name='prazo']:checked").val());
InvestCalc.taxa = parseFloat($("input[name='taxa']").val());
InvestCalc.taxaEquivalente = [];
if (InvestCalc.impostoRenda) {
InvestCalc.taxaEquivalente = [
InvestCalc.taxa * (1 - 0.225),
InvestCalc.taxa * (1 - 0.20),
InvestCalc.taxa * (1 - 0.175),
InvestCalc.taxa * (1 - 0.15),
];
} else {
InvestCalc.taxaEquivalente = [
InvestCalc.taxa / (1 - 0.225),
InvestCalc.taxa / (1 - 0.20),
InvestCalc.taxa / (1 - 0.175),
InvestCalc.taxa / (1 - 0.15),
];
}
$("#prazo-0").html(accounting.formatMoney(InvestCalc.taxaEquivalente[0], '', 2, ".", ","));
$("#prazo-6").html(accounting.formatMoney(InvestCalc.taxaEquivalente[1], '', 2, ".", ","));
$("#prazo-12").html(accounting.formatMoney(InvestCalc.taxaEquivalente[2], '', 2, ".", ","));
$("#prazo-24").html(accounting.formatMoney(InvestCalc.taxaEquivalente[3], '', 2, ".", ","));
// cor linha
if (InvestCalc.impostoRenda) {
$("tbody > tr")
.addClass("bg-info").removeClass("bg-warning");
$("thead > tr")
.addClass("bg-warning").removeClass("bg-info");
} else {
$("tbody > tr")
.addClass("bg-warning").removeClass("bg-info");
$("thead > tr")
.addClass("bg-info").removeClass("bg-warning");
}
// cor inputs
var labelForIr = "label[for='imposto-renda-FOR']";
var textFor;
if (InvestCalc.impostoRenda) {
labelForIr = labelForIr.replace("FOR", "tributado");
textFor = "tributado";
} else {
labelForIr = labelForIr.replace("FOR", "isento");
textFor = "isento";
}
$(labelForIr)
.addClass("bg-info").removeClass("bg-warning");
$("#imposto-renda label:not([for=imposto-renda-" + textFor + "])")
.addClass("bg-warning").removeClass("bg-info");
// cor body
if (InvestCalc.impostoRenda) {
$("body")
.addClass("bg-warning").removeClass("bg-info");
} else {
$("body")
.addClass("bg-info").removeClass("bg-warning");
}
// nome taxa equivalente
if (InvestCalc.impostoRenda) {
$("#taxa-equivalente").text("Isento");
} else {
$("#taxa-equivalente").text("Tributado");
}
});
})();