Commit 4a32b0ad965b14ebae1b35185fda39404dfd1ae9
Exists in
master
Merge branch 'master' into 'develop'
Master(efernandez) See merge request !67
Showing
5 changed files
Show diff stats
gulpfile.js
| ... | ... | @@ -21,7 +21,9 @@ var paths = { |
| 21 | 21 | dist: 'dist/' |
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | -gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); | |
| 24 | +gulp.task('uglify', function(callback) { | |
| 25 | + gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')(callback); | |
| 26 | +}); | |
| 25 | 27 | |
| 26 | 28 | |
| 27 | 29 | gulp.task('templates', function() { |
spec/controllerSpec.js
| ... | ... | @@ -254,8 +254,8 @@ describe('controladores módulo crear cobranza', function() { |
| 254 | 254 | cobrador: { |
| 255 | 255 | NUM: true |
| 256 | 256 | }, |
| 257 | - cotizacion: { | |
| 258 | - moneda: { SIMBOLO: '' }, | |
| 257 | + moneda: { | |
| 258 | + SIMBOLO: '' | |
| 259 | 259 | }, |
| 260 | 260 | facturas: [1] |
| 261 | 261 | }; |
| ... | ... | @@ -319,15 +319,12 @@ describe('controladores módulo crear cobranza', function() { |
| 319 | 319 | cobrador: { |
| 320 | 320 | NUM: true |
| 321 | 321 | }, |
| 322 | - cotizacion: { | |
| 323 | - moneda: { | |
| 324 | - ID: true, | |
| 325 | - SIMBOLO: '' | |
| 326 | - } | |
| 322 | + moneda: { | |
| 323 | + cotizacion: {} | |
| 327 | 324 | }, |
| 328 | 325 | facturas: [1], |
| 329 | 326 | cobros: [{ |
| 330 | - fecha: new Date(), | |
| 327 | + FEC: new Date(), | |
| 331 | 328 | fechaPresentacion: new Date(), |
| 332 | 329 | fechaEmision: new Date(), |
| 333 | 330 | tipo: true, |
| ... | ... | @@ -342,7 +339,7 @@ describe('controladores módulo crear cobranza', function() { |
| 342 | 339 | ID: true |
| 343 | 340 | } |
| 344 | 341 | }], |
| 345 | - fecha: new Date() | |
| 342 | + FEC: new Date() | |
| 346 | 343 | }; |
| 347 | 344 | |
| 348 | 345 | //act |
| ... | ... | @@ -479,7 +476,14 @@ describe('controladores módulo crear cobranza', function() { |
| 479 | 476 | focaLoginService: {}, |
| 480 | 477 | $localStorage: true |
| 481 | 478 | }); |
| 482 | - var respuesta = { facturas: 1, cobros: 2, cliente: { } }; | |
| 479 | + var respuesta = { | |
| 480 | + facturas: 1, | |
| 481 | + cobros: 2, | |
| 482 | + cliente: { }, | |
| 483 | + moneda: { | |
| 484 | + cotizaciones: [] | |
| 485 | + } | |
| 486 | + }; | |
| 483 | 487 | var promesa = { result: Promise.resolve(respuesta) }; |
| 484 | 488 | |
| 485 | 489 | //act |
| ... | ... | @@ -717,7 +721,9 @@ describe('controladores módulo crear cobranza', function() { |
| 717 | 721 | $localStorage: true |
| 718 | 722 | }); |
| 719 | 723 | scope.cobranza = { |
| 720 | - cliente: { } | |
| 724 | + cliente: { }, | |
| 725 | + facturas: [], | |
| 726 | + cobros: [] | |
| 721 | 727 | }; |
| 722 | 728 | |
| 723 | 729 | var respuesta = { result: { then: function() { } } }; |
| ... | ... | @@ -768,7 +774,8 @@ describe('controladores módulo crear cobranza', function() { |
| 768 | 774 | $localStorage: true |
| 769 | 775 | }); |
| 770 | 776 | scope.cobranza = { |
| 771 | - cliente: { } | |
| 777 | + cliente: { }, | |
| 778 | + cobros: [] | |
| 772 | 779 | }; |
| 773 | 780 | |
| 774 | 781 | var respuesta = { result: { then: function() { } } }; |
| ... | ... | @@ -819,7 +826,9 @@ describe('controladores módulo crear cobranza', function() { |
| 819 | 826 | $localStorage: true |
| 820 | 827 | }); |
| 821 | 828 | scope.cobranza = { |
| 822 | - cliente: { } | |
| 829 | + cliente: { }, | |
| 830 | + facturas: [], | |
| 831 | + cobros: [] | |
| 823 | 832 | }; |
| 824 | 833 | |
| 825 | 834 | var respuesta = { result: { then: function() { } } }; |
| ... | ... | @@ -1077,7 +1086,7 @@ describe('controladores módulo crear cobranza', function() { |
| 1077 | 1086 | $localStorage: true |
| 1078 | 1087 | }); |
| 1079 | 1088 | scope.cobranza = { |
| 1080 | - cobros: [{ importe: 1 }] | |
| 1089 | + cobros: [{ IMP: 1 }] | |
| 1081 | 1090 | }; |
| 1082 | 1091 | |
| 1083 | 1092 | //act |
spec/serviceSpec.js
| ... | ... | @@ -104,26 +104,6 @@ describe('Servicios módulo crear cobranza', function() { |
| 104 | 104 | expect(result).toEqual(responseFake); |
| 105 | 105 | }); |
| 106 | 106 | |
| 107 | - it('enviarComprobantePorMail llama a ruta correcta', function() { | |
| 108 | - | |
| 109 | - //arrange | |
| 110 | - var responseFake = 'responseFake'; | |
| 111 | - var result; | |
| 112 | - var paramFake = 1; | |
| 113 | - | |
| 114 | - httpBackend.expectPOST('localhost/mail/comprobante', | |
| 115 | - {receiver: paramFake}).respond(responseFake); | |
| 116 | - | |
| 117 | - //act | |
| 118 | - servicio.enviarComprobantePorMail(paramFake).then(function(data) { | |
| 119 | - result = data.data; | |
| 120 | - }); | |
| 121 | - httpBackend.flush(); | |
| 122 | - | |
| 123 | - //assert | |
| 124 | - expect(result).toEqual(responseFake); | |
| 125 | - }); | |
| 126 | - | |
| 127 | 107 | it('actualizarEmail llama a ruta correcta', function() { |
| 128 | 108 | |
| 129 | 109 | //arrange |
src/js/controller.js
| ... | ... | @@ -112,7 +112,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 112 | 112 | focaModalService.alert('Ingrese al menos una factura'); |
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | - if ($scope.getTotalCobrado() + (Math.abs($scope.getTotalDeuda()) * -1) !== 0) { | |
| 115 | + if ($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { | |
| 116 | 116 | focaModalService.alert('La diferencia debe ser ' + |
| 117 | 117 | $scope.cobranza.moneda.SIMBOLO + '0,00'); |
| 118 | 118 | return; |
| ... | ... | @@ -206,7 +206,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 206 | 206 | REC_CAJ: 'D', |
| 207 | 207 | TIPO_C: 0,//?? |
| 208 | 208 | SALDO_CAJ: 'S', |
| 209 | - FECHA_INGRESO: new Date($scope.cobranza.fecha) | |
| 209 | + FECHA_INGRESO: new Date($scope.cobranza.FEC) | |
| 210 | 210 | .toISOString().slice(0, 19).replace('T', ' '), |
| 211 | 211 | Vendedor_valor: 0, |
| 212 | 212 | FAMILIA: 0, |
| ... | ... | @@ -481,7 +481,20 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 481 | 481 | ); |
| 482 | 482 | }; |
| 483 | 483 | |
| 484 | - $scope.seleccionarCheque = function() { | |
| 484 | + $scope.seleccionarCheque = function(cheque) { | |
| 485 | + | |
| 486 | + var parametros; | |
| 487 | + | |
| 488 | + if(!cheque) { | |
| 489 | + parametros = { | |
| 490 | + importe: getSugerido(), | |
| 491 | + esNuevo : true | |
| 492 | + }; | |
| 493 | + } else { | |
| 494 | + parametros = cheque; | |
| 495 | + parametros.importe = cheque.IMP; | |
| 496 | + } | |
| 497 | + | |
| 485 | 498 | var modalInstance = $uibModal.open( |
| 486 | 499 | { |
| 487 | 500 | ariaLabelledBy: 'Carga de cheques', |
| ... | ... | @@ -489,9 +502,8 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 489 | 502 | controller: 'focaModalChequeController', |
| 490 | 503 | size: 'lg', |
| 491 | 504 | resolve: { |
| 492 | - sugerido: function() { | |
| 493 | - var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | |
| 494 | - return sugerido < 0 ? sugerido : null; | |
| 505 | + cheque: function() { | |
| 506 | + return parametros; | |
| 495 | 507 | } |
| 496 | 508 | } |
| 497 | 509 | } |
| ... | ... | @@ -506,14 +518,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 506 | 518 | cheque.fechaPresentacion.toLocaleDateString(), |
| 507 | 519 | fechaPresentacion: cheque.fechaPresentacion, |
| 508 | 520 | fechaEmision: cheque.fechaEmision, |
| 509 | - IMP: cheque.importe * $scope.cobranza.moneda.cotizacion.VENDEDOR, | |
| 521 | + IMP: cheque.importe, | |
| 510 | 522 | localidad: cheque.localidad, |
| 511 | 523 | librador: cheque.librador, |
| 512 | 524 | provincia: cheque.provincia, |
| 513 | 525 | observaciones: cheque.observaciones, |
| 514 | 526 | TIL: 'EF' |
| 515 | 527 | }; |
| 516 | - $scope.cobranza.cobros.push(cobro); | |
| 528 | + pushearCobro(cobro, cheque.$$hashKey); | |
| 517 | 529 | }, function() { |
| 518 | 530 | |
| 519 | 531 | } |
| ... | ... | @@ -521,6 +533,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 521 | 533 | }; |
| 522 | 534 | |
| 523 | 535 | $scope.seleccionarEfectivo = function() { |
| 536 | + | |
| 537 | + var importe = 0; | |
| 538 | + $scope.cobranza.cobros.filter(function(a) { | |
| 539 | + if(a.COM === 'Efectivo') { | |
| 540 | + importe = a.IMP; | |
| 541 | + } | |
| 542 | + }); | |
| 543 | + | |
| 524 | 544 | var modalInstance = $uibModal.open( |
| 525 | 545 | { |
| 526 | 546 | ariaLabelledBy: 'Carga de cheques', |
| ... | ... | @@ -529,23 +549,25 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 529 | 549 | size: 'sm', |
| 530 | 550 | resolve: { |
| 531 | 551 | sugerido: function() { |
| 532 | - var sugerido = $scope.getTotalDeuda() - $scope.getTotalCobrado(); | |
| 533 | - return sugerido < 0 ? sugerido : null; | |
| 552 | + return parseFloat(getSugerido()) + parseFloat(importe); | |
| 534 | 553 | } |
| 535 | 554 | } |
| 536 | 555 | } |
| 537 | 556 | ); |
| 538 | 557 | modalInstance.result.then( |
| 539 | 558 | function(efectivo) { |
| 559 | + | |
| 540 | 560 | var cobro = { |
| 541 | 561 | COM: 'Efectivo', |
| 542 | 562 | FEC: new Date(), |
| 543 | - IMP: efectivo * $scope.cobranza.moneda.cotizacion.VENDEDOR, | |
| 563 | + IMP: efectivo, | |
| 544 | 564 | TIL: 'EF' |
| 545 | 565 | }; |
| 566 | + | |
| 546 | 567 | $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function(a) { |
| 547 | - return a.tipo !== 'Efectivo'; | |
| 568 | + return a.COM !== 'Efectivo'; | |
| 548 | 569 | }); |
| 570 | + | |
| 549 | 571 | $scope.cobranza.cobros.push(cobro); |
| 550 | 572 | }, function() { |
| 551 | 573 | |
| ... | ... | @@ -553,7 +575,21 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 553 | 575 | ); |
| 554 | 576 | }; |
| 555 | 577 | |
| 556 | - $scope.seleccionarDetalles = function() { | |
| 578 | + $scope.seleccionarDetalles = function(detalle) { | |
| 579 | + | |
| 580 | + var parametro = {}; | |
| 581 | + | |
| 582 | + if(!detalle) { | |
| 583 | + parametro = { | |
| 584 | + importe: getSugerido(), | |
| 585 | + files: [] | |
| 586 | + }; | |
| 587 | + } else { | |
| 588 | + parametro = detalle; | |
| 589 | + parametro.importe = detalle.IMP; | |
| 590 | + parametro.files= detalle.imgs; | |
| 591 | + } | |
| 592 | + | |
| 557 | 593 | var modalInstance = $uibModal.open( |
| 558 | 594 | { |
| 559 | 595 | ariaLabelledBy: 'Carga de detalles', |
| ... | ... | @@ -561,34 +597,24 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 561 | 597 | controller: 'focaModalDetallesController', |
| 562 | 598 | size: 'lg', |
| 563 | 599 | resolve: { |
| 564 | - sugerido: function() { | |
| 565 | - var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | |
| 566 | - return sugerido < 0 ? sugerido : null; | |
| 600 | + parametros: function() { | |
| 601 | + return parametro; | |
| 567 | 602 | } |
| 568 | 603 | } |
| 569 | 604 | } |
| 570 | 605 | ); |
| 571 | 606 | modalInstance.result.then( |
| 572 | 607 | function(detalles) { |
| 608 | + | |
| 573 | 609 | var cobro = { |
| 574 | 610 | COM: 'de(COBRO POR DETALLES)', |
| 575 | 611 | FEC: new Date(), |
| 576 | - IMP: detalles.monto * $scope.cobranza.moneda.cotizacion.VENDEDOR, | |
| 577 | - imgs: detalles.imgs, | |
| 612 | + IMP: detalles.importe, | |
| 613 | + imgs: detalles.files, | |
| 578 | 614 | TIL: 'DE', |
| 579 | 615 | observacion: detalles.observacion |
| 580 | 616 | }; |
| 581 | - var existe = false; | |
| 582 | - | |
| 583 | - $scope.cobranza.cobros.forEach(function(c, idx) { | |
| 584 | - if (c.til === 'DE') { | |
| 585 | - $scope.cobranza.cobros[idx] = cobro; | |
| 586 | - existe = true; | |
| 587 | - } | |
| 588 | - }); | |
| 589 | - if (!existe) { | |
| 590 | - $scope.cobranza.cobros.push(cobro); | |
| 591 | - } | |
| 617 | + pushearCobro(cobro, detalles.$$hashKey); | |
| 592 | 618 | }, function() {} |
| 593 | 619 | ); |
| 594 | 620 | }; |
| ... | ... | @@ -711,6 +737,30 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 711 | 737 | $scope.cobranza.cobros.splice(key, 1); |
| 712 | 738 | }; |
| 713 | 739 | |
| 740 | + $scope.editarCobro = function(cobro) { | |
| 741 | + if(cobro.COM === 'Efectivo') { | |
| 742 | + $scope.seleccionarEfectivo(); | |
| 743 | + } else if(cobro.COM.substring(0, 2) === 'de') { | |
| 744 | + $scope.seleccionarDetalles(cobro); | |
| 745 | + } else if(cobro.COM.substring(0, 2) === 'ch') { | |
| 746 | + $scope.seleccionarCheque(cobro); | |
| 747 | + } | |
| 748 | + }; | |
| 749 | + | |
| 750 | + function pushearCobro(cobro, hashKey) { | |
| 751 | + var existe; | |
| 752 | + | |
| 753 | + $scope.cobranza.cobros.forEach(function(c, idx) { | |
| 754 | + if(c.$$hashKey === hashKey) { | |
| 755 | + $scope.cobranza.cobros[idx] = cobro; | |
| 756 | + existe = true; | |
| 757 | + } | |
| 758 | + }); | |
| 759 | + if (!existe) { | |
| 760 | + $scope.cobranza.cobros.push(cobro); | |
| 761 | + } | |
| 762 | + } | |
| 763 | + | |
| 714 | 764 | function salir() { |
| 715 | 765 | var confirmacion = false; |
| 716 | 766 | |
| ... | ... | @@ -781,5 +831,17 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 781 | 831 | } |
| 782 | 832 | ); |
| 783 | 833 | } |
| 834 | + | |
| 835 | + function getSugerido() { | |
| 836 | + var result; | |
| 837 | + | |
| 838 | + var valor = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | |
| 839 | + | |
| 840 | + if (valor < 0) { | |
| 841 | + result = Math.abs(valor).toFixed(4); | |
| 842 | + } | |
| 843 | + | |
| 844 | + return result; | |
| 845 | + } | |
| 784 | 846 | } |
| 785 | 847 | ]); |
src/views/cobranza.html
| ... | ... | @@ -153,6 +153,12 @@ |
| 153 | 153 | <td class="text-center col-auto"> |
| 154 | 154 | <button |
| 155 | 155 | class="btn btn-outline-light" |
| 156 | + ng-click="editarCobro(cobro)" | |
| 157 | + > | |
| 158 | + <i class="fa fa-edit"></i> | |
| 159 | + </button> | |
| 160 | + <button | |
| 161 | + class="btn btn-outline-light" | |
| 156 | 162 | ng-click="quitarCobro(key)" |
| 157 | 163 | > |
| 158 | 164 | <i class="fa fa-trash"></i> |