I"ƒ(function() { $(document).on("ready page:load", function() { var sum_line, update_line_total, update_total; if ($('#quotation.edit').size() > 0) { sum_line = function(line) { var q, total, up; q = line.find('input.line-quantity').val().replace(',', '.'); up = line.find('input.line-unit_price').val().replace(',', '.'); return total = q * up; }; update_line_total = function(line) { var total; total = sum_line(line); return display_euros(total, line.find('.line-total')); }; update_total = function() { var total_duty, vat_amount, vat_rate; total_duty = 0; vat_rate = $('#quotation_vat_rate').val().replace(',', '.'); $('.quotation-line').each(function(index, element) { var remove_me; remove_me = $(element).find('.remove-line input[type="hidden"]').val(); if (remove_me === 'false') { return total_duty += sum_line($(element)); } }); vat_amount = vat_rate * total_duty / 100.0; display_euros(total_duty, $('#quotation-total_duty')); display_euros(vat_amount, $('#quotation-vat_amount')); return display_euros(vat_amount + total_duty, $('#quotation-total_all_taxes')); }; $('#quotation-lines').on('input', 'input.line-quantity, input.line-unit_price', function(event) { update_line_total($(event.currentTarget).parents('.quotation-line')); return update_total(); }); $('#quotation').on('input', 'input#quotation_vat_rate', function(event) { return update_total(); }); $('#quotation').on('cocoon:after-remove', function(event) { return update_total(); }); $('.quotation-line').each(function(index, element) { return update_line_total($(element)); }); return update_total(); } }); }).call(this); :ET