Commit b550e34c0dceb4e0bf6b19e669b90cebf8d07d01
Exists in
master
and in
1 other branch
Merge branch 'master' into 'develop'
Master(mpuebla) See merge request !82
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -26,7 +26,6 @@ angular.module('focaCrearRemito').controller('remitoController', |
26 | 26 | minDate: new Date(2010, 0, 1) |
27 | 27 | }; |
28 | 28 | |
29 | - | |
30 | 29 | crearRemitoService.getParametros().then(function (res) { |
31 | 30 | var parametros = JSON.parse(res.data[0].jsonText); |
32 | 31 | if ($localStorage.remito) { |
... | ... | @@ -37,6 +36,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
37 | 36 | $scope.inicial[property] = parametros[property]; |
38 | 37 | } |
39 | 38 | setearRemito($scope.remito); |
39 | + $scope.remitoIsDirty = true; | |
40 | 40 | } |
41 | 41 | }); |
42 | 42 | |
... | ... | @@ -54,7 +54,6 @@ angular.module('focaCrearRemito').controller('remitoController', |
54 | 54 | |
55 | 55 | function init() { |
56 | 56 | $scope.$broadcast('cleanCabecera'); |
57 | - $scope.remitoIsDirty = false; | |
58 | 57 | $scope.remito = { |
59 | 58 | id: 0, |
60 | 59 | estado: 0, |
... | ... | @@ -97,6 +96,17 @@ angular.module('focaCrearRemito').controller('remitoController', |
97 | 96 | }, true); |
98 | 97 | |
99 | 98 | $scope.seleccionarNotaPedido = function () { |
99 | + if ($scope.remitoIsDirty) { | |
100 | + focaModalService.confirm("¿Desea continuar? Se perderan los cambios") | |
101 | + .then(function () { | |
102 | + $scope.getNotaPedidoModal(); | |
103 | + }); | |
104 | + } else { | |
105 | + $scope.getNotaPedidoModal(); | |
106 | + } | |
107 | + } | |
108 | + | |
109 | + $scope.getNotaPedidoModal = function () { | |
100 | 110 | if (varlidarRemitoFacturado()) { |
101 | 111 | var modalInstance = $uibModal.open( |
102 | 112 | { |
... | ... | @@ -402,7 +412,6 @@ angular.module('focaCrearRemito').controller('remitoController', |
402 | 412 | } |
403 | 413 | ); |
404 | 414 | }; |
405 | - | |
406 | 415 | $scope.seleccionarProductos = function () { |
407 | 416 | if ($scope.idLista === undefined) { |
408 | 417 | focaModalService.alert( |
... | ... | @@ -462,7 +471,6 @@ angular.module('focaCrearRemito').controller('remitoController', |
462 | 471 | } |
463 | 472 | ); |
464 | 473 | }; |
465 | - | |
466 | 474 | $scope.seleccionarPuntosDeDescarga = function () { |
467 | 475 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { |
468 | 476 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
... | ... | @@ -506,80 +514,30 @@ angular.module('focaCrearRemito').controller('remitoController', |
506 | 514 | ); |
507 | 515 | } |
508 | 516 | }; |
509 | - | |
510 | - $scope.seleccionarVendedor = function (callback, ocultarVendedor) { | |
511 | - if (ocultarVendedor) { | |
512 | - callback(); | |
513 | - return; | |
514 | - } | |
515 | - | |
517 | + $scope.seleccionarCliente = function () { | |
516 | 518 | if (varlidarRemitoFacturado()) { |
517 | - var parametrosModal = { | |
518 | - titulo: 'Búsqueda vendedores', | |
519 | - query: '/vendedor', | |
520 | - columnas: [ | |
521 | - { | |
522 | - propiedad: 'NUM', | |
523 | - nombre: 'Código', | |
524 | - filtro: { | |
525 | - nombre: 'rellenarDigitos', | |
526 | - parametro: 3 | |
527 | - } | |
519 | + var modalInstance = $uibModal.open( | |
520 | + { | |
521 | + ariaLabelledBy: 'Busqueda de Cliente', | |
522 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
523 | + controller: 'focaBusquedaClienteModalController', | |
524 | + resolve: { | |
525 | + vendedor: function () { return null; }, | |
526 | + cobrador: function () { return null; } | |
528 | 527 | }, |
529 | - { | |
530 | - propiedad: 'NOM', | |
531 | - nombre: 'Nombre' | |
532 | - } | |
533 | - ], | |
534 | - size: 'md' | |
535 | - }; | |
536 | - focaModalService.modal(parametrosModal).then( | |
537 | - function (vendedor) { | |
538 | - $scope.remitoIsDirty = true; | |
539 | - $scope.$broadcast('addCabecera', { | |
540 | - label: 'Vendedor:', | |
541 | - valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | |
542 | - vendedor.NOM | |
543 | - }); | |
544 | - $scope.remito.idVendedor = vendedor.id; | |
545 | - $scope.remito.vendedor = vendedor; | |
546 | - deleteCliente(); | |
547 | - callback(); | |
528 | + size: 'lg' | |
529 | + } | |
530 | + ); | |
531 | + modalInstance.result.then( | |
532 | + function (cliente) { | |
533 | + $scope.abrirModalDomicilios(cliente); | |
534 | + $scope.cliente = cliente; | |
548 | 535 | }, function () { |
549 | - | |
550 | 536 | } |
551 | 537 | ); |
552 | 538 | } |
553 | 539 | }; |
554 | 540 | |
555 | - $scope.seleccionarCliente = function (ocultarVendedor) { | |
556 | - | |
557 | - $scope.seleccionarVendedor(function () { | |
558 | - if (varlidarRemitoFacturado()) { | |
559 | - var modalInstance = $uibModal.open( | |
560 | - { | |
561 | - ariaLabelledBy: 'Busqueda de Cliente', | |
562 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
563 | - controller: 'focaBusquedaClienteModalController', | |
564 | - resolve: { | |
565 | - vendedor: function () { return $scope.remito.vendedor; }, | |
566 | - cobrador: function () { return null; } | |
567 | - }, | |
568 | - size: 'lg' | |
569 | - } | |
570 | - ); | |
571 | - modalInstance.result.then( | |
572 | - function (cliente) { | |
573 | - $scope.abrirModalDomicilios(cliente); | |
574 | - $scope.cliente = cliente; | |
575 | - }, function () { | |
576 | - $scope.seleccionarCliente(); | |
577 | - } | |
578 | - ); | |
579 | - } | |
580 | - }, ocultarVendedor); | |
581 | - }; | |
582 | - | |
583 | 541 | $scope.seleccionarProveedor = function () { |
584 | 542 | if (varlidarRemitoFacturado()) { |
585 | 543 | var parametrosModal = { |
... | ... | @@ -630,35 +588,52 @@ angular.module('focaCrearRemito').controller('remitoController', |
630 | 588 | modalInstanceDomicilio.result.then( |
631 | 589 | function (domicilio) { |
632 | 590 | $scope.remito.domicilio = domicilio; |
633 | - console.log(cliente); | |
634 | 591 | $scope.remito.cliente = { |
635 | 592 | COD: cliente.cod, |
636 | 593 | CUIT: cliente.cuit, |
637 | 594 | NOM: cliente.nom, |
638 | 595 | MAIL: cliente.mail, |
639 | 596 | MOD: cliente.mod, |
640 | - IVA: cliente.iva | |
597 | + IVA: cliente.iva, | |
598 | + VEN: cliente.ven | |
641 | 599 | }; |
600 | + crearRemitoService.getVendedorById($scope.remito.cliente.VEN) | |
601 | + .then(function (res) { | |
602 | + if (res.data !== '') { | |
603 | + $scope.remito.vendedor = res.data; | |
604 | + $scope.$broadcast('addCabecera', { | |
605 | + label: 'Vendedor:', | |
606 | + valor: $filter('rellenarDigitos')($scope.remito.vendedor.NUM, 3) + ' - ' + | |
607 | + $scope.remito.vendedor.NOM | |
608 | + }); | |
609 | + } | |
610 | + var domicilioStamp = | |
611 | + domicilio.Calle + ' ' + domicilio.Numero + ', ' + | |
612 | + domicilio.Localidad + ', ' + domicilio.Provincia; | |
613 | + $scope.remito.domicilioStamp = domicilioStamp; | |
614 | + $scope.$broadcast('addCabecera', { | |
615 | + label: 'Cliente:', | |
616 | + valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom | |
617 | + }); | |
618 | + $scope.$broadcast('addCabecera', { | |
619 | + label: 'Domicilio:', | |
620 | + valor: domicilioStamp | |
621 | + }); | |
642 | 622 | |
643 | - var domicilioStamp = | |
644 | - domicilio.Calle + ' ' + domicilio.Numero + ', ' + | |
645 | - domicilio.Localidad + ', ' + domicilio.Provincia; | |
646 | - $scope.remito.domicilioStamp = domicilioStamp; | |
647 | - $scope.$broadcast('addCabecera', { | |
648 | - label: 'Cliente:', | |
649 | - valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom | |
650 | - }); | |
651 | - $scope.$broadcast('addCabecera', { | |
652 | - label: 'Domicilio:', | |
653 | - valor: domicilioStamp | |
654 | - }); | |
655 | - | |
656 | - if (domicilio.verPuntos) { | |
657 | - delete $scope.remito.domicilio.verPuntos; | |
658 | - $scope.seleccionarPuntosDeDescarga(); | |
659 | - } | |
623 | + if (domicilio.verPuntos) { | |
624 | + delete $scope.remito.domicilio.verPuntos; | |
625 | + $scope.seleccionarPuntosDeDescarga(); | |
626 | + } else { | |
627 | + crearRemitoService | |
628 | + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | |
629 | + .then(function (res) { | |
630 | + if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | |
631 | + }); | |
632 | + } | |
660 | 633 | |
661 | - $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | |
634 | + $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | |
635 | + }) | |
636 | + .catch(function (e) { console.log(e); }) | |
662 | 637 | }, function () { |
663 | 638 | $scope.seleccionarCliente(true); |
664 | 639 | return; |
src/js/service.js
... | ... | @@ -3,6 +3,9 @@ angular.module('focaCrearRemito') |
3 | 3 | function($http, API_ENDPOINT) { |
4 | 4 | var route = API_ENDPOINT.URL; |
5 | 5 | return { |
6 | + getVendedorById: function (idVendedor) { | |
7 | + return $http.get(route + '/vendedor-cobrador/' + idVendedor); | |
8 | + }, | |
6 | 9 | crearRemito: function(remito) { |
7 | 10 | // TODO: Cambiar para usar el servicio /remito |
8 | 11 | return $http.post(route + '/remito', remito); |