Commit a409239f0b5890572556d46f60b1377e6e24dd9a
Exists in
develop
Merge branch 'develop' of git.focasoftware.com:npm/foca-crear-remito into develop
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -692,6 +692,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
692 | 692 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
693 | 693 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
694 | 694 | } |
695 | + $scope.comprobarTotal(parseFloat(total.toFixed(2))); | |
695 | 696 | return parseFloat(total.toFixed(2)); |
696 | 697 | }; |
697 | 698 | |
... | ... | @@ -966,12 +967,25 @@ angular.module('focaCrearRemito').controller('remitoController', |
966 | 967 | $scope.agregarATabla = function (key) { |
967 | 968 | if (key === 13) { |
968 | 969 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { |
969 | - focaModalService.alert('El valor debe ser al menos 1'); | |
970 | + focaModalService.alert('Debes introducir algún valor'); | |
971 | + return; | |
972 | + } else if ($scope.articuloACargar.cantidad === '0' || $scope.articuloACargar.precio === '0') { | |
973 | + focaModalService.alert('Esta ingresando un producto con valor 0'); | |
974 | + return; | |
975 | + } else if ($scope.articuloACargar.cantidad < 0 || $scope.articuloACargar.precio < 0) { | |
976 | + focaModalService.alert('Los valores no pueden ser negativos'); | |
970 | 977 | return; |
978 | + } else if (!Number.isInteger(+$scope.articuloACargar.cantidad)) { | |
979 | + focaModalService.alert('La cantidad debe ser un número entero'); | |
980 | + return; | |
981 | + } else if ($scope.articuloACargar.cantidad > 100000) { | |
982 | + focaModalService.alert('La cantidad máxima permitida es 100.000'); | |
983 | + return | |
984 | + } else { | |
985 | + delete $scope.articuloACargar.sectorCodigo; | |
986 | + $scope.remito.articulosRemito.push($scope.articuloACargar); | |
987 | + $scope.cargando = true; | |
971 | 988 | } |
972 | - delete $scope.articuloACargar.sectorCodigo; | |
973 | - $scope.remito.articulosRemito.push($scope.articuloACargar); | |
974 | - $scope.cargando = true; | |
975 | 989 | } |
976 | 990 | }; |
977 | 991 | |
... | ... | @@ -1005,9 +1019,12 @@ angular.module('focaCrearRemito').controller('remitoController', |
1005 | 1019 | } else if (tmpCantidad < 0 || tmpPrecio < 0) { |
1006 | 1020 | focaModalService.alert('Los valores no pueden ser negativos'); |
1007 | 1021 | return; |
1008 | - } else if (!Number.isInteger(tmpCantidad)) { | |
1022 | + } else if (!Number.isInteger(+tmpCantidad)) { | |
1009 | 1023 | focaModalService.alert('Debes introducir un número entero'); |
1010 | 1024 | return; |
1025 | + } else if (tmpCantidad > 100000) { | |
1026 | + focaModalService.alert('La cantidad máxima permitida es 100.000'); | |
1027 | + return | |
1011 | 1028 | } else { |
1012 | 1029 | articulo.cantidad = tmpCantidad; |
1013 | 1030 | articulo.precio = tmpPrecio; |
... | ... | @@ -1016,6 +1033,16 @@ angular.module('focaCrearRemito').controller('remitoController', |
1016 | 1033 | } |
1017 | 1034 | } |
1018 | 1035 | }; |
1036 | + //Si el monto Total es superior a $10.000.000.000,00 desactivo el botón Guardar | |
1037 | + $scope.comprobarTotal = function(total) { | |
1038 | + if (total >= 10000000000) { | |
1039 | + $scope.auxComprobar = true; | |
1040 | + $( "#guardar" ).prop( "disabled", true ); | |
1041 | + } else { | |
1042 | + $scope.auxComprobar = false; | |
1043 | + $( "#guardar" ).prop( "disabled", false ); | |
1044 | + } | |
1045 | + }; | |
1019 | 1046 | |
1020 | 1047 | $scope.cancelarEditar = function (articulo) { |
1021 | 1048 | $scope.tmpCantidad = articulo.cantidad; |
src/views/remito.html
... | ... | @@ -73,6 +73,8 @@ |
73 | 73 | class="form-control" |
74 | 74 | foca-tipo-input |
75 | 75 | min="1" |
76 | + max="100000" | |
77 | + maxlength="6" | |
76 | 78 | foca-focus="articulo.editCantidad" |
77 | 79 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
78 | 80 | esc-key="cancelarEditar(articulo)" |
... | ... | @@ -157,6 +159,8 @@ |
157 | 159 | class="form-control" |
158 | 160 | foca-tipo-input |
159 | 161 | min="1" |
162 | + max="100000" | |
163 | + maxlength="6" | |
160 | 164 | ng-model="articuloACargar.cantidad" |
161 | 165 | foca-focus="!cargando" |
162 | 166 | esc-key="resetFilter()" |
... | ... | @@ -217,6 +221,17 @@ |
217 | 221 | </table> |
218 | 222 | </div> |
219 | 223 | </div> |
224 | + <div | |
225 | + class="col-12 col-md-10 col-lg-10 p-0" | |
226 | + ng-if="auxComprobar"> | |
227 | + <div | |
228 | + class="alert alert-danger ml-auto mt-2" | |
229 | + role="alert" | |
230 | + style="width: 60%;"> | |
231 | + <i class="fa fa-exclamation-triangle fa-lg"></i> | |
232 | + El monto total debe ser menor a $10.000.000.000,00, elimina un artículo o reduce las cantidades | |
233 | + </div> | |
234 | + </div> | |
220 | 235 | </div> |
221 | 236 | </div> |
222 | 237 | <div class="row d-md-none fixed-bottom"> |
... | ... | @@ -224,6 +239,7 @@ |
224 | 239 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
225 | 240 | <span |
226 | 241 | class="mr-3 ml-auto" |
242 | + ng-disabled="comprobarTotal()" | |
227 | 243 | ng-class="saveLoading ? 'text-muted' : ''" |
228 | 244 | ng-click="crearRemito()" |
229 | 245 | ladda="saveLoading" |