Commit 608368ad43a3022a96616b3482bd792b19fdc2e4
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !15
Showing
1 changed file
Show diff stats
src/js/controller.js
... | ... | @@ -380,7 +380,10 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
380 | 380 | ariaLabelledBy: 'Carga de cheques', |
381 | 381 | templateUrl: 'modal-efectivo.html', |
382 | 382 | controller: 'focaModalEfectivoController', |
383 | - size: 'sm' | |
383 | + size: 'sm', | |
384 | + resolve: { | |
385 | + sugerido: function() {return $scope.getTotalDeuda();} | |
386 | + } | |
384 | 387 | } |
385 | 388 | ); |
386 | 389 | modalInstance.result.then( |
... | ... | @@ -390,7 +393,15 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
390 | 393 | fecha: new Date(), |
391 | 394 | importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR |
392 | 395 | }; |
393 | - $scope.cobrosTabla.push(cobro); | |
396 | + var existeCobroEfectivo = $scope.cobrosTabla.filter(function(a) { | |
397 | + return a.tipo === 'Efectivo'; | |
398 | + }); | |
399 | + if(existeCobroEfectivo.length > 0) { | |
400 | + existeCobroEfectivo[0].importe += efectivo * | |
401 | + $scope.cobranza.cotizacion.VENDEDOR; | |
402 | + } else { | |
403 | + $scope.cobrosTabla.push(cobro); | |
404 | + } | |
394 | 405 | }, function() { |
395 | 406 | |
396 | 407 | } |