diff --git a/src/js/controller.js b/src/js/controller.js index fcb608a..ab37097 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -69,7 +69,7 @@ angular.module('focaModalFactura') $scope.selectedFactura = -1; $scope.searchLoading = false; $scope.primerBusqueda = true; - $scope.facturas = res.data; + $scope.facturas = calcularSaldos(res.data); $scope.search(); primera(); } @@ -193,6 +193,26 @@ angular.module('focaModalFactura') $scope.selectedFactura = 0; } } + + function calcularSaldos(facturas) { + var saldo = 0; + + facturas.forEach(function(factura) { + if (factura.TCO === 'CI' || + factura.TCO === 'FT' || + factura.TCO === 'ND'){ + factura.IPA = factura.IPA * -1; + }else{ + factura.IPA = factura.IPA; + } + saldo += factura.IPA; + factura.saldo = saldo; + }); + + return facturas; + } + + $scope.busquedaPress(13); } ] ); diff --git a/src/views/foca-modal-factura.html b/src/views/foca-modal-factura.html index 58d7931..3947f1a 100644 --- a/src/views/foca-modal-factura.html +++ b/src/views/foca-modal-factura.html @@ -3,44 +3,16 @@
-
- -
- -
-
-