Commit e5c4b5bb60bfd25ac4e29721449bed42372195a2
1 parent
793054655b
Exists in
develop
editarArticulo no acepta cantidades decimales ni valores negativos
Showing
2 changed files
with
12 additions
and
7 deletions
Show diff stats
package.json
src/js/controller.js
... | ... | @@ -984,18 +984,23 @@ angular.module('focaCrearRemito').controller('remitoController', |
984 | 984 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { |
985 | 985 | if (key === 13) { |
986 | 986 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { |
987 | - focaModalService.alert('Los valores deben ser al menos 1'); | |
987 | + focaModalService.alert('Debes introducir algún valor'); | |
988 | 988 | return; |
989 | 989 | } else if (tmpCantidad === '0' || tmpPrecio === '0') { |
990 | 990 | focaModalService.alert('Esta ingresando un producto con valor 0'); |
991 | - } else if (articulo.cantidad < 0 || articulo.precio < 0) { | |
991 | + return; | |
992 | + } else if (tmpCantidad < 0 || tmpPrecio < 0) { | |
992 | 993 | focaModalService.alert('Los valores no pueden ser negativos'); |
993 | 994 | return; |
995 | + } else if (!Number.isInteger(tmpCantidad)) { | |
996 | + focaModalService.alert('Debes introducir un número entero'); | |
997 | + return; | |
998 | + } else { | |
999 | + articulo.cantidad = tmpCantidad; | |
1000 | + articulo.precio = tmpPrecio; | |
1001 | + $scope.getTotal(); | |
1002 | + articulo.editCantidad = articulo.editPrecio = false; | |
994 | 1003 | } |
995 | - articulo.cantidad = tmpCantidad; | |
996 | - articulo.precio = tmpPrecio; | |
997 | - $scope.getTotal(); | |
998 | - articulo.editCantidad = articulo.editPrecio = false; | |
999 | 1004 | } |
1000 | 1005 | }; |
1001 | 1006 |