Commit d59ba6059b7282c8210267f9bc527524b9c61b9d
1 parent
988b6dab93
Exists in
master
Agregada validacion para input con valor a descargar.
Showing
1 changed file
with
12 additions
and
21 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -20,7 +20,7 @@ angular.module('focaModalDescarga') |
| 20 | 20 | $scope.remito = remito; |
| 21 | 21 | $scope.nroRecibo = 0; |
| 22 | 22 | $scope.cisternas = remito.cisternas; |
| 23 | - $scope.nroRemito = "00" + remito.sucursal + "-000000000" + remito.numeroRemito; | |
| 23 | + $scope.nroSucursal = "00" + remito.sucursal; | |
| 24 | 24 | $scope.articulos = []; |
| 25 | 25 | //#endregion |
| 26 | 26 | |
| ... | ... | @@ -29,12 +29,7 @@ angular.module('focaModalDescarga') |
| 29 | 29 | focaModalService.alert("No has seleccionado cliente"); |
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | - if (!validarDescarga()) { | |
| 33 | - focaModalService.alert("Cantidad de descarga ingresada erronea"); | |
| 34 | - return; | |
| 35 | - } | |
| 36 | - if (!$scope.nroRecibo) { | |
| 37 | - focaModalService.alert("No ingresaste nro de recibo"); | |
| 32 | + if (validarDescarga()) { | |
| 38 | 33 | return; |
| 39 | 34 | } |
| 40 | 35 | //#region OBJETO REMITO |
| ... | ... | @@ -85,10 +80,9 @@ angular.module('focaModalDescarga') |
| 85 | 80 | operacionTipo: 0, //TODO |
| 86 | 81 | idHojaRuta: $scope.remito.idHojaRuta |
| 87 | 82 | } |
| 88 | - //#endregionc | |
| 83 | + //#endregion | |
| 89 | 84 | focaModalDescargasService.crearRemito({ remito: remito, notaPedido: { id: 0 } }) |
| 90 | 85 | .then(function (res) { |
| 91 | - console.log(res); | |
| 92 | 86 | remitoId = res.data.id |
| 93 | 87 | descargar(remitoId); |
| 94 | 88 | focaModalDescargasService. |
| ... | ... | @@ -120,12 +114,6 @@ angular.module('focaModalDescarga') |
| 120 | 114 | var cisternaCargas = []; |
| 121 | 115 | var cisternaCarga = $scope.cisternas[i].cisternaCarga; |
| 122 | 116 | if (!descarga) continue; |
| 123 | - // if (descarga > cisternaCarga.cantidad) { | |
| 124 | - // focaModalService.alert('La cantidad a descargar no debe ser ' + | |
| 125 | - // 'mayor a la cantidad de la cisterna'); | |
| 126 | - // $scope.cargando = false; | |
| 127 | - // return; | |
| 128 | - // } | |
| 129 | 117 | cisternaCarga.cantidad -= descarga; |
| 130 | 118 | |
| 131 | 119 | //Guardar |
| ... | ... | @@ -177,12 +165,15 @@ angular.module('focaModalDescarga') |
| 177 | 165 | return importe; |
| 178 | 166 | }; |
| 179 | 167 | function validarDescarga() { |
| 180 | - hasDisponible = $scope.cisternas.find(function (cisterna) { | |
| 181 | - return parseInt(cisterna.cisternaCarga.descargar) >= 0 && | |
| 182 | - parseInt(cisterna.cisternaCarga.descargar) <= | |
| 183 | - cisterna.cisternaCarga.cantidad | |
| 184 | - }); | |
| 185 | - return hasDisponible; | |
| 168 | + for (var i = 0; i < $scope.cisternas.length; i++) { | |
| 169 | + if (parseInt($scope.cisternas[i].cisternaCarga.descargar) > | |
| 170 | + $scope.cisternas[i].cisternaCarga.cantidad || | |
| 171 | + parseInt($scope.cisternas[i].cisternaCarga.descargar) < 0) { | |
| 172 | + focaModalService.alert("Cantidad de descarga ingresada erronea"); | |
| 173 | + return true; | |
| 174 | + } | |
| 175 | + } | |
| 176 | + return false; | |
| 186 | 177 | }; |
| 187 | 178 | $scope.seleccionarCliente = function () { |
| 188 | 179 |