Commit 3e9bc33af9eedbe88df185b88b275130ca63a523
1 parent
6a883d52bc
Exists in
master
and in
1 other branch
inteligencia para autocompletar y validaciones
Showing
1 changed file
with
24 additions
and
8 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -181,17 +181,28 @@ angular.module('focaModalDetalleCisternas') |
181 | 181 | } |
182 | 182 | }; |
183 | 183 | $scope.autoCompletar = function() { |
184 | - $scope.aCargar = []; | |
185 | - var disponible = $filter('filter')($scope.cisternas, {disabled: false}); | |
186 | - var index = $scope.cisternas.indexOf(disponible[0]); | |
187 | - $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad; | |
188 | - }; | |
189 | - $scope.cisternaDisponible = function() { | |
190 | 184 | for(var i = 0; i < $scope.cisternas.length; i++) { |
191 | - if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { | |
192 | - $scope.cisternas[i].disabled = true; | |
185 | + if($scope.cisternas[i].disabled) { | |
193 | 186 | continue; |
194 | 187 | } |
188 | + var aCargar = $scope.articuloSeleccionado.cantidad - | |
189 | + ($scope.articuloSeleccionado.cantidadCargada || 0); | |
190 | + if(aCargar > $scope.cisternas[i].disponible) { | |
191 | + aCargar = $scope.cisternas[i].disponible; | |
192 | + } | |
193 | + if(aCargar) { | |
194 | + $scope.aCargar[i] = aCargar; | |
195 | + $scope.actualizarArticulo(); | |
196 | + } | |
197 | + } | |
198 | + }; | |
199 | + $scope.cisternaDisponible = function() { | |
200 | + for(var i = 0; i < $scope.cisternas.length; i++) { | |
201 | + //Puede meter un porcentaje del total | |
202 | + // if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { | |
203 | + // $scope.cisternas[i].disabled = true; | |
204 | + // continue; | |
205 | + // } | |
195 | 206 | if($scope.cisternas[i].cisternaCarga && |
196 | 207 | $scope.cisternas[i].cisternaCarga.idProducto && |
197 | 208 | $scope.articuloSeleccionado.idArticulo !== |
... | ... | @@ -221,6 +232,11 @@ angular.module('focaModalDetalleCisternas') |
221 | 232 | !$scope.tieneArticulosPendientes()) { |
222 | 233 | return false; |
223 | 234 | } |
235 | + for(var i = 0; i < $scope.cisternas.length; i++) { | |
236 | + if($scope.aCargar[i] > $scope.cisternas[i].disponible) { | |
237 | + return false; | |
238 | + } | |
239 | + } | |
224 | 240 | return true; |
225 | 241 | }; |
226 | 242 | $scope.tieneArticulosPendientes = function() { |