|
|
|
@ -1,4 +1,10 @@ |
|
|
|
$(function() { |
|
|
|
$(function() { |
|
|
|
|
|
|
|
var fix_float_input = function (e) { |
|
|
|
|
|
|
|
var el = $(this); |
|
|
|
|
|
|
|
var new_val = fix_float_string(el.val()); |
|
|
|
|
|
|
|
if (new_val != el.val()) |
|
|
|
|
|
|
|
el.val(new_val); |
|
|
|
|
|
|
|
} |
|
|
|
var calc_summa = function (e) { |
|
|
|
var calc_summa = function (e) { |
|
|
|
var $this = $(this); |
|
|
|
var $this = $(this); |
|
|
|
var qty = parseFloat($this.closest('tr.row').find('td.qty input').val()); |
|
|
|
var qty = parseFloat($this.closest('tr.row').find('td.qty input').val()); |
|
|
|
@ -22,6 +28,16 @@ $(function() { |
|
|
|
calc_itogo_nds(); |
|
|
|
calc_itogo_nds(); |
|
|
|
} |
|
|
|
} |
|
|
|
window.set_events = function set_events() { |
|
|
|
window.set_events = function set_events() { |
|
|
|
|
|
|
|
$("#tbl_items tr.row td.qty input").on('keyup', fix_float_input); |
|
|
|
|
|
|
|
$("#tbl_items tr.row td.price input").on('keyup', fix_float_input); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#tbl_items tr.row td.debit input").on('keyup', fix_float_input); |
|
|
|
|
|
|
|
$("#tbl_items tr.row td.credit input").on('keyup', fix_float_input); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// not formset fields though...
|
|
|
|
|
|
|
|
$("div#saldo_debit input").on('keyup', fix_float_input); |
|
|
|
|
|
|
|
$("div#saldo_credit input").on('keyup', fix_float_input); |
|
|
|
|
|
|
|
|
|
|
|
$("#tbl_items tr.row td.qty input").on('keyup', calc_summa); |
|
|
|
$("#tbl_items tr.row td.qty input").on('keyup', calc_summa); |
|
|
|
$("#tbl_items tr.row td.price input").on('keyup', calc_summa); |
|
|
|
$("#tbl_items tr.row td.price input").on('keyup', calc_summa); |
|
|
|
|
|
|
|
|
|
|
|
@ -31,7 +47,7 @@ $(function() { |
|
|
|
|
|
|
|
|
|
|
|
//$('input[name=nds_type]').change(calc_itogo_nds);
|
|
|
|
//$('input[name=nds_type]').change(calc_itogo_nds);
|
|
|
|
$('#id_nds_value').change(calc_itogo_nds); |
|
|
|
$('#id_nds_value').change(calc_itogo_nds); |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//$("#tbl_items tr.row td.qty input").blur(calc_itogo_nds);
|
|
|
|
//$("#tbl_items tr.row td.qty input").blur(calc_itogo_nds);
|
|
|
|
//$("#tbl_items tr.row td.price input").blur(calc_itogo_nds);
|
|
|
|
//$("#tbl_items tr.row td.price input").blur(calc_itogo_nds);
|
|
|
|
@ -40,4 +56,32 @@ $(function() { |
|
|
|
window.set_events(); |
|
|
|
window.set_events(); |
|
|
|
window.calc_itogo(); |
|
|
|
window.calc_itogo(); |
|
|
|
calc_itogo_nds(); |
|
|
|
calc_itogo_nds(); |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fix_float_string(val) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
var part1, part2, lastpos; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lastpos = val.lastIndexOf('.'); |
|
|
|
|
|
|
|
if (lastpos != -1) { // string have at least one dot
|
|
|
|
|
|
|
|
part1 = val.substr(0, lastpos); |
|
|
|
|
|
|
|
part2 = val.substr(lastpos+1); |
|
|
|
|
|
|
|
val = part1.replace('.', '').replace(',', '') + '.' + part2.replace('.', '').replace(',', ''); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
lastpos = val.lastIndexOf(','); |
|
|
|
|
|
|
|
if (lastpos != -1) { // string have at least one comma
|
|
|
|
|
|
|
|
part1 = val.substr(0, lastpos); |
|
|
|
|
|
|
|
part2 = val.substr(lastpos+1); |
|
|
|
|
|
|
|
val = part1.replace('.', '').replace(',', '') + '.' + part2.replace('.', '').replace(',', ''); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (e) { |
|
|
|
|
|
|
|
if (!e instanceof TypeError) |
|
|
|
|
|
|
|
throw(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return val; |
|
|
|
|
|
|
|
} |
|
|
|
|