Commit 315870f6d71385f993575d76206cbd2a05bb76ed

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

Merge branch 'master' into 'develop'

Master(mpuebla)

See merge request !91
src/js/controller.js
1   -angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
  1 +angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl',
2 2 [
3 3 '$scope',
4 4 '$uibModal',
... ... @@ -14,11 +14,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
14 14 'APP',
15 15 'focaLoginService',
16 16 '$localStorage',
17   - function(
  17 + function (
18 18 $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService,
19 19 focaBotoneraLateralService, focaModalService, notaPedidoBusinessService,
20   - $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage)
21   - {
  20 + $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) {
22 21 config();
23 22 var cotizacionPArgentino = {};
24 23  
... ... @@ -38,9 +37,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
38 37 maxDate: new Date(),
39 38 minDate: new Date(2010, 0, 1)
40 39 };
41   -
  40 +
42 41 //SETEO BOTONERA LATERAL
43   - $timeout(function() {
  42 + $timeout(function () {
44 43 focaBotoneraLateralService.showSalir(false);
45 44 focaBotoneraLateralService.showPausar(true);
46 45 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido);
... ... @@ -52,10 +51,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
52 51 $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador;
53 52 }
54 53  
55   - crearNotaPedidoService.getParametros().then(function(res) {
  54 + crearNotaPedidoService.getParametros().then(function (res) {
56 55 var parametros = JSON.parse(res.data[0].jsonText);
57 56 if ($localStorage.notaPedido) {
58   - $timeout(function() { getLSNotaPedido();} );
  57 + $timeout(function () { getLSNotaPedido(); });
59 58 } else {
60 59 for (var property in parametros) {
61 60 $scope.notaPedido[property] = parametros[property];
... ... @@ -76,7 +75,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
76 75 id: 0,
77 76 cliente: {},
78 77 proveedor: {},
79   - domicilio: {dom: ''},
  78 + domicilio: { dom: '' },
80 79 vendedor: {},
81 80 fechaCarga: new Date(),
82 81 cotizacion: {},
... ... @@ -87,16 +86,16 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
87 86 $scope.idLista = undefined;
88 87  
89 88 crearNotaPedidoService.getNumeroNotaPedido().then(
90   - function(res) {
  89 + function (res) {
91 90 $scope.puntoVenta = $filter('rellenarDigitos')(
92 91 res.data.sucursal, 4
93 92 );
94   -
  93 +
95 94 $scope.comprobante = $filter('rellenarDigitos')(
96 95 res.data.numeroNotaPedido, 8
97 96 );
98 97 },
99   - function(err) {
  98 + function (err) {
100 99 focaModalService.alert('La terminal no esta configurada correctamente');
101 100 console.info(err);
102 101 }
... ... @@ -104,7 +103,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
104 103  
105 104 if (APP === 'distribuidor') {
106 105 crearNotaPedidoService.getVendedorById($scope.idVendedor).then(
107   - function(res) {
  106 + function (res) {
108 107 var vendedor = res.data;
109 108 $scope.$broadcast('addCabecera', {
110 109 label: 'Vendedor:',
... ... @@ -121,14 +120,14 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
121 120 $scope.inicial = angular.copy($scope.notaPedido);
122 121 }
123 122  
124   - $scope.$watch('notaPedido', function(newValue) {
  123 + $scope.$watch('notaPedido', function (newValue) {
125 124 focaBotoneraLateralService.setPausarData({
126 125 label: 'notaPedido',
127 126 val: newValue
128 127 });
129 128 }, true);
130 129  
131   - $scope.crearNotaPedido = function() {
  130 + $scope.crearNotaPedido = function () {
132 131 if (!$scope.notaPedido.cliente.COD) {
133 132 focaModalService.alert('Ingrese Cliente');
134 133 return;
... ... @@ -148,8 +147,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
148 147 focaModalService.alert('Ingrese Precios y Condiciones');
149 148 return;
150 149 } else if (
151   - $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null)
152   - {
  150 + $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) {
153 151 focaModalService.alert('Ingrese Flete');
154 152 return;
155 153 } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto
... ... @@ -185,7 +183,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
185 183 total: $scope.getTotal()
186 184 };
187 185 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
188   - function(data) {
  186 + function (data) {
189 187 // Al guardar los datos de la nota de pedido logueamos la
190 188 // actividad para su seguimiento.
191 189 //TODO: GUARDAR POSISIONAMIENTO AL EDITAR?
... ... @@ -205,7 +203,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
205 203  
206 204 var plazos = $scope.notaPedido.notaPedidoPlazo;
207 205 var plazosACrear = [];
208   - plazos.forEach(function(plazo) {
  206 + plazos.forEach(function (plazo) {
209 207 plazosACrear.push({
210 208 idNotaPedido: data.data.id,
211 209 dias: plazo.dias
... ... @@ -223,7 +221,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
223 221 $scope.saveLoading = false;
224 222  
225 223 config();
226   - }, function(error) {
  224 + }, function (error) {
227 225 focaModalService.alert('Hubo un error al crear la nota de pedido');
228 226 focaBotoneraLateralService.endGuardar();
229 227 $scope.saveLoading = false;
... ... @@ -231,7 +229,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
231 229 });
232 230 };
233 231  
234   - $scope.seleccionarNotaPedido = function() {
  232 + $scope.seleccionarNotaPedido = function () {
235 233 var modalInstance = $uibModal.open(
236 234 {
237 235 ariaLabelledBy: 'Busqueda de Nota de Pedido',
... ... @@ -239,8 +237,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
239 237 controller: 'focaModalNotaPedidoController',
240 238 size: 'lg',
241 239 resolve: {
242   - usadoPor: function() {return 'notaPedido';},
243   - idVendedor: function() {
  240 + usadoPor: function () { return 'notaPedido'; },
  241 + idVendedor: function () {
244 242 if (APP === 'distribuidor')
245 243 return $scope.notaPedido.vendedor.id;
246 244 else
... ... @@ -252,7 +250,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
252 250 modalInstance.result.then(setearNotaPedido);
253 251 };
254 252  
255   - $scope.seleccionarProductos = function() {
  253 + $scope.seleccionarProductos = function () {
256 254  
257 255 if ($scope.idLista === undefined) {
258 256 focaModalService.alert(
... ... @@ -278,7 +276,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
278 276 }
279 277 );
280 278 modalInstance.result.then(
281   - function(producto) {
  279 + function (producto) {
282 280 var newArt =
283 281 {
284 282 id: 0,
... ... @@ -296,7 +294,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
296 294 ivaUnitario: producto.IMPIVA,
297 295 impuestoInternoUnitario: producto.ImpInt,
298 296 impuestoInterno1Unitario: producto.ImpInt2,
299   - impuestoInterno2Unitario: producto.ImpInt3,
  297 + impuestoInterno2Unitario: producto.ImpInt3,
300 298 precioLista: producto.precio,
301 299 combustible: 1,
302 300 facturado: 0,
... ... @@ -309,13 +307,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
309 307  
310 308 $scope.articuloACargar = newArt;
311 309 $scope.cargando = false;
312   - }, function() {
  310 + }, function () {
313 311 // funcion ejecutada cuando se cancela el modal
314 312 }
315 313 );
316 314 };
317 315  
318   - $scope.seleccionarPuntosDeDescarga = function() {
  316 + $scope.seleccionarPuntosDeDescarga = function () {
319 317 if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) {
320 318 focaModalService.alert('Primero seleccione un cliente y un domicilio');
321 319 return;
... ... @@ -338,9 +336,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
338 336 }
339 337 );
340 338 modalInstance.result.then(
341   - function(puntoDescarga) {
  339 + function (puntoDescarga) {
342 340  
343   - puntoDescarga.forEach(function(punto) {
  341 + puntoDescarga.forEach(function (punto) {
344 342 $scope.notaPedido.notaPedidoPuntoDescarga.push(
345 343 {
346 344 puntoDescarga: punto
... ... @@ -352,15 +350,15 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
352 350 label: 'Puntos de descarga:',
353 351 valor: getCabeceraPuntoDescarga(puntoDescarga)
354 352 });
355   - }, function() {
  353 + }, function () {
356 354 $scope.abrirModalDomicilios($scope.cliente);
357 355 }
358 356 );
359 357 }
360 358 };
361 359  
362   - $scope.seleccionarProveedor = function() {
363   - $scope.abrirModalProveedores(function() {
  360 + $scope.seleccionarProveedor = function () {
  361 + $scope.abrirModalProveedores(function () {
364 362 if (validarNotaRemitada()) {
365 363 var modalInstance = $uibModal.open(
366 364 {
... ... @@ -370,12 +368,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
370 368 size: 'lg',
371 369 resolve: {
372 370 parametrosFlete:
373   - function() {
  371 + function () {
374 372 return {
375 373 flete: $scope.notaPedido.fob ? 'FOB' :
376   - ( $scope.notaPedido.flete ? '1' :
377   - ($scope.notaPedido.flete === undefined ?
378   - null : '0')),
  374 + ($scope.notaPedido.flete ? '1' :
  375 + ($scope.notaPedido.flete === undefined ?
  376 + null : '0')),
379 377 bomba: $scope.notaPedido.bomba ? '1' :
380 378 ($scope.notaPedido.bomba === undefined ?
381 379 null : '0'),
... ... @@ -386,7 +384,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
386 384 }
387 385 );
388 386 modalInstance.result.then(
389   - function(datos) {
  387 + function (datos) {
390 388 $scope.notaPedido.flete = datos.flete;
391 389 $scope.notaPedido.fob = datos.FOB;
392 390 $scope.notaPedido.bomba = datos.bomba;
... ... @@ -412,8 +410,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
412 410 }
413 411  
414 412 $filter('filter')($scope.botonera,
415   - { label: 'Proveedor'})[0].checked = true;
416   - }, function() {
  413 + { label: 'Proveedor' })[0].checked = true;
  414 + }, function () {
417 415 $scope.seleccionarTransportista();
418 416 }
419 417 );
... ... @@ -421,7 +419,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
421 419 });
422 420 };
423 421  
424   - $scope.seleccionarVendedor = function(callback, ocultarVendedor) {
  422 + $scope.seleccionarVendedor = function (callback, ocultarVendedor) {
425 423 if (APP === 'distribuidor' || ocultarVendedor) {
426 424 callback();
427 425 return;
... ... @@ -448,7 +446,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
448 446 size: 'md'
449 447 };
450 448 focaModalService.modal(parametrosModal).then(
451   - function(vendedor) {
  449 + function (vendedor) {
452 450 $scope.$broadcast('addCabecera', {
453 451 label: 'Vendedor:',
454 452 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' +
... ... @@ -457,39 +455,35 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
457 455 $scope.notaPedido.vendedor = vendedor;
458 456 deleteCliente();
459 457 callback();
460   - }, function() {}
  458 + }, function () { }
461 459 );
462 460 }
463 461 };
464 462  
465   - $scope.seleccionarCliente = function(ocultarVendedor) {
466   - $scope.seleccionarVendedor(function() {
467   - if (validarNotaRemitada()) {
468   - var modalInstance = $uibModal.open(
469   - {
470   - ariaLabelledBy: 'Busqueda de Cliente',
471   - templateUrl: 'foca-busqueda-cliente-modal.html',
472   - controller: 'focaBusquedaClienteModalController',
473   - resolve: {
474   - vendedor: function() { return $scope.notaPedido.vendedor; },
475   - cobrador: function() { return null; }
476   - },
477   - size: 'lg'
478   - }
479   - );
480   - modalInstance.result.then(
481   - function(cliente) {
482   - $scope.abrirModalDomicilios(cliente);
483   - $scope.cliente = cliente;
484   - }, function() {
485   - if (APP !== 'distribuidor') $scope.seleccionarCliente();
486   - }
487   - );
488   - }
489   - }, ocultarVendedor);
  463 + $scope.seleccionarCliente = function (ocultarVendedor) {
  464 + if (validarNotaRemitada()) {
  465 + var modalInstance = $uibModal.open(
  466 + {
  467 + ariaLabelledBy: 'Busqueda de Cliente',
  468 + templateUrl: 'foca-busqueda-cliente-modal.html',
  469 + controller: 'focaBusquedaClienteModalController',
  470 + resolve: {
  471 + vendedor: function () { return null; },
  472 + cobrador: function () { return null; }
  473 + },
  474 + size: 'lg'
  475 + }
  476 + );
  477 + modalInstance.result.then(
  478 + function (cliente) {
  479 + $scope.abrirModalDomicilios(cliente);
  480 + $scope.cliente = cliente;
  481 + }, function () { }
  482 + );
  483 + }
490 484 };
491 485  
492   - $scope.abrirModalProveedores = function(callback) {
  486 + $scope.abrirModalProveedores = function (callback) {
493 487 if (validarNotaRemitada()) {
494 488 var parametrosModal = {
495 489 titulo: 'Búsqueda de Proveedor',
... ... @@ -513,10 +507,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
513 507 }
514 508 ],
515 509 tipo: 'POST',
516   - json: {razonCuitCod: ''}
  510 + json: { razonCuitCod: '' }
517 511 };
518 512 focaModalService.modal(parametrosModal).then(
519   - function(proveedor) {
  513 + function (proveedor) {
520 514 $scope.notaPedido.proveedor = proveedor;
521 515 $scope.$broadcast('addCabecera', {
522 516 label: 'Proveedor:',
... ... @@ -524,66 +518,78 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
524 518 proveedor.NOM
525 519 });
526 520 callback();
527   - }, function() {
  521 + }, function () {
528 522  
529 523 }
530 524 );
531 525 }
532 526 };
533 527  
534   - $scope.abrirModalDomicilios = function(cliente) {
  528 + $scope.abrirModalDomicilios = function (cliente) {
535 529 var modalInstanceDomicilio = $uibModal.open(
536 530 {
537 531 ariaLabelledBy: 'Busqueda de Domicilios',
538 532 templateUrl: 'modal-domicilio.html',
539 533 controller: 'focaModalDomicilioController',
540   - resolve: {
541   - idCliente: function() { return cliente.cod; },
542   - esNuevo: function() { return cliente.esNuevo; }
  534 + resolve: {
  535 + idCliente: function () { return cliente.cod; },
  536 + esNuevo: function () { return cliente.esNuevo; }
543 537 },
544 538 size: 'lg',
545 539 }
546 540 );
547 541 modalInstanceDomicilio.result.then(
548   - function(domicilio) {
  542 + function (domicilio) {
549 543 $scope.notaPedido.domicilio = domicilio;
550 544 $scope.notaPedido.cliente = {
551 545 COD: cliente.cod,
552 546 CUIT: cliente.cuit,
553 547 NOM: cliente.nom,
554   - MOD: cliente.mod
  548 + MOD: cliente.mod,
  549 + VEN: cliente.ven
555 550 };
556   - var domicilioStamp =
557   - domicilio.Calle + ' ' + domicilio.Numero + ', ' +
558   - domicilio.Localidad + ', ' + domicilio.Provincia;
559   - $scope.notaPedido.domicilioStamp = domicilioStamp;
560   -
561   - $scope.$broadcast('addCabecera', {
562   - label: 'Cliente:',
563   - valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom
564   - });
  551 + crearNotaPedidoService.getVendedorById($scope.notaPedido.cliente.VEN)
  552 + .then(function (res) {
  553 + if (res.data !== '') {
  554 + $scope.notaPedido.vendedor = res.data;
  555 + $scope.$broadcast('addCabecera', {
  556 + label: 'Vendedor:',
  557 + valor: $filter('rellenarDigitos')($scope.notaPedido.vendedor.NUM, 3) + ' - ' +
  558 + $scope.notaPedido.vendedor.NOM
  559 + });
  560 + }
  561 + var domicilioStamp =
  562 + domicilio.Calle + ' ' + domicilio.Numero + ', ' +
  563 + domicilio.Localidad + ', ' + domicilio.Provincia;
  564 + $scope.notaPedido.domicilioStamp = domicilioStamp;
565 565  
566   - $scope.$broadcast('addCabecera', {
567   - label: 'Domicilio:',
568   - valor: domicilioStamp
569   - });
  566 + $scope.$broadcast('addCabecera', {
  567 + label: 'Cliente:',
  568 + valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom
  569 + });
570 570  
571   - if (domicilio.verPuntos) {
572   - delete $scope.notaPedido.domicilio.verPuntos;
573   - $scope.seleccionarPuntosDeDescarga();
574   - }
  571 + $scope.$broadcast('addCabecera', {
  572 + label: 'Domicilio:',
  573 + valor: domicilioStamp
  574 + });
575 575  
576   - // Seteo checked en botonera
577   - $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true;
  576 + if (domicilio.verPuntos) {
  577 + delete $scope.notaPedido.domicilio.verPuntos;
  578 + $scope.seleccionarPuntosDeDescarga();
  579 + }
578 580  
579   - }, function() {
  581 + // Seteo checked en botonera
  582 + $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
  583 + })
  584 + .catch(function (e) { console.log(e); })
  585 + }, function () {
580 586 $scope.seleccionarCliente(true);
581 587 return;
582 588 }
583 589 );
584 590 };
585 591  
586   - $scope.getTotal = function() {
  592 + $scope.getTotal = function () {
587 593 var total = 0;
588 594 if ($scope.notaPedido.articulosNotaPedido) {
589 595 var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido;
... ... @@ -594,13 +600,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
594 600 return parseFloat(total.toFixed(2));
595 601 };
596 602  
597   - $scope.getSubTotal = function() {
  603 + $scope.getSubTotal = function () {
598 604 if ($scope.articuloACargar) {
599 605 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
600 606 }
601 607 };
602 608  
603   - $scope.seleccionarPreciosYCondiciones = function() {
  609 + $scope.seleccionarPreciosYCondiciones = function () {
604 610  
605 611 if (!validarNotaRemitada()) {
606 612 return;
... ... @@ -611,12 +617,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
611 617 return;
612 618 }
613 619 if ($scope.notaPedido.articulosNotaPedido.length !== 0) {
614   - focaModalService.confirm('Se perderan los productos ingresados')
615   - .then(function(data) {
616   - if (data) {
617   - abrirModal();
618   - }
619   - });
  620 + focaModalService.confirm('Se perderan los productos ingresados')
  621 + .then(function (data) {
  622 + if (data) {
  623 + abrirModal();
  624 + }
  625 + });
620 626 } else if (validarNotaRemitada()) {
621 627 abrirModal();
622 628 }
... ... @@ -628,7 +634,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
628 634 controller: 'focaModalPrecioCondicionController',
629 635 size: 'lg',
630 636 resolve: {
631   - idListaPrecio: function() {
  637 + idListaPrecio: function () {
632 638 return $scope.notaPedido.cliente.MOD || null;
633 639 }
634 640 }
... ... @@ -636,7 +642,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
636 642 );
637 643  
638 644 modalInstance.result.then(
639   - function(precioCondicion) {
  645 + function (precioCondicion) {
640 646 var cabecera = '';
641 647 var plazosConcat = '';
642 648 if (!Array.isArray(precioCondicion)) {
... ... @@ -652,7 +658,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
652 658 } else { //Cuando se ingresan los plazos manualmente
653 659 $scope.notaPedido.idPrecioCondicion = 0;
654 660 //-1, el modal productos busca todos los productos
655   - $scope.idLista = -1;
  661 + $scope.idLista = -1;
656 662 $scope.notaPedido.notaPedidoPlazo = precioCondicion;
657 663 for (var j = 0; j < precioCondicion.length; j++) {
658 664 plazosConcat += precioCondicion[j].dias + ' ';
... ... @@ -666,15 +672,15 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
666 672 });
667 673  
668 674 $filter('filter')($scope.botonera,
669   - { label: 'Precios y Condiciones'})[0].checked = true;
670   - }, function() {
  675 + { label: 'Precios y Condiciones' })[0].checked = true;
  676 + }, function () {
671 677  
672 678 }
673 679 );
674 680 }
675 681 };
676 682  
677   - $scope.seleccionarMoneda = function() {
  683 + $scope.seleccionarMoneda = function () {
678 684 if (validarNotaRemitada()) {
679 685 var parametrosModal = {
680 686 titulo: 'Búsqueda de monedas',
... ... @@ -692,7 +698,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
692 698 size: 'md'
693 699 };
694 700 focaModalService.modal(parametrosModal).then(
695   - function(moneda) {
  701 + function (moneda) {
696 702  
697 703 if (moneda.ID !== 1) {
698 704 $scope.abrirModalCotizacion(moneda);
... ... @@ -713,7 +719,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
713 719 }
714 720 };
715 721  
716   - $scope.seleccionarObservaciones = function() {
  722 + $scope.seleccionarObservaciones = function () {
717 723 var observacion = {
718 724 titulo: 'Ingrese Observaciones',
719 725 value: $scope.notaPedido.observaciones,
... ... @@ -723,12 +729,12 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
723 729  
724 730 focaModalService
725 731 .prompt(observacion)
726   - .then(function(observaciones) {
  732 + .then(function (observaciones) {
727 733 $scope.notaPedido.observaciones = observaciones;
728 734 });
729 735 };
730 736  
731   - $scope.abrirModalCotizacion = function(moneda) {
  737 + $scope.abrirModalCotizacion = function (moneda) {
732 738 var modalInstance = $uibModal.open(
733 739 {
734 740 ariaLabelledBy: 'Busqueda de Cotización',
... ... @@ -736,29 +742,29 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
736 742 controller: 'focaModalCotizacionController',
737 743 size: 'lg',
738 744 resolve: {
739   - idMoneda: function() {
  745 + idMoneda: function () {
740 746 return moneda.ID;
741 747 }
742 748 }
743 749 }
744 750 );
745 751 modalInstance.result.then(
746   - function(cotizacion) {
  752 + function (cotizacion) {
747 753  
748 754 cotizacion.moneda = moneda;
749 755 actualizarCabeceraMoneda(cotizacion);
750 756  
751 757 $scope.notaPedido.cotizacion = cotizacion;
752   - $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true;
753   - }, function() {
  758 + $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true;
  759 + }, function () {
754 760  
755 761 }
756 762 );
757 763 };
758 764  
759   - function actualizarCabeceraMoneda (cotizacion) {
  765 + function actualizarCabeceraMoneda(cotizacion) {
760 766  
761   - $scope.notaPedido.articulosNotaPedido.forEach(function(art) {
  767 + $scope.notaPedido.articulosNotaPedido.forEach(function (art) {
762 768 art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4);
763 769 art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4);
764 770 });
... ... @@ -783,13 +789,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
783 789 }
784 790 }
785 791  
786   - $scope.agregarATabla = function(key) {
  792 + $scope.agregarATabla = function (key) {
787 793 if (key === 13) {
788 794 if ($scope.articuloACargar.cantidad === undefined ||
789 795 $scope.articuloACargar.cantidad === 0 ||
790   - $scope.articuloACargar.cantidad === null ) {
791   - focaModalService.alert('El valor debe ser al menos 1');
792   - return;
  796 + $scope.articuloACargar.cantidad === null) {
  797 + focaModalService.alert('El valor debe ser al menos 1');
  798 + return;
793 799 }
794 800 delete $scope.articuloACargar.sectorCodigo;
795 801 $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar);
... ... @@ -797,13 +803,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
797 803 }
798 804 };
799 805  
800   - $scope.quitarArticulo = function(key) {
  806 + $scope.quitarArticulo = function (key) {
801 807 if (validarNotaRemitada()) {
802 808 $scope.notaPedido.articulosNotaPedido.splice(key, 1);
803 809 }
804 810 };
805 811  
806   - $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) {
  812 + $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) {
807 813 if (key === 13) {
808 814 if (!articulo.cantidad || !articulo.precio) {
809 815 focaModalService.alert('Los valores deben ser al menos 1');
... ... @@ -819,13 +825,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
819 825 }
820 826 };
821 827  
822   - $scope.cancelarEditar = function(articulo) {
  828 + $scope.cancelarEditar = function (articulo) {
823 829 $scope.tmpCantidad = articulo.cantidad;
824 830 $scope.tmpPrecio = articulo.precio;
825 831 articulo.editCantidad = articulo.editPrecio = false;
826 832 };
827 833  
828   - $scope.cambioEdit = function(articulo, propiedad) {
  834 + $scope.cambioEdit = function (articulo, propiedad) {
829 835 if (propiedad === 'cantidad') {
830 836 articulo.editCantidad = true;
831 837 } else if (propiedad === 'precio') {
... ... @@ -833,12 +839,12 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
833 839 }
834 840 };
835 841  
836   - $scope.resetFilter = function() {
  842 + $scope.resetFilter = function () {
837 843 $scope.articuloACargar = {};
838 844 $scope.cargando = true;
839 845 };
840 846 //Recibe aviso si el teclado está en uso
841   - $rootScope.$on('usarTeclado', function(event, data) {
  847 + $rootScope.$on('usarTeclado', function (event, data) {
842 848 if (data) {
843 849 $scope.mostrarTeclado = true;
844 850 return;
... ... @@ -846,7 +852,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
846 852 $scope.mostrarTeclado = false;
847 853 });
848 854  
849   - $scope.selectFocus = function($event) {
  855 + $scope.selectFocus = function ($event) {
850 856 // Si el teclado esta en uso no selecciona el valor
851 857 if ($scope.mostrarTeclado) {
852 858 return;
... ... @@ -854,23 +860,23 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
854 860 $event.target.select();
855 861 };
856 862  
857   - $scope.salir = function() {
  863 + $scope.salir = function () {
858 864 $location.path('/');
859 865 };
860 866  
861   - $scope.parsearATexto = function(articulo) {
  867 + $scope.parsearATexto = function (articulo) {
862 868 articulo.cantidad = parseFloat(articulo.cantidad);
863 869 articulo.precio = parseFloat(articulo.precio);
864 870 };
865 871  
866 872 // TODO: quitar watch usar función de articulos pedido cuando se haga
867   - $scope.$watch('notaPedido.articulosNotaPedido', function() {
  873 + $scope.$watch('notaPedido.articulosNotaPedido', function () {
868 874 if ($scope.notaPedido.articulosNotaPedido.length) {
869 875 $filter('filter')($scope.botonera,
870   - { label: 'Productos'})[0].checked = true;
  876 + { label: 'Productos' })[0].checked = true;
871 877 } else {
872 878 $filter('filter')($scope.botonera,
873   - { label: 'Productos'})[0].checked = false;
  879 + { label: 'Productos' })[0].checked = false;
874 880 }
875 881 }, true);
876 882  
... ... @@ -906,7 +912,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
906 912 }
907 913  
908 914 if (notaPedido.cotizacion.moneda) {
909   - $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true;
  915 + $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true;
910 916 }
911 917  
912 918 if (notaPedido.vendedor.NUM) {
... ... @@ -927,7 +933,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
927 933 valor: notaPedido.domicilioStamp
928 934 });
929 935  
930   - $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true;
  936 + $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
931 937 }
932 938  
933 939 if (notaPedido.proveedor.COD) {
... ... @@ -937,7 +943,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
937 943 ' - ' + notaPedido.proveedor.NOM
938 944 });
939 945  
940   - $filter('filter')($scope.botonera, { label: 'Proveedor'})[0].checked = true;
  946 + $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true;
941 947 }
942 948  
943 949 if (notaPedido.notaPedidoPlazo.length) {
... ... @@ -949,7 +955,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
949 955 });
950 956  
951 957 $filter('filter')($scope.botonera,
952   - { label: 'Precios y condiciones'})[0].checked = true;
  958 + { label: 'Precios y condiciones' })[0].checked = true;
953 959 }
954 960  
955 961 if (notaPedido.flete !== undefined) {
... ... @@ -999,7 +1005,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
999 1005  
1000 1006 if (notaPedido.notaPedidoPuntoDescarga.length) {
1001 1007 var puntos = [];
1002   - notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedidoPuntoDescarga) {
  1008 + notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedidoPuntoDescarga) {
1003 1009 puntos.push(notaPedidoPuntoDescarga.puntoDescarga);
1004 1010 });
1005 1011 cabeceras.push({
... ... @@ -1020,7 +1026,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
1020 1026  
1021 1027 function getCabeceraPuntoDescarga(puntoDescarga) {
1022 1028 var puntosStamp = '';
1023   - puntoDescarga.forEach(function(punto, idx, arr) {
  1029 + puntoDescarga.forEach(function (punto, idx, arr) {
1024 1030 puntosStamp += punto.descripcion;
1025 1031 if ((idx + 1) !== arr.length) puntosStamp += ', ';
1026 1032 });
... ... @@ -1055,7 +1061,7 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
1055 1061 if (confirmacion) {
1056 1062 focaModalService.confirm(
1057 1063 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
1058   - ).then(function(data) {
  1064 + ).then(function (data) {
1059 1065 if (data) {
1060 1066 $location.path('/');
1061 1067 }
... ... @@ -1076,12 +1082,12 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
1076 1082 function deleteCliente() {
1077 1083 $scope.notaPedido.domicilioStamp = '';
1078 1084 $scope.notaPedido.notaPedidoPuntoDescarga = [];
1079   - $scope.notaPedido.domicilio = {dom: ''};
  1085 + $scope.notaPedido.domicilio = { dom: '' };
1080 1086 $scope.notaPedido.cliente = {};
1081 1087 $scope.$broadcast('removeCabecera', 'Cliente:');
1082 1088 $scope.$broadcast('removeCabecera', 'Domicilio:');
1083 1089 $scope.$broadcast('removeCabecera', 'Puntos de descarga:');
1084   - $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = false;
  1090 + $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = false;
1085 1091 }
1086 1092 }
1087 1093 ]);