Commit 34a1c6900762f818610606870e4b6f7c46406f83

Authored by Benjamin Rodriguez
Exists in master

cc abre solo si cliente posee cc

src/js/controller.js
1 angular.module('focaCrearFactura').controller('facturaController', [ 1 angular.module('focaCrearFactura').controller('facturaController', [
2 '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', 2 '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout',
3 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', 3 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService',
4 '$localStorage', 'APP', 'focaLoginService', 4 '$localStorage', 'APP', 'focaLoginService',
5 function ( 5 function (
6 $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, 6 $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService,
7 crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { 7 crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) {
8 8
9 config(); 9 config();
10 10
11 function config() { 11 function config() {
12 $scope.tmpCantidad = '0'; 12 $scope.tmpCantidad = '0';
13 $scope.botonera = crearFacturaService.getBotonera(); 13 $scope.botonera = crearFacturaService.getBotonera();
14 $scope.botoneraProductos = []; 14 $scope.botoneraProductos = [];
15 $scope.isNumber = angular.isNumber; 15 $scope.isNumber = angular.isNumber;
16 $scope.datepickerAbierto = false; 16 $scope.datepickerAbierto = false;
17 $scope.show = false; 17 $scope.show = false;
18 $scope.cargando = true; 18 $scope.cargando = true;
19 $scope.now = new Date(); 19 $scope.now = new Date();
20 $scope.puntoVenta = rellenar(0, 4); 20 $scope.puntoVenta = rellenar(0, 4);
21 $scope.comprobante = rellenar(0, 8); 21 $scope.comprobante = rellenar(0, 8);
22 $scope.dateOptions = { 22 $scope.dateOptions = {
23 maxDate: new Date(), 23 maxDate: new Date(),
24 minDate: new Date(2010, 0, 1) 24 minDate: new Date(2010, 0, 1)
25 }; 25 };
26 $scope.cabeceras = []; 26 $scope.cabeceras = [];
27 crearFacturaService.getParametros().then(function (res) { 27 crearFacturaService.getParametros().then(function (res) {
28 28
29 var parametros = JSON.parse(res.data[0].jsonText); 29 var parametros = JSON.parse(res.data[0].jsonText);
30 30
31 if ($localStorage.factura) { 31 if ($localStorage.factura) {
32 32
33 $timeout(function () { getLSFactura(); }); 33 $timeout(function () { getLSFactura(); });
34 } else { 34 } else {
35 35
36 for (var property in parametros) { 36 for (var property in parametros) {
37 $scope.factura[property] = parametros[property]; 37 $scope.factura[property] = parametros[property];
38 $scope.inicial[property] = parametros[property]; 38 $scope.inicial[property] = parametros[property];
39 } 39 }
40 40
41 setearFactura($scope.factura); 41 setearFactura($scope.factura);
42 } 42 }
43 43
44 }); 44 });
45 45
46 //SETEO BOTONERA LATERAL 46 //SETEO BOTONERA LATERAL
47 $timeout(function () { 47 $timeout(function () {
48 focaBotoneraLateralService.showSalir(false); 48 focaBotoneraLateralService.showSalir(false);
49 focaBotoneraLateralService.showPausar(true); 49 focaBotoneraLateralService.showPausar(true);
50 focaBotoneraLateralService.showPagar(true, $scope.seleccionarFormaDePago); 50 focaBotoneraLateralService.showPagar(true, $scope.seleccionarFormaDePago);
51 focaBotoneraLateralService.addCustomButton('Salir', $scope.salir); 51 focaBotoneraLateralService.addCustomButton('Salir', $scope.salir);
52 }); 52 });
53 53
54 init(); 54 init();
55 55
56 } 56 }
57 57
58 function init() { 58 function init() {
59 59
60 $scope.$broadcast('cleanCabecera'); 60 $scope.$broadcast('cleanCabecera');
61 61
62 $scope.factura = { 62 $scope.factura = {
63 id: 0, 63 id: 0,
64 estado: 0, 64 estado: 0,
65 vendedor: {}, 65 vendedor: {},
66 cliente: {}, 66 cliente: {},
67 proveedor: {}, 67 proveedor: {},
68 domicilio: { dom: '' }, 68 domicilio: { dom: '' },
69 moneda: {}, 69 moneda: {},
70 formaPago: 1, // Por defecto paga contado 70 formaPago: 1, // Por defecto paga contado
71 cotizacion: $scope.cotizacionPorDefecto || {}, 71 cotizacion: $scope.cotizacionPorDefecto || {},
72 articulosFactura: [], 72 articulosFactura: [],
73 despachos: [] 73 despachos: []
74 }; 74 };
75 75
76 $scope.estadoCuenta = { 76 $scope.estadoCuenta = {
77 autorizado: 0.0, 77 autorizado: 0.0,
78 extracciones: 0.0, 78 extracciones: 0.0,
79 saldo: 0.0, 79 saldo: 0.0,
80 situacion: false, 80 situacion: false,
81 facturasVencidas: 0.0 81 facturasVencidas: 0.0
82 }; 82 };
83 83
84 $scope.factura.articulosFactura = []; 84 $scope.factura.articulosFactura = [];
85 $scope.idLista = undefined; 85 $scope.idLista = undefined;
86 86
87 $scope.inicial = angular.copy($scope.factura); 87 $scope.inicial = angular.copy($scope.factura);
88 88
89 getNumeroFactura('B'); 89 getNumeroFactura('B');
90 90
91 if (APP === 'facturador') { 91 if (APP === 'facturador') {
92 crearFacturaService 92 crearFacturaService
93 .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) 93 .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya)
94 .then(function (res) { 94 .then(function (res) {
95 95
96 validarPlanillaVendedor(res.data) 96 validarPlanillaVendedor(res.data)
97 .then(function () { 97 .then(function () {
98 98
99 $scope.$broadcast('addCabecera', { 99 $scope.$broadcast('addCabecera', {
100 label: 'Vendedor:', 100 label: 'Vendedor:',
101 valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + 101 valor: $filter('rellenarDigitos')(res.data.CodVen, 3) +
102 ' - ' + 102 ' - ' +
103 res.data.NomVen 103 res.data.NomVen
104 }); 104 });
105 $scope.$broadcast('addCabecera', { 105 $scope.$broadcast('addCabecera', {
106 label: 'Planilla:', 106 label: 'Planilla:',
107 valor: res.data.NplVen 107 valor: res.data.NplVen
108 }); 108 });
109 109
110 $scope.factura.vendedor = res.data; 110 $scope.factura.vendedor = res.data;
111 $scope.inicial.vendedor = res.data; 111 $scope.inicial.vendedor = res.data;
112 112
113 getProductosByPlanilla(res.data.NplVen); 113 getProductosByPlanilla(res.data.NplVen);
114 }) 114 })
115 .catch(function (err) { 115 .catch(function (err) {
116 console.log(err); 116 console.log(err);
117 focaModalService.alert('Ocurrió un error al intentar recuperar' + 117 focaModalService.alert('Ocurrió un error al intentar recuperar' +
118 'el vendedor logeado'); 118 'el vendedor logeado');
119 }); 119 });
120 }); 120 });
121 } 121 }
122 } 122 }
123 123
124 $scope.$watch('factura', function (newValue) { 124 $scope.$watch('factura', function (newValue) {
125 focaBotoneraLateralService.setPausarData({ 125 focaBotoneraLateralService.setPausarData({
126 label: 'factura', 126 label: 'factura',
127 val: newValue 127 val: newValue
128 }); 128 });
129 }, true); 129 }, true);
130 130
131 $scope.seleccionarFormaDePago = function () { 131 $scope.seleccionarFormaDePago = function () {
132 132
133 if (!validarGuardar()) return; 133 if (!validarGuardar()) return;
134 134
135 if ($scope.factura.formaPago === 2) { 135 if ($scope.factura.formaPago === 2) {
136 $scope.crearFactura(); 136 $scope.crearFactura();
137 return; 137 return;
138 } 138 }
139 139
140 var modalInstance = $uibModal.open( 140 var modalInstance = $uibModal.open(
141 { 141 {
142 templateUrl: 'modal-forma-pago.html', 142 templateUrl: 'modal-forma-pago.html',
143 controller: 'focaModalFormaPagoController', 143 controller: 'focaModalFormaPagoController',
144 resolve: { 144 resolve: {
145 parametros: function () { 145 parametros: function () {
146 return { 146 return {
147 importe: $scope.getTotal() 147 importe: $scope.getTotal()
148 }; 148 };
149 }, 149 },
150 }, 150 },
151 size: 'lg', 151 size: 'lg',
152 } 152 }
153 ); 153 );
154 modalInstance.result 154 modalInstance.result
155 .then(function (data) { 155 .then(function (data) {
156 156
157 if (data.tipo === 'tarjeta') { 157 if (data.tipo === 'tarjeta') {
158 $scope.factura.formaPago = 4; 158 $scope.factura.formaPago = 4;
159 } else { 159 } else {
160 $scope.factura.formaPago = 1; 160 $scope.factura.formaPago = 1;
161 } 161 }
162 162
163 $scope.crearFactura(data); 163 $scope.crearFactura(data);
164 }) 164 })
165 .catch(function (e) { console.error(e); }); 165 .catch(function (e) { console.error(e); });
166 }; 166 };
167 167
168 $scope.crearFactura = function (formaPago) { 168 $scope.crearFactura = function (formaPago) {
169 169
170 var save = { 170 var save = {
171 factura: { 171 factura: {
172 172
173 BONIF: 0, 173 BONIF: 0,
174 CLI: $scope.factura.cliente.COD, 174 CLI: $scope.factura.cliente.COD,
175 CUI: $scope.factura.cliente.CUIT, 175 CUI: $scope.factura.cliente.CUIT,
176 CTA: $scope.factura.cliente.COD, 176 CTA: $scope.factura.cliente.COD,
177 DC1: '', 177 DC1: '',
178 DC2: '', 178 DC2: '',
179 DE1: '', 179 DE1: '',
180 DOM: $scope.factura.cliente.DOM, 180 DOM: $scope.factura.cliente.DOM,
181 FACAUT: 0, 181 FACAUT: 0,
182 DTO: 0, 182 DTO: 0,
183 FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), 183 FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'),
184 FEC_ANT: '19000101', 184 FEC_ANT: '19000101',
185 FPA: $scope.factura.formaPago, 185 FPA: $scope.factura.formaPago,
186 IDEXCEPCION: 0, 186 IDEXCEPCION: 0,
187 IDLP: $scope.factura.cliente.MOD.trim() || 0, 187 IDLP: $scope.factura.cliente.MOD.trim() || 0,
188 IDPERSONERIA: 0, 188 IDPERSONERIA: 0,
189 IMI: getImporte('IMI'), 189 IMI: getImporte('IMI'),
190 IMI2: getImporte('IMI2'), 190 IMI2: getImporte('IMI2'),
191 IMI3: getImporte('IMI3'), 191 IMI3: getImporte('IMI3'),
192 IMP_LEY: 0, 192 IMP_LEY: 0,
193 IRI: getImporte('IVA'), 193 IRI: getImporte('IVA'),
194 IRS: 0, 194 IRS: 0,
195 LEG: '', 195 LEG: '',
196 LUG: $scope.factura.vendedor.LugVen, 196 LUG: $scope.factura.vendedor.LugVen,
197 MK_M: 0, 197 MK_M: 0,
198 NEE: getImporte('NEX'), 198 NEE: getImporte('NEX'),
199 NET: getImporte('NET'), 199 NET: getImporte('NET'),
200 NFI: '', 200 NFI: '',
201 NNP: 0, 201 NNP: 0,
202 NOM: $scope.factura.cliente.NOM, 202 NOM: $scope.factura.cliente.NOM,
203 OPE: $scope.factura.vendedor.CodVen, 203 OPE: $scope.factura.vendedor.CodVen,
204 PAG: $scope.getTotal(), 204 PAG: $scope.getTotal(),
205 PER: 0, 205 PER: 0,
206 PER_IVA: 0, 206 PER_IVA: 0,
207 PLA: $scope.factura.vendedor.NplVen, 207 PLA: $scope.factura.vendedor.NplVen,
208 PRO: '', 208 PRO: '',
209 REC_ANT: 0, 209 REC_ANT: 0,
210 SUC: parseInt($scope.puntoVenta), 210 SUC: parseInt($scope.puntoVenta),
211 TCA: 1, 211 TCA: 1,
212 TCO: 'FT', 212 TCO: 'FT',
213 TFI: '', 213 TFI: '',
214 TIP: $scope.factura.cliente.TIP, 214 TIP: $scope.factura.cliente.TIP,
215 TIV: $scope.factura.cliente.IVA, 215 TIV: $scope.factura.cliente.IVA,
216 TOT: $scope.getTotal(), 216 TOT: $scope.getTotal(),
217 TUR: $scope.factura.vendedor.TurVen, 217 TUR: $scope.factura.vendedor.TurVen,
218 VEN: $scope.factura.vendedor.CodVen, 218 VEN: $scope.factura.vendedor.CodVen,
219 VTO_CLI: '', 219 VTO_CLI: '',
220 ZON: 1, // TODO: ZON DE APAREMP 220 ZON: 1, // TODO: ZON DE APAREMP
221 OBSERVACIONES: $scope.factura.observaciones 221 OBSERVACIONES: $scope.factura.observaciones
222 }, 222 },
223 cuerpo: $scope.articulosFiltro(), 223 cuerpo: $scope.articulosFiltro(),
224 despachos: $scope.factura.despachos, 224 despachos: $scope.factura.despachos,
225 formaPago: formaPago 225 formaPago: formaPago
226 }; 226 };
227 227
228 crearFacturaService.guardarFactura(save).then(function () { 228 crearFacturaService.guardarFactura(save).then(function () {
229 229
230 focaBotoneraLateralService.endGuardar(true); 230 focaBotoneraLateralService.endGuardar(true);
231 231
232 focaModalService.alert('Comprobante guardado con éxito'); 232 focaModalService.alert('Comprobante guardado con éxito');
233 233
234 config(); 234 config();
235 235
236 }).catch(function (err) { 236 }).catch(function (err) {
237 focaModalService.alert('Hubo un error al guardar la factura'); 237 focaModalService.alert('Hubo un error al guardar la factura');
238 console.error(err); 238 console.error(err);
239 }); 239 });
240 240
241 }; 241 };
242 242
243 $scope.seleccionarCliente = function () { 243 $scope.seleccionarCliente = function () {
244 244
245 var modalInstance = $uibModal.open( 245 var modalInstance = $uibModal.open(
246 { 246 {
247 ariaLabelledBy: 'Busqueda de Cliente', 247 ariaLabelledBy: 'Busqueda de Cliente',
248 templateUrl: 'foca-busqueda-cliente-modal.html', 248 templateUrl: 'foca-busqueda-cliente-modal.html',
249 controller: 'focaBusquedaClienteModalController', 249 controller: 'focaBusquedaClienteModalController',
250 resolve: { 250 resolve: {
251 parametros: function () { 251 parametros: function () {
252 return { 252 return {
253 vendedor: function () { return null; }, 253 vendedor: function () { return null; },
254 cobrador: function () { return null; } 254 cobrador: function () { return null; }
255 }; 255 };
256 } 256 }
257 }, 257 },
258 size: 'lg' 258 size: 'lg'
259 } 259 }
260 ); 260 );
261 modalInstance.result.then( 261 modalInstance.result.then(
262 function (cliente) { 262 function (cliente) {
263 crearFacturaService.getResumenCuenta(cliente.COD) 263 crearFacturaService.getResumenCuenta(cliente.COD)
264 .then(function (res) { 264 .then(function (res) {
265 $scope.estadoCuenta = res.data[0]; 265 $scope.estadoCuenta = res.data[0];
266 if ($scope.estadoCuenta.autorizado > 0) { 266 if ($scope.estadoCuenta.autorizado > 0) {
267 var modalInstance = $uibModal.open( 267 var modalInstance = $uibModal.open(
268 { 268 {
269 templateUrl: 'modal-estado-cuenta.html', 269 templateUrl: 'modal-estado-cuenta.html',
270 controller: 'focaModalEstadoCuentaController', 270 controller: 'focaModalEstadoCuentaController',
271 size: 'lg', 271 size: 'lg',
272 resolve: { 272 resolve: {
273 parametros: function () { 273 parametros: function () {
274 return { 274 return {
275 idCliente: cliente.COD, 275 idCliente: cliente.COD,
276 nombreCliente: cliente.NOM 276 nombreCliente: cliente.NOM
277 }; 277 };
278 }, 278 },
279 } 279 }
280 } 280 }
281 ) 281 )
282 }; 282 };
283 283 })
284 }) 284 .catch(function (err) { console.error(err); })
285 .catch(function (err) { console.error(err); }) 285
286 286 modalInstance.result
287 287 .then(function (data) {
288 modalInstance.result 288
289 .then(function (data) { 289 $scope.factura.formaPago = data.formaDePago;
290 290 $scope.factura.cliente = cliente;
291 $scope.factura.formaPago = data.formaDePago; 291
292 $scope.factura.cliente = cliente; 292 getNumeroFactura(cliente.TIP);
293 293
294 getNumeroFactura(cliente.TIP); 294 $scope.$broadcast('addCabecera', {
295 295 label: 'Cliente:',
296 $scope.$broadcast('addCabecera', { 296 valor: $filter('rellenarDigitos')(cliente.COD, 3) +
297 label: 'Cliente:', 297 ' - ' + cliente.NOM
298 valor: $filter('rellenarDigitos')(cliente.COD, 3) + 298 });
299 ' - ' + cliente.NOM 299
300 }); 300 $filter('filter')($scope.botonera,
301 301 { label: 'Cliente' })[0].checked = true;
302 $filter('filter')($scope.botonera, 302
303 { label: 'Cliente' })[0].checked = true; 303 $scope.$broadcast('addCabecera', {
304 304 label: 'Forma de pago: ',
305 $scope.$broadcast('addCabecera', { 305 valor: data.tipo
306 label: 'Forma de pago: ', 306 });
307 valor: data.tipo 307 })
308 }); 308 .catch($scope.seleccionarCliente);
309 }) 309
310 .catch($scope.seleccionarCliente); 310 }, function () {
311 311 }
312 }, function () { 312 );
313 } 313
314 ); 314 };
315 315
316 }; 316 $scope.seleccionarVendedor = function () {
317 317 var parametrosModal = {
318 $scope.seleccionarVendedor = function () { 318 titulo: 'Búsqueda vendedores',
319 var parametrosModal = { 319 query: '/vendedor-playa',
320 titulo: 'Búsqueda vendedores', 320 columnas: [
321 query: '/vendedor-playa', 321 {
322 columnas: [ 322 propiedad: 'CodVen',
323 { 323 nombre: 'Código',
324 propiedad: 'CodVen', 324 filtro: {
325 nombre: 'Código', 325 nombre: 'rellenarDigitos',
326 filtro: { 326 parametro: 3
327 nombre: 'rellenarDigitos', 327 }
328 parametro: 3 328 },
329 } 329 {
330 }, 330 propiedad: 'NomVen',
331 { 331 nombre: 'Nombre'
332 propiedad: 'NomVen', 332 }
333 nombre: 'Nombre' 333 ],
334 } 334 size: 'md'
335 ], 335 };
336 size: 'md' 336 focaModalService.modal(parametrosModal).then(
337 }; 337 function (vendedor) {
338 focaModalService.modal(parametrosModal).then( 338
339 function (vendedor) { 339 indicarPassword(vendedor)
340 340 .then(function () {
341 indicarPassword(vendedor) 341 validarPlanillaVendedor(vendedor)
342 .then(function () { 342 .then(function () {
343 validarPlanillaVendedor(vendedor) 343
344 .then(function () { 344 $filter('filter')($scope.botonera, {
345 345 label: 'Vendedor'
346 $filter('filter')($scope.botonera, { 346 })[0].checked = true;
347 label: 'Vendedor' 347
348 })[0].checked = true; 348 $scope.$broadcast('addCabecera', {
349 349 label: 'Vendedor:',
350 $scope.$broadcast('addCabecera', { 350 valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) +
351 label: 'Vendedor:', 351 ' - ' +
352 valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + 352 vendedor.NomVen
353 ' - ' + 353 });
354 vendedor.NomVen 354 $scope.$broadcast('addCabecera', {
355 }); 355 label: 'Planilla:',
356 $scope.$broadcast('addCabecera', { 356 valor: vendedor.NplVen
357 label: 'Planilla:', 357 });
358 valor: vendedor.NplVen 358
359 }); 359 $scope.factura.vendedor = vendedor;
360 360
361 $scope.factura.vendedor = vendedor; 361 getProductosByPlanilla(vendedor.NplVen);
362 362 })
363 getProductosByPlanilla(vendedor.NplVen); 363 .catch($scope.seleccionarVendedor);
364 }) 364 })
365 .catch($scope.seleccionarVendedor); 365 .catch(function (err) {
366 }) 366 console.error(err);
367 .catch(function (err) { 367 });
368 console.error(err); 368
369 }); 369 }, function () { }
370 370 );
371 }, function () { } 371 };
372 ); 372
373 }; 373 $scope.seleccionarMoneda = function () {
374 374
375 $scope.seleccionarMoneda = function () { 375 var parametrosModal = {
376 376 titulo: 'Búsqueda de monedas',
377 var parametrosModal = { 377 query: '/moneda',
378 titulo: 'Búsqueda de monedas', 378 columnas: [
379 query: '/moneda', 379 {
380 columnas: [ 380 propiedad: 'DETALLE',
381 { 381 nombre: 'Nombre'
382 propiedad: 'DETALLE', 382 },
383 nombre: 'Nombre' 383 {
384 }, 384 propiedad: 'SIMBOLO',
385 { 385 nombre: 'Símbolo'
386 propiedad: 'SIMBOLO', 386 }
387 nombre: 'Símbolo' 387 ],
388 } 388 size: 'md'
389 ], 389 };
390 size: 'md' 390 focaModalService.modal(parametrosModal).then(
391 }; 391 function (moneda) {
392 focaModalService.modal(parametrosModal).then( 392
393 function (moneda) { 393 if (moneda.ID !== 1) {
394 394 $scope.abrirModalCotizacion(moneda);
395 if (moneda.ID !== 1) { 395 return;
396 $scope.abrirModalCotizacion(moneda); 396 }
397 return; 397
398 } 398 crearRemitoService.getCotizacionByIdMoneda(1)
399 399 .then(function (res) {
400 crearRemitoService.getCotizacionByIdMoneda(1) 400
401 .then(function (res) { 401 var cotizacionPArgentino = res.data[0].cotizaciones[0];
402 402 cotizacionPArgentino.moneda = moneda;
403 var cotizacionPArgentino = res.data[0].cotizaciones[0]; 403
404 cotizacionPArgentino.moneda = moneda; 404 actualizarCabeceraMoneda(cotizacionPArgentino);
405 405
406 actualizarCabeceraMoneda(cotizacionPArgentino); 406 $scope.remito.cotizacion = cotizacionPArgentino;
407 407 });
408 $scope.remito.cotizacion = cotizacionPArgentino; 408 }, function () {
409 }); 409
410 }, function () { 410 }
411 411 );
412 } 412 };
413 ); 413
414 }; 414 $scope.abrirModalCotizacion = function (moneda) {
415 415 var modalInstance = $uibModal.open(
416 $scope.abrirModalCotizacion = function (moneda) { 416 {
417 var modalInstance = $uibModal.open( 417 ariaLabelledBy: 'Busqueda de Cotización',
418 { 418 templateUrl: 'modal-cotizacion.html',
419 ariaLabelledBy: 'Busqueda de Cotización', 419 controller: 'focaModalCotizacionController',
420 templateUrl: 'modal-cotizacion.html', 420 size: 'lg',
421 controller: 'focaModalCotizacionController', 421 resolve: { idMoneda: function () { return moneda.ID; } }
422 size: 'lg', 422 }
423 resolve: { idMoneda: function () { return moneda.ID; } } 423 );
424 } 424 modalInstance.result.then(
425 ); 425 function (cotizacion) {
426 modalInstance.result.then( 426
427 function (cotizacion) { 427 cotizacion.moneda = moneda;
428 428 actualizarCabeceraMoneda(cotizacion);
429 cotizacion.moneda = moneda; 429 $scope.factura.cotizacion = cotizacion;
430 actualizarCabeceraMoneda(cotizacion); 430
431 $scope.factura.cotizacion = cotizacion; 431 }, function () {
432 432
433 }, function () { 433 }
434 434 );
435 } 435 };
436 ); 436
437 }; 437 $scope.seleccionarObservaciones = function () {
438 438 var observacion = {
439 $scope.seleccionarObservaciones = function () { 439 titulo: 'Ingrese Observaciones',
440 var observacion = { 440 value: $scope.factura.observaciones,
441 titulo: 'Ingrese Observaciones', 441 maxlength: 155,
442 value: $scope.factura.observaciones, 442 textarea: true
443 maxlength: 155, 443 };
444 textarea: true 444
445 }; 445 focaModalService
446 446 .prompt(observacion)
447 focaModalService 447 .then(function (observaciones) {
448 .prompt(observacion) 448 $scope.factura.observaciones = observaciones;
449 .then(function (observaciones) { 449 });
450 $scope.factura.observaciones = observaciones; 450 };
451 }); 451
452 }; 452 $scope.articulosFiltro = function () {
453 453 return $scope.factura.articulosFactura.filter(function (articulo) {
454 $scope.articulosFiltro = function () { 454 return !articulo.desactivado;
455 return $scope.factura.articulosFactura.filter(function (articulo) { 455 });
456 return !articulo.desactivado; 456 };
457 }); 457
458 }; 458 $scope.getTotal = function () {
459 459
460 $scope.getTotal = function () { 460 var total = 0;
461 461
462 var total = 0; 462 $scope.articulosFiltro().forEach(function (articulo) {
463 463 total += articulo.PUN * articulo.CAN;
464 $scope.articulosFiltro().forEach(function (articulo) { 464 });
465 total += articulo.PUN * articulo.CAN; 465
466 }); 466 return parseFloat(total.toFixed(2));
467 467 };
468 return parseFloat(total.toFixed(2)); 468
469 }; 469 $scope.quitarDespacho = function (articulo, index) {
470 470
471 $scope.quitarDespacho = function (articulo, index) { 471 if (articulo.SUR === 0) {
472 472 articulo.desactivado = true;
473 if (articulo.SUR === 0) { 473 return;
474 articulo.desactivado = true; 474 }
475 return; 475
476 } 476 crearFacturaService
477 477 .setearDespachoDesocupado({
478 crearFacturaService 478 surtidor: $scope.factura.despachos[index].SUR,
479 .setearDespachoDesocupado({ 479 producto: $scope.factura.despachos[index].PRO,
480 surtidor: $scope.factura.despachos[index].SUR, 480 carga: $scope.factura.despachos[index].CAR,
481 producto: $scope.factura.despachos[index].PRO, 481 planilla: $scope.factura.despachos[index].PLA
482 carga: $scope.factura.despachos[index].CAR, 482 })
483 planilla: $scope.factura.despachos[index].PLA 483 .then(function () {
484 }) 484 articulo.desactivado = true;
485 .then(function () { 485 $scope.factura.despachos.splice(index, 1);
486 articulo.desactivado = true; 486 })
487 $scope.factura.despachos.splice(index, 1); 487 .catch(function () {
488 }) 488 focaModalService.alert('Hubo un error al desasociar este despacho');
489 .catch(function () { 489 });
490 focaModalService.alert('Hubo un error al desasociar este despacho'); 490 };
491 }); 491
492 }; 492 //Recibe aviso si el teclado está en uso
493 493 $rootScope.$on('usarTeclado', function (event, data) {
494 //Recibe aviso si el teclado está en uso 494 if (data) {
495 $rootScope.$on('usarTeclado', function (event, data) { 495 $scope.mostrarTeclado = true;
496 if (data) { 496 return;
497 $scope.mostrarTeclado = true; 497 }
498 return; 498 $scope.mostrarTeclado = false;
499 } 499 });
500 $scope.mostrarTeclado = false; 500
501 }); 501 $scope.selectFocus = function ($event) {
502 502 // Si el teclado esta en uso no selecciona el valor
503 $scope.selectFocus = function ($event) { 503 if ($scope.mostrarTeclado) {
504 // Si el teclado esta en uso no selecciona el valor 504 return;
505 if ($scope.mostrarTeclado) { 505 }
506 return; 506 $event.target.select();
507 } 507 };
508 $event.target.select(); 508
509 }; 509
510 510 function getProductosByPlanilla(numeroPlanilla) {
511 511
512 function getProductosByPlanilla(numeroPlanilla) { 512 crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) {
513 513
514 crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { 514 if (!res.data.length) {
515 515
516 if (!res.data.length) { 516 focaModalService.alert('No hay despachos disponibles por el momento');
517 517 return;
518 focaModalService.alert('No hay despachos disponibles por el momento'); 518 }
519 return; 519
520 } 520 $scope.botoneraProductos.length = 0;
521 521 $scope.topDespachos = res.data[0][0].CID;
522 $scope.botoneraProductos.length = 0; 522
523 $scope.topDespachos = res.data[0][0].CID; 523 res.data.slice(1, res.data.length).forEach(function (producto) {
524 524
525 res.data.slice(1, res.data.length).forEach(function (producto) { 525 $scope.botoneraProductos.push({
526 526 label: producto.DetArt,
527 $scope.botoneraProductos.push({ 527 image: producto.nombreImagen,
528 label: producto.DetArt, 528 imageDefault: 'productoDefault.png'
529 image: producto.nombreImagen, 529 });
530 imageDefault: 'productoDefault.png' 530
531 }); 531 crearFuncionesProductos(producto);
532 532 });
533 crearFuncionesProductos(producto); 533
534 }); 534 $scope.botonera.push({
535 535 label: 'Últimos despachos',
536 $scope.botonera.push({ 536 image: 'ultimos-despachos.png',
537 label: 'Ultimos despachos', 537 imageDefault: 'productoDefault.png'
538 image: 'ultimos-despachos.png', 538 });
539 imageDefault: 'productoDefault.png' 539 });
540 }); 540 }
541 }); 541
542 } 542 $scope.seleccionarBusquedaProductos = function () {
543 543
544 $scope.seleccionarBusquedaProductos = function () { 544 if (angular.equals({}, $scope.factura.vendedor)) {
545 545
546 if (angular.equals({}, $scope.factura.vendedor)) { 546 focaModalService.alert('Seleccione Vendedor');
547 547 return false;
548 focaModalService.alert('Seleccione Vendedor'); 548 }
549 return false; 549
550 } 550 var modalInstance = $uibModal.open(
551 551 {
552 var modalInstance = $uibModal.open( 552 ariaLabelledBy: 'Busqueda de Productos',
553 { 553 templateUrl: 'modal-busqueda-productos.html',
554 ariaLabelledBy: 'Busqueda de Productos', 554 controller: 'modalBusquedaProductosCtrl',
555 templateUrl: 'modal-busqueda-productos.html', 555 resolve: {
556 controller: 'modalBusquedaProductosCtrl', 556 parametroProducto: {
557 resolve: { 557 idLista: null,
558 parametroProducto: { 558 cotizacion: $scope.factura.cotizacion.VENDEDOR,
559 idLista: null, 559 simbolo: $scope.factura.cotizacion.moneda.SIMBOLO,
560 cotizacion: $scope.factura.cotizacion.VENDEDOR, 560 buscarTodos: true
561 simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, 561 }
562 buscarTodos: true 562 },
563 } 563 size: 'lg'
564 }, 564 }
565 size: 'lg' 565 );
566 } 566
567 ); 567 modalInstance.result
568 568 .then(function (producto) {
569 modalInstance.result 569
570 .then(function (producto) { 570 var articulo = {
571 571 TIP: $scope.factura.cliente.TIP,
572 var articulo = { 572 TCO: 'FT',
573 TIP: $scope.factura.cliente.TIP, 573 SUC: parseInt($scope.puntoVenta),
574 TCO: 'FT', 574 ORD: $scope.articulosFiltro().length + 1,
575 SUC: parseInt($scope.puntoVenta), 575 SEC: producto.sector,
576 ORD: $scope.articulosFiltro().length + 1, 576 ART: producto.codigo,
577 SEC: producto.sector, 577 RUB: producto.CodRub,
578 ART: producto.codigo, 578 DES: producto.descripcionLarga,
579 RUB: producto.CodRub, 579 PUN: producto.precio,
580 DES: producto.descripcionLarga, 580 IVA: producto.IMPIVA,
581 PUN: producto.precio, 581 NET: producto.IvaCO !== 0 ? parseFloat(producto.neto) : 0,
582 IVA: producto.IMPIVA, 582 NEX: producto.IvaCO === 0 ? parseFloat(producto.neto) : 0,
583 NET: producto.IvaCO !== 0 ? parseFloat(producto.neto) : 0, 583 IMI: producto.ImpInt,
584 NEX: producto.IvaCO === 0 ? parseFloat(producto.neto) : 0, 584 IMI2: producto.ImpInt2,
585 IMI: producto.ImpInt, 585 IMI3: producto.ImpInt3,
586 IMI2: producto.ImpInt2, 586 PUT: producto.precio,
587 IMI3: producto.ImpInt3, 587 SUR: 0,
588 PUT: producto.precio, 588 PLA: $scope.factura.vendedor.NplVen,
589 SUR: 0, 589 LUG: $scope.factura.vendedor.LugVen,
590 PLA: $scope.factura.vendedor.NplVen, 590 LEG: $scope.factura.vendedor.CodVen,
591 LUG: $scope.factura.vendedor.LugVen, 591 TUR: $scope.factura.vendedor.TurVen,
592 LEG: $scope.factura.vendedor.CodVen, 592 ORDEN_PRECOMPRA: '',
593 TUR: $scope.factura.vendedor.TurVen, 593 ESC: producto.tipoFactura === 'L' ? 1 : 0,
594 ORDEN_PRECOMPRA: '', 594 CMF: 0,
595 ESC: producto.tipoFactura === 'L' ? 1 : 0, 595 PTA: 0,
596 CMF: 0, 596 IVS: 0,
597 PTA: 0, 597 TIVA: 0,
598 IVS: 0, 598 CON: 0,
599 TIVA: 0, 599 SINO: '',
600 CON: 0, 600 ORD_TRA: 0,
601 SINO: '', 601 IMP_DESP: 0,
602 ORD_TRA: 0, 602 PCD: 0,
603 IMP_DESP: 0, 603 RTO: '',
604 PCD: 0, 604 };
605 RTO: '', 605
606 }; 606 $scope.factura.articulosFactura.push(articulo);
607 607 $scope.cambioEdit(articulo, 'cantidad');
608 $scope.factura.articulosFactura.push(articulo); 608
609 $scope.cambioEdit(articulo, 'cantidad'); 609 })
610 610 .catch(function (e) { console.error(e); });
611 }) 611 };
612 .catch(function (e) { console.error(e); }); 612
613 }; 613 $scope.seleccionarUltimosDespachos = function () {
614 614
615 $scope.seleccionarUltimosDespachos = function () { 615 if (angular.equals($scope.factura.cliente, {})) {
616 616 focaModalService.alert('Seleccione cliente');
617 if (angular.equals($scope.factura.cliente, {})) { 617 return;
618 focaModalService.alert('Seleccione cliente'); 618 }
619 return; 619
620 } 620 var modalInstance = $uibModal.open(
621 621 {
622 var modalInstance = $uibModal.open( 622 templateUrl: 'modal-ultimos-despachos.html',
623 { 623 controller: 'ultimosDespachosController',
624 templateUrl: 'modal-ultimos-despachos.html', 624 resolve: {
625 controller: 'ultimosDespachosController', 625 parametros: function () {
626 resolve: { 626 return {
627 parametros: function () { 627 planilla: $scope.factura.vendedor.NplVen,
628 return { 628 };
629 planilla: $scope.factura.vendedor.NplVen, 629 }
630 }; 630 },
631 } 631 size: 'md'
632 }, 632 }
633 size: 'md' 633 );
634 } 634
635 ); 635 modalInstance.result.then(function (producto) {
636 636
637 modalInstance.result.then(function (producto) { 637 var articulo = {
638 638 TIP: $scope.factura.cliente.TIP,
639 var articulo = { 639 TCO: 'FT',
640 TIP: $scope.factura.cliente.TIP, 640 SUC: parseInt($scope.puntoVenta),
641 TCO: 'FT', 641 ORD: $scope.articulosFiltro().length + 1,
642 SUC: parseInt($scope.puntoVenta), 642 SEC: producto.despachos[0].SEC,
643 ORD: $scope.articulosFiltro().length + 1, 643 ART: producto.despachos[0].PRO,
644 SEC: producto.despachos[0].SEC, 644 RUB: producto.CodRub,
645 ART: producto.despachos[0].PRO, 645 DES: producto.DetArt,
646 RUB: producto.CodRub, 646 CAN: producto.despachos[0].LTS,
647 DES: producto.DetArt, 647 PUN: producto.PreVen,
648 CAN: producto.despachos[0].LTS, 648 IVA: producto.IMPIVA,
649 PUN: producto.PreVen, 649 NET: producto.IvaCO !== 0 ? producto.PreNet : 0,
650 IVA: producto.IMPIVA, 650 NEX: producto.IvaCO === 0 ? producto.PreNet : 0,
651 NET: producto.IvaCO !== 0 ? producto.PreNet : 0, 651 IMI: producto.ImpInt,
652 NEX: producto.IvaCO === 0 ? producto.PreNet : 0, 652 IMI2: producto.ImpInt2,
653 IMI: producto.ImpInt, 653 IMI3: producto.ImpInt3,
654 IMI2: producto.ImpInt2, 654 PUT: producto.PreVen,
655 IMI3: producto.ImpInt3, 655 SUR: producto.despachos[0].SUR,
656 PUT: producto.PreVen, 656 PLA: producto.despachos[0].PLA,
657 SUR: producto.despachos[0].SUR, 657 LUG: producto.despachos[0].LUG,
658 PLA: producto.despachos[0].PLA, 658 LEG: $scope.factura.vendedor.CodVen,
659 LUG: producto.despachos[0].LUG, 659 TUR: $scope.factura.vendedor.TurVen,
660 LEG: $scope.factura.vendedor.CodVen, 660 ORDEN_PRECOMPRA: '',
661 TUR: $scope.factura.vendedor.TurVen, 661 ESC: producto.tipoFactura === 'L' ? 1 : 0,
662 ORDEN_PRECOMPRA: '', 662 CMF: 0,
663 ESC: producto.tipoFactura === 'L' ? 1 : 0, 663 PTA: 0,
664 CMF: 0, 664 IVS: 0,
665 PTA: 0, 665 TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO
666 IVS: 0, 666 CON: 0,
667 TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO 667 SINO: '',
668 CON: 0, 668 ORD_TRA: 0,
669 SINO: '', 669 IMP_DESP: 0,
670 ORD_TRA: 0, 670 PCD: 0,
671 IMP_DESP: 0, 671 RTO: '',
672 PCD: 0, 672 };
673 RTO: '', 673
674 }; 674 crearFacturaService.setearDespachoOcupado({
675 675 surtidor: producto.despachos[0].SUR,
676 crearFacturaService.setearDespachoOcupado({ 676 producto: producto.despachos[0].PRO,
677 surtidor: producto.despachos[0].SUR, 677 carga: producto.despachos[0].CAR
678 producto: producto.despachos[0].PRO, 678 })
679 carga: producto.despachos[0].CAR 679 .then(function () {
680 }) 680 $scope.factura.articulosFactura.push(articulo);
681 .then(function () { 681 $scope.factura.despachos.push(producto.despachos[0]);
682 $scope.factura.articulosFactura.push(articulo); 682 })
683 $scope.factura.despachos.push(producto.despachos[0]); 683 .catch(function (err) {
684 }) 684
685 .catch(function (err) { 685 console.error(err);
686 686 focaModalService.alert('El despacho esta en uso');
687 console.error(err); 687 });
688 focaModalService.alert('El despacho esta en uso'); 688
689 }); 689 })
690 690 .catch(function (err) {
691 }) 691 console.error(err);
692 .catch(function (err) { 692 });
693 console.error(err); 693
694 }); 694 };
695 695
696 }; 696 function crearFuncionesProductos(producto) {
697 697
698 function crearFuncionesProductos(producto) { 698 $scope[nombreFuncion(producto.DetArt)] = function () {
699 699
700 $scope[nombreFuncion(producto.DetArt)] = function () { 700 if (angular.equals($scope.factura.cliente, {})) {
701 701 focaModalService.alert('Seleccione cliente');
702 if (angular.equals($scope.factura.cliente, {})) { 702 return;
703 focaModalService.alert('Seleccione cliente'); 703 }
704 return; 704
705 } 705 var modalInstance = $uibModal.open(
706 706 {
707 var modalInstance = $uibModal.open( 707 templateUrl: 'modal-combustibles.html',
708 { 708 controller: 'focaModalCombustiblesController',
709 templateUrl: 'modal-combustibles.html', 709 resolve: {
710 controller: 'focaModalCombustiblesController', 710 parametros: function () {
711 resolve: { 711 return {
712 parametros: function () { 712 despachos: producto.despachos,
713 return { 713 nombreProducto: producto.DetArt,
714 despachos: producto.despachos, 714 topDespachos: $scope.topDespachos
715 nombreProducto: producto.DetArt, 715 };
716 topDespachos: $scope.topDespachos 716 }
717 }; 717 },
718 } 718 size: 'md'
719 }, 719 }
720 size: 'md' 720 );
721 } 721
722 ); 722 modalInstance.result.then(function (despacho) {
723 723
724 modalInstance.result.then(function (despacho) { 724 var articulo = {
725 725 TIP: $scope.factura.cliente.TIP,
726 var articulo = { 726 TCO: 'FT',
727 TIP: $scope.factura.cliente.TIP, 727 SUC: parseInt($scope.puntoVenta),
728 TCO: 'FT', 728 ORD: $scope.articulosFiltro().length + 1,
729 SUC: parseInt($scope.puntoVenta), 729 SEC: despacho.SEC,
730 ORD: $scope.articulosFiltro().length + 1, 730 ART: despacho.PRO,
731 SEC: despacho.SEC, 731 RUB: producto.CodRub,
732 ART: despacho.PRO, 732 DES: producto.DetArt,
733 RUB: producto.CodRub, 733 CAN: despacho.LTS,
734 DES: producto.DetArt, 734 PUN: producto.PreVen,
735 CAN: despacho.LTS, 735 IVA: producto.IMPIVA,
736 PUN: producto.PreVen, 736 NET: producto.IvaCO !== 0 ? producto.PreNet : 0,
737 IVA: producto.IMPIVA, 737 NEX: producto.IvaCO === 0 ? producto.PreNet : 0,
738 NET: producto.IvaCO !== 0 ? producto.PreNet : 0, 738 IMI: producto.ImpInt,
739 NEX: producto.IvaCO === 0 ? producto.PreNet : 0, 739 IMI2: producto.ImpInt2,
740 IMI: producto.ImpInt, 740 IMI3: producto.ImpInt3,
741 IMI2: producto.ImpInt2, 741 PUT: producto.PreVen,
742 IMI3: producto.ImpInt3, 742 SUR: despacho.SUR,
743 PUT: producto.PreVen, 743 PLA: despacho.PLA,
744 SUR: despacho.SUR, 744 LUG: despacho.LUG,
745 PLA: despacho.PLA, 745 LEG: $scope.factura.vendedor.CodVen,
746 LUG: despacho.LUG, 746 TUR: $scope.factura.vendedor.TurVen,
747 LEG: $scope.factura.vendedor.CodVen, 747 ORDEN_PRECOMPRA: '',
748 TUR: $scope.factura.vendedor.TurVen, 748 ESC: producto.tipoFactura === 'L' ? 1 : 0,
749 ORDEN_PRECOMPRA: '', 749 CMF: 0,
750 ESC: producto.tipoFactura === 'L' ? 1 : 0, 750 PTA: 0,
751 CMF: 0, 751 IVS: 0,
752 PTA: 0, 752 TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO
753 IVS: 0, 753 CON: 0,
754 TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO 754 SINO: '',
755 CON: 0, 755 ORD_TRA: 0,
756 SINO: '', 756 IMP_DESP: 0,
757 ORD_TRA: 0, 757 PCD: 0,
758 IMP_DESP: 0, 758 RTO: '',
759 PCD: 0, 759 };
760 RTO: '', 760
761 }; 761 crearFacturaService.setearDespachoOcupado({
762 762 surtidor: despacho.SUR,
763 crearFacturaService.setearDespachoOcupado({ 763 producto: despacho.PRO,
764 surtidor: despacho.SUR, 764 carga: despacho.CAR
765 producto: despacho.PRO, 765 })
766 carga: despacho.CAR 766 .then(function () {
767 }) 767 $scope.factura.articulosFactura.push(articulo);
768 .then(function () { 768 $scope.factura.despachos.push(despacho);
769 $scope.factura.articulosFactura.push(articulo); 769 })
770 $scope.factura.despachos.push(despacho); 770 .catch(function (err) {
771 }) 771
772 .catch(function (err) { 772 console.error(err);
773 773 focaModalService.alert('El despacho está en uso');
774 console.error(err); 774 });
775 focaModalService.alert('El despacho esta en uso'); 775
776 }); 776 })
777 777 .catch(function (err) {
778 }) 778 console.error(err);
779 .catch(function (err) { 779 });
780 console.error(err); 780
781 }); 781 };
782 782 }
783 }; 783
784 } 784 function nombreFuncion(string) {
785 785 var texto = 'seleccionar';
786 function nombreFuncion(string) { 786 var arr = string.split(' ');
787 var texto = 'seleccionar'; 787 arr.forEach(function (palabra) {
788 var arr = string.split(' '); 788 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1);
789 arr.forEach(function (palabra) { 789 texto += palabra;
790 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); 790 });
791 texto += palabra; 791 return texto;
792 }); 792 }
793 return texto; 793
794 } 794 function indicarPassword(vendedor) {
795 795
796 function indicarPassword(vendedor) { 796 return new Promise(function (resolve, reject) {
797 797
798 return new Promise(function (resolve, reject) { 798 function openPrompt() {
799 799 return focaModalService
800 function openPrompt() { 800 .prompt({
801 return focaModalService 801 titulo: 'Indique Contraseña',
802 .prompt({ 802 value: '',
803 titulo: 'Indique Contraseña', 803 tipo: 'password'
804 value: '', 804 })
805 tipo: 'password' 805 .then(function (contraseña) {
806 }) 806
807 .then(function (contraseña) { 807 if (contraseña !== vendedor.ClaVen.trim()) {
808 808
809 if (contraseña !== vendedor.ClaVen.trim()) { 809 focaModalService.alert('Clave incorrecta').then(function () {
810 810 openPrompt(vendedor);
811 focaModalService.alert('Clave incorrecta').then(function () { 811 });
812 openPrompt(vendedor); 812 } else {
813 }); 813 resolve();
814 } else { 814 }
815 resolve(); 815 })
816 } 816 .catch(reject);
817 }) 817 }
818 .catch(reject); 818
819 } 819 openPrompt();
820 820 });
821 openPrompt(); 821 }
822 }); 822
823 } 823 function validarPlanillaVendedor(vendedor) {
824 824
825 function validarPlanillaVendedor(vendedor) { 825 return new Promise(function (resolve, reject) {
826 826
827 return new Promise(function (resolve, reject) { 827 crearFacturaService
828 828 .validarPlanillaVendedor(vendedor.CodVen.toString().trim())
829 crearFacturaService 829 .then(function (res) {
830 .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) 830
831 .then(function (res) { 831 if (!res.data.length) {
832 832
833 if (!res.data.length) { 833 focaModalService
834 834 .alert('No se encontró planilla abierta para el vendedor')
835 focaModalService 835 .then(reject);
836 .alert('No se encontró planilla abierta para el vendedor') 836
837 .then(reject); 837 } else {
838 838 resolve();
839 } else { 839 }
840 resolve(); 840
841 } 841 })
842 842 .catch(function (err) {
843 }) 843 console.log(err);
844 .catch(function (err) { 844 reject();
845 console.log(err); 845 });
846 reject(); 846 });
847 }); 847 }
848 }); 848
849 } 849 function rellenar(relleno, longitud) {
850 850 relleno = '' + relleno;
851 function rellenar(relleno, longitud) { 851 while (relleno.length < longitud) {
852 relleno = '' + relleno; 852 relleno = '0' + relleno;
853 while (relleno.length < longitud) { 853 }
854 relleno = '0' + relleno; 854 return relleno;
855 } 855 }
856 return relleno; 856
857 } 857 $scope.salir = function () {
858 858 var confirmacion = false;
859 $scope.salir = function () { 859
860 var confirmacion = false; 860 if (!angular.equals($scope.factura, $scope.inicial)) {
861 861 confirmacion = true;
862 if (!angular.equals($scope.factura, $scope.inicial)) { 862 }
863 confirmacion = true; 863
864 } 864 if (confirmacion) {
865 865 focaModalService.confirm(
866 if (confirmacion) { 866 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
867 focaModalService.confirm( 867 ).then(function (data) {
868 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' 868 if (data) {
869 ).then(function (data) { 869 $location.path('/');
870 if (data) { 870 }
871 $location.path('/'); 871 });
872 } 872 } else {
873 }); 873 $location.path('/');
874 } else { 874 }
875 $location.path('/'); 875 };
876 } 876
877 }; 877 function setearFactura(factura) {
878 878
879 function setearFactura(factura) { 879 $scope.$broadcast('cleanCabecera');
880 880
881 $scope.$broadcast('cleanCabecera'); 881 $scope.cabeceras = [];
882 882
883 $scope.cabeceras = []; 883 if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') {
884 884 $scope.cabeceras.push({
885 if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { 885 label: 'Moneda:',
886 $scope.cabeceras.push({ 886 valor: factura.cotizacion.moneda.DETALLE
887 label: 'Moneda:', 887 });
888 valor: factura.cotizacion.moneda.DETALLE 888 $scope.cabeceras.push({
889 }); 889 label: 'Fecha cotizacion:',
890 $scope.cabeceras.push({ 890 valor: $filter('date')(factura.cotizacion.FECHA,
891 label: 'Fecha cotizacion:', 891 'dd/MM/yyyy')
892 valor: $filter('date')(factura.cotizacion.FECHA, 892 });
893 'dd/MM/yyyy') 893 $scope.cabeceras.push({
894 }); 894 label: 'Cotizacion:',
895 $scope.cabeceras.push({ 895 valor: $filter('number')(factura.cotizacion.VENDEDOR,
896 label: 'Cotizacion:', 896 '2')
897 valor: $filter('number')(factura.cotizacion.VENDEDOR, 897 });
898 '2') 898 }
899 }); 899
900 } 900 if (factura.cotizacion && factura.cotizacion.moneda) {
901 901 // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true;
902 if (factura.cotizacion && factura.cotizacion.moneda) { 902 }
903 // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; 903
904 } 904 if (factura.cliente && factura.cliente.COD) {
905 905 $scope.cabeceras.push({
906 if (factura.cliente && factura.cliente.COD) { 906 label: 'Cliente:',
907 $scope.cabeceras.push({ 907 valor: $filter('rellenarDigitos')(factura.cliente.COD, 3) + ' - ' +
908 label: 'Cliente:', 908 factura.cliente.NOM
909 valor: $filter('rellenarDigitos')(factura.cliente.COD, 3) + ' - ' + 909 });
910 factura.cliente.NOM 910
911 }); 911 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
912 912 }
913 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; 913
914 } 914 $scope.puntoVenta = rellenar(factura.sucursal, 4);
915 915 $scope.comprobante = rellenar(factura.numerofactura, 8);
916 $scope.puntoVenta = rellenar(factura.sucursal, 4); 916 $scope.factura = factura;
917 $scope.comprobante = rellenar(factura.numerofactura, 8); 917
918 $scope.factura = factura; 918 addArrayCabecera($scope.cabeceras);
919 919 }
920 addArrayCabecera($scope.cabeceras); 920
921 } 921 function getLSFactura() {
922 922 var factura = JSON.parse($localStorage.factura || null);
923 function getLSFactura() { 923 if (factura) {
924 var factura = JSON.parse($localStorage.factura || null); 924 setearFactura(factura);
925 if (factura) { 925 delete $localStorage.factura;
926 setearFactura(factura); 926 }
927 delete $localStorage.factura; 927 }
928 } 928
929 } 929 function addArrayCabecera(array) {
930 930 for (var i = 0; i < array.length; i++) {
931 function addArrayCabecera(array) { 931 $scope.$broadcast('addCabecera', {
932 for (var i = 0; i < array.length; i++) { 932 label: array[i].label,
933 $scope.$broadcast('addCabecera', { 933 valor: array[i].valor
934 label: array[i].label, 934 });
935 valor: array[i].valor 935 }
936 }); 936 }
937 } 937
938 } 938 $scope.cambioEdit = function (articulo, propiedad) {
939 939 if (propiedad === 'cantidad' && articulo.SUR === 0) {
940 $scope.cambioEdit = function (articulo, propiedad) { 940 articulo.editCantidad = true;
941 if (propiedad === 'cantidad' && articulo.SUR === 0) { 941 }
942 articulo.editCantidad = true; 942 };
943 } 943
944 }; 944 $scope.editarArticulo = function (key, articulo, tmpCantidad) {
945 945 if (key === 13) {
946 $scope.editarArticulo = function (key, articulo, tmpCantidad) { 946 if (!articulo.cantidad && tmpCantidad.length === 0) {
947 if (key === 13) { 947 focaModalService.alert('Los valores deben ser al menos 1');
948 if (!articulo.cantidad && tmpCantidad.length === 0) { 948 return;
949 focaModalService.alert('Los valores deben ser al menos 1'); 949 } else if (tmpCantidad === '0') {
950 return; 950 focaModalService.alert('Está ingresando un producto con valor 0');
951 } else if (tmpCantidad === '0') { 951 return;
952 focaModalService.alert('Esta ingresando un producto con valor 0'); 952 } else if (parseInt(tmpCantidad) < 0) {
953 return; 953 focaModalService.alert('Los valores no pueden ser negativos');
954 } else if (parseInt(tmpCantidad) < 0) { 954 return;
955 focaModalService.alert('Los valores no pueden ser negativos'); 955 }
956 return; 956 articulo.CAN = parseInt(tmpCantidad);
957 } 957 $scope.getTotal();
958 articulo.CAN = parseInt(tmpCantidad); 958 articulo.editCantidad = false;
959 $scope.getTotal(); 959 }
960 articulo.editCantidad = false; 960 };
961 } 961
962 }; 962 $scope.cancelarEditar = function (articulo) {
963 963 $scope.tmpCantidad = articulo.CAN;
964 $scope.cancelarEditar = function (articulo) { 964 articulo.editCantidad = false;
965 $scope.tmpCantidad = articulo.CAN; 965 };
966 articulo.editCantidad = false; 966
967 }; 967 function actualizarCabeceraMoneda(cotizacion) {
968 968
969 function actualizarCabeceraMoneda(cotizacion) { 969 $scope.factura.articulosFactura.forEach(function (art) {
970 970 art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4);
971 $scope.factura.articulosFactura.forEach(function (art) { 971 art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4);
972 art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); 972 });
973 art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); 973
974 }); 974 if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') {
975 975 $scope.$broadcast('removeCabecera', 'Moneda:');
976 if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { 976 $scope.$broadcast('removeCabecera', 'Fecha cotización:');
977 $scope.$broadcast('removeCabecera', 'Moneda:'); 977 $scope.$broadcast('removeCabecera', 'Cotización:');
978 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 978 } else {
979 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 979 $scope.$broadcast('addCabecera', {
980 } else { 980 label: 'Moneda:',
981 $scope.$broadcast('addCabecera', { 981 valor: cotizacion.moneda.DETALLE
982 label: 'Moneda:', 982 });
983 valor: cotizacion.moneda.DETALLE 983 $scope.$broadcast('addCabecera', {
984 }); 984 label: 'Fecha cotización:',
985 $scope.$broadcast('addCabecera', { 985 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
986 label: 'Fecha cotizacion:', 986 });
987 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 987 $scope.$broadcast('addCabecera', {
988 }); 988 label: 'Cotización:',
989 $scope.$broadcast('addCabecera', { 989 valor: $filter('number')(cotizacion.VENDEDOR, '2')
990 label: 'Cotizacion:', 990 });
991 valor: $filter('number')(cotizacion.VENDEDOR, '2') 991 }
992 }); 992 }
993 } 993
994 } 994 function validarGuardar() {
995 995
996 function validarGuardar() { 996 if (angular.equals({}, $scope.factura.vendedor)) {
997 997
998 if (angular.equals({}, $scope.factura.vendedor)) { 998 focaModalService.alert('Seleccione Vendedor');
999 999 return false;
1000 focaModalService.alert('Seleccione Vendedor'); 1000 } else if (angular.equals({}, $scope.factura.cliente)) {
1001 return false; 1001
1002 } else if (angular.equals({}, $scope.factura.cliente)) { 1002 focaModalService.alert('Seleccione Cliente');
1003 1003 return false;
1004 focaModalService.alert('Seleccione Cliente'); 1004 } else if (!$scope.articulosFiltro().length) {
1005 return false; 1005
1006 } else if (!$scope.articulosFiltro().length) { 1006 focaModalService.alert('Seleccione al menos un Artículo');
1007 1007 return false;
1008 focaModalService.alert('Seleccione al menos un Articulo'); 1008 }
1009 return false; 1009
1010 } 1010 return true;
1011 1011 }
1012 return true; 1012
1013 } 1013 //recibo la propiedad por la cual quiero obtener el valor
1014 1014 function getImporte(propiedad) {
1015 //recibo la propiedad por la cual quiero obtener el valor 1015 var importe = 0;
1016 function getImporte(propiedad) { 1016
1017 var importe = 0; 1017 $scope.articulosFiltro().forEach(function (articulo) {
1018 1018
1019 $scope.articulosFiltro().forEach(function (articulo) { 1019 if (articulo[propiedad]) {
1020 1020 importe += articulo[propiedad] * articulo.CAN;
1021 if (articulo[propiedad]) { 1021 }
1022 importe += articulo[propiedad] * articulo.CAN; 1022 return;
1023 } 1023
1024 return; 1024 });
1025 1025
1026 }); 1026 return importe;
1027 1027 }
1028 return importe; 1028
1029 } 1029 function getNumeroFactura(tipoFactura) {
1030 1030
1031 function getNumeroFactura(tipoFactura) { 1031 crearRemitoService.getNumeroRemito(tipoFactura).then(
1032 1032 function (res) {
1033 crearRemitoService.getNumeroRemito(tipoFactura).then( 1033 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
1034 function (res) { 1034 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
1035 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 1035 },
1036 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 1036 function (err) {
1037 }, 1037 focaModalService.alert('La terminal no está configurada correctamente');
1038 function (err) { 1038 console.info(err);
1039 focaModalService.alert('La terminal no esta configurada correctamente'); 1039 }
1040 console.info(err); 1040 );
1041 } 1041 }
1042 ); 1042 }
1043 } 1043 ]);
1044 } 1044
1045 ]);
1046
src/js/controllerUltimosDespachos.js
1 angular.module('focaCrearFactura') 1 angular.module('focaCrearFactura')
2 .controller('ultimosDespachosController', [ 2 .controller('ultimosDespachosController', [
3 '$filter', 3 '$filter',
4 '$scope', 4 '$scope',
5 '$uibModalInstance', 5 '$uibModalInstance',
6 'crearFacturaService', 6 'crearFacturaService',
7 'parametros', 7 'parametros',
8 function ($filter, $scope, $uibModalInstance, crearFacturaService, parametros) { 8 function ($filter, $scope, $uibModalInstance, crearFacturaService, parametros) {
9 9
10 config(); 10 config();
11 11
12 function config() { 12 function config() {
13 13
14 $scope.productos = []; 14 $scope.productos = [];
15 15
16 crearFacturaService.getUltimosDespachos(parametros.planilla).then(function (res) { 16 crearFacturaService.getUltimosDespachos(parametros.planilla).then(function (res) {
17 17
18 res.data.slice(1, res.data.length).forEach(function (producto) { 18 res.data.slice(1, res.data.length).forEach(function (producto) {
19 19
20 producto.mangueras = []; 20 producto.mangueras = [];
21 21
22 producto.despachos.forEach(function (despacho) { 22 producto.despachos.forEach(function (despacho) {
23 23
24 var findCsu = producto.mangueras.filter(function (csu) { 24 var findCsu = producto.mangueras.filter(function (csu) {
25 return csu.csu === despacho.CSU.trim(); 25 return csu.csu === despacho.CSU.trim();
26 })[0]; 26 })[0];
27 27
28 if (!findCsu) { 28 if (!findCsu) {
29 29
30 var manguera = { 30 var manguera = {
31 csu: despacho.CSU.trim(), 31 csu: despacho.CSU.trim(),
32 despachos: [despacho], 32 despachos: [despacho],
33 show: true 33 show: true
34 }; 34 };
35 35
36 producto.mangueras.unshift(manguera); 36 producto.mangueras.unshift(manguera);
37 } else { 37 } else {
38 findCsu.despachos.push(despacho); 38 findCsu.despachos.push(despacho);
39 } 39 }
40 }); 40 });
41 41
42 $scope.productos.push(producto); 42 $scope.productos.push(producto);
43 }); 43 });
44 44
45 console.log($scope.productos); 45 console.log($scope.productos);
46 46
47 }); 47 });
48 } 48 }
49 49
50 $scope.aceptar = function (despacho) { 50 $scope.aceptar = function (producto, despacho) {
51 $uibModalInstance.close(despacho); 51 producto.despachos = [];
52 producto.despachos.push(despacho);
53 $uibModalInstance.close(producto);
52 }; 54 };
53 55
54 $scope.cancel = function () { 56 $scope.cancel = function () {
55 $uibModalInstance.dismiss('cancel'); 57 $uibModalInstance.dismiss('cancel');
56 }; 58 };
57 59
58 } 60 }
59 ]); 61 ]);
60 62
1 angular.module('focaCrearFactura') 1 angular.module('focaCrearFactura')
2 .service('crearFacturaService', ['$http', 'API_ENDPOINT', 'APP', 2 .service('crearFacturaService', ['$http', 'API_ENDPOINT', 'APP',
3 function ($http, API_ENDPOINT, APP) { 3 function ($http, API_ENDPOINT, APP) {
4 var route = API_ENDPOINT.URL; 4 var route = API_ENDPOINT.URL;
5 return { 5 return {
6 guardarFactura: function (factura) { 6 guardarFactura: function (factura) {
7 return $http.post(route + '/factura/guardar', factura); 7 return $http.post(route + '/factura/guardar', factura);
8 }, 8 },
9 getParametros: function () { 9 getParametros: function () {
10 return $http.get(API_ENDPOINT.URL + '/parametros/factura'); 10 return $http.get(API_ENDPOINT.URL + '/parametros/factura');
11 }, 11 },
12 validarPlanillaVendedor: function (idVendedor) { 12 validarPlanillaVendedor: function (idVendedor) {
13 return $http.get(route + '/turnos/validar-planilla/' + idVendedor); 13 return $http.get(route + '/turnos/validar-planilla/' + idVendedor);
14 }, 14 },
15 getProductosByPlanilla: function (numeroPlanilla) { 15 getProductosByPlanilla: function (numeroPlanilla) {
16 return $http.get(route + '/turnos/productos/' + numeroPlanilla); 16 return $http.get(route + '/turnos/productos/' + numeroPlanilla);
17 }, 17 },
18 getUltimosDespachos: function (numeroPlanilla) { 18 getUltimosDespachos: function (numeroPlanilla) {
19 return $http.get(route + '/turnos/productos/' + numeroPlanilla + '/true'); 19 return $http.get(route + '/turnos/productos/' + numeroPlanilla + '/true');
20 }, 20 },
21 setearDespachoOcupado: function (parametros) { 21 setearDespachoOcupado: function (parametros) {
22 return $http.post(route + '/turnos/despacho-en-uso', parametros); 22 return $http.post(route + '/turnos/despacho-en-uso', parametros);
23 }, 23 },
24 setearDespachoDesocupado: function (parametros) { 24 setearDespachoDesocupado: function (parametros) {
25 return $http.post(route + '/turnos/depacho-sin-uso', parametros); 25 return $http.post(route + '/turnos/depacho-sin-uso', parametros);
26 }, 26 },
27 getResumenCuenta: function (idCliente) { 27 getResumenCuenta: function (idCliente) {
28 return $http.get(route + '/cliente/resumen-cuenta/' + idCliente); 28 return $http.get(route + '/cliente/resumen-cuenta/' + idCliente);
29 }, 29 },
30 getVendedorPlayaById: function (id) { 30 getVendedorPlayaById: function (id) {
31 return $http.get(route + '/vendedor-playa/' + id); 31 return $http.get(route + '/vendedor-playa/' + id);
32 }, 32 },
33 getBotonera: function () { 33 getBotonera: function () {
34 var vendedor = { 34 var vendedor = {
35 label: 'Vendedor', 35 label: 'Vendedor',
36 image: 'vendedor.png' 36 image: 'vendedor.png'
37 }; 37 };
38 // $scope.botoneraProductos.push({ 38 // $scope.botoneraProductos.push({
39 // label: 'Busqueda Productos', 39 // label: 'Busqueda Productos',
40 // image: 'buscarProductos.png', 40 // image: 'buscarProductos.png',
41 // imageDefault: 'productoDefault.png' 41 // imageDefault: 'productoDefault.png'
42 // }); 42 // });
43 var botones = [ 43 var botones = [
44 { 44 {
45 label: 'Cliente', 45 label: 'Cliente',
46 image: 'cliente.png' 46 image: 'cliente.png'
47 }, 47 },
48 { 48 {
49 label: 'Busqueda Productos', 49 label: 'Búsqueda Productos',
50 image: 'productos.png' 50 image: 'productos.png'
51 } 51 }
52 // { 52 // {
53 // label: 'Moneda', 53 // label: 'Moneda',
54 // image: 'moneda.png' 54 // image: 'moneda.png'
55 // }, 55 // },
56 // { 56 // {
57 // label: 'Observaciones', 57 // label: 'Observaciones',
58 // image: 'botonObservaciones.png' 58 // image: 'botonObservaciones.png'
59 // } 59 // }
60 ]; 60 ];
61 61
62 if (APP !== 'facturador') { 62 if (APP !== 'facturador') {
63 botones.unshift(vendedor); 63 botones.unshift(vendedor);
64 } 64 }
65 65
66 return botones; 66 return botones;
67 } 67 }
68 }; 68 };
69 } 69 }
70 ]); 70 ]);
71 71
src/views/modal-ultimos-despachos.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"><b>Últimos Despachos</b></h5> 4 <h5 class="modal-title my-1"><b>Últimos Despachos</b></h5>
5 </div> 5 </div>
6 </div> 6 </div>
7 </div> 7 </div>
8 <div class="modal-body" id="modal-body"> 8 <div class="modal-body" id="modal-body">
9 <div ng-repeat="(key, producto) in productos"> 9 <div ng-repeat="(key, producto) in productos">
10 <div class="row pb-2 border-bottom"> 10 <div class="row pb-2 border-bottom">
11 <div class="col"> 11 <div class="col">
12 <p class="m-1 h6"> 12 <p class="m-1 h6">
13 <b> 13 <b>
14 <i class="fa fa-circle" aria-hidden="true"></i>&nbsp;&nbsp;{{producto.DetArt}} 14 <i class="fa fa-circle" aria-hidden="true"></i>&nbsp;&nbsp;{{producto.DetArt}}
15 </b> 15 </b>
16 </p> 16 </p>
17 </div> 17 </div>
18 </div> 18 </div>
19 <div class="row my-2" ng-repeat="(key, manguera) in producto.mangueras"> 19 <div class="row my-2" ng-repeat="(key, manguera) in producto.mangueras">
20 <div class="col"> 20 <div class="col">
21 <label> 21 <label>
22 <img class="w-50" ng-src="./img/surtidor.png" alt=""> 22 <img class="w-50" ng-src="./img/surtidor.png" alt="">
23 {{manguera.csu}} 23 {{manguera.csu}}
24 </label> 24 </label>
25 <button 25 <button
26 type="button" 26 type="button"
27 class="btn p-1 text-secondary float-right border" 27 class="btn p-1 text-secondary float-right border"
28 ng-click="manguera.show = !manguera.show"> 28 ng-click="manguera.show = !manguera.show">
29 <i ng-show="manguera.show" class="fa fa-minus px-1"></i> 29 <i ng-show="manguera.show" class="fa fa-minus px-1"></i>
30 <i ng-show="!manguera.show" class="fa fa-plus px-1"></i> 30 <i ng-show="!manguera.show" class="fa fa-plus px-1"></i>
31 </button> 31 </button>
32 <table class="table table-sm table-striped" ng-show="manguera.show"> 32 <table class="table table-sm table-striped" ng-show="manguera.show">
33 <tbody> 33 <tbody>
34 <tr ng-repeat="despacho in manguera.despachos"> 34 <tr ng-repeat="despacho in manguera.despachos">
35 <td class="py-2 py-sm-1" ng-bind="despacho.FEC | date:'dd/MM/yyyy hh:MM:ss'"></td> 35 <td class="py-2 py-sm-1" ng-bind="despacho.FEC | date:'dd/MM/yyyy hh:MM'"></td>
36 <td class="py-2 py-sm-1" ng-bind="despacho.LTS"></td> 36 <td class="py-2 py-sm-1" ng-bind="(despacho.LTS | number: 2) + ' Lts.'"></td>
37 <td class="py-2 py-sm-1" ng-bind="despacho.IMP | currency: '$'"></td> 37 <td class="py-2 py-sm-1" ng-bind="despacho.IMP | currency: '$'"></td>
38 <td class="py-2 py-sm-1"> 38 <td class="py-2 py-sm-1">
39 <button 39 <button
40 type="button" 40 type="button"
41 class="btn btn-default btn-xs p-1 float-right" 41 class="btn btn-default btn-xs p-1 float-right"
42 title="Seleccionar" 42 title="Seleccionar"
43 ng-click="aceptar(producto)" 43 ng-click="aceptar(producto, despacho)"
44 ><i class="fa fa-circle-thin" aria-hidden="true"></i> 44 ><i class="fa fa-circle-thin" aria-hidden="true"></i>
45 </button> 45 </button>
46 </td> 46 </td>
47 </tr> 47 </tr>
48 </tbody> 48 </tbody>
49 </table> 49 </table>
50 </div> 50 </div>
51 </div> 51 </div>
52 </div> 52 </div>
53 53
54 </div> 54 </div>
55 <div class="modal-footer py-2"> 55 <div class="modal-footer py-2">
56 <nav ng-show="currentPageProveedores.length > 0 && primerBusqueda" class="mr-auto"> 56 <nav ng-show="currentPageProveedores.length > 0 && primerBusqueda" class="mr-auto">
57 <ul class="pagination pagination-sm mb-0"> 57 <ul class="pagination pagination-sm mb-0">
58 <li class="page-item" ng-class="{'disabled': currentPage == 1}"> 58 <li class="page-item" ng-class="{'disabled': currentPage == 1}">
59 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)"> 59 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)">
60 <span aria-hidden="true">&laquo;</span> 60 <span aria-hidden="true">&laquo;</span>
61 <span class="sr-only">Anterior</span> 61 <span class="sr-only">Anterior</span>
62 </a> 62 </a>
63 </li> 63 </li>
64 <li 64 <li
65 class="page-item" 65 class="page-item"
66 ng-repeat="pagina in paginas" 66 ng-repeat="pagina in paginas"
67 ng-class="{'active': pagina == currentPage}" 67 ng-class="{'active': pagina == currentPage}"
68 > 68 >
69 <a 69 <a
70 class="page-link" 70 class="page-link"
71 href="javascript:void();" 71 href="javascript:void();"
72 ng-click="selectPage(pagina)" 72 ng-click="selectPage(pagina)"
73 ng-bind="pagina" 73 ng-bind="pagina"
74 ></a> 74 ></a>
75 </li> 75 </li>
76 <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> 76 <li class="page-item" ng-class="{'disabled': currentPage == lastPage}">
77 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)"> 77 <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)">
78 <span aria-hidden="true">&raquo;</span> 78 <span aria-hidden="true">&raquo;</span>
79 <span class="sr-only">Siguiente</span> 79 <span class="sr-only">Siguiente</span>
80 </a> 80 </a>
81 </li> 81 </li>
82 </ul> 82 </ul>
83 </nav> 83 </nav>
84 <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> 84 <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button>
85 </div> 85 </div>
86 86