diff --git a/project/static/js/formset-events.js b/project/static/js/formset-events.js index c07f523..5ba3d24 100644 --- a/project/static/js/formset-events.js +++ b/project/static/js/formset-events.js @@ -6,25 +6,25 @@ $(function() { el.val(new_val); } var calc_summa = function (e) { - var $this = $(this); - var qty = parseFloat($this.closest('tr.row').find('td.qty input').val()); - var price = parseFloat($this.closest('tr.row').find('td.price input').val()); + var el = $(this); + var qty = parseFloat(el.closest('tr.row').find('td.qty input').val()); + var price = parseFloat(el.closest('tr.row').find('td.price input').val()); var total_price = qty * price; - if (total_price) { - $this.closest('tr.row').find('td.total_price input').val(qty * price); - } + if (total_price) + el.closest('tr.row').find('td.total_price input').val(total_price.toFixed(2)); } var calc_itogo_nds = function() { $('#itogo_nds_text').html('НДС ' + $('#id_nds_value option:selected').text()); - $('#itogo_nds').html(parseFloat($('#id_nds_value').val()) * parseFloat($('#itogo').html()) / 100); + var nds = parseFloat($('#id_nds_value').val()) * parseFloat($('#itogo').html()) / 100; + $('#itogo_nds').html(nds.toFixed(2)); } window.calc_itogo = function (e) { var itogo_sum = 0; - $('#tbl_items').find('.total_price input:visible').each(function(){ - var itogo_sum_row = $(this).val()? parseInt($(this).val()) : 0; + $('#tbl_items').find('.total_price input:visible').each(function() { + var itogo_sum_row = $(this).val() ? parseFloat($(this).val()) : 0; itogo_sum += itogo_sum_row; }) - $('#itogo').html(itogo_sum); + $('#itogo').html(itogo_sum.toFixed(2)); calc_itogo_nds(); } window.set_events = function set_events() { diff --git a/project/templates/base.html b/project/templates/base.html index 0e55986..9da693e 100644 --- a/project/templates/base.html +++ b/project/templates/base.html @@ -152,7 +152,7 @@ - +