{:uriI"file:///Users/benoit/www/agilidee/dorsale/app/assets/javascripts/dorsale/billing_machine/invoices.coffee?type=application/javascript&pipeline=self&id=b03fcb559c258fed0e250ada791b6916fbd047ad9f27bafff006a0c4f1720b9c:ET:load_pathI">/Users/benoit/www/agilidee/dorsale/app/assets/javascripts;T: filenameI"f/Users/benoit/www/agilidee/dorsale/app/assets/javascripts/dorsale/billing_machine/invoices.coffee;T: nameI"%dorsale/billing_machine/invoices;T:logical_pathI"-dorsale/billing_machine/invoices.self.js;T:content_typeI"application/javascript;T: sourceI"[ (function() { $(document).on("ready page:load", function() { var sum_line, update_line_total, update_total; if ($('#invoice.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 advance, commercial_discount, total_duty, vat_amount, vat_rate; total_duty = 0; vat_rate = parseFloat($('#invoice_vat_rate').val().replace(',', '.') || 0); advance = parseFloat($('#invoice_advance').val().replace(',', '.') || 0); commercial_discount = parseFloat($('#invoice_commercial_discount').val().replace(',', '.') || 0); $('.invoice-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)); } }); total_duty -= commercial_discount; vat_amount = vat_rate * total_duty / 100.0; display_euros(commercial_discount, $('#invoice-commercial_discount')); display_euros(total_duty, $('#invoice-total_duty')); display_euros(vat_amount, $('#invoice-vat_amount')); display_euros(vat_amount + total_duty, $('#invoice-total_all_taxes')); return display_euros(vat_amount + total_duty - advance, $('#invoice-balance')); }; $('#invoice-lines').on('input', 'input.line-quantity, input.line-unit_price', function(event) { update_line_total($(event.currentTarget).parents('.invoice-line')); return update_total(); }); $('#invoice').on('input', 'input#invoice_commercial_discount, input#invoice_vat_rate, input#invoice_advance', function(event) { return update_total(); }); $('#invoice').on('cocoon:after-remove', function(event) { return update_total(); }); $('.invoice-line').each(function(index, element) { return update_line_total($(element)); }); return update_total(); } }); }).call(this); ;T: metadata{ :dependencieso:Set: @hash{ I"environment-version;TTI"environment-paths;TTI"jprocessors:type=application/javascript&file_type=application/javascript&engines=.coffee&pipeline=self;TTI"tfile-digest:///Users/benoit/www/agilidee/dorsale/app/assets/javascripts/dorsale/billing_machine/invoices.coffee;TT: requiredo;;{: stubbedo;;{: linkso;;{: charsetI" utf-8;F: digest"%Dwsi?'FFz\zP!F~%: lengthi[ :dependencies_digest"%_~:3L$ "y.w+3ضP 3:idI"Eb03fcb559c258fed0e250ada791b6916fbd047ad9f27bafff006a0c4f1720b9c;F: mtimel+mV