Commit a75d80f78f3e690d47a8218b3663eb68570dbc4d
1 parent
12d6f6d4c0
Exists in
master
Cambio para que al seleccionar cliente automaticamente me agregue el cobrador que corresponde.
Showing
2 changed files
with
54 additions
and
203 deletions
Show diff stats
spec/controllerSpec.js
| ... | ... | @@ -439,68 +439,6 @@ describe('controladores módulo crear cobranza', function() { |
| 439 | 439 | expect(scope.cobroDeuda).toEqual(true); |
| 440 | 440 | }); |
| 441 | 441 | |
| 442 | - it('seleccionarCobranza levanta modal y setea datos', function(done) { | |
| 443 | - | |
| 444 | - //arrange | |
| 445 | - var scope = { | |
| 446 | - $broadcast: function() { }, | |
| 447 | - $watch: function() { } | |
| 448 | - }; | |
| 449 | - var uibModal = { | |
| 450 | - open: function() { } | |
| 451 | - }; | |
| 452 | - | |
| 453 | - $controller('cobranzaController', { | |
| 454 | - $scope: scope, | |
| 455 | - $timeout: $timeout, | |
| 456 | - $uibModal: uibModal, | |
| 457 | - $location: {}, | |
| 458 | - focaCrearCobranzaService: { | |
| 459 | - getCotizacionByIdMoneda: function() { | |
| 460 | - return { | |
| 461 | - then: function() { } | |
| 462 | - }; | |
| 463 | - }, | |
| 464 | - getBotonera: function() { }, | |
| 465 | - getNumeroRecibo: function() { | |
| 466 | - return { | |
| 467 | - then: function() { } | |
| 468 | - }; | |
| 469 | - } | |
| 470 | - }, | |
| 471 | - focaModalService: {}, | |
| 472 | - $filter: $filter, | |
| 473 | - focaSeguimientoService: {}, | |
| 474 | - focaBotoneraLateralService: {}, | |
| 475 | - APP: {}, | |
| 476 | - focaLoginService: {}, | |
| 477 | - $localStorage: true | |
| 478 | - }); | |
| 479 | - var respuesta = { | |
| 480 | - facturas: 1, | |
| 481 | - cobros: 2, | |
| 482 | - cliente: { }, | |
| 483 | - moneda: { | |
| 484 | - cotizaciones: [] | |
| 485 | - } | |
| 486 | - }; | |
| 487 | - var promesa = { result: Promise.resolve(respuesta) }; | |
| 488 | - | |
| 489 | - //act | |
| 490 | - spyOn(uibModal, 'open').and.returnValue(promesa); | |
| 491 | - spyOn(scope, '$broadcast'); | |
| 492 | - scope.seleccionarCobranza(); | |
| 493 | - | |
| 494 | - //assert | |
| 495 | - promesa.result.then(function() { | |
| 496 | - expect(uibModal.open).toHaveBeenCalled(); | |
| 497 | - expect(scope.$broadcast).toHaveBeenCalledWith('cleanCabecera'); | |
| 498 | - expect(scope.cobranza.facturas).toEqual(respuesta.facturas); | |
| 499 | - expect(scope.cobranza.cobros).toEqual(respuesta.cobros); | |
| 500 | - done(); | |
| 501 | - }); | |
| 502 | - }); | |
| 503 | - | |
| 504 | 442 | it('seleccionarCliente levanta modal y setea datos', function(done) { |
| 505 | 443 | |
| 506 | 444 | //arrange |
| ... | ... | @@ -950,61 +888,6 @@ describe('controladores módulo crear cobranza', function() { |
| 950 | 888 | }); |
| 951 | 889 | }); |
| 952 | 890 | |
| 953 | - it('seleccionarCobrador levanta modal', function(done) { | |
| 954 | - | |
| 955 | - //arrange | |
| 956 | - var scope = { | |
| 957 | - $broadcast: function() { }, | |
| 958 | - $watch: function() { } | |
| 959 | - }; | |
| 960 | - var focaModalService = { | |
| 961 | - modal: function() { } | |
| 962 | - }; | |
| 963 | - | |
| 964 | - $controller('cobranzaController', { | |
| 965 | - $scope: scope, | |
| 966 | - $timeout: $timeout, | |
| 967 | - $uibModal: {}, | |
| 968 | - $location: {}, | |
| 969 | - focaCrearCobranzaService: { | |
| 970 | - getCotizacionByIdMoneda: function() { | |
| 971 | - return { | |
| 972 | - then: function() { } | |
| 973 | - }; | |
| 974 | - }, | |
| 975 | - getBotonera: function() { }, | |
| 976 | - getNumeroRecibo: function() { | |
| 977 | - return { | |
| 978 | - then: function() { } | |
| 979 | - }; | |
| 980 | - } | |
| 981 | - }, | |
| 982 | - focaModalService: focaModalService, | |
| 983 | - $filter: $filter, | |
| 984 | - focaSeguimientoService: {}, | |
| 985 | - focaBotoneraLateralService: {}, | |
| 986 | - APP: {}, | |
| 987 | - focaLoginService: {}, | |
| 988 | - $localStorage: true | |
| 989 | - }); | |
| 990 | - | |
| 991 | - var respuesta = 1; | |
| 992 | - var promesa = Promise.resolve(respuesta); | |
| 993 | - | |
| 994 | - //act | |
| 995 | - spyOn(focaModalService, 'modal').and.returnValue(promesa); | |
| 996 | - spyOn(scope, '$broadcast'); | |
| 997 | - scope.seleccionarCobrador({ }); | |
| 998 | - | |
| 999 | - //assert | |
| 1000 | - promesa.then(function() { | |
| 1001 | - expect(focaModalService.modal).toHaveBeenCalled(); | |
| 1002 | - expect(scope.$broadcast).toHaveBeenCalled(); | |
| 1003 | - scope.cobranza.cobrador = respuesta; | |
| 1004 | - done(); | |
| 1005 | - }); | |
| 1006 | - }); | |
| 1007 | - | |
| 1008 | 891 | it('getTotalDeuda devuelve correcto', function() { |
| 1009 | 892 | |
| 1010 | 893 | //arrange |
src/js/controller.js
| ... | ... | @@ -365,95 +365,62 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 365 | 365 | |
| 366 | 366 | $scope.seleccionarCliente = function() { |
| 367 | 367 | if ($scope.cobranza.id === undefined) { |
| 368 | - $scope.seleccionarCobrador(function() { | |
| 369 | - var modalInstance = $uibModal.open( | |
| 370 | - { | |
| 371 | - ariaLabelledBy: 'Busqueda de Cliente', | |
| 372 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 373 | - controller: 'focaBusquedaClienteModalController', | |
| 374 | - resolve: { | |
| 375 | - vendedor: function() { return null; }, | |
| 376 | - cobrador: function() { return $scope.cobranza.cobrador; } | |
| 377 | - }, | |
| 378 | - size: 'lg' | |
| 379 | - } | |
| 380 | - ); | |
| 381 | - modalInstance.result.then( | |
| 382 | - function(cliente) { | |
| 383 | - | |
| 384 | - var clienteMayus = { | |
| 385 | - COD: cliente.cod, | |
| 386 | - NOM: cliente.nom, | |
| 387 | - CUIT: cliente.cuit, | |
| 388 | - MAIL: cliente.mail, | |
| 389 | - DOM: cliente.DOM, | |
| 390 | - LOC: cliente.LOC, | |
| 391 | - PCI: cliente.PCI | |
| 392 | - }; | |
| 393 | - console.log(clienteMayus); | |
| 394 | - $scope.$broadcast('addCabecera', { | |
| 395 | - label: 'Cliente:', | |
| 396 | - valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | |
| 397 | - clienteMayus.NOM | |
| 398 | - }); | |
| 399 | - | |
| 400 | - $filter('filter')($scope.botonera, | |
| 401 | - { label: 'Cliente'})[0].checked = true; | |
| 402 | - | |
| 403 | - $scope.cobranza.cliente = clienteMayus; | |
| 404 | - $scope.cobranza.facturas = []; | |
| 405 | - }, function() { | |
| 406 | - if (APP !== 'cobranza') $scope.seleccionarCliente(); | |
| 407 | - } | |
| 408 | - ); | |
| 409 | - }); | |
| 410 | - } else { | |
| 411 | - focaModalService.alert('Esta cobranza no se puede editar'); | |
| 412 | - return; | |
| 413 | - } | |
| 414 | - }; | |
| 368 | + var modalInstance = $uibModal.open( | |
| 369 | + { | |
| 370 | + ariaLabelledBy: 'Busqueda de Cliente', | |
| 371 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 372 | + controller: 'focaBusquedaClienteModalController', | |
| 373 | + resolve: { | |
| 374 | + vendedor: function() { return null; }, | |
| 375 | + cobrador: function() { return null; } | |
| 376 | + }, | |
| 377 | + size: 'lg' | |
| 378 | + } | |
| 379 | + ); | |
| 380 | + modalInstance.result.then( | |
| 381 | + function(cliente) { | |
| 382 | + //ELIMINO CLIENTE | |
| 383 | + $scope.$broadcast('removeCabecera', 'Cliente:'); | |
| 384 | + $scope.cobranza.cliente = {}; | |
| 385 | + | |
| 386 | + var clienteMayus = { | |
| 387 | + COD: cliente.cod, | |
| 388 | + NOM: cliente.nom, | |
| 389 | + CUIT: cliente.cuit, | |
| 390 | + MAIL: cliente.mail, | |
| 391 | + DOM: cliente.DOM, | |
| 392 | + LOC: cliente.LOC, | |
| 393 | + PCI: cliente.PCI, | |
| 394 | + idCobrador: cliente.idCobrador, | |
| 395 | + cobrador: cliente.cobrador | |
| 396 | + }; | |
| 397 | + $scope.$broadcast('addCabecera', { | |
| 398 | + label: 'Cobrador:', | |
| 399 | + valor: $filter('rellenarDigitos')(clienteMayus.cobrador.NUM, 3) + | |
| 400 | + ' - ' + clienteMayus.cobrador.NOM | |
| 401 | + }); | |
| 402 | + $scope.cobranza.cobrador = clienteMayus.cobrador; | |
| 415 | 403 | |
| 416 | - $scope.seleccionarCobrador = function(callback) { | |
| 404 | + $scope.$broadcast('addCabecera', { | |
| 405 | + label: 'Cliente:', | |
| 406 | + valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | |
| 407 | + clienteMayus.NOM | |
| 408 | + }); | |
| 417 | 409 | |
| 418 | - if (APP === 'cobranza') { | |
| 419 | - callback(); | |
| 420 | - return; | |
| 421 | - } | |
| 410 | + $filter('filter')($scope.botonera, | |
| 411 | + { label: 'Cliente'})[0].checked = true; | |
| 422 | 412 | |
| 423 | - var parametrosModal = { | |
| 424 | - query: '/cobrador', | |
| 425 | - columnas: [ | |
| 426 | - { | |
| 427 | - propiedad: 'NUM', | |
| 428 | - nombre: 'Codigo', | |
| 429 | - filtro: { | |
| 430 | - nombre: 'rellenarDigitos', | |
| 431 | - parametro: 3 | |
| 432 | - } | |
| 433 | - }, | |
| 434 | - { | |
| 435 | - propiedad: 'NOM', | |
| 436 | - nombre: 'Nombre' | |
| 413 | + $scope.cobranza.cliente = clienteMayus; | |
| 414 | + $scope.cobranza.facturas = []; | |
| 415 | + focaCrearCobranzaService | |
| 416 | + .getCobradorById($scope.cobranza.cliente.idCobrador); | |
| 417 | + }, function() { | |
| 437 | 418 | } |
| 438 | - ], | |
| 439 | - titulo:'Búsqueda de cobradores' | |
| 440 | - }; | |
| 441 | - focaModalService.modal(parametrosModal).then( | |
| 442 | - function(cobrador) { | |
| 443 | - $scope.$broadcast('addCabecera', { | |
| 444 | - label: 'Cobrador:', | |
| 445 | - valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | |
| 446 | - cobrador.NOM | |
| 447 | - }); | |
| 448 | - $scope.cobranza.cobrador = cobrador; | |
| 449 | - | |
| 450 | - //ELIMINO CLIENTE | |
| 451 | - $scope.$broadcast('removeCabecera', 'Cliente:'); | |
| 452 | - $scope.cobranza.cliente = {}; | |
| 453 | - | |
| 454 | - callback(); | |
| 455 | - }, function() {} | |
| 456 | - ); | |
| 419 | + ); | |
| 420 | + } else { | |
| 421 | + focaModalService.alert('Esta cobranza no se puede editar'); | |
| 422 | + return; | |
| 423 | + } | |
| 457 | 424 | }; |
| 458 | 425 | |
| 459 | 426 | $scope.seleccionarFactura = function() { |
| ... | ... | @@ -492,7 +459,8 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 492 | 459 | if (!existe.length) facturasResult.push(factura); |
| 493 | 460 | }); |
| 494 | 461 | |
| 495 | - $scope.cobranza.facturas = $scope.cobranza.facturas.concat(facturasResult); | |
| 462 | + $scope.cobranza.facturas = | |
| 463 | + $scope.cobranza.facturas.concat(facturasResult); | |
| 496 | 464 | }, function() { } |
| 497 | 465 | ); |
| 498 | 466 | } else { |