Commit a60243a481852254a13c9072d9233629dca8e09d

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

recibo parametros para mostrar divisas

src/js/controller.js
1 angular.module('focaModalFactura') 1 angular.module('focaModalFactura')
2 .controller('focaModalFacturaController', 2 .controller('focaModalFacturaController',
3 [ 3 [
4 '$filter', 4 '$filter',
5 '$scope', 5 '$scope',
6 '$uibModalInstance', 6 '$uibModalInstance',
7 'focaModalFacturaService', 7 'focaModalFacturaService',
8 'cliente', 8 'parametrosFactura',
9 function($filter, $scope, $uibModalInstance, 9 function($filter, $scope, $uibModalInstance,
10 focaModalFacturaService, cliente 10 focaModalFacturaService, parametrosFactura
11 ) { 11 ) {
12 var fecha = new Date(); 12 var fecha = new Date();
13 $scope.fechaHasta = new Date(); 13 $scope.fechaHasta = new Date();
14 $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); 14 $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1));
15 $scope.filters = ''; 15 $scope.filters = '';
16 $scope.facturas = []; 16 $scope.facturas = [];
17 $scope.primerBusqueda = false; 17 $scope.primerBusqueda = false;
18 $scope.searchLoading = false; 18 $scope.searchLoading = false;
19 $scope.parametrosFactura = parametrosFactura;
19 // pagination 20 // pagination
20 $scope.numPerPage = 10; 21 $scope.numPerPage = 10;
21 $scope.currentPage = 1; 22 $scope.currentPage = 1;
22 $scope.filteredFacturas = []; 23 $scope.filteredFacturas = [];
23 $scope.currentPageFacturas = []; 24 $scope.currentPageFacturas = [];
24 $scope.selectedFactura = -1; 25 $scope.selectedFactura = -1;
25 26
26 //METODOS 27 //METODOS
27 $scope.busquedaPress = function(key) { 28 $scope.busquedaPress = function(key) {
28 if (key === 13) { 29 if (key === 13) {
29 //TODO Validaciones con alertas 30 //TODO Validaciones con alertas
30 if(!$scope.fechaDesde) { 31 if(!$scope.fechaDesde) {
31 alert('INGRESE FECHA DESDE'); 32 alert('INGRESE FECHA DESDE');
32 return; 33 return;
33 } 34 }
34 if(!$scope.fechaHasta) { 35 if(!$scope.fechaHasta) {
35 alert('INGRESE FECHA HASTA'); 36 alert('INGRESE FECHA HASTA');
36 return; 37 return;
37 } 38 }
38 if($scope.fechaDesde > $scope.fechaHasta) { 39 if($scope.fechaDesde > $scope.fechaHasta) {
39 alert('La fecha desde no puede ser mayor a la fecha hasta'); 40 alert('La fecha desde no puede ser mayor a la fecha hasta');
40 return; 41 return;
41 } 42 }
42 $scope.searchLoading = true; 43 $scope.searchLoading = true;
43 //TODO hacer filtro de fecha 44 //TODO hacer filtro de fecha
44 focaModalFacturaService 45 focaModalFacturaService
45 .getFacturasByIdCliente(cliente, $scope.fechaDesde 46 .getFacturasByIdCliente(parametrosFactura.cliente, $scope.fechaDesde
46 .toISOString().split('.')[0], 47 .toISOString().split('.')[0],
47 $scope.fechaHasta.toISOString().split('.')[0]) 48 $scope.fechaHasta.toISOString().split('.')[0])
48 .then(llenarDatos); 49 .then(llenarDatos);
49 } 50 }
50 }; 51 };
51 52
52 $scope.aceptar = function() { 53 $scope.aceptar = function() {
53 var result = $scope.facturas.filter(function(a) {return a.checked === true;}); 54 var result = $scope.facturas.filter(function(a) {return a.checked === true;});
54 $uibModalInstance.close(result); 55 $uibModalInstance.close(result);
55 }; 56 };
56 57
57 $scope.tieneAlMenosUno = function() { 58 $scope.tieneAlMenosUno = function() {
58 var result = $scope.facturas.filter(function(a) {return a.checked === true;}); 59 var result = $scope.facturas.filter(function(a) {return a.checked === true;});
59 return !result.length; 60 return !result.length;
60 }; 61 };
61 62
62 function llenarDatos(res) { 63 function llenarDatos(res) {
63 $scope.facturas = []; 64 $scope.facturas = [];
64 $scope.filteredFacturas = []; 65 $scope.filteredFacturas = [];
65 $scope.currentPageFacturas = []; 66 $scope.currentPageFacturas = [];
66 $scope.selectedFactura = -1; 67 $scope.selectedFactura = -1;
67 $scope.searchLoading = false; 68 $scope.searchLoading = false;
68 $scope.primerBusqueda = true; 69 $scope.primerBusqueda = true;
69 $scope.facturas = res.data; 70 $scope.facturas = res.data;
70 $scope.search(); 71 $scope.search();
71 primera(); 72 primera();
72 } 73 }
73 $scope.search = function() { 74 $scope.search = function() {
74 if($scope.facturas.length > 0) { 75 if($scope.facturas.length > 0) {
75 $scope.filteredFacturas = $filter('filter')( 76 $scope.filteredFacturas = $filter('filter')(
76 $scope.facturas, 77 $scope.facturas,
77 {$: $scope.filters} 78 {$: $scope.filters}
78 ); 79 );
79 80
80 $scope.lastPage = Math.ceil( 81 $scope.lastPage = Math.ceil(
81 $scope.filteredFacturas.length / $scope.numPerPage 82 $scope.filteredFacturas.length / $scope.numPerPage
82 ); 83 );
83 84
84 $scope.resetPage(); 85 $scope.resetPage();
85 } 86 }
86 }; 87 };
87 88
88 $scope.resetPage = function() { 89 $scope.resetPage = function() {
89 $scope.currentPage = 1; 90 $scope.currentPage = 1;
90 $scope.selectPage(1); 91 $scope.selectPage(1);
91 }; 92 };
92 93
93 $scope.selectPage = function(page) { 94 $scope.selectPage = function(page) {
94 var start = (page - 1) * $scope.numPerPage; 95 var start = (page - 1) * $scope.numPerPage;
95 var end = start + $scope.numPerPage; 96 var end = start + $scope.numPerPage;
96 $scope.paginas = []; 97 $scope.paginas = [];
97 $scope.paginas = calcularPages(page); 98 $scope.paginas = calcularPages(page);
98 $scope.currentPageFacturas = $scope.filteredFacturas.slice(start, end); 99 $scope.currentPageFacturas = $scope.filteredFacturas.slice(start, end);
99 $scope.currentPage = page; 100 $scope.currentPage = page;
100 }; 101 };
101 102
102 $scope.cancel = function() { 103 $scope.cancel = function() {
103 $uibModalInstance.dismiss('cancel'); 104 $uibModalInstance.dismiss('cancel');
104 }; 105 };
105 106
106 $scope.busquedaDown = function(key) { 107 $scope.busquedaDown = function(key) {
107 if (key === 40) { 108 if (key === 40) {
108 primera(key); 109 primera(key);
109 } 110 }
110 }; 111 };
111 112
112 $scope.itemFactura = function(key) { 113 $scope.itemFactura = function(key) {
113 if (key === 38) { 114 if (key === 38) {
114 anterior(key); 115 anterior(key);
115 } 116 }
116 117
117 if (key === 40) { 118 if (key === 40) {
118 siguiente(key); 119 siguiente(key);
119 } 120 }
120 121
121 if (key === 37) { 122 if (key === 37) {
122 retrocederPagina(); 123 retrocederPagina();
123 } 124 }
124 125
125 if (key === 39) { 126 if (key === 39) {
126 avanzarPagina(); 127 avanzarPagina();
127 } 128 }
128 }; 129 };
129 130
130 function calcularPages(paginaActual) { 131 function calcularPages(paginaActual) {
131 var paginas = []; 132 var paginas = [];
132 paginas.push(paginaActual); 133 paginas.push(paginaActual);
133 134
134 if (paginaActual - 1 > 1) { 135 if (paginaActual - 1 > 1) {
135 136
136 paginas.unshift(paginaActual - 1); 137 paginas.unshift(paginaActual - 1);
137 if (paginaActual - 2 > 1) { 138 if (paginaActual - 2 > 1) {
138 paginas.unshift(paginaActual - 2); 139 paginas.unshift(paginaActual - 2);
139 } 140 }
140 } 141 }
141 142
142 if (paginaActual + 1 < $scope.lastPage) { 143 if (paginaActual + 1 < $scope.lastPage) {
143 paginas.push(paginaActual + 1); 144 paginas.push(paginaActual + 1);
144 if (paginaActual + 2 < $scope.lastPage) { 145 if (paginaActual + 2 < $scope.lastPage) {
145 paginas.push(paginaActual + 2); 146 paginas.push(paginaActual + 2);
146 } 147 }
147 } 148 }
148 149
149 if (paginaActual !== 1) { 150 if (paginaActual !== 1) {
150 paginas.unshift(1); 151 paginas.unshift(1);
151 } 152 }
152 153
153 if (paginaActual !== $scope.lastPage) { 154 if (paginaActual !== $scope.lastPage) {
154 paginas.push($scope.lastPage); 155 paginas.push($scope.lastPage);
155 } 156 }
156 157
157 return paginas; 158 return paginas;
158 } 159 }
159 160
160 function primera() { 161 function primera() {
161 $scope.selectedFactura = 0; 162 $scope.selectedFactura = 0;
162 } 163 }
163 164
164 function anterior() { 165 function anterior() {
165 if ($scope.selectedFactura === 0 && $scope.currentPage > 1) { 166 if ($scope.selectedFactura === 0 && $scope.currentPage > 1) {
166 retrocederPagina(); 167 retrocederPagina();
167 } else { 168 } else {
168 $scope.selectedFactura--; 169 $scope.selectedFactura--;
169 } 170 }
170 } 171 }
171 172
172 function siguiente() { 173 function siguiente() {
173 if ($scope.selectedFactura < $scope.currentPageFacturas.length - 1 ) { 174 if ($scope.selectedFactura < $scope.currentPageFacturas.length - 1 ) {
174 $scope.selectedFactura++; 175 $scope.selectedFactura++;
175 } else { 176 } else {
176 avanzarPagina(); 177 avanzarPagina();
177 } 178 }
178 } 179 }
179 180
180 function retrocederPagina() { 181 function retrocederPagina() {
181 if ($scope.currentPage > 1) { 182 if ($scope.currentPage > 1) {
182 $scope.selectPage($scope.currentPage - 1); 183 $scope.selectPage($scope.currentPage - 1);
183 $scope.selectedFactura = $scope.numPerPage - 1; 184 $scope.selectedFactura = $scope.numPerPage - 1;
184 } 185 }
185 } 186 }
186 187
187 function avanzarPagina() { 188 function avanzarPagina() {
188 if ($scope.currentPage < $scope.lastPage) { 189 if ($scope.currentPage < $scope.lastPage) {
189 $scope.selectPage($scope.currentPage + 1); 190 $scope.selectPage($scope.currentPage + 1);
190 $scope.selectedFactura = 0; 191 $scope.selectedFactura = 0;
191 } 192 }
192 } 193 }
193 } 194 }
194 ] 195 ]
195 ); 196 );
196 197
src/views/foca-modal-factura.html
1 <div class="modal-header py-1"> 1 <div class="modal-header py-1">
2 <h5 class="modal-title">Busqueda de Facturas</h5> 2 <h5 class="modal-title">Busqueda de Facturas</h5>
3 </div> 3 </div>
4 <div class="modal-body" id="modal-body"> 4 <div class="modal-body" id="modal-body">
5 <div class="input-group row"> 5 <div class="input-group row">
6 <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small> 6 <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small>
7 <div class="col-md-4 col-8 input-group mb-2"> 7 <div class="col-md-4 col-8 input-group mb-2">
8 <div class="input-group-prepend"> 8 <div class="input-group-prepend">
9 <div class="input-group-text form-control-sm"> 9 <div class="input-group-text form-control-sm">
10 <i class="fa fa-calendar"></i> 10 <i class="fa fa-calendar"></i>
11 </div> 11 </div>
12 </div> 12 </div>
13 <input 13 <input
14 class="form-control form-control-sm" 14 class="form-control form-control-sm"
15 id="inlineFormInputGroup" 15 id="inlineFormInputGroup"
16 ladda="searchLoading" 16 ladda="searchLoading"
17 type="date" 17 type="date"
18 ng-model="fechaDesde" 18 ng-model="fechaDesde"
19 hasta-hoy 19 hasta-hoy
20 ng-required="true" 20 ng-required="true"
21 /> 21 />
22 </div> 22 </div>
23 <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small> 23 <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small>
24 <div class="col-md-4 col-8 input-group mb-2"> 24 <div class="col-md-4 col-8 input-group mb-2">
25 <div class="input-group-prepend"> 25 <div class="input-group-prepend">
26 <div class="input-group-text form-control-sm"> 26 <div class="input-group-text form-control-sm">
27 <i class="fa fa-calendar"></i> 27 <i class="fa fa-calendar"></i>
28 </div> 28 </div>
29 </div> 29 </div>
30 <input 30 <input
31 class="form-control form-control-sm" 31 class="form-control form-control-sm"
32 id="inlineFormInputGroup" 32 id="inlineFormInputGroup"
33 ladda="searchLoading" 33 ladda="searchLoading"
34 type="date" 34 type="date"
35 ng-model="fechaHasta" 35 ng-model="fechaHasta"
36 ng-required="true" 36 ng-required="true"
37 hasta-hoy 37 hasta-hoy
38 /> 38 />
39 </div> 39 </div>
40 </div> 40 </div>
41 <div class="input-group"> 41 <div class="input-group">
42 <input 42 <input
43 ladda="searchLoading" 43 ladda="searchLoading"
44 type="text" 44 type="text"
45 class="form-control form-control-sm" 45 class="form-control form-control-sm"
46 placeholder="Busqueda" 46 placeholder="Busqueda"
47 ng-model="filters" 47 ng-model="filters"
48 ng-change="search()" 48 ng-change="search()"
49 ng-keydown="busquedaDown($event.keyCode)" 49 ng-keydown="busquedaDown($event.keyCode)"
50 ng-keypress="busquedaPress($event.keyCode)" 50 ng-keypress="busquedaPress($event.keyCode)"
51 foca-focus="selectedFactura == -1" 51 foca-focus="selectedFactura == -1"
52 ng-focus="selectedFactura = -1" 52 ng-focus="selectedFactura = -1"
53 teclado-virtual 53 teclado-virtual
54 /> 54 />
55 <div class="input-group-append"> 55 <div class="input-group-append">
56 <button 56 <button
57 ladda="searchLoading" 57 ladda="searchLoading"
58 class="btn btn-outline-secondary" 58 class="btn btn-outline-secondary"
59 type="button" 59 type="button"
60 ng-click="busquedaPress(13)" 60 ng-click="busquedaPress(13)"
61 > 61 >
62 <i class="fa fa-search" aria-hidden="true"></i> 62 <i class="fa fa-search" aria-hidden="true"></i>
63 </button> 63 </button>
64 </div> 64 </div>
65 </div> 65 </div>
66 <table ng-show="primerBusqueda" class="table table-striped table-sm"> 66 <table ng-show="primerBusqueda" class="table table-striped table-sm">
67 <thead> 67 <thead>
68 <tr> 68 <tr>
69 <th>Cliente</th> 69 <th>Cliente</th>
70 <th>Fecha</th> 70 <th>Fecha</th>
71 <th>Nro</th> 71 <th>Nro</th>
72 <th>Importe</th> 72 <th>Importe</th>
73 <th></th> 73 <th></th>
74 </tr> 74 </tr>
75 </thead> 75 </thead>
76 <tbody> 76 <tbody>
77 <tr ng-show="currentPageFacturas.length == 0 && primerBusqueda"> 77 <tr ng-show="currentPageFacturas.length == 0 && primerBusqueda">
78 <td colspan="5"> 78 <td colspan="5">
79 No se encontraron resultados. 79 No se encontraron resultados.
80 </td> 80 </td>
81 </tr> 81 </tr>
82 <tr class="selectable" 82 <tr class="selectable"
83 ng-repeat="(key,factura) in currentPageFacturas"> 83 ng-repeat="(key,factura) in currentPageFacturas">
84 <td ng-bind="factura.cliente.NOM"></td> 84 <td ng-bind="factura.cliente.NOM"></td>
85 <td ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td> 85 <td ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td>
86 <td ng-bind= 86 <td ng-bind=
87 "(factura.TCO + '-' + factura.TIP + '-' + factura.SUC + '-' + factura.NCO)"> 87 "(factura.TCO + '-' + factura.TIP + '-' + factura.SUC + '-' + factura.NCO)">
88 </td> 88 </td>
89 <td class="text-right" ng-bind="factura.IPA | currency:'$'"></td> 89 <td
90 class="text-right"
91 ng-bind="(factura.IPA / parametrosFactura.cotizacion) |
92 currency: parametrosFactura.simbolo"></td>
90 <td><input 93 <td><input
91 ng-class="{ 94 ng-class="{
92 'btn-secondary': selectedFactura != key, 95 'btn-secondary': selectedFactura != key,
93 'btn-primary': selectedFactura == key}" 96 'btn-primary': selectedFactura == key}"
94 ng-keydown="itemFactura($event.keyCode)" 97 ng-keydown="itemFactura($event.keyCode)"
95 foca-focus="selectedFactura == {{key}}" 98 foca-focus="selectedFactura == {{key}}"
96 type="checkbox" 99 type="checkbox"
97 ng-model="factura.checked"/> 100 ng-model="factura.checked"/>
98 </td> 101 </td>
99 </tr> 102 </tr>
100 </tbody> 103 </tbody>
101 </table> 104 </table>
102 <nav ng-show="currentPageFacturas.length > 0 && primerBusqueda"> 105 <nav ng-show="currentPageFacturas.length > 0 && primerBusqueda">
103 <ul class="pagination pagination-sm justify-content mb-0"> 106 <ul class="pagination pagination-sm justify-content mb-0">
104 <li class="page-item" ng-class="{'disabled': currentPage == 1}"> 107 <li class="page-item" ng-class="{'disabled': currentPage == 1}">
105 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)"> 108 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)">
106 <span aria-hidden="true">&laquo;</span> 109 <span aria-hidden="true">&laquo;</span>
107 <span class="sr-only">Anterior</span> 110 <span class="sr-only">Anterior</span>
108 </a> 111 </a>
109 </li> 112 </li>
110 <li 113 <li
111 class="page-item" 114 class="page-item"
112 ng-repeat="pagina in paginas" 115 ng-repeat="pagina in paginas"
113 ng-class="{'active': pagina == currentPage}" 116 ng-class="{'active': pagina == currentPage}"
114 > 117 >
115 <a 118 <a
116 class="page-link" 119 class="page-link"
117 href="javascript:void();" 120 href="javascript:void();"
118 ng-click="selectPage(pagina)" 121 ng-click="selectPage(pagina)"
119 ng-bind="pagina" 122 ng-bind="pagina"
120 ></a> 123 ></a>
121 </li> 124 </li>
122 <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> 125 <li class="page-item" ng-class="{'disabled': currentPage == lastPage}">
123 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)"> 126 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)">
124 <span aria-hidden="true">&raquo;</span> 127 <span aria-hidden="true">&raquo;</span>
125 <span class="sr-only">Siguiente</span> 128 <span class="sr-only">Siguiente</span>
126 </a> 129 </a>
127 </li> 130 </li>
128 </ul> 131 </ul>
129 </nav> 132 </nav>
130 </div> 133 </div>
131 <div class="modal-footer py-1"> 134 <div class="modal-footer py-1">
132 <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> 135 <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button>
133 <button 136 <button
134 class="btn btn-sm btn-primary" 137 class="btn btn-sm btn-primary"
135 type="button" 138 type="button"
136 ng-click="aceptar()" 139 ng-click="aceptar()"
137 ng-disabled="tieneAlMenosUno()" 140 ng-disabled="tieneAlMenosUno()"
138 >Aceptar</button> 141 >Aceptar</button>
139 </div> 142 </div>
140 143