Commit 92a728e90618defede0a6dca2f6064613a237c16

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

See merge request !10
... ... @@ -4,6 +4,7 @@
4 4 "description": "Modal para resumen de cuenta en cobranzas",
5 5 "main": "index.js",
6 6 "scripts": {
  7 + "refresh" : "gulp uglify && cp tmp/foca-modal-resumen-cuenta.js ../wrapper-demo/node_modules/foca-modal-resumen-cuenta/dist/foca-modal-resumen-cuenta.min.js",
7 8 "test": "echo \"Error: no test specified\" && exit 1",
8 9 "gulp-pre-commit": "gulp pre-commit",
9 10 "compile": "gulp uglify",
src/js/controller.js
... ... @@ -6,10 +6,11 @@ angular.module('focaModalResumenCuenta')
6 6 '$uibModalInstance',
7 7 'focaModalResumenCuentaService',
8 8 'cliente',
  9 + 'idMoneda',
9 10 '$uibModal',
10 11 'focaModalService',
11   - function($timeout, $filter, $scope, $uibModalInstance,
12   - focaModalResumenCuentaService, cliente, $uibModal, focaModalService) {
  12 + function ($timeout, $filter, $scope, $uibModalInstance,
  13 + focaModalResumenCuentaService, cliente, idMoneda, $uibModal, focaModalService) {
13 14 var fecha = new Date();
14 15 $scope.generado = false;
15 16 $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1));
... ... @@ -18,19 +19,22 @@ angular.module('focaModalResumenCuenta')
18 19 $scope.numPerPage = 10;
19 20 $scope.selectedFactura = -1;
20 21  
21   - $scope.generar = function() {
  22 + $scope.generar = function () {
22 23 focaModalResumenCuentaService
23   - .getResumenCuenta(cliente.COD, $scope.fechaDesde)
24   - .then(function(res) {
25   - res.data.facturas = calcularSaldos(res.data.facturas);
  24 + .getResumenCuenta(cliente.COD, idMoneda, $scope.fechaDesde)
  25 + .then(function (res) {
  26 + res.data = res.data.filter(function(factura){
  27 + return factura.TCO !== "RC" && factura.TCO !== "RE"
  28 + })
  29 + res.data = calcularSaldos(res.data);
26 30 $scope.generado = true;
27 31 $scope.results = res.data;
28   - $scope.results.fechaDesde = $scope.fechaDesde;
  32 + // $scope.results.fechaDesde = $scope.fechaDesde;
29 33 $scope.search();
30 34 });
31 35 };
32 36  
33   - $scope.cancel = function() {
  37 + $scope.cancel = function () {
34 38 if ($scope.generado) {
35 39 $scope.generado = false;
36 40 } else {
... ... @@ -38,7 +42,7 @@ angular.module('focaModalResumenCuenta')
38 42 }
39 43 };
40 44  
41   - $scope.enviarMail = function(factura) {
  45 + $scope.enviarMail = function (factura) {
42 46 focaModalService.mail(
43 47 {
44 48 titulo: 'Enviar comprobante',
... ... @@ -57,7 +61,7 @@ angular.module('focaModalResumenCuenta')
57 61 );
58 62 };
59 63  
60   - $scope.enviarResumen = function() {
  64 + $scope.enviarResumen = function () {
61 65 focaModalService.mail(
62 66 {
63 67 titulo: 'Enviar resumen de cuenta',
... ... @@ -76,8 +80,8 @@ angular.module('focaModalResumenCuenta')
76 80 );
77 81 };
78 82  
79   - $scope.verFactura = function(factura) {
80   - var modalInstance = $uibModal.open(
  83 + $scope.verFactura = function (factura) {
  84 + var modalInstance = $uibModal.open(
81 85 {
82 86 ariaLabelledBy: 'Detalle de factura',
83 87 templateUrl: 'foca-modal-factura-detalle.html',
... ... @@ -92,26 +96,26 @@ angular.module('focaModalResumenCuenta')
92 96 };
93 97  
94 98  
95   - $scope.search = function() {
96   - if ($scope.results.facturas.length) {
  99 + $scope.search = function () {
  100 + if ($scope.results.length) {
97 101 $scope.lastPage = Math.ceil(
98   - $scope.results.facturas.length / $scope.numPerPage
  102 + $scope.results.length / $scope.numPerPage
99 103 );
100 104 $scope.resetPage();
101 105 }
102 106 };
103 107  
104   - $scope.resetPage = function() {
  108 + $scope.resetPage = function () {
105 109 $scope.currentPage = 1;
106 110 $scope.selectPage(1);
107 111 };
108 112  
109   - $scope.selectPage = function(page) {
  113 + $scope.selectPage = function (page) {
110 114 var start = (page - 1) * $scope.numPerPage;
111 115 var end = start + $scope.numPerPage;
112 116 $scope.paginas = [];
113 117 $scope.paginas = calcularPages(page);
114   - $scope.currentPageFacturas = $scope.results.facturas.slice(start, end);
  118 + $scope.currentPageFacturas = $scope.results.slice(start, end);
115 119 $scope.currentPage = page;
116 120 };
117 121  
... ... @@ -120,7 +124,7 @@ angular.module('focaModalResumenCuenta')
120 124 paginas.push(paginaActual);
121 125  
122 126 if (paginaActual - 1 > 1) {
123   -
  127 +
124 128 paginas.unshift(paginaActual - 1);
125 129 if (paginaActual - 2 > 1) {
126 130 paginas.unshift(paginaActual - 2);
... ... @@ -148,10 +152,10 @@ angular.module('focaModalResumenCuenta')
148 152 function calcularSaldos(facturas) {
149 153 var saldo = 0;
150 154  
151   - facturas.forEach(function(factura) {
  155 + facturas.forEach(function (factura) {
152 156 if (factura.TCO === 'CI' ||
153 157 factura.TCO === 'FT' ||
154   - factura.TCO === 'ND'){
  158 + factura.TCO === 'ND') {
155 159 factura.IPA = factura.IPA * -1;
156 160 } else {
157 161 factura.IPA = factura.IPA;
... ... @@ -161,7 +165,7 @@ angular.module('focaModalResumenCuenta')
161 165 factura.saldo_show = Math.abs(saldo);
162 166 factura.IPA_SHOW = Math.abs(factura.IPA);
163 167 });
164   -
  168 + facturas.saldo = saldo;
165 169 return facturas;
166 170 }
167 171 }]
1 1 angular.module('focaModalResumenCuenta')
2   - .factory('focaModalResumenCuentaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
  2 + .factory('focaModalResumenCuentaService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) {
3 3 return {
4   - getResumenCuenta: function(idCliente, fechaDesde) {
5   - return $http.get(API_ENDPOINT.URL +
6   - '/factura/resumen/' + idCliente + '/' + fechaDesde);
  4 + getResumenCuenta: function (idCliente, idMoneda, fechaDesde) {
  5 + return $http.get(API_ENDPOINT.URL + '/factura/cliente/' + idCliente + '/' + idMoneda + '/' +
  6 + fechaDesde + '/' + '2100-12-31' + '/' + true);
  7 + // '2001-01-01',
  8 + // '2100-12-31'
7 9 },
8   - enviarFacturaPorMail: function(receiver, factura) {
  10 + enviarFacturaPorMail: function (receiver, factura) {
9 11 return $http.post(API_ENDPOINT.URL + '/mail',
10   - {receiver: receiver, factura: factura});
  12 + { receiver: receiver, factura: factura });
11 13 },
12   - enviarResumenPorMail: function(receiver, resumen) {
  14 + enviarResumenPorMail: function (receiver, resumen) {
13 15 return $http.post(API_ENDPOINT.URL + '/mail/resumen-cuenta',
14   - {receiver: receiver, resumen: resumen});
  16 + { receiver: receiver, resumen: resumen });
15 17 }
16 18 };
17 19 }]);
src/views/modal-resumen-cuenta.html
... ... @@ -12,11 +12,14 @@
12 12 <div class="input-group row"
13 13 ng-hide="generado">
14 14 <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small>
15   - <div class="col-md-4 col-8 input-group mb-2">
  15 + <div class="col-md-4 col-8 input-group mb-3">
16 16 <div class="input-group-prepend">
17   - <div class="input-group-text form-control-sm">
  17 + <button
  18 + type="button"
  19 + ng-click="datepickerOpen = true"
  20 + class="input-group-text">
18 21 <i class="fa fa-calendar"></i>
19   - </div>
  22 + </button>
20 23 </div>
21 24 <input
22 25 class="form-control form-control-sm"
... ... @@ -108,7 +111,7 @@
108 111 </li>
109 112 </ul>
110 113 </nav>
111   - <button class="btn btn-sm btn-secondary my-1" type="button" ng-click="generar()" ng-hide="generado">Generar</button>
  114 + <button class="btn btn-sm btn-primary my-1" type="button" ng-click="generar()" ng-hide="generado">Generar</button>
112 115 <button class="btn btn-sm btn-primary my-1" type="button" ng-click="enviarResumen()" ng-show="generado">Enviar</button>
113 116 <button class="btn btn-sm btn-secondary my-1" type="button" ng-click="cancel()">Cancelar</button>
114 117 </div>