Commit 8f31709ebd96a2623acd4b97a862b23585aad438
1 parent
53321f9708
Exists in
master
and in
1 other branch
Arreglo para setear en el input de busqueda un cliente en caso de anteriormente …
…haber elegido alguno.
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaBusquedaCliente') | 1 | angular.module('focaBusquedaCliente') |
2 | .controller('focaBusquedaClienteModalController', [ | 2 | .controller('focaBusquedaClienteModalController', [ |
3 | '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', | 3 | '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', |
4 | '$uibModal', 'focaModalService', '$timeout', '$rootScope', 'vendedor', 'cobrador', | 4 | '$uibModal', 'focaModalService', '$timeout', '$rootScope', |
5 | 'vendedor', 'cobrador', 'searchText', | ||
5 | function ($uibModalInstance, focaBusquedaClienteService, $scope, $filter, | 6 | function ($uibModalInstance, focaBusquedaClienteService, $scope, $filter, |
6 | $uibModal, focaModalService, $timeout, $rootScope, vendedor, cobrador) { | 7 | $uibModal, focaModalService, $timeout, $rootScope, |
8 | vendedor, cobrador, searchText) { | ||
7 | 9 | ||
8 | $scope.cobrador = cobrador ? cobrador : {}; | 10 | $scope.cobrador = cobrador ? cobrador : {}; |
9 | $scope.vendedor = vendedor ? vendedor : {}; | 11 | $scope.vendedor = vendedor ? vendedor : {}; |
10 | $scope.filters = ''; | 12 | $scope.filters = searchText; |
11 | $scope.primerBusqueda = false; | 13 | $scope.primerBusqueda = false; |
12 | 14 | ||
13 | //#region pagination | 15 | //#region pagination |
14 | $scope.numPerPage = 10; | 16 | $scope.numPerPage = 10; |
15 | $scope.currentPage = 1; | 17 | $scope.currentPage = 1; |
16 | $scope.filteredClientes = []; | 18 | $scope.filteredClientes = []; |
17 | $scope.currentPageClientes = []; | 19 | $scope.currentPageClientes = []; |
18 | $scope.selectedClientes = -1; | 20 | $scope.selectedClientes = -1; |
19 | $scope.ingreso = false; | 21 | $scope.ingreso = false; |
20 | $scope.accion = ''; | 22 | $scope.accion = ''; |
21 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/); | 23 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/); |
22 | $scope.focused = 1; | 24 | $scope.focused = 1; |
23 | //#endregion | 25 | //#endregion |
24 | 26 | ||
25 | $scope.clienteTemplate = { | 27 | $scope.clienteTemplate = { |
26 | COD: 0, | 28 | COD: 0, |
27 | ES_MAY: true, | 29 | ES_MAY: true, |
28 | cuit1: '', | 30 | cuit1: '', |
29 | cuit2: '', | 31 | cuit2: '', |
30 | cuit3: '', | 32 | cuit3: '', |
31 | provincia: { | 33 | provincia: { |
32 | NOMBRE: '' | 34 | NOMBRE: '' |
33 | }, | 35 | }, |
34 | localidad: { | 36 | localidad: { |
35 | NOMBRE: '' | 37 | NOMBRE: '' |
36 | }, | 38 | }, |
37 | iva: { | 39 | iva: { |
38 | NOMBRE: '' | 40 | NOMBRE: '' |
39 | }, | 41 | }, |
40 | actividad: { | 42 | actividad: { |
41 | NOM: '' | 43 | NOM: '' |
42 | }, | 44 | }, |
43 | zona: { | 45 | zona: { |
44 | NOM: '' | 46 | NOM: '' |
45 | }, | 47 | }, |
46 | tipoFactura: { | 48 | tipoFactura: { |
47 | NOMBRE: '' | 49 | NOMBRE: '' |
48 | }, | 50 | }, |
49 | tipoComprobante: { | 51 | tipoComprobante: { |
50 | NOMBRE: '' | 52 | NOMBRE: '' |
51 | }, | 53 | }, |
52 | formaPago: { | 54 | formaPago: { |
53 | NOMBRE: '' | 55 | NOMBRE: '' |
54 | }, | 56 | }, |
55 | cobrador: { | 57 | cobrador: { |
56 | NOM: '' | 58 | NOM: '' |
57 | } | 59 | } |
58 | }; | 60 | }; |
59 | $scope.cliente = angular.copy($scope.clienteTemplate); | 61 | $scope.cliente = angular.copy($scope.clienteTemplate); |
60 | $scope.busquedaPress = function (key) { | 62 | $scope.busquedaPress = function (key) { |
61 | if (key === 13) { | 63 | if (key === 13) { |
62 | var funcion; | 64 | var funcion; |
63 | if ($scope.vendedor.id) { | 65 | if ($scope.vendedor.id) { |
64 | funcion = 'obtenerClientesPorNombreOCuitByVendedor'; | 66 | funcion = 'obtenerClientesPorNombreOCuitByVendedor'; |
65 | } else if ($scope.cobrador.id) { | 67 | } else if ($scope.cobrador.id) { |
66 | funcion = 'obtenerClientesPorNombreOCuitByCobrador'; | 68 | funcion = 'obtenerClientesPorNombreOCuitByCobrador'; |
67 | } else { | 69 | } else { |
68 | funcion = 'obtenerClientesPorNombreOCuit'; | 70 | funcion = 'obtenerClientesPorNombreOCuit'; |
69 | } | 71 | } |
70 | 72 | ||
71 | $scope.searchLoading = true; | 73 | $scope.searchLoading = true; |
72 | focaBusquedaClienteService | 74 | focaBusquedaClienteService |
73 | [funcion]($scope.filters, $scope.vendedor.id || $scope.cobrador.id) | 75 | [funcion]($scope.filters, $scope.vendedor.id || $scope.cobrador.id) |
74 | .then( | 76 | .then( |
75 | function (res) { | 77 | function (res) { |
76 | $scope.primerBusqueda = true; | 78 | $scope.primerBusqueda = true; |
77 | $scope.clientes = res.data; | 79 | $scope.clientes = res.data; |
78 | $scope.search(true); | 80 | $scope.search(true); |
79 | primera(); | 81 | primera(); |
80 | $scope.searchLoading = false; | 82 | $scope.searchLoading = false; |
81 | }); | 83 | }); |
82 | } | 84 | } |
83 | }; | 85 | }; |
84 | 86 | ||
85 | $scope.search = function (pressed) { | 87 | $scope.search = function (pressed) { |
86 | if ($scope.primerBusqueda) { | 88 | if ($scope.primerBusqueda) { |
87 | $scope.filteredClientes = $filter('filter')( | 89 | $scope.filteredClientes = $filter('filter')( |
88 | $scope.clientes, { $: $scope.filters } | 90 | $scope.clientes, { $: $scope.filters } |
89 | ); | 91 | ); |
90 | 92 | ||
91 | if (pressed && $scope.filteredClientes.length === 0) { | 93 | if (pressed && $scope.filteredClientes.length === 0) { |
92 | $timeout(function () { | 94 | $timeout(function () { |
93 | angular.element('#search')[0].focus(); | 95 | angular.element('#search')[0].focus(); |
94 | $scope.filters = ''; | 96 | $scope.filters = ''; |
95 | }); | 97 | }); |
96 | } | 98 | } |
97 | 99 | ||
98 | $scope.lastPage = Math.ceil( | 100 | $scope.lastPage = Math.ceil( |
99 | $scope.filteredClientes.length / $scope.numPerPage | 101 | $scope.filteredClientes.length / $scope.numPerPage |
100 | ); | 102 | ); |
101 | 103 | ||
102 | $scope.resetPage(); | 104 | $scope.resetPage(); |
103 | } | 105 | } |
104 | }; | 106 | }; |
105 | 107 | ||
106 | $scope.resetPage = function () { | 108 | $scope.resetPage = function () { |
107 | $scope.currentPage = 1; | 109 | $scope.currentPage = 1; |
108 | $scope.selectPage(1); | 110 | $scope.selectPage(1); |
109 | }; | 111 | }; |
110 | 112 | ||
111 | $scope.selectPage = function (page) { | 113 | $scope.selectPage = function (page) { |
112 | var start = (page - 1) * $scope.numPerPage; | 114 | var start = (page - 1) * $scope.numPerPage; |
113 | var end = start + $scope.numPerPage; | 115 | var end = start + $scope.numPerPage; |
114 | $scope.paginas = []; | 116 | $scope.paginas = []; |
115 | $scope.paginas = calcularPages(page); | 117 | $scope.paginas = calcularPages(page); |
116 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); | 118 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); |
117 | $scope.currentPage = page; | 119 | $scope.currentPage = page; |
118 | }; | 120 | }; |
119 | 121 | ||
120 | $scope.select = function (cliente, esNuevo = false) { | 122 | $scope.select = function (cliente, esNuevo = false) { |
121 | cliente.esNuevo = esNuevo; | 123 | cliente.esNuevo = esNuevo; |
122 | $uibModalInstance.close(cliente); | 124 | $uibModalInstance.close(cliente); |
123 | }; | 125 | }; |
124 | 126 | ||
125 | $scope.cancel = function () { | 127 | $scope.cancel = function () { |
126 | if ($scope.ingreso) { | 128 | if ($scope.ingreso) { |
127 | $scope.ingreso = false; | 129 | $scope.ingreso = false; |
128 | } else { | 130 | } else { |
129 | $uibModalInstance.dismiss('cancel'); | 131 | $uibModalInstance.dismiss('cancel'); |
130 | } | 132 | } |
131 | }; | 133 | }; |
132 | 134 | ||
133 | $scope.crearCliente = function () { | 135 | $scope.crearCliente = function () { |
134 | $scope.cliente = angular.copy($scope.clienteTemplate); | 136 | $scope.cliente = angular.copy($scope.clienteTemplate); |
135 | $scope.vendedor.NOM = ''; | 137 | $scope.vendedor.NOM = ''; |
136 | $scope.vendedor.id = undefined; | 138 | $scope.vendedor.id = undefined; |
137 | $scope.cliente.cobrador.NOM = ''; | 139 | $scope.cliente.cobrador.NOM = ''; |
138 | $scope.cliente.cobrador.ID = undefined; | 140 | $scope.cliente.cobrador.ID = undefined; |
139 | $scope.accion = "Crear Cliente"; | 141 | $scope.accion = "Crear Cliente"; |
140 | $scope.ingreso = true; | 142 | $scope.ingreso = true; |
141 | } | 143 | } |
142 | 144 | ||
143 | $scope.openModal = function (cliente) { | 145 | $scope.openModal = function (cliente) { |
144 | focaBusquedaClienteService.obtenerClientePorCodigo(cliente.cod) | 146 | focaBusquedaClienteService.obtenerClientePorCodigo(cliente.cod) |
145 | .then(function (res) { | 147 | .then(function (res) { |
146 | var data = res.data[0]; | 148 | var data = res.data[0]; |
147 | $scope.cliente.codigo = res.data[0].COD; | 149 | $scope.cliente.codigo = res.data[0].COD; |
148 | $scope.cliente.NOM = data.NOM; | 150 | $scope.cliente.NOM = data.NOM; |
149 | $scope.cliente.DOM = data.DOM; | 151 | $scope.cliente.DOM = data.DOM; |
150 | $scope.cliente.CPO = data.CPO; | 152 | $scope.cliente.CPO = data.CPO; |
151 | $scope.cliente.provincia.ID = data.PCX; | 153 | $scope.cliente.provincia.ID = data.PCX; |
152 | $scope.cliente.provincia.NOMBRE = data.PCI; | 154 | $scope.cliente.provincia.NOMBRE = data.PCI; |
153 | $scope.cliente.localidad.ID = data.LOX; | 155 | $scope.cliente.localidad.ID = data.LOX; |
154 | $scope.cliente.localidad.NOMBRE = data.LOC; | 156 | $scope.cliente.localidad.NOMBRE = data.LOC; |
155 | $scope.cliente.zona.ID = data.zona.ID; | 157 | $scope.cliente.zona.ID = data.zona.ID; |
156 | $scope.cliente.zona.NOM = data.zona.NOM; | 158 | $scope.cliente.zona.NOM = data.zona.NOM; |
157 | $scope.cliente.actividad.NOM = data.actividad.NOM; | 159 | $scope.cliente.actividad.NOM = data.actividad.NOM; |
158 | $scope.cliente.actividad.ID = data.actividad.ID; | 160 | $scope.cliente.actividad.ID = data.actividad.ID; |
159 | $scope.cliente.cobrador.NOM = data.cobrador ? data.cobrador.NOM : ''; | 161 | $scope.cliente.cobrador.NOM = data.cobrador ? data.cobrador.NOM : ''; |
160 | $scope.cliente.cobrador.NUM = data.cobrador ? data.cobrador.NUM : undefined; | 162 | $scope.cliente.cobrador.NUM = data.cobrador ? data.cobrador.NUM : undefined; |
161 | $scope.cliente.cobrador.ID = data.cobrador ? data.cobrador.id : undefined; | 163 | $scope.cliente.cobrador.ID = data.cobrador ? data.cobrador.id : undefined; |
162 | $scope.vendedor.NOM = data.vendedor.NOM; | 164 | $scope.vendedor.NOM = data.vendedor.NOM; |
163 | $scope.vendedor.id = data.vendedor.id; | 165 | $scope.vendedor.id = data.vendedor.id; |
164 | $scope.cliente.MAIL = data.MAIL; | 166 | $scope.cliente.MAIL = data.MAIL; |
165 | $scope.cliente.TEL = data.TEL; | 167 | $scope.cliente.TEL = data.TEL; |
166 | $scope.cliente.iva.NOMBRE = data.iva.NOMBRE; | 168 | $scope.cliente.iva.NOMBRE = data.iva.NOMBRE; |
167 | $scope.cliente.tipoFactura.NOMBRE = data.tipoFactura.NOMBRE; | 169 | $scope.cliente.tipoFactura.NOMBRE = data.tipoFactura.NOMBRE; |
168 | $scope.cliente.tipoFactura.ID = data.tipoFactura.ID; | 170 | $scope.cliente.tipoFactura.ID = data.tipoFactura.ID; |
169 | var cuit = data.CUIT.split('-'); | 171 | var cuit = data.CUIT.split('-'); |
170 | $scope.cliente.cuit1 = cuit[0]; | 172 | $scope.cliente.cuit1 = cuit[0]; |
171 | $scope.cliente.cuit2 = cuit[1]; | 173 | $scope.cliente.cuit2 = cuit[1]; |
172 | $scope.cliente.cuit3 = cuit[2]; | 174 | $scope.cliente.cuit3 = cuit[2]; |
173 | $scope.cliente.tipoComprobante.NOMBRE = data.tipoComprobante.NOMBRE; | 175 | $scope.cliente.tipoComprobante.NOMBRE = data.tipoComprobante.NOMBRE; |
174 | $scope.cliente.tipoComprobante.ID = data.tipoComprobante.ID; | 176 | $scope.cliente.tipoComprobante.ID = data.tipoComprobante.ID; |
175 | $scope.cliente.formaPago.NOMBRE = data.formaPago.NOMBRE; | 177 | $scope.cliente.formaPago.NOMBRE = data.formaPago.NOMBRE; |
176 | $scope.cliente.formaPago.ID = data.formaPago.ID; | 178 | $scope.cliente.formaPago.ID = data.formaPago.ID; |
177 | $scope.cliente.ES_PROS = data.ES_PROS; | 179 | $scope.cliente.ES_PROS = data.ES_PROS; |
178 | $scope.cliente.ES_MAY = data.ES_MAY; | 180 | $scope.cliente.ES_MAY = data.ES_MAY; |
179 | $scope.accion = "Editar Cliente"; | 181 | $scope.accion = "Editar Cliente"; |
180 | $scope.ingreso = true; | 182 | $scope.ingreso = true; |
181 | }) | 183 | }) |
182 | .catch(function (e) { console.log(e); }) | 184 | .catch(function (e) { console.log(e); }); |
183 | } | 185 | } |
184 | 186 | ||
185 | $scope.busquedaDown = function (key) { | 187 | $scope.busquedaDown = function (key) { |
186 | if (key === 40) { | 188 | if (key === 40) { |
187 | primera(key); | 189 | primera(key); |
188 | } | 190 | } |
189 | }; | 191 | }; |
190 | 192 | ||
191 | $scope.itemCliente = function (key) { | 193 | $scope.itemCliente = function (key) { |
192 | if (key === 38) { | 194 | if (key === 38) { |
193 | anterior(key); | 195 | anterior(key); |
194 | } | 196 | } |
195 | 197 | ||
196 | if (key === 40) { | 198 | if (key === 40) { |
197 | siguiente(key); | 199 | siguiente(key); |
198 | } | 200 | } |
199 | 201 | ||
200 | if (key === 37) { | 202 | if (key === 37) { |
201 | retrocederPagina(); | 203 | retrocederPagina(); |
202 | } | 204 | } |
203 | 205 | ||
204 | if (key === 39) { | 206 | if (key === 39) { |
205 | avanzarPagina(); | 207 | avanzarPagina(); |
206 | } | 208 | } |
207 | }; | 209 | }; |
208 | 210 | ||
209 | $scope.focus = function (val) { | 211 | $scope.focus = function (val) { |
210 | $scope.focused = val; | 212 | $scope.focused = val; |
211 | }; | 213 | }; |
212 | 214 | ||
213 | //Recibe aviso si el teclado está en uso | 215 | //Recibe aviso si el teclado está en uso |
214 | $rootScope.$on('usarTeclado', function (event, data) { | 216 | $rootScope.$on('usarTeclado', function (event, data) { |
215 | if (data) { | 217 | if (data) { |
216 | $scope.mostrarTeclado = true; | 218 | $scope.mostrarTeclado = true; |
217 | return; | 219 | return; |
218 | } | 220 | } |
219 | $scope.mostrarTeclado = false; | 221 | $scope.mostrarTeclado = false; |
220 | }); | 222 | }); |
221 | 223 | ||
222 | $scope.selectFocus = function ($event) { | 224 | $scope.selectFocus = function ($event) { |
223 | // Si el teclado esta en uso no selecciona el valor | 225 | // Si el teclado esta en uso no selecciona el valor |
224 | if ($scope.mostrarTeclado) { | 226 | if ($scope.mostrarTeclado) { |
225 | return; | 227 | return; |
226 | } | 228 | } |
227 | $event.target.select(); | 229 | $event.target.select(); |
228 | }; | 230 | }; |
229 | 231 | ||
230 | $scope.next = function (key) { | 232 | $scope.next = function (key) { |
231 | if (key === 13) $scope.focused++; | 233 | if (key === 13) $scope.focused++; |
232 | }; | 234 | }; |
233 | 235 | ||
234 | $scope.seleccionarProvincia = function (key) { | 236 | $scope.seleccionarProvincia = function (key) { |
235 | if (key === 13) { | 237 | if (key === 13) { |
236 | var parametrosModal = { | 238 | var parametrosModal = { |
237 | searchText: $scope.cliente.provincia.NOMBRE, | 239 | searchText: $scope.cliente.provincia.NOMBRE, |
238 | query: '/provincia', | 240 | query: '/provincia', |
239 | columnas: [ | 241 | columnas: [ |
240 | { | 242 | { |
241 | propiedad: 'ID', | 243 | propiedad: 'ID', |
242 | nombre: 'Codigo', | 244 | nombre: 'Codigo', |
243 | filtro: { | 245 | filtro: { |
244 | nombre: 'rellenarDigitos', | 246 | nombre: 'rellenarDigitos', |
245 | parametro: 3 | 247 | parametro: 3 |
246 | } | 248 | } |
247 | }, | 249 | }, |
248 | { | 250 | { |
249 | propiedad: 'NOMBRE', | 251 | propiedad: 'NOMBRE', |
250 | nombre: 'Nombre' | 252 | nombre: 'Nombre' |
251 | } | 253 | } |
252 | ], | 254 | ], |
253 | titulo: 'Búsqueda de provincias', | 255 | titulo: 'Búsqueda de provincias', |
254 | size: 'md' | 256 | size: 'md' |
255 | }; | 257 | }; |
256 | focaModalService.modal(parametrosModal).then(function (provincia) { | 258 | focaModalService.modal(parametrosModal).then(function (provincia) { |
257 | $scope.cliente.provincia = provincia; | 259 | $scope.cliente.provincia = provincia; |
258 | $timeout(function () { | 260 | $timeout(function () { |
259 | $scope.focused = 4; | 261 | $scope.focused = 4; |
260 | }); | 262 | }); |
261 | }, function () { | 263 | }, function () { |
262 | //TODO: función llamada cuando cancela el modal | 264 | //TODO: función llamada cuando cancela el modal |
263 | }); | 265 | }); |
264 | } | 266 | } |
265 | }; | 267 | }; |
266 | $scope.seleccionarLocalidad = function (key) { | 268 | $scope.seleccionarLocalidad = function (key) { |
267 | if ($scope.cliente.provincia.ID === undefined) { | 269 | if ($scope.cliente.provincia.ID === undefined) { |
268 | focaModalService.alert('Seleccione una provincia'); | 270 | focaModalService.alert('Seleccione una provincia'); |
269 | return; | 271 | return; |
270 | } | 272 | } |
271 | if (key === 13) { | 273 | if (key === 13) { |
272 | var parametrosModal = { | 274 | var parametrosModal = { |
273 | searchText: $scope.cliente.localidad.NOMBRE, | 275 | searchText: $scope.cliente.localidad.NOMBRE, |
274 | query: '/localidad/' + parseInt($scope.cliente.provincia.ID), | 276 | query: '/localidad/' + parseInt($scope.cliente.provincia.ID), |
275 | columnas: [ | 277 | columnas: [ |
276 | { | 278 | { |
277 | propiedad: 'ID', | 279 | propiedad: 'ID', |
278 | nombre: 'Código', | 280 | nombre: 'Código', |
279 | }, | 281 | }, |
280 | { | 282 | { |
281 | propiedad: 'NOMBRE', | 283 | propiedad: 'NOMBRE', |
282 | nombre: 'Nombre' | 284 | nombre: 'Nombre' |
283 | } | 285 | } |
284 | ], | 286 | ], |
285 | titulo: 'Búsqueda de localidades', | 287 | titulo: 'Búsqueda de localidades', |
286 | size: 'md' | 288 | size: 'md' |
287 | }; | 289 | }; |
288 | focaModalService.modal(parametrosModal).then(function (localidad) { | 290 | focaModalService.modal(parametrosModal).then(function (localidad) { |
289 | $scope.cliente.localidad = localidad; | 291 | $scope.cliente.localidad = localidad; |
290 | $timeout(function () { | 292 | $timeout(function () { |
291 | $scope.focused = 5; | 293 | $scope.focused = 5; |
292 | }); | 294 | }); |
293 | }, function () { | 295 | }, function () { |
294 | //TODO: función llamada cuando cancela el modal | 296 | //TODO: función llamada cuando cancela el modal |
295 | }); | 297 | }); |
296 | } | 298 | } |
297 | }; | 299 | }; |
298 | $scope.seleccionarIva = function (key) { | 300 | $scope.seleccionarIva = function (key) { |
299 | if (key === 13) { | 301 | if (key === 13) { |
300 | var parametrosModal = { | 302 | var parametrosModal = { |
301 | query: '/iva', | 303 | query: '/iva', |
302 | searchText: $scope.cliente.iva.NOMBRE, | 304 | searchText: $scope.cliente.iva.NOMBRE, |
303 | columnas: [ | 305 | columnas: [ |
304 | { | 306 | { |
305 | propiedad: 'ID', | 307 | propiedad: 'ID', |
306 | nombre: 'Código', | 308 | nombre: 'Código', |
307 | filtro: { | 309 | filtro: { |
308 | nombre: 'rellenarDigitos', | 310 | nombre: 'rellenarDigitos', |
309 | parametro: 3 | 311 | parametro: 3 |
310 | } | 312 | } |
311 | }, | 313 | }, |
312 | { | 314 | { |
313 | propiedad: 'NOMBRE', | 315 | propiedad: 'NOMBRE', |
314 | nombre: 'Nombre' | 316 | nombre: 'Nombre' |
315 | } | 317 | } |
316 | ], | 318 | ], |
317 | titulo: 'Búsqueda de responsabilidad ante el IVA', | 319 | titulo: 'Búsqueda de responsabilidad ante el IVA', |
318 | size: 'md' | 320 | size: 'md' |
319 | }; | 321 | }; |
320 | focaModalService.modal(parametrosModal).then( | 322 | focaModalService.modal(parametrosModal).then( |
321 | function (iva) { | 323 | function (iva) { |
322 | if (iva) { | 324 | if (iva) { |
323 | delete $scope.cliente.tipoFactura.NOMBRE; | 325 | delete $scope.cliente.tipoFactura.NOMBRE; |
324 | } | 326 | } |
325 | $scope.cliente.iva = iva; | 327 | $scope.cliente.iva = iva; |
326 | $timeout(function () { | 328 | $timeout(function () { |
327 | $scope.focused = 12; | 329 | $scope.focused = 12; |
328 | }); | 330 | }); |
329 | }, function () { | 331 | }, function () { |
330 | // funcion ejecutada cuando se cancela el modal | 332 | // funcion ejecutada cuando se cancela el modal |
331 | }); | 333 | }); |
332 | } | 334 | } |
333 | }; | 335 | }; |
334 | $scope.seleccionarActividad = function (key) { | 336 | $scope.seleccionarActividad = function (key) { |
335 | if (key === 13) { | 337 | if (key === 13) { |
336 | var parametrosModal = { | 338 | var parametrosModal = { |
337 | searchText: $scope.cliente.actividad.NOM, | 339 | searchText: $scope.cliente.actividad.NOM, |
338 | query: '/actividad', | 340 | query: '/actividad', |
339 | columnas: [ | 341 | columnas: [ |
340 | { | 342 | { |
341 | propiedad: 'ID', | 343 | propiedad: 'ID', |
342 | nombre: 'Código', | 344 | nombre: 'Código', |
343 | filtro: { | 345 | filtro: { |
344 | nombre: 'rellenarDigitos', | 346 | nombre: 'rellenarDigitos', |
345 | parametro: 3 | 347 | parametro: 3 |
346 | } | 348 | } |
347 | }, | 349 | }, |
348 | { | 350 | { |
349 | propiedad: 'NOM', | 351 | propiedad: 'NOM', |
350 | nombre: 'Nombre' | 352 | nombre: 'Nombre' |
351 | } | 353 | } |
352 | ], | 354 | ], |
353 | titulo: 'Búsqueda de actividades', | 355 | titulo: 'Búsqueda de actividades', |
354 | size: 'md' | 356 | size: 'md' |
355 | }; | 357 | }; |
356 | focaModalService.modal(parametrosModal).then( | 358 | focaModalService.modal(parametrosModal).then( |
357 | function (actividad) { | 359 | function (actividad) { |
358 | $scope.cliente.actividad = actividad; | 360 | $scope.cliente.actividad = actividad; |
359 | $timeout(function () { | 361 | $timeout(function () { |
360 | $scope.focused = 7; | 362 | $scope.focused = 7; |
361 | }); | 363 | }); |
362 | }, function () { | 364 | }, function () { |
363 | // funcion ejecutada cuando se cancela el modal | 365 | // funcion ejecutada cuando se cancela el modal |
364 | }); | 366 | }); |
365 | } | 367 | } |
366 | }; | 368 | }; |
367 | $scope.seleccionarZona = function (key) { | 369 | $scope.seleccionarZona = function (key) { |
368 | if (key === 13) { | 370 | if (key === 13) { |
369 | var parametrosModal = { | 371 | var parametrosModal = { |
370 | searchText: $scope.cliente.zona.NOM, | 372 | searchText: $scope.cliente.zona.NOM, |
371 | query: '/zona', | 373 | query: '/zona', |
372 | columnas: [ | 374 | columnas: [ |
373 | { | 375 | { |
374 | propiedad: 'ID', | 376 | propiedad: 'ID', |
375 | nombre: 'Código', | 377 | nombre: 'Código', |
376 | filtro: { | 378 | filtro: { |
377 | nombre: 'rellenarDigitos', | 379 | nombre: 'rellenarDigitos', |
378 | parametro: 3 | 380 | parametro: 3 |
379 | } | 381 | } |
380 | }, | 382 | }, |
381 | { | 383 | { |
382 | propiedad: 'NOM', | 384 | propiedad: 'NOM', |
383 | nombre: 'Nombre' | 385 | nombre: 'Nombre' |
384 | } | 386 | } |
385 | ], | 387 | ], |
386 | titulo: 'Búsqueda de zonas', | 388 | titulo: 'Búsqueda de zonas', |
387 | size: 'md' | 389 | size: 'md' |
388 | }; | 390 | }; |
389 | focaModalService.modal(parametrosModal).then( | 391 | focaModalService.modal(parametrosModal).then( |
390 | function (zona) { | 392 | function (zona) { |
391 | $scope.cliente.zona = zona; | 393 | $scope.cliente.zona = zona; |
392 | $timeout(function () { | 394 | $timeout(function () { |
393 | $scope.focused = 6; | 395 | $scope.focused = 6; |
394 | }); | 396 | }); |
395 | }, function () { | 397 | }, function () { |
396 | // funcion ejecutada cuando se cancela el modal | 398 | // funcion ejecutada cuando se cancela el modal |
397 | }); | 399 | }); |
398 | } | 400 | } |
399 | }; | 401 | }; |
400 | $scope.seleccionarTipoFactura = function (key) { | 402 | $scope.seleccionarTipoFactura = function (key) { |
401 | 403 | ||
402 | if ($scope.cliente.iva.NOMBRE == '') { | 404 | if ($scope.cliente.iva.NOMBRE == '') { |
403 | focaModalService.alert('Seleccione una responsabilidad ante el IVA'); | 405 | focaModalService.alert('Seleccione una responsabilidad ante el IVA'); |
404 | return; | 406 | return; |
405 | } | 407 | } |
406 | 408 | ||
407 | if (key === 13) { | 409 | if (key === 13) { |
408 | var datos; | 410 | var datos; |
409 | if ($scope.cliente.iva.ID == 1) { | 411 | if ($scope.cliente.iva.ID == 1) { |
410 | datos = [ | 412 | datos = [ |
411 | { | 413 | { |
412 | ID: 'A', | 414 | ID: 'A', |
413 | NOMBRE: 'Factura A' | 415 | NOMBRE: 'Factura A' |
414 | }, | 416 | }, |
415 | { | 417 | { |
416 | ID: 'M', | 418 | ID: 'M', |
417 | NOMBRE: 'Factura M' | 419 | NOMBRE: 'Factura M' |
418 | }, | 420 | }, |
419 | { | 421 | { |
420 | ID: 'R', | 422 | ID: 'R', |
421 | NOMBRE: 'Remito' | 423 | NOMBRE: 'Remito' |
422 | } | 424 | } |
423 | ]; | 425 | ]; |
424 | } else { | 426 | } else { |
425 | datos = [ | 427 | datos = [ |
426 | { | 428 | { |
427 | ID: 'B', | 429 | ID: 'B', |
428 | NOMBRE: 'Factura B' | 430 | NOMBRE: 'Factura B' |
429 | }, | 431 | }, |
430 | { | 432 | { |
431 | ID: 'R', | 433 | ID: 'R', |
432 | NOMBRE: 'Remito' | 434 | NOMBRE: 'Remito' |
433 | } | 435 | } |
434 | ]; | 436 | ]; |
435 | } | 437 | } |
436 | focaModalService.modal({ | 438 | focaModalService.modal({ |
437 | titulo: 'Seleccionar Factura', | 439 | titulo: 'Seleccionar Factura', |
438 | data: datos, | 440 | data: datos, |
439 | size: 'md', | 441 | size: 'md', |
440 | columnas: [ | 442 | columnas: [ |
441 | { | 443 | { |
442 | propiedad: 'ID', | 444 | propiedad: 'ID', |
443 | NOMBRE: 'Codigo' | 445 | NOMBRE: 'Codigo' |
444 | }, | 446 | }, |
445 | { | 447 | { |
446 | propiedad: 'NOMBRE', | 448 | propiedad: 'NOMBRE', |
447 | NOMBRE: 'Factura' | 449 | NOMBRE: 'Factura' |
448 | } | 450 | } |
449 | ], | 451 | ], |
450 | }).then(function (res) { | 452 | }).then(function (res) { |
451 | $scope.cliente.tipoFactura = res; | 453 | $scope.cliente.tipoFactura = res; |
452 | }); | 454 | }); |
453 | } | 455 | } |
454 | }; | 456 | }; |
455 | $scope.seleccionarTipoComprobante = function (key) { | 457 | $scope.seleccionarTipoComprobante = function (key) { |
456 | if (key === 13) { | 458 | if (key === 13) { |
457 | var parametrosModal = { | 459 | var parametrosModal = { |
458 | searchText: $scope.cliente.tipoComprobante.NOMBRE, | 460 | searchText: $scope.cliente.tipoComprobante.NOMBRE, |
459 | query: '/tipo-comprobante', | 461 | query: '/tipo-comprobante', |
460 | columnas: [ | 462 | columnas: [ |
461 | { | 463 | { |
462 | propiedad: 'ID', | 464 | propiedad: 'ID', |
463 | nombre: 'Código' | 465 | nombre: 'Código' |
464 | }, | 466 | }, |
465 | { | 467 | { |
466 | propiedad: 'NOMBRE', | 468 | propiedad: 'NOMBRE', |
467 | nombre: 'Nombre' | 469 | nombre: 'Nombre' |
468 | } | 470 | } |
469 | ], | 471 | ], |
470 | titulo: 'Búsqueda de tipos de comprobante', | 472 | titulo: 'Búsqueda de tipos de comprobante', |
471 | size: 'md' | 473 | size: 'md' |
472 | }; | 474 | }; |
473 | focaModalService.modal(parametrosModal).then( | 475 | focaModalService.modal(parametrosModal).then( |
474 | function (tipoComprobante) { | 476 | function (tipoComprobante) { |
475 | $scope.cliente.tipoComprobante = tipoComprobante; | 477 | $scope.cliente.tipoComprobante = tipoComprobante; |
476 | $timeout(function () { | 478 | $timeout(function () { |
477 | $scope.focused = 17; | 479 | $scope.focused = 17; |
478 | }); | 480 | }); |
479 | }, function () { | 481 | }, function () { |
480 | // funcion ejecutada cuando se cancela el modal | 482 | // funcion ejecutada cuando se cancela el modal |
481 | }); | 483 | }); |
482 | } | 484 | } |
483 | }; | 485 | }; |
484 | $scope.seleccionarFormaPago = function (key) { | 486 | $scope.seleccionarFormaPago = function (key) { |
485 | if (key === 13) { | 487 | if (key === 13) { |
486 | var parametrosModal = { | 488 | var parametrosModal = { |
487 | searchText: $scope.cliente.formaPago.NOMBRE, | 489 | searchText: $scope.cliente.formaPago.NOMBRE, |
488 | query: '/forma-pago', | 490 | query: '/forma-pago', |
489 | columnas: [ | 491 | columnas: [ |
490 | { | 492 | { |
491 | propiedad: 'ID', | 493 | propiedad: 'ID', |
492 | nombre: 'Código', | 494 | nombre: 'Código', |
493 | filtro: { | 495 | filtro: { |
494 | nombre: 'rellenarDigitos', | 496 | nombre: 'rellenarDigitos', |
495 | parametro: 3 | 497 | parametro: 3 |
496 | } | 498 | } |
497 | }, | 499 | }, |
498 | { | 500 | { |
499 | propiedad: 'NOMBRE', | 501 | propiedad: 'NOMBRE', |
500 | nombre: 'Nombre' | 502 | nombre: 'Nombre' |
501 | } | 503 | } |
502 | ], | 504 | ], |
503 | titulo: 'Búsqueda de formas de pago', | 505 | titulo: 'Búsqueda de formas de pago', |
504 | size: 'md' | 506 | size: 'md' |
505 | }; | 507 | }; |
506 | focaModalService.modal(parametrosModal).then( | 508 | focaModalService.modal(parametrosModal).then( |
507 | function (formaPago) { | 509 | function (formaPago) { |
508 | $scope.cliente.formaPago = formaPago; | 510 | $scope.cliente.formaPago = formaPago; |
509 | }, function () { | 511 | }, function () { |
510 | // funcion ejecutada cuando se cancela el modal | 512 | // funcion ejecutada cuando se cancela el modal |
511 | }); | 513 | }); |
512 | } | 514 | } |
513 | }; | 515 | }; |
514 | $scope.seleccionarCobrador = function (key) { | 516 | $scope.seleccionarCobrador = function (key) { |
515 | if (key === 13) { | 517 | if (key === 13) { |
516 | var parametrosModal = { | 518 | var parametrosModal = { |
517 | searchText: $scope.cliente.cobrador.NOM, | 519 | searchText: $scope.cliente.cobrador.NOM, |
518 | query: '/cobrador', | 520 | query: '/cobrador', |
519 | columnas: [ | 521 | columnas: [ |
520 | { | 522 | { |
521 | propiedad: 'NUM', | 523 | propiedad: 'NUM', |
522 | nombre: 'Código' | 524 | nombre: 'Código' |
523 | }, | 525 | }, |
524 | { | 526 | { |
525 | propiedad: 'NOM', | 527 | propiedad: 'NOM', |
526 | nombre: 'Nombre' | 528 | nombre: 'Nombre' |
527 | } | 529 | } |
528 | ], | 530 | ], |
529 | titulo: 'Búsqueda de cobradores', | 531 | titulo: 'Búsqueda de cobradores', |
530 | size: 'md' | 532 | size: 'md' |
531 | }; | 533 | }; |
532 | focaModalService.modal(parametrosModal).then( | 534 | focaModalService.modal(parametrosModal).then( |
533 | function (cobrador) { | 535 | function (cobrador) { |
534 | $scope.cliente.cobrador = cobrador; | 536 | $scope.cliente.cobrador = cobrador; |
535 | }, function () { | 537 | }, function () { |
536 | // funcion ejecutada cuando se cancela el modal | 538 | // funcion ejecutada cuando se cancela el modal |
537 | }); | 539 | }); |
538 | } | 540 | } |
539 | }; | 541 | }; |
540 | $scope.seleccionarVendedor = function (key) { | 542 | $scope.seleccionarVendedor = function (key) { |
541 | if (key === 13) { | 543 | if (key === 13) { |
542 | var parametrosModal = { | 544 | var parametrosModal = { |
543 | titulo: 'Búsqueda vendedores', | 545 | titulo: 'Búsqueda vendedores', |
544 | query: '/vendedor', | 546 | query: '/vendedor', |
545 | columnas: [ | 547 | columnas: [ |
546 | { | 548 | { |
547 | propiedad: 'NUM', | 549 | propiedad: 'NUM', |
548 | nombre: 'Código', | 550 | nombre: 'Código', |
549 | filtro: { | 551 | filtro: { |
550 | nombre: 'rellenarDigitos', | 552 | nombre: 'rellenarDigitos', |
551 | parametro: 3 | 553 | parametro: 3 |
552 | } | 554 | } |
553 | }, | 555 | }, |
554 | { | 556 | { |
555 | propiedad: 'NOM', | 557 | propiedad: 'NOM', |
556 | nombre: 'Nombre' | 558 | nombre: 'Nombre' |
557 | } | 559 | } |
558 | ], | 560 | ], |
559 | size: 'md' | 561 | size: 'md' |
560 | }; | 562 | }; |
561 | focaModalService.modal(parametrosModal).then( | 563 | focaModalService.modal(parametrosModal).then( |
562 | function (vendedor) { | 564 | function (vendedor) { |
563 | console.log("vendedor seleccionado => ", vendedor); | 565 | console.log("vendedor seleccionado => ", vendedor); |
564 | $scope.vendedor = vendedor; | 566 | $scope.vendedor = vendedor; |
565 | }, function () { | 567 | }, function () { |
566 | // funcion ejecutada cuando se cancela el modal | 568 | // funcion ejecutada cuando se cancela el modal |
567 | }); | 569 | }); |
568 | } | 570 | } |
569 | }; | 571 | }; |
570 | 572 | ||
571 | $scope.pasarCampoCuit = function (numeroCuit) { | 573 | $scope.pasarCampoCuit = function (numeroCuit) { |
572 | if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { | 574 | if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { |
573 | $scope.cuitActivo = 2; | 575 | $scope.cuitActivo = 2; |
574 | } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { | 576 | } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { |
575 | $scope.cuitActivo = 3; | 577 | $scope.cuitActivo = 3; |
576 | } | 578 | } |
577 | }; | 579 | }; |
578 | 580 | ||
579 | $scope.guardar = function () { | 581 | $scope.guardar = function () { |
580 | if (!$scope.cliente.NOM) { | 582 | if (!$scope.cliente.NOM) { |
581 | focaModalService.alert('Ingrese Nombre'); | 583 | focaModalService.alert('Ingrese Nombre'); |
582 | return; | 584 | return; |
583 | } else if (!$scope.cliente.CPO) { | 585 | } else if (!$scope.cliente.CPO) { |
584 | focaModalService.alert('Ingrese Codigo Postal'); | 586 | focaModalService.alert('Ingrese Codigo Postal'); |
585 | return; | 587 | return; |
586 | } else if (!$scope.cliente.provincia.NOMBRE) { | 588 | } else if (!$scope.cliente.provincia.NOMBRE) { |
587 | focaModalService.alert('Seleccione una provincia'); | 589 | focaModalService.alert('Seleccione una provincia'); |
588 | return; | 590 | return; |
589 | } else if (!$scope.cliente.DOM) { | 591 | } else if (!$scope.cliente.DOM) { |
590 | focaModalService.alert('Ingrese Domicilio'); | 592 | focaModalService.alert('Ingrese Domicilio'); |
591 | return; | 593 | return; |
592 | } else if (!$scope.cliente.localidad.NOMBRE) { | 594 | } else if (!$scope.cliente.localidad.NOMBRE) { |
593 | focaModalService.alert('Seleccione una localidad'); | 595 | focaModalService.alert('Seleccione una localidad'); |
594 | return; | 596 | return; |
595 | } else if (!$scope.cliente.zona.NOM) { | 597 | } else if (!$scope.cliente.zona.NOM) { |
596 | focaModalService.alert('Seleccione una zona'); | 598 | focaModalService.alert('Seleccione una zona'); |
597 | return; | 599 | return; |
598 | } else if (!$scope.cliente.actividad.NOM) { | 600 | } else if (!$scope.cliente.actividad.NOM) { |
599 | focaModalService.alert('Seleccione actividad'); | 601 | focaModalService.alert('Seleccione actividad'); |
600 | return; | 602 | return; |
601 | } else if (!$scope.cliente.cobrador.NUM) { | 603 | } else if (!$scope.cliente.cobrador.NUM) { |
602 | focaModalService.alert('Seleccione un cobrador'); | 604 | focaModalService.alert('Seleccione un cobrador'); |
603 | return; | 605 | return; |
604 | } else if (!$scope.vendedor.NOM) { | 606 | } else if (!$scope.vendedor.NOM) { |
605 | focaModalService.alert('Seleccione un vendedor'); | 607 | focaModalService.alert('Seleccione un vendedor'); |
606 | return; | 608 | return; |
607 | } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { | 609 | } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { |
608 | focaModalService.alert('Ingrese un formato de email válido'); | 610 | focaModalService.alert('Ingrese un formato de email válido'); |
609 | return; | 611 | return; |
610 | } else if (!$scope.cliente.TEL) { | 612 | } else if (!$scope.cliente.TEL) { |
611 | focaModalService.alert('Ingrese un numero de telefono'); | 613 | focaModalService.alert('Ingrese un numero de telefono'); |
612 | return; | 614 | return; |
613 | } else if (!$scope.cliente.iva.NOMBRE) { | 615 | } else if (!$scope.cliente.iva.NOMBRE) { |
614 | focaModalService.alert('Seleccione responsabilidad ante el IVA'); | 616 | focaModalService.alert('Seleccione responsabilidad ante el IVA'); |
615 | return; | 617 | return; |
616 | } else if (!$scope.cliente.tipoFactura.NOMBRE) { | 618 | } else if (!$scope.cliente.tipoFactura.NOMBRE) { |
617 | focaModalService.alert('Seleccione tipo de Factura'); | 619 | focaModalService.alert('Seleccione tipo de Factura'); |
618 | return; | 620 | return; |
619 | } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { | 621 | } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { |
620 | focaModalService.alert('Ingrese CUIT'); | 622 | focaModalService.alert('Ingrese CUIT'); |
621 | return; | 623 | return; |
622 | } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { | 624 | } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { |
623 | focaModalService.alert('Ingrese CUIT válido'); | 625 | focaModalService.alert('Ingrese CUIT válido'); |
624 | return; | 626 | return; |
625 | } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { | 627 | } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { |
626 | focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); | 628 | focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); |
627 | return; | 629 | return; |
628 | } else if (!$scope.cliente.tipoComprobante.NOMBRE) { | 630 | } else if (!$scope.cliente.tipoComprobante.NOMBRE) { |
629 | focaModalService.alert('Seleccione un Comprobante'); | 631 | focaModalService.alert('Seleccione un Comprobante'); |
630 | return; | 632 | return; |
631 | } else if (!$scope.cliente.formaPago.NOMBRE) { | 633 | } else if (!$scope.cliente.formaPago.NOMBRE) { |
632 | focaModalService.alert('Seleccione una forma de pago'); | 634 | focaModalService.alert('Seleccione una forma de pago'); |
633 | return; | 635 | return; |
634 | } | 636 | } |
635 | 637 | ||
636 | $scope.cliente.actividad.ID = parseInt($scope.cliente.actividad.ID); | 638 | $scope.cliente.actividad.ID = parseInt($scope.cliente.actividad.ID); |
637 | 639 | ||
638 | var cliente = crearCopia(); | 640 | var cliente = crearCopia(); |
639 | 641 | ||
640 | focaBusquedaClienteService | 642 | focaBusquedaClienteService |
641 | .guardarCliente(cliente) | 643 | .guardarCliente(cliente) |
642 | .then(function (res) { | 644 | .then(function (res) { |
643 | var cliente = { | 645 | var cliente = { |
644 | cod: res.data.COD, | 646 | cod: res.data.COD, |
645 | cuit: res.data.CUIT, | 647 | cuit: res.data.CUIT, |
646 | esNuevo: res.data.esNuevo, | 648 | esNuevo: res.data.esNuevo, |
647 | nom: res.data.NOM | 649 | nom: res.data.NOM |
648 | }; | 650 | }; |
649 | $scope.select(cliente, true); | 651 | $scope.select(cliente, true); |
650 | }) | 652 | }) |
651 | .catch(function (e) { | 653 | .catch(function (e) { |
652 | console.log(e); | 654 | console.log(e); |
653 | }); | 655 | }); |
654 | }; | 656 | }; |
655 | 657 | ||
656 | function crearCopia() { | 658 | function crearCopia() { |
657 | var cliente = angular.copy($scope.cliente); | 659 | var cliente = angular.copy($scope.cliente); |
658 | cliente.COD = cliente.codigo; | 660 | cliente.COD = cliente.codigo; |
659 | cliente.CPO = cliente.CPO; | 661 | cliente.CPO = cliente.CPO; |
660 | cliente.PCX = parseInt(cliente.provincia.ID); | 662 | cliente.PCX = parseInt(cliente.provincia.ID); |
661 | cliente.LOX = parseInt(cliente.localidad.ID); | 663 | cliente.LOX = parseInt(cliente.localidad.ID); |
662 | cliente.LOC = cliente.localidad.NOMBRE; | 664 | cliente.LOC = cliente.localidad.NOMBRE; |
663 | cliente.PCI = cliente.provincia.NOMBRE; | 665 | cliente.PCI = cliente.provincia.NOMBRE; |
664 | cliente.IVA = cliente.iva.ID; | 666 | cliente.IVA = cliente.iva.ID; |
665 | cliente.ACT = cliente.actividad.ID; | 667 | cliente.ACT = cliente.actividad.ID; |
666 | cliente.ZON = (parseInt(cliente.zona.ID)).toString(); | 668 | cliente.ZON = (parseInt(cliente.zona.ID)).toString(); |
667 | cliente.TIP = cliente.tipoFactura.ID; | 669 | cliente.TIP = cliente.tipoFactura.ID; |
668 | cliente.TCO = cliente.tipoComprobante.ID; | 670 | cliente.TCO = cliente.tipoComprobante.ID; |
669 | cliente.FPA = cliente.formaPago.ID; | 671 | cliente.FPA = cliente.formaPago.ID; |
670 | cliente.VEN = $scope.vendedor.id; | 672 | cliente.VEN = $scope.vendedor.id; |
671 | cliente.CUIT = `${cliente.cuit1}-${cliente.cuit2}-${cliente.cuit3}`; | 673 | cliente.CUIT = `${cliente.cuit1}-${cliente.cuit2}-${cliente.cuit3}`; |
672 | cliente.idCobrador = cliente.cobrador.ID; | 674 | cliente.idCobrador = cliente.cobrador.ID; |
673 | 675 | ||
674 | delete cliente.codigo; | 676 | delete cliente.codigo; |
675 | delete cliente.provincia; | 677 | delete cliente.provincia; |
676 | delete cliente.localidad; | 678 | delete cliente.localidad; |
677 | delete cliente.iva; | 679 | delete cliente.iva; |
678 | delete cliente.actividad; | 680 | delete cliente.actividad; |
679 | delete cliente.zona; | 681 | delete cliente.zona; |
680 | delete cliente.tipoFactura; | 682 | delete cliente.tipoFactura; |
681 | delete cliente.tipoComprobante; | 683 | delete cliente.tipoComprobante; |
682 | delete cliente.formaPago; | 684 | delete cliente.formaPago; |
683 | delete cliente.cobrador; | 685 | delete cliente.cobrador; |
684 | delete cliente.cuit1; | 686 | delete cliente.cuit1; |
685 | delete cliente.cuit2; | 687 | delete cliente.cuit2; |
686 | delete cliente.cuit3; | 688 | delete cliente.cuit3; |
687 | 689 | ||
688 | return cliente; | 690 | return cliente; |
689 | } | 691 | } |
690 | 692 | ||
691 | //#region PAGINADOR | 693 | //#region PAGINADOR |
692 | function calcularPages(paginaActual) { | 694 | function calcularPages(paginaActual) { |
693 | var paginas = []; | 695 | var paginas = []; |
694 | paginas.push(paginaActual); | 696 | paginas.push(paginaActual); |
695 | 697 | ||
696 | if (paginaActual - 1 > 1) { | 698 | if (paginaActual - 1 > 1) { |
697 | 699 | ||
698 | paginas.unshift(paginaActual - 1); | 700 | paginas.unshift(paginaActual - 1); |
699 | if (paginaActual - 2 > 1) { | 701 | if (paginaActual - 2 > 1) { |
700 | paginas.unshift(paginaActual - 2); | 702 | paginas.unshift(paginaActual - 2); |
701 | } | 703 | } |
702 | } | 704 | } |
703 | 705 | ||
704 | if (paginaActual + 1 < $scope.lastPage) { | 706 | if (paginaActual + 1 < $scope.lastPage) { |
705 | paginas.push(paginaActual + 1); | 707 | paginas.push(paginaActual + 1); |
706 | if (paginaActual + 2 < $scope.lastPage) { | 708 | if (paginaActual + 2 < $scope.lastPage) { |
707 | paginas.push(paginaActual + 2); | 709 | paginas.push(paginaActual + 2); |
708 | } | 710 | } |
709 | } | 711 | } |
710 | 712 | ||
711 | if (paginaActual !== 1) { | 713 | if (paginaActual !== 1) { |
712 | paginas.unshift(1); | 714 | paginas.unshift(1); |
713 | } | 715 | } |
714 | 716 | ||
715 | if (paginaActual !== $scope.lastPage) { | 717 | if (paginaActual !== $scope.lastPage) { |
716 | paginas.push($scope.lastPage); | 718 | paginas.push($scope.lastPage); |
717 | } | 719 | } |
718 | 720 | ||
719 | return paginas; | 721 | return paginas; |
720 | } | 722 | } |
721 | 723 | ||
722 | function primera() { | 724 | function primera() { |
723 | $scope.selectedClientes = 0; | 725 | $scope.selectedClientes = 0; |
724 | } | 726 | } |
725 | 727 | ||
726 | function anterior() { | 728 | function anterior() { |
727 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { | 729 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { |
728 | retrocederPagina(); | 730 | retrocederPagina(); |
729 | } else { | 731 | } else { |
730 | $scope.selectedClientes--; | 732 | $scope.selectedClientes--; |
731 | } | 733 | } |
732 | } | 734 | } |
733 | 735 | ||
734 | function siguiente() { | 736 | function siguiente() { |
735 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1) { | 737 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1) { |
736 | $scope.selectedClientes++; | 738 | $scope.selectedClientes++; |
737 | } else { | 739 | } else { |
738 | avanzarPagina(); | 740 | avanzarPagina(); |
739 | } | 741 | } |
740 | } | 742 | } |
741 | 743 | ||
742 | function retrocederPagina() { | 744 | function retrocederPagina() { |
743 | if ($scope.currentPage > 1) { | 745 | if ($scope.currentPage > 1) { |
744 | $scope.selectPage($scope.currentPage - 1); | 746 | $scope.selectPage($scope.currentPage - 1); |
745 | $scope.selectedClientes = $scope.numPerPage - 1; | 747 | $scope.selectedClientes = $scope.numPerPage - 1; |
746 | } | 748 | } |
747 | } | 749 | } |
748 | 750 | ||
749 | function avanzarPagina() { | 751 | function avanzarPagina() { |
750 | if ($scope.currentPage < $scope.lastPage) { | 752 | if ($scope.currentPage < $scope.lastPage) { |
751 | $scope.selectPage($scope.currentPage + 1); | 753 | $scope.selectPage($scope.currentPage + 1); |
752 | $scope.selectedClientes = 0; | 754 | $scope.selectedClientes = 0; |
753 | } | 755 | } |
754 | } | 756 | } |
755 | //#endregion | 757 | //#endregion |
756 | 758 | ||
757 | function validateEmails(emails) { | 759 | function validateEmails(emails) { |
758 | var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | 760 | var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; |
759 | var arr = emails.split(','); | 761 | var arr = emails.split(','); |
760 | var result = true; | 762 | var result = true; |
761 | arr.forEach(function (email) { | 763 | arr.forEach(function (email) { |
762 | var val = String(email).trim().toLowerCase(); | 764 | var val = String(email).trim().toLowerCase(); |
763 | if (!re.test(val)) result = false; | 765 | if (!re.test(val)) result = false; |
764 | }); | 766 | }); |
765 | return result; | 767 | return result; |
766 | } | 768 | } |
767 | } | 769 | } |
768 | ]); | 770 | ]); |
769 | 771 |