|
@@ -484,26 +484,26 @@
|
|
|
var preSaleId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
|
|
var preSaleId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
|
|
|
$('#save_sale').attr('disabled', true);
|
|
$('#save_sale').attr('disabled', true);
|
|
|
$.ajax({
|
|
$.ajax({
|
|
|
- type: "PUT",
|
|
|
|
|
- url: "/pre_sales/" + preSaleId,
|
|
|
|
|
- dataType: "json",
|
|
|
|
|
- data: { pre_sale: { quantity: input.val() } },
|
|
|
|
|
- success: function(xhr, status, error) {
|
|
|
|
|
|
|
+ type: "PUT",
|
|
|
|
|
+ url: "/pre_sales/" + preSaleId,
|
|
|
|
|
+ dataType: "json",
|
|
|
|
|
+ data: { pre_sale: { quantity: input.val() } },
|
|
|
|
|
+ success: function(xhr, status, error) {
|
|
|
|
|
|
|
|
- input.closest('tr').find('td:eq(6)').text(Math.round(xhr.tax * 100) / 100);
|
|
|
|
|
|
|
+ input.closest('tr').find('td:eq(6)').text(Math.round(xhr.tax * 100) / 100);
|
|
|
|
|
|
|
|
- input.closest('tr').find('td:eq(7)').text(Math.round(xhr.discount * 100) / 100);
|
|
|
|
|
|
|
+ input.closest('tr').find('td:eq(7)').text(Math.round(xhr.discount * 100) / 100);
|
|
|
|
|
|
|
|
- input.closest('tr').find('td:eq(8)').text(Math.round(xhr.total * 100) / 100);
|
|
|
|
|
|
|
+ input.closest('tr').find('td:eq(8)').text(Math.round(xhr.amount * 100) / 100);
|
|
|
|
|
|
|
|
- calculateTotals();
|
|
|
|
|
|
|
+ calculateTotals();
|
|
|
|
|
|
|
|
- $('#save_sale').attr('disabled', false);
|
|
|
|
|
- },
|
|
|
|
|
- error: function (xhr, status, errorThrown) {
|
|
|
|
|
- input.val(1);
|
|
|
|
|
- toastr["error"](xhr.responseText.substr(3, (xhr.responseText.length -6)));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $('#save_sale').attr('disabled', false);
|
|
|
|
|
+ },
|
|
|
|
|
+ error: function (xhr, status, errorThrown) {
|
|
|
|
|
+ input.val(1);
|
|
|
|
|
+ toastr["error"](xhr.responseText.substr(3, (xhr.responseText.length -6)));
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
}, 500);
|
|
}, 500);
|
|
|
}
|
|
}
|
|
@@ -517,9 +517,10 @@
|
|
|
|
|
|
|
|
if($('#products_table').dataTable().fnGetData().length > 0) {
|
|
if($('#products_table').dataTable().fnGetData().length > 0) {
|
|
|
$('#products_table tbody tr').each(function() {
|
|
$('#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);
|
|
|
|
|
|
|
+ // 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
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -530,7 +531,7 @@
|
|
|
discount += parseFloat($(this).text());
|
|
discount += parseFloat($(this).text());
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- total = (amount - discount) + tax;
|
|
|
|
|
|
|
+ total = amount + tax;
|
|
|
$('#tax').val(Math.round(tax * 100) / 100);
|
|
$('#tax').val(Math.round(tax * 100) / 100);
|
|
|
$('#discount').val(Math.round(discount * 100) / 100);
|
|
$('#discount').val(Math.round(discount * 100) / 100);
|
|
|
$('#amount').val(Math.round(amount * 100) / 100);
|
|
$('#amount').val(Math.round(amount * 100) / 100);
|