Commit c4139b1786851496e20c7237bd3c4d3fb8f1d8d4
Exists in
master
and in
2 other branches
Merge branch 'develop' into 'master'
Develop See merge request !123
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -105,160 +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.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: 'Moneda:', | |
136 | - valor: notaPedido.cotizacion.moneda.DETALLE | |
137 | - }, | |
138 | - { | |
139 | - label: 'Fecha cotizacion:', | |
140 | - valor: $filter('date')(notaPedido.cotizacion.FECHA, | |
141 | - 'dd/MM/yyyy') | |
142 | - }, | |
143 | - { | |
144 | - label: 'Cotizacion:', | |
145 | - valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | |
146 | - '2') | |
147 | - }, | |
148 | - { | |
149 | - label: 'Cliente:', | |
150 | - valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | |
151 | - ' - ' + notaPedido.cliente.NOM | |
152 | - }, | |
153 | - { | |
154 | - label: 'Domicilio:', | |
155 | - valor: notaPedido.domicilioStamp | |
156 | - }, | |
157 | - { | |
158 | - label: 'Vendedor:', | |
159 | - valor: $filter('rellenarDigitos')( | |
160 | - notaPedido.vendedor.NUM, 3 | |
161 | - ) + ' - ' + notaPedido.vendedor.NOM | |
162 | - }, | |
163 | - | |
164 | - { | |
165 | - label: 'Proveedor:', | |
166 | - valor: $filter('rellenarDigitos') | |
167 | - (notaPedido.proveedor.COD, 5) + ' - ' + | |
168 | - notaPedido.proveedor.NOM | |
169 | - }, | |
170 | - | |
171 | - { | |
172 | - label: 'Flete:', | |
173 | - valor: notaPedido.fob === 1 ? 'FOB' : ( | |
174 | - notaPedido.flete === 1 ? 'Si' : 'No') | |
175 | - }, | |
176 | - { | |
177 | - label: 'Puntos de descarga: ', | |
178 | - valor: $filter('rellenarDigitos')( | |
179 | - getCabeceraPuntoDescarga(puntosDescarga)) | |
180 | - } | |
181 | - ]; | |
182 | - valorPrecioCondicion(); | |
183 | - // Seteo checked en cabeceras | |
184 | - $filter('filter')($scope.botonera, | |
185 | - { label: 'Cliente' })[0].checked = true; | |
186 | - $filter('filter')($scope.botonera, | |
187 | - { label: 'Proveedor' })[0].checked = true; | |
188 | - $filter('filter')($scope.botonera, | |
189 | - { label: 'Moneda' })[0].checked = true; | |
190 | - $filter('filter')($scope.botonera, | |
191 | - { label: 'Nota pedido' })[0].checked = true; | |
192 | - $filter('filter')($scope.botonera, | |
193 | - { label: 'Precios y condiciones' })[0].checked = true; | |
194 | - $filter('filter')($scope.botonera, | |
195 | - { 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 | + }, | |
196 | 150 | |
197 | - if (notaPedido.observaciones) { | |
198 | - $filter('filter')($scope.botonera, | |
199 | - { 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)) | |
200 | 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 | + } | |
201 | 189 | |
202 | - function valorPrecioCondicion() { | |
203 | - if (parseInt(notaPedido.idListaPrecio) > 0) { | |
204 | - crearRemitoService | |
205 | - .getListaPrecioById(parseInt(notaPedido.idListaPrecio)) | |
206 | - .then(function (res) { | |
207 | - $scope.cabeceras.push({ | |
208 | - label: 'Precios y Condiciones:', | |
209 | - valor: parseInt(res.data[0].ID) + ' - ' + | |
210 | - res.data[0].DES + ' ' + | |
211 | - remitoBusinessService | |
212 | - .plazoToString(notaPedido.notaPedidoPlazo) | |
213 | - }); | |
214 | - 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) | |
215 | 202 | }); |
216 | - } | |
203 | + addArrayCabecera($scope.cabeceras); | |
204 | + }); | |
217 | 205 | } |
206 | + } | |
218 | 207 | |
219 | - if (notaPedido.flete === 1) { | |
220 | - var cabeceraBomba = { | |
221 | - label: 'Bomba:', | |
222 | - 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 | |
223 | 217 | }; |
224 | - if (notaPedido.kilometros) { | |
225 | - var cabeceraKilometros = { | |
226 | - label: 'Kilometros:', | |
227 | - valor: notaPedido.kilometros | |
228 | - }; | |
229 | - $scope.cabeceras.push(cabeceraKilometros); | |
230 | - } | |
231 | - $scope.cabeceras.push(cabeceraBomba); | |
218 | + $scope.cabeceras.push(cabeceraKilometros); | |
232 | 219 | } |
220 | + $scope.cabeceras.push(cabeceraBomba); | |
221 | + } | |
233 | 222 | |
234 | - $scope.remito = angular.copy(notaPedido); | |
235 | - $scope.remito.id = 0; | |
236 | - $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | |
237 | - $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; | |
238 | 227 | |
239 | - notaPedido.articulosNotaPedido.forEach(function (articulo) { | |
240 | - articulo.id = 0; | |
241 | - articulo.idRemito = 0; | |
242 | - articulo.precio = | |
243 | - (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | |
244 | - }); | |
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 | + }); | |
245 | 234 | |
246 | - $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | |
235 | + $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | |
247 | 236 | |
248 | - if (notaPedido.idPrecioCondicion > 0) { | |
249 | - $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | |
250 | - } else { | |
251 | - $scope.idLista = -1; | |
252 | - } | |
237 | + if (notaPedido.idPrecioCondicion > 0) { | |
238 | + $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | |
239 | + } else { | |
240 | + $scope.idLista = -1; | |
241 | + } | |
253 | 242 | |
254 | - enableObservaciones(notaPedido.observaciones ? true : false); | |
255 | - addArrayCabecera($scope.cabeceras); | |
243 | + enableObservaciones(notaPedido.observaciones ? true : false); | |
244 | + addArrayCabecera($scope.cabeceras); | |
256 | 245 | |
257 | - }, function () { | |
258 | - // funcion ejecutada cuando se cancela el modal | |
259 | - } | |
260 | - ); | |
261 | - } | |
246 | + }, function () { | |
247 | + // funcion ejecutada cuando se cancela el modal | |
248 | + } | |
249 | + ); | |
262 | 250 | }; |
263 | 251 | |
264 | 252 | $scope.seleccionarRemito = function () { |
... | ... | @@ -281,7 +269,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
281 | 269 | resolve: { usadoPor: function () { return 'remito'; } } |
282 | 270 | } |
283 | 271 | ); |
284 | - modalInstance.result.then(function(remito) { | |
272 | + modalInstance.result.then(function (remito) { | |
285 | 273 | |
286 | 274 | remito.articulosRemito.forEach(function (articulo) { |
287 | 275 | articulo.precio = |
... | ... | @@ -291,8 +279,8 @@ angular.module('focaCrearRemito').controller('remitoController', |
291 | 279 | setearRemito(remito); |
292 | 280 | |
293 | 281 | }, function () { |
294 | - // funcion ejecutada cuando se cancela el modal | |
295 | - } | |
282 | + // funcion ejecutada cuando se cancela el modal | |
283 | + } | |
296 | 284 | ); |
297 | 285 | }; |
298 | 286 | //validacion por domicilio y por plazo pago |
... | ... | @@ -366,7 +354,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
366 | 354 | e_hd: '',//TODO |
367 | 355 | c_hd: '', |
368 | 356 | numeroLiquidoProducto: 0,//TODO |
369 | - estado: 0, | |
357 | + estado: $scope.remito.estado, | |
370 | 358 | destinoVenta: 0,//TODO |
371 | 359 | operacionTipo: 0, //TODO |
372 | 360 | }, |
... | ... | @@ -391,7 +379,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
391 | 379 | } |
392 | 380 | |
393 | 381 | // TODO: updatear plazos |
394 | - if ($scope.remito.id == 0) { | |
382 | + if ($scope.remito.id === 0) { | |
395 | 383 | |
396 | 384 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, |
397 | 385 | data.data.id, $scope.remito.cotizacion.VENDEDOR); |
... | ... | @@ -424,10 +412,12 @@ angular.module('focaCrearRemito').controller('remitoController', |
424 | 412 | } |
425 | 413 | ); |
426 | 414 | }; |
427 | - | |
415 | + | |
428 | 416 | $scope.seleccionarProductos = function () { |
417 | + if (!varlidarRemitoFacturado()) return; | |
418 | + if (!varlidarRemitoAbierto()) return; | |
429 | 419 | if ($scope.notaPedido.id !== 0) { |
430 | - $scope.idLista = parseInt($scope.notaPedido.idListaPrecio) | |
420 | + $scope.idLista = parseInt($scope.notaPedido.idListaPrecio); | |
431 | 421 | } |
432 | 422 | if ($scope.idLista === undefined) { |
433 | 423 | focaModalService.alert( |
... | ... | @@ -533,27 +523,27 @@ angular.module('focaCrearRemito').controller('remitoController', |
533 | 523 | }; |
534 | 524 | |
535 | 525 | $scope.seleccionarCliente = function () { |
536 | - if (varlidarRemitoFacturado()) { | |
537 | - var modalInstance = $uibModal.open( | |
538 | - { | |
539 | - ariaLabelledBy: 'Busqueda de Cliente', | |
540 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
541 | - controller: 'focaBusquedaClienteModalController', | |
542 | - resolve: { | |
543 | - vendedor: function () { return null; }, | |
544 | - cobrador: function () { return null; } | |
545 | - }, | |
546 | - size: 'lg' | |
547 | - } | |
548 | - ); | |
549 | - modalInstance.result.then( | |
550 | - function (cliente) { | |
551 | - $scope.abrirModalDomicilios(cliente); | |
552 | - $scope.cliente = cliente; | |
553 | - }, function () { | |
554 | - } | |
555 | - ); | |
556 | - } | |
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 | + ); | |
557 | 547 | }; |
558 | 548 | |
559 | 549 | $scope.seleccionarEliminarRemito = function () { |
... | ... | @@ -575,45 +565,48 @@ angular.module('focaCrearRemito').controller('remitoController', |
575 | 565 | }; |
576 | 566 | |
577 | 567 | $scope.seleccionarProveedor = function () { |
578 | - if (varlidarRemitoFacturado()) { | |
579 | - var parametrosModal = { | |
580 | - titulo: 'Búsqueda de Proveedor', | |
581 | - query: '/proveedor', | |
582 | - columnas: [ | |
583 | - { | |
584 | - nombre: 'Código', | |
585 | - propiedad: 'COD', | |
586 | - filtro: { | |
587 | - nombre: 'rellenarDigitos', | |
588 | - parametro: 5 | |
589 | - } | |
590 | - }, | |
591 | - { | |
592 | - nombre: 'Nombre', | |
593 | - propiedad: 'NOM' | |
594 | - }, | |
595 | - { | |
596 | - nombre: 'CUIT', | |
597 | - 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 | |
598 | 580 | } |
599 | - ], | |
600 | - tipo: 'POST', | |
601 | - json: { razonCuitCod: '' } | |
602 | - }; | |
603 | - focaModalService.modal(parametrosModal).then( | |
604 | - function (proveedor) { | |
605 | - $scope.seleccionarFlete(proveedor); | |
606 | - }, function () { } | |
607 | - ); | |
608 | - } | |
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 | + ); | |
609 | 599 | }; |
610 | 600 | |
611 | 601 | $scope.seleccionarDomicilioDeEntrega = function () { |
612 | - if (!$scope.remito.cliente.COD) { | |
602 | + if (!varlidarRemitoFacturado()) return; | |
603 | + if (!varlidarRemitoAbierto()) return; | |
604 | + if (!$scope.remito.cliente.COD && !$scope.cliente) { | |
613 | 605 | focaModalService.alert('Seleccione un Cliente'); |
614 | 606 | return; |
615 | 607 | } else { |
616 | - $scope.abrirModalDomicilios($scope.cliente); | |
608 | + $scope.abrirModalDomicilios($scope.remito.cliente.COD ? | |
609 | + $scope.remito.cliente.COD : $scope.cliente); | |
617 | 610 | } |
618 | 611 | }; |
619 | 612 | |
... | ... | @@ -625,24 +618,30 @@ angular.module('focaCrearRemito').controller('remitoController', |
625 | 618 | controller: 'focaModalDomicilioController', |
626 | 619 | size: 'lg', |
627 | 620 | resolve: { |
628 | - idCliente: function () { return $scope.notaPedido.cliente ? $scope.notaPedido.cliente.COD : | |
629 | - cliente.cod; }, | |
630 | - esNuevo: function () { return cliente.esNuevo; } | |
621 | + idCliente: function () { | |
622 | + return $scope.remito.cliente.COD ? $scope.remito.cliente.COD : | |
623 | + cliente.cod; | |
624 | + }, | |
625 | + esNuevo: function () { | |
626 | + return ($scope.remito.cliente.COD ? false : cliente.esNuevo); | |
627 | + } | |
631 | 628 | } |
632 | 629 | } |
633 | 630 | ); |
634 | - modalInstanceDomicilio.result.then( | |
635 | - function (domicilio) { | |
631 | + modalInstanceDomicilio.result | |
632 | + .then(function (domicilio) { | |
636 | 633 | $scope.remito.domicilio = domicilio; |
637 | - $scope.remito.cliente = { | |
638 | - COD: cliente.cod, | |
639 | - CUIT: cliente.cuit, | |
640 | - NOM: cliente.nom, | |
641 | - MAIL: cliente.mail, | |
642 | - MOD: cliente.mod, | |
643 | - IVA: cliente.iva, | |
644 | - VEN: cliente.ven | |
645 | - }; | |
634 | + if (!$scope.remito.cliente.COD) { | |
635 | + $scope.remito.cliente = { | |
636 | + COD: cliente.cod, | |
637 | + CUIT: cliente.cuit, | |
638 | + NOM: cliente.nom, | |
639 | + MAIL: cliente.mail, | |
640 | + MOD: cliente.mod, | |
641 | + IVA: cliente.iva, | |
642 | + VEN: cliente.ven | |
643 | + }; | |
644 | + } | |
646 | 645 | crearRemitoService.getVendedorById($scope.remito.cliente.VEN) |
647 | 646 | .then(function (res) { |
648 | 647 | if (res.data !== '') { |
... | ... | @@ -659,8 +658,9 @@ angular.module('focaCrearRemito').controller('remitoController', |
659 | 658 | $scope.remito.domicilioStamp = domicilioStamp; |
660 | 659 | $scope.$broadcast('addCabecera', { |
661 | 660 | label: 'Cliente:', |
662 | - valor: $filter('rellenarDigitos')(cliente.cod, 3) + | |
663 | - ' - ' + cliente.nom | |
661 | + valor: $filter('rellenarDigitos') | |
662 | + ($scope.remito.cliente.COD, 3) + | |
663 | + ' - ' + $scope.remito.cliente.NOM | |
664 | 664 | }); |
665 | 665 | $scope.$broadcast('addCabecera', { |
666 | 666 | label: 'Domicilio:', |
... | ... | @@ -672,7 +672,8 @@ angular.module('focaCrearRemito').controller('remitoController', |
672 | 672 | $scope.seleccionarPuntosDeDescarga(); |
673 | 673 | } else { |
674 | 674 | crearRemitoService |
675 | - .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | |
675 | + .getPuntosDescargaByClienDom(domicilio.id, | |
676 | + $scope.remito.cliente.COD) | |
676 | 677 | .then(function (res) { |
677 | 678 | if (res.data.length) { |
678 | 679 | $scope.seleccionarPuntosDeDescarga(); |
... | ... | @@ -685,12 +686,13 @@ angular.module('focaCrearRemito').controller('remitoController', |
685 | 686 | $filter('filter')($scope.botonera, |
686 | 687 | { label: 'Domicilio de Entrega' })[0].checked = true; |
687 | 688 | }) |
688 | - .catch(function (e) { console.log(e); }); | |
689 | - }, function () { | |
689 | + .catch(function (e) { console.info(e); }); | |
690 | + }) | |
691 | + .catch(function (e) { | |
692 | + console.info(e); | |
690 | 693 | $scope.seleccionarCliente(true); |
691 | 694 | return; |
692 | - } | |
693 | - ); | |
695 | + }); | |
694 | 696 | }; |
695 | 697 | |
696 | 698 | $scope.getTotal = function () { |
... | ... | @@ -714,16 +716,18 @@ angular.module('focaCrearRemito').controller('remitoController', |
714 | 716 | return; |
715 | 717 | } |
716 | 718 | if ($scope.remito.articulosRemito.length !== 0) { |
717 | - if (varlidarRemitoFacturado()) { | |
719 | + if (varlidarRemitoFacturado() && varlidarRemitoAbierto()) { | |
718 | 720 | abrirModal(); |
719 | 721 | } |
720 | 722 | } else { |
721 | 723 | abrirModal(); |
722 | 724 | } |
723 | - | |
725 | + | |
724 | 726 | function abrirModal() { |
725 | - var parametros = { idCliente: $scope.remito.cliente.COD, idListaPrecio : $scope.remito.cliente.MOD, | |
726 | - remito: $scope.remito }; | |
727 | + var parametros = { | |
728 | + idCliente: $scope.remito.cliente.COD, | |
729 | + idListaPrecio: $scope.remito.cliente.MOD | |
730 | + }; | |
727 | 731 | var modalInstance = $uibModal.open( |
728 | 732 | { |
729 | 733 | ariaLabelledBy: 'Busqueda de Precio Condición', |
... | ... | @@ -749,8 +753,10 @@ angular.module('focaCrearRemito').controller('remitoController', |
749 | 753 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; |
750 | 754 | } |
751 | 755 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); |
752 | - cabecera = $filter('rellenarDigitos')(parseInt(precioCondicion.listaPrecio.ID), 4) + | |
753 | - ' - ' + precioCondicion.listaPrecio.DES + ' ' + plazosConcat.trim(); | |
756 | + cabecera = $filter('rellenarDigitos') | |
757 | + (parseInt(precioCondicion.listaPrecio.ID), 4) + | |
758 | + ' - ' + precioCondicion.listaPrecio.DES + ' ' + | |
759 | + plazosConcat.trim(); | |
754 | 760 | } else { //Cuando se ingresan los plazos manualmente |
755 | 761 | $scope.remito.idPrecioCondicion = 0; |
756 | 762 | //-1, el modal productos busca todos los productos |
... | ... | @@ -767,14 +773,15 @@ angular.module('focaCrearRemito').controller('remitoController', |
767 | 773 | $scope.cabeceras.push({ |
768 | 774 | label: 'Precios y Condiciones:', |
769 | 775 | valor: parseInt(precioCondicion.listaPrecio.ID) + ' - ' + |
770 | - precioCondicion.listaPrecio.DES + ' ' + remitoBusinessService.plazoToString(precioCondicion.plazoPago) | |
776 | + precioCondicion.listaPrecio.DES + ' ' + | |
777 | + remitoBusinessService | |
778 | + .plazoToString(precioCondicion.plazoPago) | |
771 | 779 | }); |
772 | 780 | $scope.remito.idListaPrecio = parseInt(precioCondicion.listaPrecio.ID); |
773 | - | |
774 | 781 | } |
775 | 782 | $filter('filter')($scope.cabeceras, |
776 | 783 | { label: 'Precios y Condiciones' })[0].valor = cabecera; |
777 | - | |
784 | + | |
778 | 785 | $scope.remito.precioCondicion = precioCondicion; |
779 | 786 | $filter('filter')($scope.botonera, |
780 | 787 | { label: 'Precios y Condiciones' })[0].checked = true; |
... | ... | @@ -787,115 +794,115 @@ angular.module('focaCrearRemito').controller('remitoController', |
787 | 794 | }; |
788 | 795 | |
789 | 796 | $scope.seleccionarFlete = function (proveedor) { |
790 | - if (varlidarRemitoFacturado()) { | |
791 | - var modalInstance = $uibModal.open( | |
792 | - { | |
793 | - ariaLabelledBy: 'Busqueda de Flete', | |
794 | - templateUrl: 'modal-flete.html', | |
795 | - controller: 'focaModalFleteController', | |
796 | - size: 'lg', | |
797 | - resolve: { | |
798 | - parametrosFlete: | |
799 | - function () { | |
800 | - return { | |
801 | - flete: $scope.remito.flete ? '1' : | |
802 | - ($scope.remito.fob ? 'FOB' : | |
803 | - ($scope.remito.flete === undefined ? | |
804 | - null : '0')), | |
805 | - bomba: $scope.remito.bomba ? '1' : | |
806 | - ($scope.remito.bomba === undefined ? | |
807 | - null : '0'), | |
808 | - kilometros: $scope.remito.kilometros | |
809 | - }; | |
810 | - } | |
811 | - } | |
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 | + } | |
812 | 819 | } |
813 | - ); | |
814 | - modalInstance.result.then( | |
815 | - function (datos) { | |
816 | - $scope.remitoIsDirty = true; | |
817 | - $scope.remito.proveedor = proveedor; | |
818 | - $scope.remito.idProveedor = proveedor.COD; | |
819 | - $scope.$broadcast('addCabecera', { | |
820 | - label: 'Proveedor:', | |
821 | - valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | |
822 | - proveedor.NOM | |
823 | - }); | |
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 | + }); | |
824 | 832 | |
825 | - $scope.remito.flete = datos.flete; | |
826 | - $scope.remito.fob = datos.FOB; | |
827 | - $scope.remito.bomba = datos.bomba; | |
828 | - $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; | |
829 | 837 | |
838 | + $scope.$broadcast('addCabecera', { | |
839 | + label: 'Flete:', | |
840 | + valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | |
841 | + }); | |
842 | + if (datos.flete) { | |
830 | 843 | $scope.$broadcast('addCabecera', { |
831 | - label: 'Flete:', | |
832 | - valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | |
844 | + label: 'Bomba:', | |
845 | + valor: datos.bomba ? 'Si' : 'No' | |
833 | 846 | }); |
834 | - if (datos.flete) { | |
835 | - $scope.$broadcast('addCabecera', { | |
836 | - label: 'Bomba:', | |
837 | - valor: datos.bomba ? 'Si' : 'No' | |
838 | - }); | |
839 | - $scope.$broadcast('addCabecera', { | |
840 | - label: 'Kilometros:', | |
841 | - valor: datos.kilometros | |
842 | - }); | |
843 | - } else { | |
844 | - $scope.$broadcast('removeCabecera', 'Bomba:'); | |
845 | - $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
846 | - $scope.remito.bomba = false; | |
847 | - $scope.remito.kilometros = null; | |
848 | - } | |
849 | - | |
850 | - $filter('filter')($scope.botonera, | |
851 | - { label: 'Proveedor' })[0].checked = true; | |
852 | - }, function () { | |
853 | - $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; | |
854 | 856 | } |
855 | - ); | |
856 | - } | |
857 | + | |
858 | + $filter('filter')($scope.botonera, | |
859 | + { label: 'Proveedor' })[0].checked = true; | |
860 | + }, function () { | |
861 | + $scope.seleccionarTransportista(); | |
862 | + } | |
863 | + ); | |
857 | 864 | }; |
858 | 865 | |
859 | 866 | $scope.seleccionarMoneda = function () { |
860 | - if (varlidarRemitoFacturado()) { | |
861 | - var parametrosModal = { | |
862 | - titulo: 'Búsqueda de monedas', | |
863 | - query: '/moneda', | |
864 | - columnas: [ | |
865 | - { | |
866 | - propiedad: 'DETALLE', | |
867 | - nombre: 'Nombre' | |
868 | - }, | |
869 | - { | |
870 | - propiedad: 'SIMBOLO', | |
871 | - nombre: 'Símbolo' | |
872 | - } | |
873 | - ], | |
874 | - size: 'md' | |
875 | - }; | |
876 | - focaModalService.modal(parametrosModal).then( | |
877 | - 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) { | |
878 | 886 | |
879 | - if (moneda.ID !== 1) { | |
880 | - $scope.abrirModalCotizacion(moneda); | |
881 | - return; | |
882 | - } | |
887 | + if (moneda.ID !== 1) { | |
888 | + $scope.abrirModalCotizacion(moneda); | |
889 | + return; | |
890 | + } | |
883 | 891 | |
884 | - crearRemitoService.getCotizacionByIdMoneda(1) | |
885 | - .then(function (res) { | |
892 | + crearRemitoService.getCotizacionByIdMoneda(1) | |
893 | + .then(function (res) { | |
886 | 894 | |
887 | - cotizacionPArgentino = res.data[0].cotizaciones[0]; | |
888 | - cotizacionPArgentino.moneda = moneda; | |
895 | + cotizacionPArgentino = res.data[0].cotizaciones[0]; | |
896 | + cotizacionPArgentino.moneda = moneda; | |
889 | 897 | |
890 | - actualizarCabeceraMoneda(cotizacionPArgentino); | |
898 | + actualizarCabeceraMoneda(cotizacionPArgentino); | |
891 | 899 | |
892 | - $scope.remito.cotizacion = cotizacionPArgentino; | |
893 | - }); | |
894 | - }, function () { | |
900 | + $scope.remito.cotizacion = cotizacionPArgentino; | |
901 | + }); | |
902 | + }, function () { | |
895 | 903 | |
896 | - } | |
897 | - ); | |
898 | - } | |
904 | + } | |
905 | + ); | |
899 | 906 | }; |
900 | 907 | |
901 | 908 | $scope.seleccionarObservaciones = function () { |
... | ... | @@ -996,7 +1003,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
996 | 1003 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { |
997 | 1004 | focaModalService.alert('Los valores deben ser al menos 1'); |
998 | 1005 | return; |
999 | - } else if (tmpCantidad === "0" || tmpPrecio === "0") { | |
1006 | + } else if (tmpCantidad === '0' || tmpPrecio === '0') { | |
1000 | 1007 | focaModalService.alert('Esta ingresando un producto con valor 0'); |
1001 | 1008 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
1002 | 1009 | focaModalService.alert('Los valores no pueden ser negativos'); |
... | ... | @@ -1066,7 +1073,17 @@ angular.module('focaCrearRemito').controller('remitoController', |
1066 | 1073 | return true; |
1067 | 1074 | } else { |
1068 | 1075 | focaModalService.alert('No se puede editar un remito facturado'); |
1069 | - return false(); | |
1076 | + return false; | |
1077 | + } | |
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; | |
1070 | 1087 | } |
1071 | 1088 | } |
1072 | 1089 | |
... | ... | @@ -1099,10 +1116,13 @@ angular.module('focaCrearRemito').controller('remitoController', |
1099 | 1116 | |
1100 | 1117 | function setearRemito(remito) { |
1101 | 1118 | //añado cabeceras |
1102 | - 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) { | |
1123 | + | |
1124 | + $scope.botonera.forEach(function (boton) { | |
1103 | 1125 | |
1104 | - $scope.botonera.forEach(function(boton) { | |
1105 | - | |
1106 | 1126 | if (boton.label === 'Eliminar Remito') { |
1107 | 1127 | boton.disable = false; |
1108 | 1128 | } |
... | ... | @@ -1147,6 +1167,8 @@ angular.module('focaCrearRemito').controller('remitoController', |
1147 | 1167 | valor: remito.domicilioStamp |
1148 | 1168 | }); |
1149 | 1169 | |
1170 | + $filter('filter')($scope.botonera, | |
1171 | + { label: 'Domicilio de Entrega' })[0].checked = true; | |
1150 | 1172 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
1151 | 1173 | } |
1152 | 1174 | if (remito.vendedor && remito.vendedor.NUM) { |
... | ... | @@ -1185,13 +1207,14 @@ angular.module('focaCrearRemito').controller('remitoController', |
1185 | 1207 | $timeout(function () { |
1186 | 1208 | $scope.cabeceras.push({ |
1187 | 1209 | label: 'Precios y Condiciones:', |
1188 | - valor: parseInt(res.data[0].ID) + ' - ' + res.data[0].DES + ' ' + | |
1189 | - remitoBusinessService | |
1210 | + valor: parseInt(res.data[0].ID) + ' - ' + | |
1211 | + res.data[0].DES + ' ' + | |
1212 | + remitoBusinessService | |
1190 | 1213 | .plazoToString(remito.remitoPlazo) |
1191 | 1214 | }); |
1192 | 1215 | addArrayCabecera($scope.cabeceras); |
1193 | - },true); | |
1194 | - | |
1216 | + }, true); | |
1217 | + | |
1195 | 1218 | }); |
1196 | 1219 | $scope.idLista = parseInt(remito.idListaPrecio); |
1197 | 1220 | } |
src/views/remito.html
... | ... | @@ -68,7 +68,7 @@ |
68 | 68 | ></td> |
69 | 69 | <td class="col text-right"> |
70 | 70 | <input |
71 | - ng-show="articulo.editCantidad" | |
71 | + ng-show="articulo.editCantidad && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | |
72 | 72 | ng-model="tmpCantidad" |
73 | 73 | class="form-control" |
74 | 74 | foca-tipo-input |
... | ... | @@ -82,13 +82,13 @@ |
82 | 82 | <i |
83 | 83 | class="selectable" |
84 | 84 | ng-click="cambioEdit(articulo, 'cantidad')" |
85 | - ng-hide="articulo.editCantidad" | |
85 | + ng-hide="articulo.editCantidad && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | |
86 | 86 | ng-bind="articulo.cantidad"> |
87 | 87 | </i> |
88 | 88 | </td> |
89 | 89 | <td class="col text-right"> |
90 | 90 | <input |
91 | - ng-show="articulo.editPrecio" | |
91 | + ng-show="articulo.editPrecio && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | |
92 | 92 | ng-model="tmpPrecio" |
93 | 93 | class="form-control" |
94 | 94 | foca-tipo-input |
... | ... | @@ -105,7 +105,7 @@ |
105 | 105 | <i |
106 | 106 | class="selectable" |
107 | 107 | ng-click="cambioEdit(articulo, 'precio')" |
108 | - ng-hide="articulo.editPrecio" | |
108 | + ng-hide="articulo.editPrecio && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | |
109 | 109 | ng-bind="articulo.precio | number: 4"> |
110 | 110 | </i> |
111 | 111 | </td> |
... | ... | @@ -115,12 +115,14 @@ |
115 | 115 | </td> |
116 | 116 | <td class="text-center"> |
117 | 117 | <button |
118 | + ng-show="remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | |
118 | 119 | class="btn btn-outline-light" |
119 | 120 | ng-click="quitarArticulo(articulo)" |
120 | - > | |
121 | + > | |
121 | 122 | <i class="fa fa-trash"></i> |
122 | 123 | </button> |
123 | 124 | <button |
125 | + ng-show="remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | |
124 | 126 | class="btn btn-outline-light" |
125 | 127 | ng-click="editarArticulo(13, articulo, tmpCantidad, tmpPrecio);" |
126 | 128 | ng-show="articulo.editCantidad || articulo.editPrecio" |
... | ... | @@ -207,13 +209,8 @@ |
207 | 209 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
208 | 210 | <h3>{{getTotal() | currency: remito.cotizacion.moneda.SIMBOLO}}</h3> |
209 | 211 | </td> |
210 | - <td class="text-right no-border-top"> | |
211 | - <button | |
212 | - type="button" | |
213 | - class="btn btn-sm" | |
214 | - > | |
215 | - Totales | |
216 | - </button> | |
212 | + <td class="text-right text-dark no-border-top"> | |
213 | + <span>Totales</span> | |
217 | 214 | </td> |
218 | 215 | </tr> |
219 | 216 | </tfoot> |