diff --git a/src/js/controller.js b/src/js/controller.js index a39522f..c42626a 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -228,13 +228,6 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', console.info(error); }); }; - $scope.setTempCantidadArticulo = function (articulo) { - articulo.tmpCantidad = articulo.cantidad; - }; - - $scope.setTempPrecioArticulo = function (articulo) { - articulo.tmpPrecio = articulo.precio; - }; $scope.seleccionarNotaPedido = function () { var modalInstance = $uibModal.open( @@ -839,24 +832,19 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', } }; - $scope.editarArticulo = function (key, articulo, bandera) { + $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { if (key === 13) { - var valorAEditar = bandera === 'precio' ? articulo.precio : articulo.cantidad; - var tempValor = bandera === 'precio' ? articulo.tmpPrecio - : articulo.tmpCantidad; - if (tempValor === '') { + if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { focaModalService.alert('Los valores deben ser al menos 1'); return; - } else if (tempValor === '0') { - focaModalService.alert('Esta ingresando un producto con valor 0'); - } else if (valorAEditar < 0) { + } else if (articulo.cantidad < 0 || articulo.precio < 0) { focaModalService.alert('Los valores no pueden ser negativos'); return; } - articulo[bandera] = parseFloat(tempValor); + articulo.cantidad = tmpCantidad; + articulo.precio = tmpPrecio; $scope.getTotal(); - var propiedad = 'edit' + bandera.charAt(0).toUpperCase() + bandera.slice(1); - articulo[propiedad] = false; + articulo.editCantidad = articulo.editPrecio = false; } }; diff --git a/src/views/nota-pedido.html b/src/views/nota-pedido.html index af9d0b7..2e24802 100644 --- a/src/views/nota-pedido.html +++ b/src/views/nota-pedido.html @@ -69,14 +69,16 @@