I've done this calculation, which is working perfectly. The problem that is occurring is that when you return values to the (View) screen it returns without the calculated decimal places.
I will demonstrate what is happening. This is my JavaScript:
var QtdeDiasJuros = $("#T_FrmRecTotalDiaAtraso").val();
var TaxaJurosAoDia = $("#T_FrmRecTaxaJurosAoDia").val().replace(",", ".");
var ValorParcela = $("#T_FrmRecValorDuplicata").val();
var TotalJurosAoDia = parseFloat(QtdeDiasJuros) * parseFloat(TaxaJurosAoDia);
var TotalValorPago = (parseFloat(TotalJurosAoDia) + parseFloat(ValorParcela));
document.getElementById("T_FrmRecTotalJurosAoDia").value = TotalJurosAoDia;
document.getElementById("T_FrmRecValorPago").value = parseFloat(TotalValorPago);
Calculation Process and its result: Exemplifying the Calculation with values posting:
var QtdeDiasJuros = $("#T_FrmRecTotalDiaAtraso").val();
10
var TaxaJurosAoDia = $("#T_FrmRecTaxaJurosAoDia").val().replace(",", ".");
0,333
var ValorParcela = $("#T_FrmRecValorDuplicata").val();
100,50
var TotalJurosAoDia = parseFloat(QtdeDiasJuros) * parseFloat(TaxaJurosAoDia);
3,33
var TotalValorPago = (parseFloat(TotalJurosAoDia) + parseFloat(ValorParcela));
103,83 = 3,33 + 100,50
The problem is that when it returns to the screen it returns values without the decimal place and not positioning as the calculation generated. Type: TotalValorPago gets 10333,00 - TotalJurosAoDia stays: 333,00
Here my View: Here are the fields where you get these values generated by JavaScript
<div class="span2">
@Html.LabelFor(model => model.T_FrmRecTaxaJurosAoDia)
@Html.TextBoxFor(model => model.T_FrmRecTaxaJurosAoDia, new { style = "width: 80px; font-weight: bold; font-size: 18px; color: #39395F; background-color:#E0E0E0 ; text-align: right;" })
@Html.ValidationMessageFor(model => model.T_FrmRecTaxaJurosAoDia)
</div>
<div class="span2">
@Html.LabelFor(model => model.T_FrmRecTotalDiaAtraso)
@Html.TextBoxFor(model => model.T_FrmRecTotalDiaAtraso, new { style = "width: 100px; font-weight: bold; font-size: 18px; color: #39395F; background-color:#E0E0E0 ; text-align: right;" })
@Html.ValidationMessageFor(model => model.T_FrmRecTotalDiaAtraso)
</div>
<div class="span2">
@Html.LabelFor(model => model.T_FrmRecTotalJurosAoDia)
@Html.TextBoxFor(model => model.T_FrmRecTotalJurosAoDia, new { style = "width: 100px; font-weight: bold; font-size: 18px; color: #39395F; background-color:#E0E0E0 ; text-align: right;" })
</div>
<div class="span2">
@Html.LabelFor(model => model.T_FrmRecValorPago, new { style = "font-weight: bold;" })
@Html.TextBoxFor(model => model.T_FrmRecValorPago, new { style = "width: 200px; font-size: 20px; color: #F2F2F4; background-color:#39395F; text-align: right;" })
</div>
</div>