Commit df412d96bc9a752681f7f48e037a12dd52cb1899

Authored by Eric Fernandez
Exists in master and in 2 other branches develop, lab

Merge branch 'master' into 'develop'

Master

See merge request !49
src/js/controller.js
... ... @@ -114,12 +114,32 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
114 114 $scope.seleccionarRemitoAbierto = function () {
115 115 $scope.remitoAbierto = true;
116 116 $scope.cargaRemito = false;
117   - $scope.botoneraPrincipal.forEach(function (boton) {
118   - boton.checked = false;
  117 +
  118 + var isBotoneraDirty = $scope.botonera.find(function (boton) {
  119 + return boton.checked;
119 120 });
120   - $filter('filter')($scope.botoneraPrincipal, {
121   - label: 'Remito Abierto',
122   - })[0].checked = false;
  121 +
  122 + if (isBotoneraDirty) {
  123 + init();
  124 + focaModalService.confirm('Se perderan los cambios')
  125 + .then(function () {
  126 + limpiarBotonera($scope.botonera);
  127 + limpiarBotonera($scope.botoneraPrincipal);
  128 + $filter('filter')($scope.botoneraPrincipal, {
  129 + label: 'Remito Abierto',
  130 + })[0].checked = true;
  131 + $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
  132 +
  133 + });
  134 + } else {
  135 + init();
  136 + limpiarBotonera($scope.botoneraPrincipal);
  137 + $filter('filter')($scope.botoneraPrincipal, {
  138 + label: 'Remito Abierto',
  139 + })[0].checked = true;
  140 + $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
  141 +
  142 + }
123 143  
124 144 $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto();
125 145 };
... ... @@ -132,9 +152,11 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
132 152 });
133 153  
134 154 if (isBotoneraDirty) {
  155 + init();
135 156 focaModalService.confirm('Se perderan los cambios')
136 157 .then(function () {
137 158 limpiarBotonera($scope.botonera);
  159 + limpiarBotonera($scope.botoneraPrincipal);
138 160 $scope.preCargados = false;
139 161 $filter('filter')($scope.botoneraPrincipal, {
140 162 label: 'Cargar Remitos',
... ... @@ -142,6 +164,11 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
142 164 $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
143 165 });
144 166 } else {
  167 + init();
  168 + limpiarBotonera($scope.botoneraPrincipal);
  169 + $filter('filter')($scope.botoneraPrincipal, {
  170 + label: 'Cargar Remitos',
  171 + })[0].checked = true;
145 172 $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
146 173 }
147 174 $scope.precargado = false;
... ... @@ -149,16 +176,33 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
149 176  
150 177 $scope.seleccionarPrecargados = function () {
151 178 $scope.precargado = true;
152   - $filter('filter')($scope.botoneraPrincipal, {
153   - label: '',
154   - })[0].checked = true;
155   - $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
  179 + var isBotoneraDirty = $scope.botonera.find(function (boton) {
  180 + return boton.checked;
  181 + });
  182 +
  183 + if (isBotoneraDirty) {
  184 + init();
  185 + focaModalService.confirm('Se perderan los cambios')
  186 + .then(function () {
  187 + limpiarBotonera($scope.botonera);
  188 + limpiarBotonera($scope.botoneraPrincipal);
  189 + $filter('filter')($scope.botoneraPrincipal, {
  190 + label: 'Precargado',
  191 + })[0].checked = true;
  192 + $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
  193 + });
  194 + } else {
  195 + init();
  196 + limpiarBotonera($scope.botoneraPrincipal);
  197 + $filter('filter')($scope.botoneraPrincipal, {
  198 + label: 'Precargado',
  199 + })[0].checked = true;
  200 + $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
  201 + }
156 202 };
157 203  
158   - $scope.quitarArticulo = function (articulo) {
159   - $scope.articulosSeleccionados.forEach( function () {
160   - });
161   - articulo = -1;
  204 + $scope.quitarArticulo = function (key ,articulo) {
  205 + $scope.articulos.splice(key, 1);
162 206 };
163 207  
164 208 function validarHojaRuta() {
... ... @@ -759,16 +803,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
759 803 })[0].checked = true;
760 804  
761 805 }, function (error) {
762   - if (error && error !== 'backdrop click') {
763   - focaModalService
764   - .alert(error || 'Ha ocurrido un error')
765   - .then(function () {
766   - $scope.seleccionarRemitos();
767   - });
768   -
769   - } else {
770   - $scope.seleccionarRemitos();
771   - }
  806 + error.then($scope.seleccionarRemitos);
772 807 });
773 808 }, function () {
774 809 // funcion ejecutada cuando se cancela el modal
... ... @@ -807,7 +842,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
807 842 var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0;
808 843 var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined;
809 844  
810   - if (hasVehiculoId || hasTarifario || hasTransportista ||
  845 + if (hasVehiculoId || hasTransportista ||
811 846 hasChofer || hasDatosExtra) {
812 847 confirmacion = true;
813 848 if (confirmacion) {
... ... @@ -825,6 +860,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
825 860 }, function () {
826 861 return;
827 862 });
  863 + } else {
  864 + elegirFecha();
828 865 }
829 866 } else {
830 867 elegirFecha();
src/js/controllerDetalles.js
... ... @@ -61,7 +61,7 @@ angular.module('focaCrearHojaRuta')
61 61 descripcion: res.descripcion,
62 62 item: 1,
63 63 nombre: res.descripcion,
64   - precio: parseFloat(res.precio.toFixed(4)),
  64 + precio: parseFloat(res.precio).toFixed(4),
65 65 costoUnitario: res.costo,
66 66 editCantidad: false,
67 67 editPrecio: false,
... ... @@ -93,6 +93,16 @@ angular.module('focaCrearHojaRuta')
93 93 return parseInt(cisterna.disponible) > 0;
94 94 });
95 95  
  96 +
  97 + var cisternasIncompletas = cisternasFilter.filter(function(cisterna) {
  98 + return (cisterna.articuloSeleccionado && !cisterna.disponible) ||
  99 + (!cisterna.articuloSeleccionado && cisterna.disponible);
  100 + });
  101 +
  102 + if (cisternasIncompletas.length || !cisternasFilter.length) {
  103 + return focaModalService.alert('Ingrese todos los campos para completar el remito');
  104 + }
  105 +
96 106 var articulos = [];
97 107  
98 108 cisternasFilter.forEach(function (cisterna) {
... ... @@ -113,12 +123,6 @@ angular.module('focaCrearHojaRuta')
113 123 };
114 124 }
115 125  
116   - if (!cisterna.articuloSeleccionado) {
117   - focaModalService.alert('Seleccione Articulo');
118   -
119   - return;
120   - }
121   -
122 126 //cargar
123 127 if (cisterna.cisternaCarga.cantidad) {
124 128 cisterna.cisternaCarga.cantidad += cisterna.disponible;
... ... @@ -151,7 +155,7 @@ angular.module('focaCrearHojaRuta')
151 155 };
152 156  
153 157 $scope.cancel = function () {
154   - $uibModalInstance.close(null);
  158 + $uibModalInstance.dismiss(null);
155 159 };
156 160 }
157 161 ]);
... ... @@ -234,6 +234,11 @@ angular.module('focaCrearHojaRuta')
234 234 ];
235 235 },
236 236 guardarCisternas: function(cisterna, idRemito) {
  237 +
  238 + cisterna.cisternaMovimientos.forEach(function(cisternaMovimiento) {
  239 + cisternaMovimiento.idRemito = idRemito;
  240 + });
  241 +
237 242 return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' +
238 243 this.idUsuario + '/' + idRemito, cisterna);
239 244 },
src/views/hoja-ruta.html
... ... @@ -105,7 +105,7 @@
105 105 <td class="text-center">
106 106 <button
107 107 class="btn btn-outline-light"
108   - ng-click="quitarArticulo(articulo)"
  108 + ng-click="quitarArticulo(key, articulo)"
109 109 >
110 110 <i class="fa fa-trash"></i>
111 111 </button>