Commit e6fb13f4c838152d290d91e9d175cbaa39560072
Exists in
master
Merge branch 'master' into 'develop'
Master(mpuebla) See merge request !122
Showing
1 changed file
Show diff stats
src/js/controller.js
... | ... | @@ -105,148 +105,148 @@ angular.module('focaCrearRemito').controller('remitoController', |
105 | 105 | }; |
106 | 106 | |
107 | 107 | $scope.getNotaPedidoModal = function () { |
108 | - if (varlidarRemitoFacturado()) { | |
109 | - var modalInstance = $uibModal.open( | |
110 | - { | |
111 | - ariaLabelledBy: 'Busqueda de Nota de Pedido', | |
112 | - templateUrl: 'foca-modal-nota-pedido.html', | |
113 | - controller: 'focaModalNotaPedidoController', | |
114 | - size: 'lg', | |
115 | - resolve: { | |
116 | - usadoPor: function () { return 'remito'; }, | |
117 | - idVendedor: function () { return null; } | |
118 | - } | |
108 | + if (!varlidarRemitoFacturado()) return; | |
109 | + if (!varlidarRemitoAbierto()) return; | |
110 | + var modalInstance = $uibModal.open( | |
111 | + { | |
112 | + ariaLabelledBy: 'Busqueda de Nota de Pedido', | |
113 | + templateUrl: 'foca-modal-nota-pedido.html', | |
114 | + controller: 'focaModalNotaPedidoController', | |
115 | + size: 'lg', | |
116 | + resolve: { | |
117 | + usadoPor: function () { return 'remito'; }, | |
118 | + idVendedor: function () { return null; } | |
119 | 119 | } |
120 | - ); | |
121 | - modalInstance.result.then( | |
122 | - function (notaPedido) { | |
123 | - //añado cabeceras | |
124 | - $scope.remitoIsDirty = true; | |
125 | - $scope.notaPedido = notaPedido; | |
126 | - $scope.remito.cliente = notaPedido.cliente; | |
127 | - $scope.$broadcast('removeCabecera', 'Bomba:'); | |
128 | - $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
129 | - var puntosDescarga = []; | |
130 | - notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { | |
131 | - puntosDescarga.push(notaPedido.puntoDescarga); | |
132 | - }); | |
133 | - $scope.cabeceras = [ | |
134 | - { | |
135 | - label: 'Cliente:', | |
136 | - valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | |
137 | - ' - ' + notaPedido.cliente.NOM | |
138 | - }, | |
139 | - { | |
140 | - label: 'Domicilio:', | |
141 | - valor: notaPedido.domicilioStamp | |
142 | - }, | |
143 | - { | |
144 | - label: 'Vendedor:', | |
145 | - valor: $filter('rellenarDigitos')( | |
146 | - notaPedido.vendedor.NUM, 3 | |
147 | - ) + ' - ' + notaPedido.vendedor.NOM | |
148 | - }, | |
149 | - | |
150 | - { | |
151 | - label: 'Proveedor:', | |
152 | - valor: $filter('rellenarDigitos') | |
153 | - (notaPedido.proveedor.COD, 5) + ' - ' + | |
154 | - notaPedido.proveedor.NOM | |
155 | - }, | |
156 | - | |
157 | - { | |
158 | - label: 'Flete:', | |
159 | - valor: notaPedido.fob === 1 ? 'FOB' : ( | |
160 | - notaPedido.flete === 1 ? 'Si' : 'No') | |
161 | - }, | |
162 | - { | |
163 | - label: 'Puntos de descarga: ', | |
164 | - valor: $filter('rellenarDigitos')( | |
165 | - getCabeceraPuntoDescarga(puntosDescarga)) | |
166 | - } | |
167 | - ]; | |
168 | - actualizarCabeceraMoneda(notaPedido.cotizacion); | |
169 | - valorPrecioCondicion(); | |
170 | - // Seteo checked en cabeceras | |
171 | - $filter('filter')($scope.botonera, | |
172 | - { label: 'Cliente' })[0].checked = true; | |
173 | - $filter('filter')($scope.botonera, | |
174 | - { label: 'Proveedor' })[0].checked = true; | |
175 | - $filter('filter')($scope.botonera, | |
176 | - { label: 'Moneda' })[0].checked = true; | |
177 | - $filter('filter')($scope.botonera, | |
178 | - { label: 'Nota pedido' })[0].checked = true; | |
179 | - $filter('filter')($scope.botonera, | |
180 | - { label: 'Precios y condiciones' })[0].checked = true; | |
181 | - $filter('filter')($scope.botonera, | |
182 | - { label: 'Domicilio de Entrega' })[0].checked = true; | |
120 | + } | |
121 | + ); | |
122 | + modalInstance.result.then( | |
123 | + function (notaPedido) { | |
124 | + //añado cabeceras | |
125 | + $scope.remitoIsDirty = true; | |
126 | + $scope.notaPedido = notaPedido; | |
127 | + $scope.remito.cliente = notaPedido.cliente; | |
128 | + $scope.$broadcast('removeCabecera', 'Bomba:'); | |
129 | + $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
130 | + var puntosDescarga = []; | |
131 | + notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { | |
132 | + puntosDescarga.push(notaPedido.puntoDescarga); | |
133 | + }); | |
134 | + $scope.cabeceras = [ | |
135 | + { | |
136 | + label: 'Cliente:', | |
137 | + valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | |
138 | + ' - ' + notaPedido.cliente.NOM | |
139 | + }, | |
140 | + { | |
141 | + label: 'Domicilio:', | |
142 | + valor: notaPedido.domicilioStamp | |
143 | + }, | |
144 | + { | |
145 | + label: 'Vendedor:', | |
146 | + valor: $filter('rellenarDigitos')( | |
147 | + notaPedido.vendedor.NUM, 3 | |
148 | + ) + ' - ' + notaPedido.vendedor.NOM | |
149 | + }, | |
183 | 150 | |
184 | - if (notaPedido.observaciones) { | |
185 | - $filter('filter')($scope.botonera, | |
186 | - { label: 'Observaciones' })[0].checked = true; | |
151 | + { | |
152 | + label: 'Proveedor:', | |
153 | + valor: $filter('rellenarDigitos') | |
154 | + (notaPedido.proveedor.COD, 5) + ' - ' + | |
155 | + notaPedido.proveedor.NOM | |
156 | + }, | |
157 | + | |
158 | + { | |
159 | + label: 'Flete:', | |
160 | + valor: notaPedido.fob === 1 ? 'FOB' : ( | |
161 | + notaPedido.flete === 1 ? 'Si' : 'No') | |
162 | + }, | |
163 | + { | |
164 | + label: 'Puntos de descarga: ', | |
165 | + valor: $filter('rellenarDigitos')( | |
166 | + getCabeceraPuntoDescarga(puntosDescarga)) | |
187 | 167 | } |
168 | + ]; | |
169 | + actualizarCabeceraMoneda(notaPedido.cotizacion); | |
170 | + valorPrecioCondicion(); | |
171 | + // Seteo checked en cabeceras | |
172 | + $filter('filter')($scope.botonera, | |
173 | + { label: 'Cliente' })[0].checked = true; | |
174 | + $filter('filter')($scope.botonera, | |
175 | + { label: 'Proveedor' })[0].checked = true; | |
176 | + $filter('filter')($scope.botonera, | |
177 | + { label: 'Moneda' })[0].checked = true; | |
178 | + $filter('filter')($scope.botonera, | |
179 | + { label: 'Nota pedido' })[0].checked = true; | |
180 | + $filter('filter')($scope.botonera, | |
181 | + { label: 'Precios y condiciones' })[0].checked = true; | |
182 | + $filter('filter')($scope.botonera, | |
183 | + { label: 'Domicilio de Entrega' })[0].checked = true; | |
184 | + | |
185 | + if (notaPedido.observaciones) { | |
186 | + $filter('filter')($scope.botonera, | |
187 | + { label: 'Observaciones' })[0].checked = true; | |
188 | + } | |
188 | 189 | |
189 | - function valorPrecioCondicion() { | |
190 | - if (parseInt(notaPedido.idListaPrecio) > 0) { | |
191 | - crearRemitoService | |
192 | - .getListaPrecioById(parseInt(notaPedido.idListaPrecio)) | |
193 | - .then(function (res) { | |
194 | - $scope.cabeceras.push({ | |
195 | - label: 'Precios y Condiciones:', | |
196 | - valor: | |
197 | - parseInt(res.data[0].ID) + ' - ' + | |
198 | - res.data[0].DES + ' ' + | |
199 | - remitoBusinessService | |
200 | - .plazoToString(notaPedido.notaPedidoPlazo) | |
201 | - }); | |
202 | - addArrayCabecera($scope.cabeceras); | |
190 | + function valorPrecioCondicion() { | |
191 | + if (parseInt(notaPedido.idListaPrecio) > 0) { | |
192 | + crearRemitoService | |
193 | + .getListaPrecioById(parseInt(notaPedido.idListaPrecio)) | |
194 | + .then(function (res) { | |
195 | + $scope.cabeceras.push({ | |
196 | + label: 'Precios y Condiciones:', | |
197 | + valor: | |
198 | + parseInt(res.data[0].ID) + ' - ' + | |
199 | + res.data[0].DES + ' ' + | |
200 | + remitoBusinessService | |
201 | + .plazoToString(notaPedido.notaPedidoPlazo) | |
203 | 202 | }); |
204 | - } | |
203 | + addArrayCabecera($scope.cabeceras); | |
204 | + }); | |
205 | 205 | } |
206 | + } | |
206 | 207 | |
207 | - if (notaPedido.flete === 1) { | |
208 | - var cabeceraBomba = { | |
209 | - label: 'Bomba:', | |
210 | - valor: notaPedido.bomba === 1 ? 'Si' : 'No' | |
208 | + if (notaPedido.flete === 1) { | |
209 | + var cabeceraBomba = { | |
210 | + label: 'Bomba:', | |
211 | + valor: notaPedido.bomba === 1 ? 'Si' : 'No' | |
212 | + }; | |
213 | + if (notaPedido.kilometros) { | |
214 | + var cabeceraKilometros = { | |
215 | + label: 'Kilometros:', | |
216 | + valor: notaPedido.kilometros | |
211 | 217 | }; |
212 | - if (notaPedido.kilometros) { | |
213 | - var cabeceraKilometros = { | |
214 | - label: 'Kilometros:', | |
215 | - valor: notaPedido.kilometros | |
216 | - }; | |
217 | - $scope.cabeceras.push(cabeceraKilometros); | |
218 | - } | |
219 | - $scope.cabeceras.push(cabeceraBomba); | |
218 | + $scope.cabeceras.push(cabeceraKilometros); | |
220 | 219 | } |
220 | + $scope.cabeceras.push(cabeceraBomba); | |
221 | + } | |
221 | 222 | |
222 | - $scope.remito = angular.copy(notaPedido); | |
223 | - $scope.remito.id = 0; | |
224 | - $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | |
225 | - $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; | |
223 | + $scope.remito = angular.copy(notaPedido); | |
224 | + $scope.remito.id = 0; | |
225 | + $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | |
226 | + $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; | |
226 | 227 | |
227 | - notaPedido.articulosNotaPedido.forEach(function (articulo) { | |
228 | - articulo.id = 0; | |
229 | - articulo.idRemito = 0; | |
230 | - articulo.precio = | |
231 | - (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | |
232 | - }); | |
228 | + notaPedido.articulosNotaPedido.forEach(function (articulo) { | |
229 | + articulo.id = 0; | |
230 | + articulo.idRemito = 0; | |
231 | + articulo.precio = | |
232 | + (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | |
233 | + }); | |
233 | 234 | |
234 | - $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | |
235 | + $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | |
235 | 236 | |
236 | - if (notaPedido.idPrecioCondicion > 0) { | |
237 | - $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | |
238 | - } else { | |
239 | - $scope.idLista = -1; | |
240 | - } | |
237 | + if (notaPedido.idPrecioCondicion > 0) { | |
238 | + $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | |
239 | + } else { | |
240 | + $scope.idLista = -1; | |
241 | + } | |
241 | 242 | |
242 | - enableObservaciones(notaPedido.observaciones ? true : false); | |
243 | - addArrayCabecera($scope.cabeceras); | |
243 | + enableObservaciones(notaPedido.observaciones ? true : false); | |
244 | + addArrayCabecera($scope.cabeceras); | |
244 | 245 | |
245 | - }, function () { | |
246 | - // funcion ejecutada cuando se cancela el modal | |
247 | - } | |
248 | - ); | |
249 | - } | |
246 | + }, function () { | |
247 | + // funcion ejecutada cuando se cancela el modal | |
248 | + } | |
249 | + ); | |
250 | 250 | }; |
251 | 251 | |
252 | 252 | $scope.seleccionarRemito = function () { |
... | ... | @@ -285,7 +285,6 @@ angular.module('focaCrearRemito').controller('remitoController', |
285 | 285 | }; |
286 | 286 | //validacion por domicilio y por plazo pago |
287 | 287 | $scope.crearRemito = function () { |
288 | - varlidarRemitoFacturado(); | |
289 | 288 | if (!$scope.remito.vendedor.NUM) { |
290 | 289 | focaModalService.alert('Ingrese Vendedor'); |
291 | 290 | return; |
... | ... | @@ -416,6 +415,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
416 | 415 | |
417 | 416 | $scope.seleccionarProductos = function () { |
418 | 417 | if (!varlidarRemitoFacturado()) return; |
418 | + if (!varlidarRemitoAbierto()) return; | |
419 | 419 | if ($scope.notaPedido.id !== 0) { |
420 | 420 | $scope.idLista = parseInt($scope.notaPedido.idListaPrecio); |
421 | 421 | } |
... | ... | @@ -523,27 +523,27 @@ angular.module('focaCrearRemito').controller('remitoController', |
523 | 523 | }; |
524 | 524 | |
525 | 525 | $scope.seleccionarCliente = function () { |
526 | - if (varlidarRemitoFacturado()) { | |
527 | - var modalInstance = $uibModal.open( | |
528 | - { | |
529 | - ariaLabelledBy: 'Busqueda de Cliente', | |
530 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
531 | - controller: 'focaBusquedaClienteModalController', | |
532 | - resolve: { | |
533 | - vendedor: function () { return null; }, | |
534 | - cobrador: function () { return null; } | |
535 | - }, | |
536 | - size: 'lg' | |
537 | - } | |
538 | - ); | |
539 | - modalInstance.result.then( | |
540 | - function (cliente) { | |
541 | - $scope.cliente = cliente; | |
542 | - $scope.abrirModalDomicilios(cliente); | |
543 | - }, function () { | |
544 | - } | |
545 | - ); | |
546 | - } | |
526 | + if (!varlidarRemitoFacturado()) return; | |
527 | + if (!varlidarRemitoAbierto()) return; | |
528 | + var modalInstance = $uibModal.open( | |
529 | + { | |
530 | + ariaLabelledBy: 'Busqueda de Cliente', | |
531 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
532 | + controller: 'focaBusquedaClienteModalController', | |
533 | + resolve: { | |
534 | + vendedor: function () { return null; }, | |
535 | + cobrador: function () { return null; } | |
536 | + }, | |
537 | + size: 'lg' | |
538 | + } | |
539 | + ); | |
540 | + modalInstance.result.then( | |
541 | + function (cliente) { | |
542 | + $scope.cliente = cliente; | |
543 | + $scope.abrirModalDomicilios(cliente); | |
544 | + }, function () { | |
545 | + } | |
546 | + ); | |
547 | 547 | }; |
548 | 548 | |
549 | 549 | $scope.seleccionarEliminarRemito = function () { |
... | ... | @@ -565,41 +565,42 @@ angular.module('focaCrearRemito').controller('remitoController', |
565 | 565 | }; |
566 | 566 | |
567 | 567 | $scope.seleccionarProveedor = function () { |
568 | - if (varlidarRemitoFacturado()) { | |
569 | - var parametrosModal = { | |
570 | - titulo: 'Búsqueda de Proveedor', | |
571 | - query: '/proveedor', | |
572 | - columnas: [ | |
573 | - { | |
574 | - nombre: 'Código', | |
575 | - propiedad: 'COD', | |
576 | - filtro: { | |
577 | - nombre: 'rellenarDigitos', | |
578 | - parametro: 5 | |
579 | - } | |
580 | - }, | |
581 | - { | |
582 | - nombre: 'Nombre', | |
583 | - propiedad: 'NOM' | |
584 | - }, | |
585 | - { | |
586 | - nombre: 'CUIT', | |
587 | - propiedad: 'CUIT' | |
568 | + if (!varlidarRemitoFacturado()) return; | |
569 | + if (!varlidarRemitoAbierto()) return; | |
570 | + var parametrosModal = { | |
571 | + titulo: 'Búsqueda de Proveedor', | |
572 | + query: '/proveedor', | |
573 | + columnas: [ | |
574 | + { | |
575 | + nombre: 'Código', | |
576 | + propiedad: 'COD', | |
577 | + filtro: { | |
578 | + nombre: 'rellenarDigitos', | |
579 | + parametro: 5 | |
588 | 580 | } |
589 | - ], | |
590 | - tipo: 'POST', | |
591 | - json: { razonCuitCod: '' } | |
592 | - }; | |
593 | - focaModalService.modal(parametrosModal).then( | |
594 | - function (proveedor) { | |
595 | - $scope.seleccionarFlete(proveedor); | |
596 | - }, function () { } | |
597 | - ); | |
598 | - } | |
581 | + }, | |
582 | + { | |
583 | + nombre: 'Nombre', | |
584 | + propiedad: 'NOM' | |
585 | + }, | |
586 | + { | |
587 | + nombre: 'CUIT', | |
588 | + propiedad: 'CUIT' | |
589 | + } | |
590 | + ], | |
591 | + tipo: 'POST', | |
592 | + json: { razonCuitCod: '' } | |
593 | + }; | |
594 | + focaModalService.modal(parametrosModal).then( | |
595 | + function (proveedor) { | |
596 | + $scope.seleccionarFlete(proveedor); | |
597 | + }, function () { } | |
598 | + ); | |
599 | 599 | }; |
600 | 600 | |
601 | 601 | $scope.seleccionarDomicilioDeEntrega = function () { |
602 | 602 | if (!varlidarRemitoFacturado()) return; |
603 | + if (!varlidarRemitoAbierto()) return; | |
603 | 604 | if (!$scope.remito.cliente.COD && !$scope.cliente) { |
604 | 605 | focaModalService.alert('Seleccione un Cliente'); |
605 | 606 | return; |
... | ... | @@ -715,7 +716,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
715 | 716 | return; |
716 | 717 | } |
717 | 718 | if ($scope.remito.articulosRemito.length !== 0) { |
718 | - if (varlidarRemitoFacturado()) { | |
719 | + if (varlidarRemitoFacturado() && varlidarRemitoAbierto()) { | |
719 | 720 | abrirModal(); |
720 | 721 | } |
721 | 722 | } else { |
... | ... | @@ -793,115 +794,115 @@ angular.module('focaCrearRemito').controller('remitoController', |
793 | 794 | }; |
794 | 795 | |
795 | 796 | $scope.seleccionarFlete = function (proveedor) { |
796 | - if (varlidarRemitoFacturado()) { | |
797 | - var modalInstance = $uibModal.open( | |
798 | - { | |
799 | - ariaLabelledBy: 'Busqueda de Flete', | |
800 | - templateUrl: 'modal-flete.html', | |
801 | - controller: 'focaModalFleteController', | |
802 | - size: 'lg', | |
803 | - resolve: { | |
804 | - parametrosFlete: | |
805 | - function () { | |
806 | - return { | |
807 | - flete: $scope.remito.flete ? '1' : | |
808 | - ($scope.remito.fob ? 'FOB' : | |
809 | - ($scope.remito.flete === undefined ? | |
810 | - null : '0')), | |
811 | - bomba: $scope.remito.bomba ? '1' : | |
812 | - ($scope.remito.bomba === undefined ? | |
813 | - null : '0'), | |
814 | - kilometros: $scope.remito.kilometros | |
815 | - }; | |
816 | - } | |
817 | - } | |
797 | + if (!varlidarRemitoFacturado()) return; | |
798 | + if (!varlidarRemitoAbierto()) return; | |
799 | + var modalInstance = $uibModal.open( | |
800 | + { | |
801 | + ariaLabelledBy: 'Busqueda de Flete', | |
802 | + templateUrl: 'modal-flete.html', | |
803 | + controller: 'focaModalFleteController', | |
804 | + size: 'lg', | |
805 | + resolve: { | |
806 | + parametrosFlete: | |
807 | + function () { | |
808 | + return { | |
809 | + flete: $scope.remito.flete ? '1' : | |
810 | + ($scope.remito.fob ? 'FOB' : | |
811 | + ($scope.remito.flete === undefined ? | |
812 | + null : '0')), | |
813 | + bomba: $scope.remito.bomba ? '1' : | |
814 | + ($scope.remito.bomba === undefined ? | |
815 | + null : '0'), | |
816 | + kilometros: $scope.remito.kilometros | |
817 | + }; | |
818 | + } | |
818 | 819 | } |
819 | - ); | |
820 | - modalInstance.result.then( | |
821 | - function (datos) { | |
822 | - $scope.remitoIsDirty = true; | |
823 | - $scope.remito.proveedor = proveedor; | |
824 | - $scope.remito.idProveedor = proveedor.COD; | |
825 | - $scope.$broadcast('addCabecera', { | |
826 | - label: 'Proveedor:', | |
827 | - valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | |
828 | - proveedor.NOM | |
829 | - }); | |
820 | + } | |
821 | + ); | |
822 | + modalInstance.result.then( | |
823 | + function (datos) { | |
824 | + $scope.remitoIsDirty = true; | |
825 | + $scope.remito.proveedor = proveedor; | |
826 | + $scope.remito.idProveedor = proveedor.COD; | |
827 | + $scope.$broadcast('addCabecera', { | |
828 | + label: 'Proveedor:', | |
829 | + valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | |
830 | + proveedor.NOM | |
831 | + }); | |
830 | 832 | |
831 | - $scope.remito.flete = datos.flete; | |
832 | - $scope.remito.fob = datos.FOB; | |
833 | - $scope.remito.bomba = datos.bomba; | |
834 | - $scope.remito.kilometros = datos.kilometros; | |
833 | + $scope.remito.flete = datos.flete; | |
834 | + $scope.remito.fob = datos.FOB; | |
835 | + $scope.remito.bomba = datos.bomba; | |
836 | + $scope.remito.kilometros = datos.kilometros; | |
835 | 837 | |
838 | + $scope.$broadcast('addCabecera', { | |
839 | + label: 'Flete:', | |
840 | + valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | |
841 | + }); | |
842 | + if (datos.flete) { | |
836 | 843 | $scope.$broadcast('addCabecera', { |
837 | - label: 'Flete:', | |
838 | - valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | |
844 | + label: 'Bomba:', | |
845 | + valor: datos.bomba ? 'Si' : 'No' | |
839 | 846 | }); |
840 | - if (datos.flete) { | |
841 | - $scope.$broadcast('addCabecera', { | |
842 | - label: 'Bomba:', | |
843 | - valor: datos.bomba ? 'Si' : 'No' | |
844 | - }); | |
845 | - $scope.$broadcast('addCabecera', { | |
846 | - label: 'Kilometros:', | |
847 | - valor: datos.kilometros | |
848 | - }); | |
849 | - } else { | |
850 | - $scope.$broadcast('removeCabecera', 'Bomba:'); | |
851 | - $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
852 | - $scope.remito.bomba = false; | |
853 | - $scope.remito.kilometros = null; | |
854 | - } | |
855 | - | |
856 | - $filter('filter')($scope.botonera, | |
857 | - { label: 'Proveedor' })[0].checked = true; | |
858 | - }, function () { | |
859 | - $scope.seleccionarTransportista(); | |
847 | + $scope.$broadcast('addCabecera', { | |
848 | + label: 'Kilometros:', | |
849 | + valor: datos.kilometros | |
850 | + }); | |
851 | + } else { | |
852 | + $scope.$broadcast('removeCabecera', 'Bomba:'); | |
853 | + $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
854 | + $scope.remito.bomba = false; | |
855 | + $scope.remito.kilometros = null; | |
860 | 856 | } |
861 | - ); | |
862 | - } | |
857 | + | |
858 | + $filter('filter')($scope.botonera, | |
859 | + { label: 'Proveedor' })[0].checked = true; | |
860 | + }, function () { | |
861 | + $scope.seleccionarTransportista(); | |
862 | + } | |
863 | + ); | |
863 | 864 | }; |
864 | 865 | |
865 | 866 | $scope.seleccionarMoneda = function () { |
866 | - if (varlidarRemitoFacturado()) { | |
867 | - var parametrosModal = { | |
868 | - titulo: 'Búsqueda de monedas', | |
869 | - query: '/moneda', | |
870 | - columnas: [ | |
871 | - { | |
872 | - propiedad: 'DETALLE', | |
873 | - nombre: 'Nombre' | |
874 | - }, | |
875 | - { | |
876 | - propiedad: 'SIMBOLO', | |
877 | - nombre: 'Símbolo' | |
878 | - } | |
879 | - ], | |
880 | - size: 'md' | |
881 | - }; | |
882 | - focaModalService.modal(parametrosModal).then( | |
883 | - function (moneda) { | |
867 | + if (!varlidarRemitoFacturado()) return; | |
868 | + if (!varlidarRemitoAbierto()) return; | |
869 | + var parametrosModal = { | |
870 | + titulo: 'Búsqueda de monedas', | |
871 | + query: '/moneda', | |
872 | + columnas: [ | |
873 | + { | |
874 | + propiedad: 'DETALLE', | |
875 | + nombre: 'Nombre' | |
876 | + }, | |
877 | + { | |
878 | + propiedad: 'SIMBOLO', | |
879 | + nombre: 'Símbolo' | |
880 | + } | |
881 | + ], | |
882 | + size: 'md' | |
883 | + }; | |
884 | + focaModalService.modal(parametrosModal).then( | |
885 | + function (moneda) { | |
884 | 886 | |
885 | - if (moneda.ID !== 1) { | |
886 | - $scope.abrirModalCotizacion(moneda); | |
887 | - return; | |
888 | - } | |
887 | + if (moneda.ID !== 1) { | |
888 | + $scope.abrirModalCotizacion(moneda); | |
889 | + return; | |
890 | + } | |
889 | 891 | |
890 | - crearRemitoService.getCotizacionByIdMoneda(1) | |
891 | - .then(function (res) { | |
892 | + crearRemitoService.getCotizacionByIdMoneda(1) | |
893 | + .then(function (res) { | |
892 | 894 | |
893 | - cotizacionPArgentino = res.data[0].cotizaciones[0]; | |
894 | - cotizacionPArgentino.moneda = moneda; | |
895 | + cotizacionPArgentino = res.data[0].cotizaciones[0]; | |
896 | + cotizacionPArgentino.moneda = moneda; | |
895 | 897 | |
896 | - actualizarCabeceraMoneda(cotizacionPArgentino); | |
898 | + actualizarCabeceraMoneda(cotizacionPArgentino); | |
897 | 899 | |
898 | - $scope.remito.cotizacion = cotizacionPArgentino; | |
899 | - }); | |
900 | - }, function () { | |
900 | + $scope.remito.cotizacion = cotizacionPArgentino; | |
901 | + }); | |
902 | + }, function () { | |
901 | 903 | |
902 | - } | |
903 | - ); | |
904 | - } | |
904 | + } | |
905 | + ); | |
905 | 906 | }; |
906 | 907 | |
907 | 908 | $scope.seleccionarObservaciones = function () { |
... | ... | @@ -1076,6 +1077,16 @@ angular.module('focaCrearRemito').controller('remitoController', |
1076 | 1077 | } |
1077 | 1078 | } |
1078 | 1079 | |
1080 | + function varlidarRemitoAbierto() { | |
1081 | + if (!$scope.remito.hojaRuta) return true; | |
1082 | + if ($scope.remito.hojaRuta.abierta !== '1') { | |
1083 | + return true; | |
1084 | + } else { | |
1085 | + focaModalService.alert('No se puede editar un remito abierto'); | |
1086 | + return false; | |
1087 | + } | |
1088 | + } | |
1089 | + | |
1079 | 1090 | function salir() { |
1080 | 1091 | var confirmacion = false; |
1081 | 1092 | |
... | ... | @@ -1105,7 +1116,10 @@ angular.module('focaCrearRemito').controller('remitoController', |
1105 | 1116 | |
1106 | 1117 | function setearRemito(remito) { |
1107 | 1118 | //añado cabeceras |
1108 | - if (remito.estado !== 5 && remito.id) { | |
1119 | + console.log(remito); | |
1120 | + var esAbierto = remito.hojaRuta ? | |
1121 | + (remito.hojaRuta.abierta === '1') : false; | |
1122 | + if (remito.estado !== 5 && remito.id && !esAbierto) { | |
1109 | 1123 | |
1110 | 1124 | $scope.botonera.forEach(function (boton) { |
1111 | 1125 |