Commit 777102158e293a75a8adc8feb1a7aa76caa8528b
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !31
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -369,7 +369,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
369 | 369 | numeroLiquidoProducto: 0,//TODO |
370 | 370 | idVendedor: $scope.remito.idVendedor, |
371 | 371 | idProveedor: $scope.remito.idProveedor, |
372 | - idDomicilio: 0,//TODO | |
372 | + idDomicilio: $scope.remito.idDomicilio, | |
373 | 373 | idCotizacion: $scope.remito.cotizacion.ID, |
374 | 374 | idPrecioCondicion: $scope.remito.idPrecioCondicion, |
375 | 375 | flete: $scope.remito.flete, |
... | ... | @@ -383,6 +383,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
383 | 383 | }, |
384 | 384 | notaPedido: $scope.notaPedido |
385 | 385 | }; |
386 | + | |
386 | 387 | crearRemitoService.crearRemito(save).then( |
387 | 388 | function(data) { |
388 | 389 | remitoBusinessService.addArticulos($scope.articulosTabla, |
... | ... | @@ -467,6 +468,49 @@ angular.module('focaCrearRemito') .controller('remitoController', |
467 | 468 | ); |
468 | 469 | }; |
469 | 470 | |
471 | + $scope.seleccionarPuntosDeDescarga = function() { | |
472 | + if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | |
473 | + focaModalService.alert('Primero seleccione un cliente y un domicilio'); | |
474 | + return; | |
475 | + }else { | |
476 | + var modalInstance = $uibModal.open( | |
477 | + { | |
478 | + ariaLabelledBy: 'Búsqueda de Puntos de descarga', | |
479 | + templateUrl: 'modal-punto-descarga.html', | |
480 | + controller: 'focaModalPuntoDescargaController', | |
481 | + size: 'lg', | |
482 | + resolve: { | |
483 | + filters: { | |
484 | + idDomicilio: $scope.remito.domicilio.id, | |
485 | + idCliente: $scope.remito.cliente.COD, | |
486 | + articulos: $scope.articulosTabla, | |
487 | + puntosDescarga: $scope.remito.domicilio.puntosDescarga | |
488 | + } | |
489 | + } | |
490 | + } | |
491 | + ); | |
492 | + modalInstance.result.then( | |
493 | + function(puntosDescarga) { | |
494 | + $scope.remito.puntosDescarga = puntosDescarga; | |
495 | + | |
496 | + //AGREGO PUNTOS DE DESCARGA A CABECERA | |
497 | + var puntosStamp = ''; | |
498 | + puntosDescarga.forEach(function(punto, idx, arr) { | |
499 | + puntosStamp += punto.descripcion; | |
500 | + if((idx + 1) !== arr.length) puntosStamp += ', '; | |
501 | + }); | |
502 | + | |
503 | + $scope.$broadcast('addCabecera', { | |
504 | + label: 'Puntos de descarga:', | |
505 | + valor: puntosStamp | |
506 | + }); | |
507 | + }, function() { | |
508 | + $scope.abrirModalDomicilios($scope.cliente); | |
509 | + } | |
510 | + ); | |
511 | + } | |
512 | + }; | |
513 | + | |
470 | 514 | $scope.seleccionarVendedor = function() { |
471 | 515 | if(varlidarRemitoFacturado()) { |
472 | 516 | var parametrosModal = { |
... | ... | @@ -566,6 +610,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
566 | 610 | modalInstance.result.then( |
567 | 611 | function(cliente) { |
568 | 612 | $scope.abrirModalDomicilios(cliente); |
613 | + $scope.cliente = cliente; | |
569 | 614 | }, function() { |
570 | 615 | |
571 | 616 | } |
... | ... | @@ -588,7 +633,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
588 | 633 | ); |
589 | 634 | modalInstanceDomicilio.result.then( |
590 | 635 | function(domicilio) { |
591 | - //$scope.remito.domicilio.id = domicilio.nivel2; | |
636 | + $scope.remito.domicilio = domicilio; | |
592 | 637 | $scope.remito.cliente = { |
593 | 638 | COD: cliente.cod, |
594 | 639 | CUIT: cliente.cuit, |
... | ... | @@ -609,6 +654,17 @@ angular.module('focaCrearRemito') .controller('remitoController', |
609 | 654 | label: 'Domicilio:', |
610 | 655 | valor: domicilioStamp |
611 | 656 | }); |
657 | + | |
658 | + if(domicilio.verPuntos) { | |
659 | + delete $scope.remito.domicilio.verPuntos; | |
660 | + $scope.seleccionarPuntosDeDescarga(); | |
661 | + }else { | |
662 | + crearRemitoService | |
663 | + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | |
664 | + .then(function(res) { | |
665 | + if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | |
666 | + }); | |
667 | + } | |
612 | 668 | }, function() { |
613 | 669 | $scope.seleccionarCliente(); |
614 | 670 | return; |
src/js/service.js
... | ... | @@ -56,6 +56,10 @@ angular.module('focaCrearRemito') |
56 | 56 | getNumeroRemito: function() { |
57 | 57 | return $http.get(route + '/remito/numero-siguiente'); |
58 | 58 | }, |
59 | + getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | |
60 | + return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | |
61 | + idDomicilio + '/' + idCliente); | |
62 | + }, | |
59 | 63 | getBotonera: function() { |
60 | 64 | return [ |
61 | 65 | { |