Commit 8ffc7f9143eb14695e1163c10637382fdba6a81a
Exists in
master
Merge branch 'develop' into 'master'
Develop See merge request !63
Showing
4 changed files
Show diff stats
README.md
spec/controllerSpec.js
| ... | ... | @@ -524,14 +524,31 @@ describe('controladores módulo crear cobranza', function() { |
| 524 | 524 | return { |
| 525 | 525 | then: function() { } |
| 526 | 526 | }; |
| 527 | + }, | |
| 528 | + getCobradorById: function() { | |
| 529 | + return { | |
| 530 | + then: function() { } | |
| 531 | + }; | |
| 532 | + } | |
| 533 | + }, | |
| 534 | + focaModalService: { | |
| 535 | + modal: function() { | |
| 536 | + return { | |
| 537 | + then: function() {} | |
| 538 | + }; | |
| 527 | 539 | } |
| 528 | 540 | }, |
| 529 | - focaModalService: {}, | |
| 530 | 541 | $filter: $filter, |
| 531 | 542 | focaSeguimientoService: {}, |
| 532 | 543 | focaBotoneraLateralService: {}, |
| 533 | - APP: {}, | |
| 534 | - focaLoginService: {}, | |
| 544 | + APP: 'cobranza', | |
| 545 | + focaLoginService: { | |
| 546 | + getLoginData: function() { | |
| 547 | + return { | |
| 548 | + vendedorCobrador: true | |
| 549 | + }; | |
| 550 | + } | |
| 551 | + }, | |
| 535 | 552 | $localStorage: true |
| 536 | 553 | }); |
| 537 | 554 | scope.cobranza = { |
src/js/controller.js
| ... | ... | @@ -16,7 +16,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 16 | 16 | $scope.cargando = true; |
| 17 | 17 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| 18 | 18 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
| 19 | - | |
| 19 | + $scope.botonera = focaCrearCobranzaService.getBotonera(); | |
| 20 | 20 | $scope.dateOptions = { |
| 21 | 21 | maxDate: new Date(), |
| 22 | 22 | minDate: new Date(2010, 0, 1) |
| ... | ... | @@ -43,9 +43,6 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 43 | 43 | |
| 44 | 44 | if (APP === 'cobranza') { |
| 45 | 45 | $scope.idCobrador = loginService.getLoginData().vendedorCobrador; |
| 46 | - $scope.botonera = focaCrearCobranzaService.getBotonera($scope.idCobrador); | |
| 47 | - } else { | |
| 48 | - $scope.botonera = focaCrearCobranzaService.getBotonera(); | |
| 49 | 46 | } |
| 50 | 47 | |
| 51 | 48 | init(); |
| ... | ... | @@ -305,8 +302,12 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 305 | 302 | $scope.saveLoading = false; |
| 306 | 303 | |
| 307 | 304 | focaModalService |
| 308 | - .prompt('Ingrese los emails separados por coma para enviar comprobante', | |
| 309 | - cliente.MAIL) | |
| 305 | + .prompt({ | |
| 306 | + titulo: 'Ingrese los emails separados por' + | |
| 307 | + ' coma para enviar comprobante', | |
| 308 | + value: cliente.MAIL, | |
| 309 | + email: true | |
| 310 | + }) | |
| 310 | 311 | .then(function(res) { |
| 311 | 312 | return Promise.all([ |
| 312 | 313 | focaCrearCobranzaService |
| ... | ... | @@ -356,37 +357,106 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 356 | 357 | modalInstance.result.then(setearCobranza); |
| 357 | 358 | }; |
| 358 | 359 | |
| 359 | - $scope.seleccionarCliente = function() { | |
| 360 | - if(!$scope.cobranza.cobrador) { | |
| 361 | - focaModalService.alert('Ingrese primero cobrador'); | |
| 360 | + $scope.seleccionarResumenDeCuenta = function() { | |
| 361 | + if (!$scope.cobranza.cliente.COD) { | |
| 362 | + focaModalService.alert('Seleccione primero un cliente'); | |
| 362 | 363 | return; |
| 363 | 364 | } |
| 364 | 365 | var modalInstance = $uibModal.open( |
| 365 | 366 | { |
| 366 | - ariaLabelledBy: 'Busqueda de Cliente', | |
| 367 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 368 | - controller: 'focaBusquedaClienteModalController', | |
| 367 | + ariaLabelledBy: 'Resumen de cuentas', | |
| 368 | + templateUrl: 'modal-resumen-cuenta.html', | |
| 369 | + controller: 'focaModalResumenCuentaController', | |
| 369 | 370 | resolve: { |
| 370 | - vendedor: function() { return null; } | |
| 371 | + idCliente: function() { return $scope.cobranza.cliente.COD; } | |
| 371 | 372 | }, |
| 372 | 373 | size: 'lg' |
| 373 | 374 | } |
| 374 | 375 | ); |
| 375 | 376 | modalInstance.result.then( |
| 376 | 377 | function(cliente) { |
| 377 | - var clienteMayus = { | |
| 378 | - COD: cliente.cod, | |
| 379 | - NOM: cliente.nom, | |
| 380 | - CUIT: cliente.cuit | |
| 381 | - }; | |
| 378 | + $scope.abrirModalDomicilios(cliente); | |
| 379 | + $scope.cliente = cliente; | |
| 380 | + }, function() {} | |
| 381 | + ); | |
| 382 | + }; | |
| 383 | + | |
| 384 | + $scope.seleccionarCliente = function() { | |
| 385 | + $scope.seleccionarCobrador(function() { | |
| 386 | + var modalInstance = $uibModal.open( | |
| 387 | + { | |
| 388 | + ariaLabelledBy: 'Busqueda de Cliente', | |
| 389 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 390 | + controller: 'focaBusquedaClienteModalController', | |
| 391 | + resolve: { | |
| 392 | + vendedor: function() { return null; }, | |
| 393 | + cobrador: function() { return $scope.cobranza.cobrador; } | |
| 394 | + }, | |
| 395 | + size: 'lg' | |
| 396 | + } | |
| 397 | + ); | |
| 398 | + modalInstance.result.then( | |
| 399 | + function(cliente) { | |
| 400 | + var clienteMayus = { | |
| 401 | + COD: cliente.cod, | |
| 402 | + NOM: cliente.nom, | |
| 403 | + CUIT: cliente.cuit | |
| 404 | + }; | |
| 405 | + | |
| 406 | + $scope.$broadcast('addCabecera', { | |
| 407 | + label: 'Cliente:', | |
| 408 | + valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | |
| 409 | + clienteMayus.NOM | |
| 410 | + }); | |
| 411 | + $scope.cobranza.cliente = clienteMayus; | |
| 412 | + $scope.cobranza.facturas = []; | |
| 413 | + }, function() { | |
| 414 | + if (APP !== 'cobranza') $scope.seleccionarCliente(); | |
| 415 | + } | |
| 416 | + ); | |
| 417 | + }); | |
| 418 | + }; | |
| 419 | + | |
| 420 | + $scope.seleccionarCobrador = function(callback) { | |
| 382 | 421 | |
| 422 | + if (APP === 'cobranza') { | |
| 423 | + callback(); | |
| 424 | + return; | |
| 425 | + } | |
| 426 | + | |
| 427 | + var parametrosModal = { | |
| 428 | + query: '/cobrador', | |
| 429 | + columnas: [ | |
| 430 | + { | |
| 431 | + propiedad: 'NUM', | |
| 432 | + nombre: 'Codigo', | |
| 433 | + filtro: { | |
| 434 | + nombre: 'rellenarDigitos', | |
| 435 | + parametro: 3 | |
| 436 | + } | |
| 437 | + }, | |
| 438 | + { | |
| 439 | + propiedad: 'NOM', | |
| 440 | + nombre: 'Nombre' | |
| 441 | + } | |
| 442 | + ], | |
| 443 | + titulo:'Búsqueda de cobradores' | |
| 444 | + }; | |
| 445 | + focaModalService.modal(parametrosModal).then( | |
| 446 | + function(cobrador) { | |
| 383 | 447 | $scope.$broadcast('addCabecera', { |
| 384 | - label: 'Cliente:', | |
| 385 | - valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | |
| 386 | - clienteMayus.NOM | |
| 448 | + label: 'Cobrador:', | |
| 449 | + valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | |
| 450 | + cobrador.NOM | |
| 387 | 451 | }); |
| 388 | - $scope.cobranza.cliente = clienteMayus; | |
| 389 | - } | |
| 452 | + $scope.cobranza.cobrador = cobrador; | |
| 453 | + | |
| 454 | + //ELIMINO CLIENTE | |
| 455 | + $scope.$broadcast('removeCabecera', 'Cliente:'); | |
| 456 | + $scope.cobranza.cliente = {}; | |
| 457 | + | |
| 458 | + callback(); | |
| 459 | + }, function() {} | |
| 390 | 460 | ); |
| 391 | 461 | }; |
| 392 | 462 | |
| ... | ... | @@ -415,10 +485,18 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 415 | 485 | ); |
| 416 | 486 | modalInstance.result.then( |
| 417 | 487 | function(facturas) { |
| 418 | - $scope.cobranza.facturas = $scope.cobranza.facturas.concat(facturas); | |
| 419 | - }, function() { | |
| 488 | + var facturasResult = []; | |
| 489 | + //AGREGO A FACTURASRESULT LAS FACTURAS QUE NO HAN SIDO SELECCIONADAS | |
| 490 | + facturas.forEach(function(factura) { | |
| 491 | + var existe = $scope.cobranza.facturas.filter(function(e) { | |
| 492 | + return angular.equals(factura, e); | |
| 493 | + }); | |
| 420 | 494 | |
| 421 | - } | |
| 495 | + if (!existe.length) facturasResult.push(factura); | |
| 496 | + }); | |
| 497 | + | |
| 498 | + $scope.cobranza.facturas = $scope.cobranza.facturas.concat(facturasResult); | |
| 499 | + }, function() { } | |
| 422 | 500 | ); |
| 423 | 501 | }; |
| 424 | 502 | |
| ... | ... | @@ -597,39 +675,6 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 597 | 675 | ); |
| 598 | 676 | }; |
| 599 | 677 | |
| 600 | - $scope.seleccionarCobrador = function() { | |
| 601 | - var parametrosModal = { | |
| 602 | - query: '/cobrador', | |
| 603 | - columnas: [ | |
| 604 | - { | |
| 605 | - propiedad: 'NUM', | |
| 606 | - nombre: 'Codigo', | |
| 607 | - filtro: { | |
| 608 | - nombre: 'rellenarDigitos', | |
| 609 | - parametro: 3 | |
| 610 | - } | |
| 611 | - }, | |
| 612 | - { | |
| 613 | - propiedad: 'NOM', | |
| 614 | - nombre: 'Nombre' | |
| 615 | - } | |
| 616 | - ], | |
| 617 | - titulo:'Búsqueda de cobradores' | |
| 618 | - }; | |
| 619 | - focaModalService.modal(parametrosModal).then( | |
| 620 | - function(cobrador) { | |
| 621 | - $scope.$broadcast('addCabecera', { | |
| 622 | - label: 'Cobrador:', | |
| 623 | - valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | |
| 624 | - cobrador.NOM | |
| 625 | - }); | |
| 626 | - $scope.cobranza.cobrador = cobrador; | |
| 627 | - }, function() { | |
| 628 | - | |
| 629 | - } | |
| 630 | - ); | |
| 631 | - }; | |
| 632 | - | |
| 633 | 678 | $scope.getTotalDeuda = function() { |
| 634 | 679 | var total = 0; |
| 635 | 680 | for (var i = 0; i < $scope.cobranza.facturas.length; i++) { |
src/js/service.js
| ... | ... | @@ -22,7 +22,7 @@ angular.module('focaCrearCobranza') |
| 22 | 22 | return $http.post(API_ENDPOINT.URL + '/cliente/update/email', |
| 23 | 23 | {mail: mail, id: idCliente}); |
| 24 | 24 | }, |
| 25 | - getBotonera: function(idCobrador) { | |
| 25 | + getBotonera: function() { | |
| 26 | 26 | var result = [ |
| 27 | 27 | { |
| 28 | 28 | label: 'Cliente', |
| ... | ... | @@ -39,15 +39,12 @@ angular.module('focaCrearCobranza') |
| 39 | 39 | { |
| 40 | 40 | label: 'Moneda', |
| 41 | 41 | image: 'moneda.png' |
| 42 | + }, | |
| 43 | + { | |
| 44 | + label: 'Resumen de cuenta', | |
| 45 | + image: 'moneda.png' | |
| 42 | 46 | } |
| 43 | 47 | ]; |
| 44 | - if(!idCobrador) { | |
| 45 | - var cobradorBoton = { | |
| 46 | - label: 'Cobrador', | |
| 47 | - image: 'cobrador.png' | |
| 48 | - }; | |
| 49 | - result.unshift(cobradorBoton); | |
| 50 | - } | |
| 51 | 48 | return result; |
| 52 | 49 | } |
| 53 | 50 | }; |