Commit 85038ca7fab989fd446332f18322266e77ac1f75

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

See merge request !70
... ... @@ -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
... ... @@ -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
... ... @@ -22,16 +22,12 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
22 22 minDate: new Date(2010, 0, 1)
23 23 };
24 24  
25   - var monedaPorDefecto;
26 25 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
27 26 focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) {
28   - monedaPorDefecto = res.data[0];
29   -
30   - $scope.cobranza.cotizacion = Object.assign(
31   - {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0]
32   - );
33   - $scope.inicial.cotizacion = $scope.cobranza.cotizacion;
34   -
  27 + var moneda = res.data[0];
  28 + moneda.cotizacion = moneda.cotizaciones[0];
  29 + $scope.cobranza.moneda = $scope.inicial.moneda = moneda;
  30 + $timeout(function() {getLSCobranza();});
35 31 });
36 32  
37 33 $timeout(function() {
... ... @@ -46,14 +42,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
46 42 }
47 43  
48 44 init();
49   - $timeout(function() {getLSCobranza();});
  45 +
50 46 }
51 47  
52 48 function init() {
53 49 $scope.$broadcast('cleanCabecera');
54 50 $scope.cobranza = {
55   - fecha: new Date(),
56   - cotizacion: {},
  51 + FEC: new Date(),
  52 + moneda: {},
57 53 facturas: [],
58 54 cobros: [],
59 55 cliente: {},
... ... @@ -119,10 +115,9 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
119 115 }
120 116 if ($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) {
121 117 focaModalService.alert('La diferencia debe ser ' +
122   - $scope.cobranza.cotizacion.moneda.SIMBOLO + '0,00');
  118 + $scope.cobranza.moneda.SIMBOLO + '0,00');
123 119 return;
124 120 }
125   -
126 121 var cobranza = {};
127 122 var cheques = [];
128 123 var cuerpos = [];
... ... @@ -141,11 +136,12 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
141 136 NCO: $scope.comprobante,
142 137 LOP: 'L',
143 138 TIL: $scope.cobranza.facturas[i].TCO,
144   - COM: $scope.cobranza.facturas[i].numeroFactura + '-' +
  139 + COM: $scope.cobranza.facturas[i].COM + '-' +
145 140 $filter('rellenarDigitos')($scope.cobranza.facturas[i].NCU,2),
146   - FEC: new Date($scope.cobranza.fecha)
  141 + FEC: new Date($scope.cobranza.FEC)
147 142 .toISOString().slice(0, 19).replace('T', ' '),
148   - IMP: Math.abs($scope.cobranza.facturas[i].IPA),
  143 + IMP: Math.abs($scope.cobranza.facturas[i].IMP ||
  144 + $scope.cobranza.facturas[i].IPA),
149 145 RES: 0,//caja de tesorería
150 146 SUBM: 0,
151 147 NCU: $scope.cobranza.facturas[i].NCU
... ... @@ -164,14 +160,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
164 160 PVE: $scope.puntoVenta,
165 161 NCO: $scope.comprobante,
166 162 LOP: 'P',
167   - TIL: $scope.cobranza.cobros[j].til,
168   - COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].tipo,
  163 + TIL: $scope.cobranza.cobros[j].TIL,
  164 + COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].COM,
169 165 FEC: !$scope.cobranza.cobros[j].fechaPresentacion ?
170   - new Date($scope.cobranza.cobros[j].fecha)
  166 + new Date($scope.cobranza.cobros[j].FEC)
171 167 .toISOString().slice(0, 19).replace('T', ' ') :
172 168 new Date($scope.cobranza.cobros[j].fechaPresentacion)
173 169 .toISOString().slice(0, 19).replace('T', ' '),
174   - IMP: Math.abs($scope.cobranza.cobros[j].importe),
  170 + IMP: Math.abs($scope.cobranza.cobros[j].IMP),
175 171 RES: 0,//caja de tesorería
176 172 SUBM: 0
177 173 };
... ... @@ -211,7 +207,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
211 207 REC_CAJ: 'D',
212 208 TIPO_C: 0,//??
213 209 SALDO_CAJ: 'S',
214   - FECHA_INGRESO: new Date($scope.cobranza.fecha)
  210 + FECHA_INGRESO: new Date($scope.cobranza.FEC)
215 211 .toISOString().slice(0, 19).replace('T', ' '),
216 212 Vendedor_valor: 0,
217 213 FAMILIA: 0,
... ... @@ -237,14 +233,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
237 233 TCO: 'RC',
238 234 PVE: $scope.puntoVenta, //Sucursar, punto de venta
239 235 NCO: $scope.comprobante, //Numero de comprobante
240   - FEC: new Date($scope.cobranza.fecha)
  236 + FEC: new Date($scope.cobranza.FEC)
241 237 .toISOString().slice(0, 19).replace('T', ' '),
242 238 CLI: $scope.cobranza.cliente.COD,
243 239 ATO: 0, //número de asiento
244 240 CFE: $scope.cobranza.cobrador.NOM,
245 241 PLA: '',//Numero de planilla, sin uso
246   - ID_MONEDA: $scope.cobranza.cotizacion.moneda.ID,
247   - COTIZACION: $scope.cobranza.cotizacion.VENDEDOR,
  242 + ID_MONEDA: $scope.cobranza.moneda.ID,
  243 + COTIZACION: $scope.cobranza.moneda.cotizacion.VENDEDOR,
248 244 idCobrador: $scope.cobranza.cobrador.id
249 245 },
250 246 cuerpo: cuerpos,
... ... @@ -252,7 +248,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
252 248 acobypag: {
253 249 CYV: 'V',
254 250 COD: $scope.cobranza.cliente.COD,
255   - FEP: new Date($scope.cobranza.fecha)
  251 + FEP: new Date($scope.cobranza.FEC)
256 252 .toISOString().slice(0, 19).replace('T', ' '),
257 253 TIP: 'C',
258 254 TCO: 'RC',
... ... @@ -269,7 +265,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
269 265 REM: 0,
270 266 FRE: null,//??
271 267 PRO: 'N',
272   - FEV: new Date($scope.cobranza.fecha)
  268 + FEV: new Date($scope.cobranza.FEC)
273 269 .toISOString().slice(0, 19).replace('T', ' ')
274 270 },
275 271 datosCobrador: {
... ... @@ -278,7 +274,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
278 274 NUM: $scope.comprobante,
279 275 EST: 'C',
280 276 OBS: 'RC: ' + $scope.comprobante + '-' +
281   - new Date($scope.cobranza.fecha).toLocaleDateString(),
  277 + new Date($scope.cobranza.FEC).toLocaleDateString(),
282 278 DAT1: 'C',
283 279 CLI: $scope.cobranza.cliente.COD
284 280 },
... ... @@ -297,28 +293,10 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
297 293 .guardarCobranza(cobranza)
298 294 .then(
299 295 function(result) {
300   - var cliente = angular.copy($scope.cobranza.cliente);
301 296 focaBotoneraLateralService.endGuardar(true);
302 297 $scope.saveLoading = false;
303 298  
304   - focaModalService
305   - .prompt({
306   - titulo: 'Ingrese los emails separados por' +
307   - ' coma para enviar comprobante',
308   - value: cliente.MAIL,
309   - email: true
310   - })
311   - .then(function(res) {
312   - return Promise.all([
313   - focaCrearCobranzaService
314   - .enviarComprobantePorMail(res, cobranzaMail),
315   - focaCrearCobranzaService
316   - .actualizarEmail(res, cliente.COD)
317   - ]);
318   - })
319   - .then(function() {
320   - focaModalService.alert('Mensaje enviado correctamente');
321   - });
  299 + enviarMail(cobranzaMail);
322 300  
323 301 focaSeguimientoService.guardarPosicion(
324 302 'Cobranza',
... ... @@ -354,7 +332,10 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
354 332 size: 'lg'
355 333 }
356 334 );
357   - modalInstance.result.then(setearCobranza);
  335 + modalInstance.result.then(function(cobranza) {
  336 + cobranza.moneda.cotizacion = cobranza.moneda.cotizaciones[0];
  337 + setearCobranza(cobranza);
  338 + });
358 339 };
359 340  
360 341 $scope.seleccionarResumenDeCuenta = function() {
... ... @@ -368,7 +349,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
368 349 templateUrl: 'modal-resumen-cuenta.html',
369 350 controller: 'focaModalResumenCuentaController',
370 351 resolve: {
371   - idCliente: function() { return $scope.cobranza.cliente.COD; }
  352 + cliente: function() { return $scope.cobranza.cliente; }
372 353 },
373 354 size: 'lg'
374 355 }
... ... @@ -400,7 +381,8 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
400 381 var clienteMayus = {
401 382 COD: cliente.cod,
402 383 NOM: cliente.nom,
403   - CUIT: cliente.cuit
  384 + CUIT: cliente.cuit,
  385 + MAIL: cliente.mail
404 386 };
405 387  
406 388 $scope.$broadcast('addCabecera', {
... ... @@ -475,9 +457,9 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
475 457 parametrosFactura: function() {
476 458 return {
477 459 cliente: $scope.cobranza.cliente,
478   - simbolo: $scope.cobranza.cotizacion.moneda.SIMBOLO,
479   - cotizacion: $scope.cobranza.cotizacion.VENDEDOR,
480   - moneda: $scope.cobranza.cotizacion.moneda.ID
  460 + simbolo: $scope.cobranza.moneda.SIMBOLO,
  461 + cotizacion: $scope.cobranza.moneda,
  462 + moneda: $scope.cobranza.moneda.ID
481 463 };
482 464 }
483 465 }
... ... @@ -500,7 +482,20 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
500 482 );
501 483 };
502 484  
503   - $scope.seleccionarCheque = function() {
  485 + $scope.seleccionarCheque = function(cheque) {
  486 +
  487 + var parametros;
  488 +
  489 + if(!cheque) {
  490 + parametros = {
  491 + importe: getSugerido(),
  492 + esNuevo : true
  493 + };
  494 + } else {
  495 + parametros = cheque;
  496 + parametros.importe = cheque.IMP;
  497 + }
  498 +
504 499 var modalInstance = $uibModal.open(
505 500 {
506 501 ariaLabelledBy: 'Carga de cheques',
... ... @@ -508,9 +503,8 @@ angular.module('focaCrearCobranza') .controller('cobranzaController',
508 503 controller: 'focaModalChequeController',
509 504 size: 'lg',
510 505 resolve: {
511   - sugerido: function() {
512   - var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado();
513   - return sugerido < 0 ? sugerido : null;
  506 + cheque: function() {
  507 + return parametros;
514 508 }
515 509 }
516 510 }
... ... @@ -518,21 +512,21 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
518 512 modalInstance.result.then(
519 513 function(cheque) {
520 514 var cobro = {
521   - tipo: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco,
  515 + COM: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco,
522 516 numero: cheque.numero,
523 517 banco: cheque.banco,
524   - fecha: cheque.fechaEmision.toLocaleDateString() + '-' +
  518 + FEC: cheque.fechaEmision.toLocaleDateString() + '-' +
525 519 cheque.fechaPresentacion.toLocaleDateString(),
526 520 fechaPresentacion: cheque.fechaPresentacion,
527 521 fechaEmision: cheque.fechaEmision,
528   - importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR,
  522 + IMP: cheque.importe,
529 523 localidad: cheque.localidad,
530 524 librador: cheque.librador,
531 525 provincia: cheque.provincia,
532 526 observaciones: cheque.observaciones,
533   - til: 'EF'
  527 + TIL: 'EF'
534 528 };
535   - $scope.cobranza.cobros.push(cobro);
  529 + pushearCobro(cobro, cheque.$$hashKey);
536 530 }, function() {
537 531  
538 532 }
... ... @@ -540,6 +534,14 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
540 534 };
541 535  
542 536 $scope.seleccionarEfectivo = function() {
  537 +
  538 + var importe = 0;
  539 + $scope.cobranza.cobros.filter(function(a) {
  540 + if(a.COM === 'Efectivo') {
  541 + importe = a.IMP;
  542 + }
  543 + });
  544 +
543 545 var modalInstance = $uibModal.open(
544 546 {
545 547 ariaLabelledBy: 'Carga de cheques',
... ... @@ -548,23 +550,25 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
548 550 size: 'sm',
549 551 resolve: {
550 552 sugerido: function() {
551   - var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado();
552   - return sugerido < 0 ? sugerido : null;
  553 + return parseFloat(getSugerido()) + parseFloat(importe);
553 554 }
554 555 }
555 556 }
556 557 );
557 558 modalInstance.result.then(
558 559 function(efectivo) {
  560 +
559 561 var cobro = {
560   - tipo: 'Efectivo',
561   - fecha: new Date(),
562   - importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR,
563   - til: 'EF'
  562 + COM: 'Efectivo',
  563 + FEC: new Date(),
  564 + IMP: efectivo,
  565 + TIL: 'EF'
564 566 };
  567 +
565 568 $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function(a) {
566   - return a.tipo !== 'Efectivo';
  569 + return a.COM !== 'Efectivo';
567 570 });
  571 +
568 572 $scope.cobranza.cobros.push(cobro);
569 573 }, function() {
570 574  
... ... @@ -572,7 +576,21 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
572 576 );
573 577 };
574 578  
575   - $scope.seleccionarDetalles = function() {
  579 + $scope.seleccionarDetalles = function(detalle) {
  580 +
  581 + var parametro = {};
  582 +
  583 + if(!detalle) {
  584 + parametro = {
  585 + importe: getSugerido(),
  586 + files: []
  587 + };
  588 + } else {
  589 + parametro = detalle;
  590 + parametro.importe = detalle.IMP;
  591 + parametro.files= detalle.imgs;
  592 + }
  593 +
576 594 var modalInstance = $uibModal.open(
577 595 {
578 596 ariaLabelledBy: 'Carga de detalles',
... ... @@ -580,34 +598,24 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
580 598 controller: 'focaModalDetallesController',
581 599 size: 'lg',
582 600 resolve: {
583   - sugerido: function() {
584   - var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado();
585   - return sugerido < 0 ? sugerido : null;
  601 + parametros: function() {
  602 + return parametro;
586 603 }
587 604 }
588 605 }
589 606 );
590 607 modalInstance.result.then(
591 608 function(detalles) {
  609 +
592 610 var cobro = {
593   - tipo: 'de(COBRO POR DETALLES)',
594   - fecha: new Date(),
595   - importe: detalles.monto * $scope.cobranza.cotizacion.VENDEDOR,
596   - imgs: detalles.imgs,
597   - til: 'DE',
  611 + COM: 'de(COBRO POR DETALLES)',
  612 + FEC: new Date(),
  613 + IMP: detalles.importe,
  614 + imgs: detalles.files,
  615 + TIL: 'DE',
598 616 observacion: detalles.observacion
599 617 };
600   - var existe = false;
601   -
602   - $scope.cobranza.cobros.forEach(function(c, idx) {
603   - if (c.til === 'DE') {
604   - $scope.cobranza.cobros[idx] = cobro;
605   - existe = true;
606   - }
607   - });
608   - if (!existe) {
609   - $scope.cobranza.cobros.push(cobro);
610   - }
  618 + pushearCobro(cobro, detalles.$$hashKey);
611 619 }, function() {}
612 620 );
613 621 };
... ... @@ -649,8 +657,8 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
649 657 );
650 658 modalInstance.result.then(
651 659 function(cotizacion) {
652   - $scope.cobranza.cotizacion.moneda = moneda;
653   - $scope.cobranza.cotizacion = cotizacion;
  660 + $scope.cobranza.moneda = moneda;
  661 + $scope.cobranza.moneda.cotizacion = cotizacion;
654 662 if (moneda.DETALLE === 'PESOS ARGENTINOS') {
655 663 $scope.$broadcast('removeCabecera', 'Moneda:');
656 664 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
... ... @@ -669,6 +677,7 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
669 677 valor: $filter('number')(cotizacion.VENDEDOR, '2')
670 678 });
671 679 }
  680 +
672 681 }, function() {
673 682  
674 683 }
... ... @@ -678,7 +687,7 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
678 687 $scope.getTotalDeuda = function() {
679 688 var total = 0;
680 689 for (var i = 0; i < $scope.cobranza.facturas.length; i++) {
681   - total += $scope.cobranza.facturas[i].IPA;
  690 + total += $scope.cobranza.facturas[i].IMP || $scope.cobranza.facturas[i].IPA;
682 691 }
683 692 return parseFloat(total.toFixed(2));
684 693 };
... ... @@ -686,7 +695,7 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
686 695 $scope.getTotalCobrado = function() {
687 696 var total = 0;
688 697 for (var i = 0; i < $scope.cobranza.cobros.length; i++) {
689   - total += $scope.cobranza.cobros[i].importe;
  698 + total += $scope.cobranza.cobros[i].IMP;
690 699 }
691 700 return parseFloat(total.toFixed(2));
692 701 };
... ... @@ -729,6 +738,30 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
729 738 $scope.cobranza.cobros.splice(key, 1);
730 739 };
731 740  
  741 + $scope.editarCobro = function(cobro) {
  742 + if(cobro.COM === 'Efectivo') {
  743 + $scope.seleccionarEfectivo();
  744 + } else if(cobro.COM.substring(0, 2) === 'de') {
  745 + $scope.seleccionarDetalles(cobro);
  746 + } else if(cobro.COM.substring(0, 2) === 'ch') {
  747 + $scope.seleccionarCheque(cobro);
  748 + }
  749 + };
  750 +
  751 + function pushearCobro(cobro, hashKey) {
  752 + var existe;
  753 +
  754 + $scope.cobranza.cobros.forEach(function(c, idx) {
  755 + if(c.$$hashKey === hashKey) {
  756 + $scope.cobranza.cobros[idx] = cobro;
  757 + existe = true;
  758 + }
  759 + });
  760 + if (!existe) {
  761 + $scope.cobranza.cobros.push(cobro);
  762 + }
  763 + }
  764 +
732 765 function salir() {
733 766 var confirmacion = false;
734 767  
... ... @@ -780,5 +813,36 @@ angular.module(&#39;focaCrearCobranza&#39;) .controller(&#39;cobranzaController&#39;,
780 813 delete $localStorage.cobranza;
781 814 }
782 815 }
  816 +
  817 + function enviarMail(recibo) {
  818 + focaModalService.mail(
  819 + {
  820 + titulo: 'Enviar recibo',
  821 + descarga: {
  822 + nombre: recibo.recibo.PVE + '-' + recibo.recibo.NCO + '.pdf',
  823 + url: '/mail/recibo/descargar',
  824 + },
  825 + envio: {
  826 + mailCliente: recibo.cliente.MAIL,
  827 + url: '/mail/recibo',
  828 + },
  829 + options: {
  830 + recibo: recibo
  831 + }
  832 + }
  833 + );
  834 + }
  835 +
  836 + function getSugerido() {
  837 + var result;
  838 +
  839 + var valor = $scope.getTotalDeuda() + $scope.getTotalCobrado();
  840 +
  841 + if (valor < 0) {
  842 + result = Math.abs(valor).toFixed(4);
  843 + }
  844 +
  845 + return result;
  846 + }
783 847 }
784 848 ]);
... ... @@ -14,10 +14,6 @@ angular.module(&#39;focaCrearCobranza&#39;)
14 14 getCobradorById: function(id) {
15 15 return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id);
16 16 },
17   - enviarComprobantePorMail: function(mail, data) {
18   - return $http.post(API_ENDPOINT.URL + '/mail/comprobante',
19   - {receiver: mail, comprobante: data});
20   - },
21 17 actualizarEmail: function(mail, idCliente) {
22 18 return $http.post(API_ENDPOINT.URL + '/cliente/update/email',
23 19 {mail: mail, id: idCliente});
src/views/cobranza.html
... ... @@ -2,7 +2,7 @@
2 2 <foca-cabecera-facturador
3 3 titulo="'Recibo de cobranza'"
4 4 numero="puntoVenta + '-' + comprobante"
5   - fecha="cobranza.fecha"
  5 + fecha="cobranza.FEC"
6 6 class="mb-0 col-lg-12"
7 7 busqueda="seleccionarCobranza"
8 8 ></foca-cabecera-facturador>
... ... @@ -51,12 +51,12 @@
51 51 ng-show="show || key == cobranza.facturas.length - 1"
52 52 >
53 53 <td ng-bind="key + 1" class="col-auto"></td>
54   - <td class="col" ng-bind="factura.numeroFactura"
  54 + <td class="col" ng-bind="factura.COM || factura.numeroFactura"
55 55 ></td>
56   - <td class="col" ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td>
  56 + <td class="col" ng-bind="factura.FEC || factura.FEP | date : 'dd/MM/yyyy'"></td>
57 57 <td
58 58 class="col"
59   - ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) |
  59 + ng-bind="((factura.IMP ||factura.IPA) / cobranza.moneda.cotizacion.VENDEDOR) |
60 60 number: 4"></td>
61 61 <td class="text-center col-auto">
62 62 <button
... ... @@ -86,14 +86,14 @@
86 86 <strong>Cancela:</strong>
87 87 </td>
88 88 <td class="table-celda-total text-right no-border-top">
89   - <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) |
  89 + <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) |
90 90 currency: cobranza.moneda.SIMBOLO}}</strong>
91 91 </td>
92 92 <td class="text-right ml-auto table-celda-total no-border-top">
93 93 <strong>Total Cobrado:</strong>
94 94 </td>
95 95 <td class="table-celda-total text-right no-border-top">
96   - <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) |
  96 + <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) |
97 97 currency: cobranza.moneda.SIMBOLO}}</strong>
98 98 </td>
99 99 <td class="text-right ml-auto table-celda-total no-border-top">
... ... @@ -101,7 +101,7 @@
101 101 </td>
102 102 <td class="table-celda-total text-right no-border-top mr-1">
103 103 <strong>{{((getTotalCobrado() + getTotalDeuda()) /
104   - cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}
  104 + cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}
105 105 </strong>
106 106 </td>
107 107 </tr>
... ... @@ -144,14 +144,21 @@
144 144 ng-show="show || key == cobranza.cobros.length - 1"
145 145 >
146 146 <td ng-bind="key + 1" class="col-auto"></td>
147   - <td class="col" ng-bind="cobro.tipo"></td>
148   - <td class="col" ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></td>
  147 + <td class="col" ng-bind="cobro.COM"></td>
  148 + <td class="col" ng-bind="cobro.FEC | date : 'dd/MM/yyyy'"></td>
149 149 <td
150 150 class="col"
151   - ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) |
  151 + ng-bind="(cobro.IMP / cobranza.moneda.cotizacion.VENDEDOR) |
152 152 currency: cobranza.moneda.SIMBOLO : 4"></td>
153 153 <td class="text-center col-auto">
154 154 <button
  155 + ng-disabled="cobranza.id"
  156 + class="btn btn-outline-light"
  157 + ng-click="editarCobro(cobro)"
  158 + >
  159 + <i class="fa fa-edit"></i>
  160 + </button>
  161 + <button
155 162 class="btn btn-outline-light"
156 163 ng-click="quitarCobro(key)"
157 164 >
... ... @@ -190,14 +197,14 @@
190 197 <strong>Cancela:</strong>
191 198 </td>
192 199 <td class="table-celda-total text-right no-border-top">
193   - <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) |
  200 + <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) |
194 201 currency: cobranza.moneda.SIMBOLO}}</strong>
195 202 </td>
196 203 <td class="text-right ml-auto table-celda-total no-border-top">
197 204 <strong>Total Cobrado:</strong>
198 205 </td>
199 206 <td class="table-celda-total text-right no-border-top">
200   - <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) |
  207 + <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) |
201 208 currency: cobranza.moneda.SIMBOLO}}</strong>
202 209 </td>
203 210 <td class="text-right ml-auto table-celda-total no-border-top">
... ... @@ -205,7 +212,7 @@
205 212 </td>
206 213 <td class="table-celda-total text-right no-border-top mr-1">
207 214 <strong>{{((getTotalCobrado() + getTotalDeuda()) /
208   - cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}
  215 + cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}
209 216 </strong>
210 217 </td>
211 218 </tr>
... ... @@ -251,8 +258,8 @@
251 258 </div>
252 259 <div class="col-4 p-1">
253 260 <span
254   - ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) |
255   - currency:cobranza.moneda.SIMBOLO : 4"></span>
  261 + ng-bind="(factura.IPA / cobranza.moneda.cotizacion.VENDEDOR) |
  262 + currency: cobranza.moneda.SIMBOLO : 4"></span>
256 263 </div>
257 264 </div>
258 265 </div>
... ... @@ -339,20 +346,27 @@
339 346 <div class="col px-0">
340 347 <div class="d-flex">
341 348 <div class="col-4 p-1">
342   - <span ng-bind="cobro.tipo"
  349 + <span ng-bind="cobro.COM"
343 350 ></span>
344 351 </div>
345 352 <div class="col-4 p-1">
346   - <span ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></span>
  353 + <span ng-bind="cobro.FEC | date : 'dd/MM/yyyy'"></span>
347 354 </div>
348 355 <div class="col-4 p-1">
349 356 <span
350   - ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) |
  357 + ng-bind="(cobro.IMP / cobranza.moneda.cotizacion.VENDEDOR) |
351 358 currency: cobranza.moneda.SIMBOLO : 4"></span>
352 359 </div>
353 360 </div>
354 361 </div>
355   - <div class="align-middle p-1">
  362 + <div class="col-2 align-middle p-1">
  363 + <button
  364 + ng-disabled="cobranza.id"
  365 + class="btn btn-outline-light"
  366 + ng-click="editarCobro(cobro)"
  367 + >
  368 + <i class="fa fa-edit"></i>
  369 + </button>
356 370 <button
357 371 class="btn btn-outline-light"
358 372 ng-click="quitarCobro(key)"
... ... @@ -435,13 +449,13 @@
435 449 <strong>Diferencia:</strong>
436 450 </td>
437 451 <td class="table-celda-total text-center no-border-top col-4">
438   - <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
  452 + <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
439 453 </td>
440 454 <td class="table-celda-total text-center no-border-top col-4">
441   - <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
  455 + <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
442 456 </td>
443 457 <td class="table-celda-total text-center no-border-top col-4">
444   - <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
  458 + <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong>
445 459 </td>
446 460 </tr>
447 461 </table>