|
|
@@ -1,6 +1,7 @@
|
|
|
<%= form_for(@sale, :remote => true, :html => {:class=>"form-horizontal form-barcode", :id=> "sale_form"}) do |f| %>
|
|
|
<div class="portlet-body form">
|
|
|
<%= hidden_field_tag :barcode_for_sale %>
|
|
|
+ <%= hidden_field_tag "add_iva_to_pre_sales", @pos_config.add_iva_to_pre_sales %>
|
|
|
<!-- este error explanation se usa para mostrar errores de presales e inventarios -->
|
|
|
<!-- <div id="error_explanation"></div> -->
|
|
|
<!-- este error explanation es cuando falla alguna validacion de la venta en sí -->
|
|
|
@@ -492,13 +493,15 @@
|
|
|
pre_sale: { quantity: input.val() }
|
|
|
},
|
|
|
success: function(xhr, status, error) {
|
|
|
- var tax_ = xhr.tax;
|
|
|
- var discount_ = xhr.discount;
|
|
|
- var total_ = xhr.total;
|
|
|
+ var amount_ = xhr.amount;
|
|
|
+ var tax_ = xhr.tax;
|
|
|
+ var discount_ = xhr.discount;
|
|
|
+ var total_ = xhr.total;
|
|
|
|
|
|
- $("#tax_" + preSaleId).val(tax_);
|
|
|
- $("#discount_" + preSaleId).val(discount_);
|
|
|
- $("#total_" + preSaleId).val(total_);
|
|
|
+ $("#amount_" + preSaleId).val(amount_);
|
|
|
+ $("#tax_" + preSaleId).val(tax_);
|
|
|
+ $("#discount_" + preSaleId).val(discount_);
|
|
|
+ $("#total_" + preSaleId).val(total_);
|
|
|
|
|
|
input.closest('tr').find('td:eq(6) label').text("$ " + xhr.tax);
|
|
|
input.closest('tr').find('td:eq(7) label').text("$ " + xhr.discount);
|
|
|
@@ -512,19 +515,21 @@
|
|
|
var data = JSON.parse(xhr.responseText);
|
|
|
input.val(data.quantity);
|
|
|
toastr["error"](data.errors);
|
|
|
+ var amount_ = (Math.round(data.presale.amount * 100) / 100).toFixed(2);
|
|
|
var tax_ = (Math.round(data.presale.tax * 100) / 100).toFixed(2);
|
|
|
- var discount_ = (Math.round(data.presale.discount * 100) / 100).toFixed(2);
|
|
|
- var total_ = (Math.round(data.presale.total * 100) / 100).toFixed(2);
|
|
|
+ var discount_ = (Math.round(data.presale.discount * 100) / 100).toFixed(2);
|
|
|
+ var total_ = (Math.round(data.presale.total * 100) / 100).toFixed(2);
|
|
|
|
|
|
- $("#tax_" + preSaleId).val(tax_);
|
|
|
- $("#discount_" + preSaleId).val(discount_);
|
|
|
- $("#total_" + preSaleId).val(total_);
|
|
|
+ $("#amount_" + preSaleId).val(amount_);
|
|
|
+ $("#tax_" + preSaleId).val(tax_);
|
|
|
+ $("#discount_" + preSaleId).val(discount_);
|
|
|
+ $("#total_" + preSaleId).val(total_);
|
|
|
|
|
|
- input.closest('tr').find('td:eq(6) label').text("$ " + tax_);
|
|
|
- input.closest('tr').find('td:eq(7) label').text("$ " + discount_);
|
|
|
- input.closest('tr').find('td:eq(8) label').text("$ " + total_);
|
|
|
+ input.closest('tr').find('td:eq(6) label').text("$ " + tax_);
|
|
|
+ input.closest('tr').find('td:eq(7) label').text("$ " + discount_);
|
|
|
+ input.closest('tr').find('td:eq(8) label').text("$ " + total_);
|
|
|
|
|
|
- calculateTotals();
|
|
|
+ calculateTotals();
|
|
|
}
|
|
|
});
|
|
|
}, 500);
|
|
|
@@ -536,37 +541,21 @@
|
|
|
var discount = 0;
|
|
|
var tax = 0;
|
|
|
var total = 0;
|
|
|
-
|
|
|
- // if($('#products_table').dataTable().fnGetData().length > 0) {
|
|
|
- // $('#products_table tbody tr').each(function() {
|
|
|
- // // quantity = parseFloat(($(this).find('td:nth-child(5) input').val()));
|
|
|
- // // price = parseFloat($(this).find('td:nth-child(6)').text());
|
|
|
- // // amount += (quantity * price);
|
|
|
- // amount += parseFloat($(this).find('td:nth-child(9)').text()); // importe
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
$('#products_table').dataTable().fnGetNodes().forEach(function(row) {
|
|
|
- quantity = parseFloat(($(row).find('td:nth-child(5) input').val()));
|
|
|
- price = parseFloat($(row).find('td:nth-child(6) input').val());
|
|
|
- amount += (quantity * price);
|
|
|
- tax += parseFloat($(row).find('td:nth-child(7) input').val());
|
|
|
- discount += parseFloat($(row).find('td:nth-child(8) input').val());
|
|
|
- });
|
|
|
+ quantity = parseFloat(($(row).find('td:nth-child(5) input').val()));
|
|
|
+ price = parseFloat($(row).find('td:nth-child(6) input').val());
|
|
|
+ amount += parseFloat(($(row).find('td:nth-child(1) input').val()));
|
|
|
+ tax += parseFloat($(row).find('td:nth-child(7) input').val());
|
|
|
+ discount += parseFloat($(row).find('td:nth-child(8) input').val());
|
|
|
+ });
|
|
|
|
|
|
- // $('#products_table tbody tr td:nth-child(7)').each(function() {
|
|
|
- // tax += parseFloat($(this).text());
|
|
|
- // });
|
|
|
- // $('#products_table tbody tr td:nth-child(8)').each(function() {
|
|
|
- // discount += parseFloat($(this).text());
|
|
|
- // });
|
|
|
+ amount = amount + discount;
|
|
|
+ total = amount + tax - discount;
|
|
|
|
|
|
- total = amount + tax;
|
|
|
- total -= discount;
|
|
|
$('#tax').val((Math.round(tax * 100) / 100).toFixed(2));
|
|
|
- $('#discount').val((Math.round(discount * 100) / 100).toFixed(2));
|
|
|
- $('#amount').val((Math.round(amount * 100) / 100).toFixed(2));
|
|
|
- $('#total').val((Math.round(total * 100) / 100).toFixed(2));
|
|
|
+ $('#discount').val((Math.round(discount * 100) / 100).toFixed(2));
|
|
|
+ $('#amount').val((Math.round(amount * 100) / 100).toFixed(2));
|
|
|
+ $('#total').val((Math.round(total * 100) / 100).toFixed(2));
|
|
|
if(total < parseFloat($("#available_credit").val())) {
|
|
|
$('#types_credit').attr('disabled', false);
|
|
|
$('#types_credit').closest('label').removeClass('disabled');
|