Compare View

switch
from
...
to
 
Commits (19)
src/js/controller.js
... ... @@ -684,6 +684,7 @@ angular.module('focaCrearRemito').controller('remitoController',
684 684 for (var i = 0; i < arrayTempArticulos.length; i++) {
685 685 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
686 686 }
  687 + $scope.comprobarTotal(parseFloat(total.toFixed(2)));
687 688 return parseFloat(total.toFixed(2));
688 689 };
689 690  
... ... @@ -958,12 +959,25 @@ angular.module(&#39;focaCrearRemito&#39;).controller(&#39;remitoController&#39;,
958 959 $scope.agregarATabla = function (key) {
959 960 if (key === 13) {
960 961 if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) {
961   - focaModalService.alert('El valor debe ser al menos 1');
  962 + focaModalService.alert('Debes introducir algún valor');
  963 + return;
  964 + } else if ($scope.articuloACargar.cantidad === '0' || $scope.articuloACargar.precio === '0') {
  965 + focaModalService.alert('Esta ingresando un producto con valor 0');
  966 + return;
  967 + } else if ($scope.articuloACargar.cantidad < 0 || $scope.articuloACargar.precio < 0) {
  968 + focaModalService.alert('Los valores no pueden ser negativos');
962 969 return;
  970 + } else if (!Number.isInteger(+$scope.articuloACargar.cantidad)) {
  971 + focaModalService.alert('La cantidad debe ser un número entero');
  972 + return;
  973 + } else if ($scope.articuloACargar.cantidad > 100000) {
  974 + focaModalService.alert('La cantidad máxima permitida es 100.000');
  975 + return
  976 + } else {
  977 + delete $scope.articuloACargar.sectorCodigo;
  978 + $scope.remito.articulosRemito.push($scope.articuloACargar);
  979 + $scope.cargando = true;
963 980 }
964   - delete $scope.articuloACargar.sectorCodigo;
965   - $scope.remito.articulosRemito.push($scope.articuloACargar);
966   - $scope.cargando = true;
967 981 }
968 982 };
969 983  
... ... @@ -997,9 +1011,12 @@ angular.module(&#39;focaCrearRemito&#39;).controller(&#39;remitoController&#39;,
997 1011 } else if (tmpCantidad < 0 || tmpPrecio < 0) {
998 1012 focaModalService.alert('Los valores no pueden ser negativos');
999 1013 return;
1000   - } else if (!Number.isInteger(tmpCantidad)) {
  1014 + } else if (!Number.isInteger(+tmpCantidad)) {
1001 1015 focaModalService.alert('Debes introducir un número entero');
1002 1016 return;
  1017 + } else if (tmpCantidad > 100000) {
  1018 + focaModalService.alert('La cantidad máxima permitida es 100.000');
  1019 + return
1003 1020 } else {
1004 1021 articulo.cantidad = tmpCantidad;
1005 1022 articulo.precio = tmpPrecio;
... ... @@ -1008,6 +1025,16 @@ angular.module(&#39;focaCrearRemito&#39;).controller(&#39;remitoController&#39;,
1008 1025 }
1009 1026 }
1010 1027 };
  1028 + //Si el monto Total es superior a $10.000.000.000,00 desactivo el botón Guardar
  1029 + $scope.comprobarTotal = function(total) {
  1030 + if (total >= 10000000000) {
  1031 + $scope.auxComprobar = true;
  1032 + $( "#guardar" ).prop( "disabled", true );
  1033 + } else {
  1034 + $scope.auxComprobar = false;
  1035 + $( "#guardar" ).prop( "disabled", false );
  1036 + }
  1037 + };
1011 1038  
1012 1039 $scope.cancelarEditar = function (articulo) {
1013 1040 $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"