Commit ae30a41553c1af3d0397c5a89d4f9de5ef1f0940

Authored by Marcelo Puebla
1 parent 2de32ead93
Exists in master and in 1 other branch develop

Cambio el vendedor se saca del mismo cliente seleccionado, ya no hay modal para …

…elegir vendedor primero
Showing 2 changed files with 55 additions and 94 deletions   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,
... ... @@ -499,80 +498,30 @@ angular.module('focaCrearRemito').controller('remitoController',
499 498 );
500 499 }
501 500 };
502   -
503   - $scope.seleccionarVendedor = function (callback, ocultarVendedor) {
504   - if (ocultarVendedor) {
505   - callback();
506   - return;
507   - }
508   -
  501 + $scope.seleccionarCliente = function () {
509 502 if (varlidarRemitoFacturado()) {
510   - var parametrosModal = {
511   - titulo: 'Búsqueda vendedores',
512   - query: '/vendedor',
513   - columnas: [
514   - {
515   - propiedad: 'NUM',
516   - nombre: 'Código',
517   - filtro: {
518   - nombre: 'rellenarDigitos',
519   - parametro: 3
520   - }
  503 + var modalInstance = $uibModal.open(
  504 + {
  505 + ariaLabelledBy: 'Busqueda de Cliente',
  506 + templateUrl: 'foca-busqueda-cliente-modal.html',
  507 + controller: 'focaBusquedaClienteModalController',
  508 + resolve: {
  509 + vendedor: function () { return null; },
  510 + cobrador: function () { return null; }
521 511 },
522   - {
523   - propiedad: 'NOM',
524   - nombre: 'Nombre'
525   - }
526   - ],
527   - size: 'md'
528   - };
529   - focaModalService.modal(parametrosModal).then(
530   - function (vendedor) {
531   - $scope.remitoIsDirty = true;
532   - $scope.$broadcast('addCabecera', {
533   - label: 'Vendedor:',
534   - valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' +
535   - vendedor.NOM
536   - });
537   - $scope.remito.idVendedor = vendedor.id;
538   - $scope.remito.vendedor = vendedor;
539   - deleteCliente();
540   - callback();
  512 + size: 'lg'
  513 + }
  514 + );
  515 + modalInstance.result.then(
  516 + function (cliente) {
  517 + $scope.abrirModalDomicilios(cliente);
  518 + $scope.cliente = cliente;
541 519 }, function () {
542   -
543 520 }
544 521 );
545 522 }
546 523 };
547 524  
548   - $scope.seleccionarCliente = function (ocultarVendedor) {
549   -
550   - $scope.seleccionarVendedor(function () {
551   - if (varlidarRemitoFacturado()) {
552   - var modalInstance = $uibModal.open(
553   - {
554   - ariaLabelledBy: 'Busqueda de Cliente',
555   - templateUrl: 'foca-busqueda-cliente-modal.html',
556   - controller: 'focaBusquedaClienteModalController',
557   - resolve: {
558   - vendedor: function () { return $scope.remito.vendedor; },
559   - cobrador: function () { return null; }
560   - },
561   - size: 'lg'
562   - }
563   - );
564   - modalInstance.result.then(
565   - function (cliente) {
566   - $scope.abrirModalDomicilios(cliente);
567   - $scope.cliente = cliente;
568   - }, function () {
569   - $scope.seleccionarCliente();
570   - }
571   - );
572   - }
573   - }, ocultarVendedor);
574   - };
575   -
576 525 $scope.seleccionarProveedor = function () {
577 526 if (varlidarRemitoFacturado()) {
578 527 var parametrosModal = {
... ... @@ -623,41 +572,50 @@ angular.module('focaCrearRemito').controller('remitoController',
623 572 modalInstanceDomicilio.result.then(
624 573 function (domicilio) {
625 574 $scope.remito.domicilio = domicilio;
626   - console.log(cliente);
627 575 $scope.remito.cliente = {
628 576 COD: cliente.cod,
629 577 CUIT: cliente.cuit,
630 578 NOM: cliente.nom,
631 579 MAIL: cliente.mail,
632 580 MOD: cliente.mod,
633   - IVA: cliente.iva
  581 + IVA: cliente.iva,
  582 + VEN: cliente.ven
634 583 };
635   -
636   - var domicilioStamp =
637   - domicilio.Calle + ' ' + domicilio.Numero + ', ' +
638   - domicilio.Localidad + ', ' + domicilio.Provincia;
639   - $scope.remito.domicilioStamp = domicilioStamp;
640   - $scope.$broadcast('addCabecera', {
641   - label: 'Cliente:',
642   - valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom
643   - });
644   - $scope.$broadcast('addCabecera', {
645   - label: 'Domicilio:',
646   - valor: domicilioStamp
647   - });
648   -
649   - if (domicilio.verPuntos) {
650   - delete $scope.remito.domicilio.verPuntos;
651   - $scope.seleccionarPuntosDeDescarga();
652   - } else {
653   - crearRemitoService
654   - .getPuntosDescargaByClienDom(domicilio.id, cliente.cod)
655   - .then(function (res) {
656   - if (res.data.length) $scope.seleccionarPuntosDeDescarga();
  584 + crearRemitoService.getVendedorById($scope.remito.cliente.VEN)
  585 + .then(function (res) {
  586 + $scope.remito.vendedor = res.data;
  587 + $scope.$broadcast('addCabecera', {
  588 + label: 'Vendedor:',
  589 + valor: $filter('rellenarDigitos')($scope.remito.vendedor.NUM, 3) + ' - ' +
  590 + $scope.remito.vendedor.NOM
657 591 });
658   - }
  592 + var domicilioStamp =
  593 + domicilio.Calle + ' ' + domicilio.Numero + ', ' +
  594 + domicilio.Localidad + ', ' + domicilio.Provincia;
  595 + $scope.remito.domicilioStamp = domicilioStamp;
  596 + $scope.$broadcast('addCabecera', {
  597 + label: 'Cliente:',
  598 + valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom
  599 + });
  600 + $scope.$broadcast('addCabecera', {
  601 + label: 'Domicilio:',
  602 + valor: domicilioStamp
  603 + });
  604 +
  605 + if (domicilio.verPuntos) {
  606 + delete $scope.remito.domicilio.verPuntos;
  607 + $scope.seleccionarPuntosDeDescarga();
  608 + } else {
  609 + crearRemitoService
  610 + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod)
  611 + .then(function (res) {
  612 + if (res.data.length) $scope.seleccionarPuntosDeDescarga();
  613 + });
  614 + }
659 615  
660   - $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
  616 + $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
  617 + })
  618 + .catch(function (e) { console.log(e); })
661 619 }, function () {
662 620 $scope.seleccionarCliente(true);
663 621 return;
... ... @@ -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);