Commit 2a7d3bc419b8544d462a153ffe733a2badd8f51c

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'master' into 'develop'

Master(mpuebla)

See merge request !8
1 { 1 {
2 "name": "foca-modal-resumen-cuenta", 2 "name": "foca-modal-resumen-cuenta",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "Modal para resumen de cuenta en cobranzas", 4 "description": "Modal para resumen de cuenta en cobranzas",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 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 "test": "echo \"Error: no test specified\" && exit 1", 8 "test": "echo \"Error: no test specified\" && exit 1",
8 "gulp-pre-commit": "gulp pre-commit", 9 "gulp-pre-commit": "gulp pre-commit",
9 "compile": "gulp uglify", 10 "compile": "gulp uglify",
10 "postinstall": "npm run compile && gulp clean-post-install", 11 "postinstall": "npm run compile && gulp clean-post-install",
11 "install-dev": "npm install --ignore-scripts" 12 "install-dev": "npm install --ignore-scripts"
12 }, 13 },
13 "pre-commit": [ 14 "pre-commit": [
14 "gulp-pre-commit" 15 "gulp-pre-commit"
15 ], 16 ],
16 "repository": { 17 "repository": {
17 "type": "git", 18 "type": "git",
18 "url": "http://git.focasoftware.com/npm/foca-modal-resumen-cuenta" 19 "url": "http://git.focasoftware.com/npm/foca-modal-resumen-cuenta"
19 }, 20 },
20 "author": "Foca Software", 21 "author": "Foca Software",
21 "license": "ISC", 22 "license": "ISC",
22 "peerDependencies": { 23 "peerDependencies": {
23 "angular": "^1.7.4", 24 "angular": "^1.7.4",
24 "bootstrap": "^4.1.3", 25 "bootstrap": "^4.1.3",
25 "font-awesome": "^4.7.0", 26 "font-awesome": "^4.7.0",
26 "ui-bootstrap4": "^3.0.4", 27 "ui-bootstrap4": "^3.0.4",
27 "gulp": "^3.9.1", 28 "gulp": "^3.9.1",
28 "gulp-angular-templatecache": "^2.2.1", 29 "gulp-angular-templatecache": "^2.2.1",
29 "gulp-concat": "^2.6.1", 30 "gulp-concat": "^2.6.1",
30 "gulp-connect": "^5.6.1", 31 "gulp-connect": "^5.6.1",
31 "gulp-htmlmin": "^5.0.1", 32 "gulp-htmlmin": "^5.0.1",
32 "gulp-rename": "^1.4.0", 33 "gulp-rename": "^1.4.0",
33 "gulp-replace": "^1.0.0", 34 "gulp-replace": "^1.0.0",
34 "gulp-uglify": "^3.0.1", 35 "gulp-uglify": "^3.0.1",
35 "jquery": "^3.3.1", 36 "jquery": "^3.3.1",
36 "pump": "^3.0.0", 37 "pump": "^3.0.0",
37 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" 38 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git"
38 }, 39 },
39 "devDependencies": { 40 "devDependencies": {
40 "angular": "1.7.5", 41 "angular": "1.7.5",
41 "angular-ladda": "0.4.3", 42 "angular-ladda": "0.4.3",
42 "bootstrap": "4.1.3", 43 "bootstrap": "4.1.3",
43 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", 44 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git",
44 "font-awesome": "4.7.0", 45 "font-awesome": "4.7.0",
45 "gulp": "3.9.1", 46 "gulp": "3.9.1",
46 "gulp-angular-templatecache": "2.2.5", 47 "gulp-angular-templatecache": "2.2.5",
47 "gulp-clean": "0.4.0", 48 "gulp-clean": "0.4.0",
48 "gulp-concat": "2.6.1", 49 "gulp-concat": "2.6.1",
49 "gulp-connect": "5.6.1", 50 "gulp-connect": "5.6.1",
50 "gulp-htmlmin": "5.0.1", 51 "gulp-htmlmin": "5.0.1",
51 "gulp-jshint": "2.1.0", 52 "gulp-jshint": "2.1.0",
52 "gulp-rename": "1.4.0", 53 "gulp-rename": "1.4.0",
53 "gulp-replace": "1.0.0", 54 "gulp-replace": "1.0.0",
54 "gulp-uglify": "3.0.1", 55 "gulp-uglify": "3.0.1",
55 "jasmine-core": "3.3.0", 56 "jasmine-core": "3.3.0",
56 "jquery": "3.3.1", 57 "jquery": "3.3.1",
57 "jshint": "2.9.6", 58 "jshint": "2.9.6",
58 "ladda": "1.0.6", 59 "ladda": "1.0.6",
59 "pre-commit": "1.2.2", 60 "pre-commit": "1.2.2",
60 "pump": "3.0.0", 61 "pump": "3.0.0",
61 "ui-bootstrap4": "3.0.5" 62 "ui-bootstrap4": "3.0.5"
62 } 63 }
63 } 64 }
64 65
src/js/controller.js
1 angular.module('focaModalResumenCuenta') 1 angular.module('focaModalResumenCuenta')
2 .controller('focaModalResumenCuentaController', [ 2 .controller('focaModalResumenCuentaController', [
3 '$timeout', 3 '$timeout',
4 '$filter', 4 '$filter',
5 '$scope', 5 '$scope',
6 '$uibModalInstance', 6 '$uibModalInstance',
7 'focaModalResumenCuentaService', 7 'focaModalResumenCuentaService',
8 'cliente', 8 'cliente',
9 '$uibModal', 9 '$uibModal',
10 'focaModalService', 10 'focaModalService',
11 function($timeout, $filter, $scope, $uibModalInstance, 11 function ($timeout, $filter, $scope, $uibModalInstance,
12 focaModalResumenCuentaService, cliente, $uibModal, focaModalService) { 12 focaModalResumenCuentaService, cliente, $uibModal, focaModalService) {
13 var fecha = new Date(); 13 var fecha = new Date();
14 $scope.generado = false; 14 $scope.generado = false;
15 $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); 15 $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1));
16 $scope.currentPageFacturas = []; 16 $scope.currentPageFacturas = [];
17 $scope.currentPage = 1; 17 $scope.currentPage = 1;
18 $scope.numPerPage = 10; 18 $scope.numPerPage = 10;
19 $scope.selectedFactura = -1; 19 $scope.selectedFactura = -1;
20 20
21 $scope.generar = function() { 21 $scope.generar = function () {
22 focaModalResumenCuentaService 22 focaModalResumenCuentaService
23 .getResumenCuenta(cliente.COD, $scope.fechaDesde) 23 .getResumenCuenta(cliente.COD, $scope.fechaDesde)
24 .then(function(res) { 24 .then(function (res) {
25 res.data.facturas = calcularSaldos(res.data.facturas); 25 res.data.facturas = res.data.facturas.filter(function(factura){
26 return factura.TCO !== "RC" && factura.TCO !== "RE"
27 })
28 res.data.facturas = calcularSaldos(res.data.facturas);
26 $scope.generado = true; 29 $scope.generado = true;
27 $scope.results = res.data; 30 $scope.results = res.data;
28 $scope.results.fechaDesde = $scope.fechaDesde; 31 $scope.results.fechaDesde = $scope.fechaDesde;
29 $scope.search(); 32 $scope.search();
30 }); 33 });
31 }; 34 };
32 35
33 $scope.cancel = function() { 36 $scope.cancel = function () {
34 if ($scope.generado) { 37 if ($scope.generado) {
35 $scope.generado = false; 38 $scope.generado = false;
36 } else { 39 } else {
37 $uibModalInstance.dismiss('cancel'); 40 $uibModalInstance.dismiss('cancel');
38 } 41 }
39 }; 42 };
40 43
41 $scope.enviarMail = function(factura) { 44 $scope.enviarMail = function (factura) {
42 focaModalService.mail( 45 focaModalService.mail(
43 { 46 {
44 titulo: 'Enviar comprobante', 47 titulo: 'Enviar comprobante',
45 descarga: { 48 descarga: {
46 nombre: factura.numeroFactura + '.pdf', 49 nombre: factura.numeroFactura + '.pdf',
47 url: '/mail/comprobante/descargar', 50 url: '/mail/comprobante/descargar',
48 }, 51 },
49 envio: { 52 envio: {
50 mailCliente: cliente.MAIL, 53 mailCliente: cliente.MAIL,
51 url: '/mail/comprobante' 54 url: '/mail/comprobante'
52 }, 55 },
53 options: { 56 options: {
54 factura: factura 57 factura: factura
55 } 58 }
56 } 59 }
57 ); 60 );
58 }; 61 };
59 62
60 $scope.enviarResumen = function() { 63 $scope.enviarResumen = function () {
61 focaModalService.mail( 64 focaModalService.mail(
62 { 65 {
63 titulo: 'Enviar resumen de cuenta', 66 titulo: 'Enviar resumen de cuenta',
64 descarga: { 67 descarga: {
65 nombre: 'resumen-de-cuenta.pdf', 68 nombre: 'resumen-de-cuenta.pdf',
66 url: '/mail/resumen-cuenta/descargar', 69 url: '/mail/resumen-cuenta/descargar',
67 }, 70 },
68 envio: { 71 envio: {
69 mailCliente: cliente.MAIL, 72 mailCliente: cliente.MAIL,
70 url: '/mail/resumen-cuenta', 73 url: '/mail/resumen-cuenta',
71 }, 74 },
72 options: { 75 options: {
73 resumen: $scope.results 76 resumen: $scope.results
74 } 77 }
75 } 78 }
76 ); 79 );
77 }; 80 };
78 81
79 $scope.verFactura = function(factura) { 82 $scope.verFactura = function (factura) {
80 var modalInstance = $uibModal.open( 83 var modalInstance = $uibModal.open(
81 { 84 {
82 ariaLabelledBy: 'Detalle de factura', 85 ariaLabelledBy: 'Detalle de factura',
83 templateUrl: 'foca-modal-factura-detalle.html', 86 templateUrl: 'foca-modal-factura-detalle.html',
84 controller: 'focaModalFacturaDetalleController', 87 controller: 'focaModalFacturaDetalleController',
85 size: 'md', 88 size: 'md',
86 resolve: { 89 resolve: {
87 factura: factura 90 factura: factura
88 } 91 }
89 } 92 }
90 ); 93 );
91 modalInstance.result.then(); 94 modalInstance.result.then();
92 }; 95 };
93 96
94 97
95 $scope.search = function() { 98 $scope.search = function () {
96 if ($scope.results.facturas.length) { 99 if ($scope.results.facturas.length) {
97 $scope.lastPage = Math.ceil( 100 $scope.lastPage = Math.ceil(
98 $scope.results.facturas.length / $scope.numPerPage 101 $scope.results.facturas.length / $scope.numPerPage
99 ); 102 );
100 $scope.resetPage(); 103 $scope.resetPage();
101 } 104 }
102 }; 105 };
103 106
104 $scope.resetPage = function() { 107 $scope.resetPage = function () {
105 $scope.currentPage = 1; 108 $scope.currentPage = 1;
106 $scope.selectPage(1); 109 $scope.selectPage(1);
107 }; 110 };
108 111
109 $scope.selectPage = function(page) { 112 $scope.selectPage = function (page) {
110 var start = (page - 1) * $scope.numPerPage; 113 var start = (page - 1) * $scope.numPerPage;
111 var end = start + $scope.numPerPage; 114 var end = start + $scope.numPerPage;
112 $scope.paginas = []; 115 $scope.paginas = [];
113 $scope.paginas = calcularPages(page); 116 $scope.paginas = calcularPages(page);
114 $scope.currentPageFacturas = $scope.results.facturas.slice(start, end); 117 $scope.currentPageFacturas = $scope.results.facturas.slice(start, end);
115 $scope.currentPage = page; 118 $scope.currentPage = page;
116 }; 119 };
117 120
118 function calcularPages(paginaActual) { 121 function calcularPages(paginaActual) {
119 var paginas = []; 122 var paginas = [];
120 paginas.push(paginaActual); 123 paginas.push(paginaActual);
121 124
122 if (paginaActual - 1 > 1) { 125 if (paginaActual - 1 > 1) {
123 126
124 paginas.unshift(paginaActual - 1); 127 paginas.unshift(paginaActual - 1);
125 if (paginaActual - 2 > 1) { 128 if (paginaActual - 2 > 1) {
126 paginas.unshift(paginaActual - 2); 129 paginas.unshift(paginaActual - 2);
127 } 130 }
128 } 131 }
129 132
130 if (paginaActual + 1 < $scope.lastPage) { 133 if (paginaActual + 1 < $scope.lastPage) {
131 paginas.push(paginaActual + 1); 134 paginas.push(paginaActual + 1);
132 if (paginaActual + 2 < $scope.lastPage) { 135 if (paginaActual + 2 < $scope.lastPage) {
133 paginas.push(paginaActual + 2); 136 paginas.push(paginaActual + 2);
134 } 137 }
135 } 138 }
136 139
137 if (paginaActual !== 1) { 140 if (paginaActual !== 1) {
138 paginas.unshift(1); 141 paginas.unshift(1);
139 } 142 }
140 143
141 if (paginaActual !== $scope.lastPage) { 144 if (paginaActual !== $scope.lastPage) {
142 paginas.push($scope.lastPage); 145 paginas.push($scope.lastPage);
143 } 146 }
144 147
145 return paginas; 148 return paginas;
146 } 149 }
147 150
148 function calcularSaldos(facturas) { 151 function calcularSaldos(facturas) {
149 var saldo = 0; 152 var saldo = 0;
150 153
151 facturas.forEach(function(factura) { 154 facturas.forEach(function (factura) {
152 if (factura.TCO === 'CI' || 155 if (factura.TCO === 'CI' ||
153 factura.TCO === 'FT' || 156 factura.TCO === 'FT' ||
154 factura.TCO === 'ND'){ 157 factura.TCO === 'ND') {
155 factura.IPA = factura.IPA * -1; 158 factura.IPA = factura.IPA * -1;
156 } else { 159 } else {
157 factura.IPA = factura.IPA; 160 factura.IPA = factura.IPA;
158 } 161 }
159 saldo += factura.IPA; 162 saldo += factura.IPA;
160 factura.saldo = saldo; 163 factura.saldo = saldo;
161 factura.saldo_show = Math.abs(saldo); 164 factura.saldo_show = Math.abs(saldo);
162 factura.IPA_SHOW = Math.abs(factura.IPA); 165 factura.IPA_SHOW = Math.abs(factura.IPA);
163 }); 166 });
164 167
165 return facturas; 168 return facturas;
166 } 169 }
167 }] 170 }]
168 ); 171 );
169 172
src/views/modal-resumen-cuenta.html
1 <div class="modal-header py-1"> 1 <div class="modal-header py-1">
2 <div class="row w-100"> 2 <div class="row w-100">
3 <div class="col-lg-6"> 3 <div class="col-lg-6">
4 <h5 class="modal-title my-1">Resumen de cuenta</h5> 4 <h5 class="modal-title my-1">Resumen de cuenta</h5>
5 </div> 5 </div>
6 <div class="col-lg-6 text-right" ng-show="generado"> 6 <div class="col-lg-6 text-right" ng-show="generado">
7 <h6 class="modal-title my-1">Saldo hasta la fecha: {{results.saldo | number: 2}}</h6> 7 <h6 class="modal-title my-1">Saldo hasta la fecha: {{results.saldo | number: 2}}</h6>
8 </div> 8 </div>
9 </div> 9 </div>
10 </div> 10 </div>
11 <div class="modal-body" id="modal-body"> 11 <div class="modal-body" id="modal-body">
12 <div class="input-group row" 12 <div class="input-group row"
13 ng-hide="generado"> 13 ng-hide="generado">
14 <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small> 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 <div class="input-group-prepend"> 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 <i class="fa fa-calendar"></i> 21 <i class="fa fa-calendar"></i>
19 </div> 22 </button>
20 </div> 23 </div>
21 <input 24 <input
22 class="form-control form-control-sm" 25 class="form-control form-control-sm"
23 id="inlineFormInputGroup" 26 id="inlineFormInputGroup"
24 ladda="searchLoading" 27 ladda="searchLoading"
25 type="text" 28 type="text"
26 ng-model="fechaDesde" 29 ng-model="fechaDesde"
27 ng-required="true" 30 ng-required="true"
28 uib-datepicker-popup="dd/MM/yyyy" 31 uib-datepicker-popup="dd/MM/yyyy"
29 show-button-bar="false" 32 show-button-bar="false"
30 is-open="datepickerOpen" 33 is-open="datepickerOpen"
31 on-open-focus="false" 34 on-open-focus="false"
32 ng-focus="datepickerOpen = true" 35 ng-focus="datepickerOpen = true"
33 /> 36 />
34 </div> 37 </div>
35 </div> 38 </div>
36 <table class="table table-striped table-sm" ng-show="generado"> 39 <table class="table table-striped table-sm" ng-show="generado">
37 <thead> 40 <thead>
38 <tr> 41 <tr>
39 <th>Comprobante</th> 42 <th>Comprobante</th>
40 <th>Vencimiento</th> 43 <th>Vencimiento</th>
41 <th class="text-right">Importe</th> 44 <th class="text-right">Importe</th>
42 <th class="text-right">Saldo</th> 45 <th class="text-right">Saldo</th>
43 <th class="text-right"></th> 46 <th class="text-right"></th>
44 <th class="text-right"></th> 47 <th class="text-right"></th>
45 </tr> 48 </tr>
46 </thead> 49 </thead>
47 <tbody> 50 <tbody>
48 <tr class="selectable" 51 <tr class="selectable"
49 ng-repeat="(key, factura) in currentPageFacturas"> 52 ng-repeat="(key, factura) in currentPageFacturas">
50 <td>{{factura.numeroFactura}} {{factura.FECHA_COMPROBANTE | date : 'dd/MM/yyyy' : 'GMT'}}</td> 53 <td>{{factura.numeroFactura}} {{factura.FECHA_COMPROBANTE | date : 'dd/MM/yyyy' : 'GMT'}}</td>
51 <td>{{(factura.TCO == 'FT') ? factura.NCU + ' - ' : ''}}{{factura.FEV | date : 'dd/MM/yyyy' : 'GMT'}}</td> 54 <td>{{(factura.TCO == 'FT') ? factura.NCU + ' - ' : ''}}{{factura.FEV | date : 'dd/MM/yyyy' : 'GMT'}}</td>
52 <td class="text-right"> 55 <td class="text-right">
53 {{ factura.IPA_SHOW | number:2 }} 56 {{ factura.IPA_SHOW | number:2 }}
54 <span ng-class="{'invisible': factura.IPA >= 0}">-</span> 57 <span ng-class="{'invisible': factura.IPA >= 0}">-</span>
55 </td> 58 </td>
56 <td class="text-right"> 59 <td class="text-right">
57 {{ factura.saldo_show | number:2 }} 60 {{ factura.saldo_show | number:2 }}
58 <span ng-class="{'invisible': factura.saldo >= 0}">-</span> 61 <span ng-class="{'invisible': factura.saldo >= 0}">-</span>
59 </td> 62 </td>
60 <td> 63 <td>
61 <button 64 <button
62 class="btn p-1" 65 class="btn p-1"
63 ng-click="verFactura(factura)" 66 ng-click="verFactura(factura)"
64 title="Ver comprobante" 67 title="Ver comprobante"
65 > 68 >
66 <i class="fa fa-eye" aria-hidden="true"></i> 69 <i class="fa fa-eye" aria-hidden="true"></i>
67 </button> 70 </button>
68 </td> 71 </td>
69 <td> 72 <td>
70 <button 73 <button
71 class="btn p-1" 74 class="btn p-1"
72 ng-click="enviarMail(factura)" 75 ng-click="enviarMail(factura)"
73 title="Enviar comprobante por mail" 76 title="Enviar comprobante por mail"
74 > 77 >
75 <i class="fa fa-envelope-o" aria-hidden="true"></i> 78 <i class="fa fa-envelope-o" aria-hidden="true"></i>
76 </button> 79 </button>
77 </td> 80 </td>
78 </tr> 81 </tr>
79 </tbody> 82 </tbody>
80 </table> 83 </table>
81 </div> 84 </div>
82 <div class="modal-footer py-1"> 85 <div class="modal-footer py-1">
83 <nav ng-show="currentPageFacturas.length" class="mr-auto"> 86 <nav ng-show="currentPageFacturas.length" class="mr-auto">
84 <ul class="pagination pagination-sm justify-content mb-0"> 87 <ul class="pagination pagination-sm justify-content mb-0">
85 <li class="page-item" ng-class="{'disabled': currentPage == 1}"> 88 <li class="page-item" ng-class="{'disabled': currentPage == 1}">
86 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)"> 89 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)">
87 <span aria-hidden="true">&laquo;</span> 90 <span aria-hidden="true">&laquo;</span>
88 <span class="sr-only">Anterior</span> 91 <span class="sr-only">Anterior</span>
89 </a> 92 </a>
90 </li> 93 </li>
91 <li 94 <li
92 class="page-item" 95 class="page-item"
93 ng-repeat="pagina in paginas" 96 ng-repeat="pagina in paginas"
94 ng-class="{'active': pagina == currentPage}" 97 ng-class="{'active': pagina == currentPage}"
95 > 98 >
96 <a 99 <a
97 class="page-link" 100 class="page-link"
98 href="javascript:void();" 101 href="javascript:void();"
99 ng-click="selectPage(pagina)" 102 ng-click="selectPage(pagina)"
100 ng-bind="pagina" 103 ng-bind="pagina"
101 ></a> 104 ></a>
102 </li> 105 </li>
103 <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> 106 <li class="page-item" ng-class="{'disabled': currentPage == lastPage}">
104 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)"> 107 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)">
105 <span aria-hidden="true">&raquo;</span> 108 <span aria-hidden="true">&raquo;</span>
106 <span class="sr-only">Siguiente</span> 109 <span class="sr-only">Siguiente</span>
107 </a> 110 </a>
108 </li> 111 </li>
109 </ul> 112 </ul>
110 </nav> 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 <button class="btn btn-sm btn-primary my-1" type="button" ng-click="enviarResumen()" ng-show="generado">Enviar</button> 115 <button class="btn btn-sm btn-primary my-1" type="button" ng-click="enviarResumen()" ng-show="generado">Enviar</button>
113 <button class="btn btn-sm btn-secondary my-1" type="button" ng-click="cancel()">Cancelar</button> 116 <button class="btn btn-sm btn-secondary my-1" type="button" ng-click="cancel()">Cancelar</button>
114 </div> 117 </div>
115 118