Compare View

switch
from
...
to
 
Commits (25)
... ... @@ -43,11 +43,6 @@ gulp.task('uglify', ['templates'], function() {
43 43 gulp.dest(paths.tmp),
44 44 rename('foca-crear-remito.min.js'),
45 45 uglify(),
46   - replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+
47   - '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+
48   - '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+
49   - '"focaModalMoneda","focaModalCotizacion","focaConfiguracion","angular-ladda",'+
50   - '"focaModalNotaPedido","focaBotoneraLateral"', ''),
51 46 gulp.dest(paths.dist)
52 47 ]
53 48 );
1   -angular.module('focaCrearRemito', [
2   - 'ngRoute',
3   - 'ui.bootstrap',
4   - 'focaModalVendedores',
5   - 'focaBusquedaProductos',
6   - 'focaModalProveedor',
7   - 'focaBusquedaCliente',
8   - 'focaModalPrecioCondicion',
9   - 'focaModalFlete',
10   - 'focaDirectivas',
11   - 'focaModal',
12   - 'focaModalDomicilio',
13   - 'focaModalMoneda',
14   - 'focaModalCotizacion',
15   - 'focaConfiguracion',
16   - 'angular-ladda',
17   - 'focaModalNotaPedido',
18   - 'focaBotoneraLateral'
19   -]);
  1 +angular.module('focaCrearRemito', []);
src/js/controller.js
... ... @@ -153,7 +153,7 @@ angular.module('focaCrearRemito') .controller('remitoController',
153 153 notaPedido.flete === 1 ? 'Si' : 'No')
154 154 }
155 155 ];
156   -
  156 +
157 157 function valorPrecioCondicion() {
158 158 if(notaPedido.idPrecioCondicion > 0) {
159 159 return notaPedido.precioCondicion.nombre;
... ... @@ -161,7 +161,7 @@ angular.module('focaCrearRemito') .controller('remitoController',
161 161 return 'Ingreso Manual';
162 162 }
163 163 }
164   -
  164 +
165 165 if(notaPedido.flete === 1) {
166 166 var cabeceraBomba = {
167 167 label: 'Bomba:',
... ... @@ -176,28 +176,29 @@ angular.module('focaCrearRemito') .controller('remitoController',
176 176 }
177 177 cabeceras.push(cabeceraBomba);
178 178 }
179   -
  179 +
180 180 for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) {
181 181 notaPedido.articulosNotaPedido[i].id = 0;
182 182 }
183   -
  183 +
184 184 $scope.articulosTabla = notaPedido.articulosNotaPedido;
185 185 remitoBusinessService.calcularArticulos($scope.articulosTabla,
186 186 notaPedido.cotizacion.VENDEDOR);
187   -
  187 +
188 188 if(notaPedido.idPrecioCondicion > 0) {
189 189 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
190 190 }else {
191 191 $scope.idLista = -1;
192 192 }
193   -
  193 +
194 194 delete notaPedido.id;
195 195 $scope.remito = notaPedido;
196 196 $scope.remito.id = 0;
197 197 $scope.remito.moneda = notaPedido.cotizacion.moneda;
198 198 $scope.plazosPagos = notaPedido.notaPedidoPlazo;
  199 + enableObservaciones(notaPedido.observaciones ? true : false);
199 200 addArrayCabecera(cabeceras);
200   -
  201 +
201 202 }, function() {
202 203 // funcion ejecutada cuando se cancela el modal
203 204 }
... ... @@ -368,7 +369,7 @@ angular.module('focaCrearRemito') .controller('remitoController',
368 369 numeroLiquidoProducto: 0,//TODO
369 370 idVendedor: $scope.remito.idVendedor,
370 371 idProveedor: $scope.remito.idProveedor,
371   - idDomicilio: 0,//TODO
  372 + idDomicilio: $scope.remito.idDomicilio,
372 373 idCotizacion: $scope.remito.cotizacion.ID,
373 374 idPrecioCondicion: $scope.remito.idPrecioCondicion,
374 375 flete: $scope.remito.flete,
... ... @@ -382,6 +383,7 @@ angular.module('focaCrearRemito') .controller('remitoController',
382 383 },
383 384 notaPedido: $scope.notaPedido
384 385 };
  386 +
385 387 crearRemitoService.crearRemito(save).then(
386 388 function(data) {
387 389 remitoBusinessService.addArticulos($scope.articulosTabla,
... ... @@ -389,20 +391,33 @@ angular.module('focaCrearRemito') .controller('remitoController',
389 391  
390 392 focaBotoneraLateralService.endGuardar(true);
391 393 $scope.saveLoading = false;
  394 +
392 395 //TODO: updatear plazos
393 396 if($scope.remito.id === 0) {
  397 + $scope.remito.id = data.data.id;
394 398 var plazos = $scope.plazosPagos;
395 399  
396 400 for(var j = 0; j < plazos.length; j++) {
397 401 var json = {
398   - idRemito: data.data.id,
  402 + idRemito: $scope.remito.id,
399 403 dias: plazos[j].dias
400 404 };
401 405 crearRemitoService.crearPlazosParaRemito(json);
402 406 }
403 407 }
404   -
  408 +
  409 + $uibModal.open({
  410 + templateUrl: 'remito-comprobante.html',
  411 + controller: 'focaRemitoComprobanteController',
  412 + resolve: {
  413 + parametros: {
  414 + remito: $scope.remito
  415 + }
  416 + }
  417 + });
  418 +
405 419 init();
  420 +
406 421 }, function(error) {
407 422 focaModalService.alert('Hubo un error al crear el remito');
408 423 focaBotoneraLateralService.endGuardar();
... ... @@ -466,17 +481,71 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
466 481 );
467 482 };
468 483  
469   - $scope.seleccionarVendedor = function() {
470   - if(varlidarRemitoFacturado()) {
  484 + $scope.seleccionarPuntosDeDescarga = function() {
  485 + if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) {
  486 + focaModalService.alert('Primero seleccione un cliente y un domicilio');
  487 + return;
  488 + }else {
471 489 var modalInstance = $uibModal.open(
472 490 {
473   - ariaLabelledBy: 'Busqueda de Vendedores',
474   - templateUrl: 'modal-vendedores.html',
475   - controller: 'modalVendedoresCtrl',
476   - size: 'lg'
  491 + ariaLabelledBy: 'Búsqueda de Puntos de descarga',
  492 + templateUrl: 'modal-punto-descarga.html',
  493 + controller: 'focaModalPuntoDescargaController',
  494 + size: 'lg',
  495 + resolve: {
  496 + filters: {
  497 + idDomicilio: $scope.remito.domicilio.id,
  498 + idCliente: $scope.remito.cliente.COD,
  499 + articulos: $scope.articulosTabla,
  500 + puntosDescarga: $scope.remito.domicilio.puntosDescarga
  501 + }
  502 + }
477 503 }
478 504 );
479 505 modalInstance.result.then(
  506 + function(puntosDescarga) {
  507 + $scope.remito.puntosDescarga = puntosDescarga;
  508 +
  509 + //AGREGO PUNTOS DE DESCARGA A CABECERA
  510 + var puntosStamp = '';
  511 + puntosDescarga.forEach(function(punto, idx, arr) {
  512 + puntosStamp += punto.descripcion;
  513 + if((idx + 1) !== arr.length) puntosStamp += ', ';
  514 + });
  515 +
  516 + $scope.$broadcast('addCabecera', {
  517 + label: 'Puntos de descarga:',
  518 + valor: puntosStamp
  519 + });
  520 + }, function() {
  521 + $scope.abrirModalDomicilios($scope.cliente);
  522 + }
  523 + );
  524 + }
  525 + };
  526 +
  527 + $scope.seleccionarVendedor = function() {
  528 + if(varlidarRemitoFacturado()) {
  529 + var parametrosModal = {
  530 + titulo: 'Búsqueda vendedores',
  531 + query: '/vendedor',
  532 + columnas: [
  533 + {
  534 + propiedad: 'NUM',
  535 + nombre: 'Código',
  536 + filtro: {
  537 + nombre: 'rellenarDigitos',
  538 + parametro: 3
  539 + }
  540 + },
  541 + {
  542 + propiedad: 'NOM',
  543 + nombre: 'Nombre'
  544 + }
  545 + ],
  546 + size: 'md'
  547 + };
  548 + focaModalService.modal(parametrosModal).then(
480 549 function(vendedor) {
481 550 $scope.$broadcast('addCabecera',{
482 551 label: 'Vendedor:',
... ... @@ -486,7 +555,7 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
486 555 $scope.remito.idVendedor = vendedor.id;
487 556 $scope.vendedor = vendedor;
488 557 }, function() {
489   -
  558 +
490 559 }
491 560 );
492 561 }
... ... @@ -494,20 +563,31 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
494 563  
495 564 $scope.seleccionarProveedor = function() {
496 565 if(varlidarRemitoFacturado()) {
497   - var modalInstance = $uibModal.open(
498   - {
499   - ariaLabelledBy: 'Busqueda de Proveedor',
500   - templateUrl: 'modal-proveedor.html',
501   - controller: 'focaModalProveedorCtrl',
502   - size: 'lg',
503   - resolve: {
504   - transportista: function() {
505   - return false;
  566 + var parametrosModal = {
  567 + titulo: 'Búsqueda de Proveedor',
  568 + query: '/proveedor',
  569 + columnas: [
  570 + {
  571 + nombre: 'Código',
  572 + propiedad: 'COD',
  573 + filtro: {
  574 + nombre: 'rellenarDigitos',
  575 + parametro: 5
506 576 }
  577 + },
  578 + {
  579 + nombre: 'Nombre',
  580 + propiedad: 'NOM'
  581 + },
  582 + {
  583 + nombre: 'CUIT',
  584 + propiedad: 'CUIT'
507 585 }
508   - }
509   - );
510   - modalInstance.result.then(
  586 + ],
  587 + tipo: 'POST',
  588 + json: {razonCuitCod: ''}
  589 + };
  590 + focaModalService.modal(parametrosModal).then(
511 591 function(proveedor) {
512 592 $scope.remito.idProveedor = proveedor.COD;
513 593 $scope.$broadcast('addCabecera',{
... ... @@ -543,6 +623,7 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
543 623 modalInstance.result.then(
544 624 function(cliente) {
545 625 $scope.abrirModalDomicilios(cliente);
  626 + $scope.cliente = cliente;
546 627 }, function() {
547 628  
548 629 }
... ... @@ -565,11 +646,12 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
565 646 );
566 647 modalInstanceDomicilio.result.then(
567 648 function(domicilio) {
568   - //$scope.remito.domicilio.id = domicilio.nivel2;
  649 + $scope.remito.domicilio = domicilio;
569 650 $scope.remito.cliente = {
570 651 COD: cliente.cod,
571 652 CUIT: cliente.cuit,
572   - NOM: cliente.nom
  653 + NOM: cliente.nom,
  654 + MAIL: cliente.mail
573 655 };
574 656  
575 657  
... ... @@ -586,6 +668,17 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
586 668 label: 'Domicilio:',
587 669 valor: domicilioStamp
588 670 });
  671 +
  672 + if(domicilio.verPuntos) {
  673 + delete $scope.remito.domicilio.verPuntos;
  674 + $scope.seleccionarPuntosDeDescarga();
  675 + }else {
  676 + crearRemitoService
  677 + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod)
  678 + .then(function(res) {
  679 + if(res.data.length) $scope.seleccionarPuntosDeDescarga();
  680 + });
  681 + }
589 682 }, function() {
590 683 $scope.seleccionarCliente();
591 684 return;
... ... @@ -658,7 +751,7 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
658 751 valor: cabecera
659 752 });
660 753 }, function() {
661   -
  754 +
662 755 }
663 756 );
664 757 }
... ... @@ -693,7 +786,7 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
693 786 $scope.remito.fob = datos.FOB;
694 787 $scope.remito.bomba = datos.bomba;
695 788 $scope.remito.kilometros = datos.kilometros;
696   -
  789 +
697 790 $scope.$broadcast('addCabecera',{
698 791 label: 'Flete:',
699 792 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No')
... ... @@ -715,7 +808,7 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
715 808 $scope.remito.kilometros = null;
716 809 }
717 810 }, function() {
718   -
  811 +
719 812 }
720 813 );
721 814 }
... ... @@ -742,12 +835,20 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
742 835 function(moneda) {
743 836 $scope.abrirModalCotizacion(moneda);
744 837 }, function() {
745   -
  838 +
746 839 }
747 840 );
748 841 }
749 842 };
750 843  
  844 + $scope.seleccionarObservaciones = function() {
  845 + focaModalService
  846 + .prompt('Ingrese observaciones', $scope.remito.observaciones, true)
  847 + .then(function(observaciones) {
  848 + $scope.remito.observaciones = observaciones;
  849 + });
  850 + };
  851 +
751 852 $scope.abrirModalCotizacion = function(moneda) {
752 853 var modalInstance = $uibModal.open(
753 854 {
... ... @@ -923,5 +1024,13 @@ angular.module(&#39;focaCrearRemito&#39;) .controller(&#39;remitoController&#39;,
923 1024 $location.path('/');
924 1025 }
925 1026 }
  1027 +
  1028 + function enableObservaciones(val) {
  1029 + var boton = $scope.botonera.filter(function(botonObs) {
  1030 + return botonObs.label === 'Observaciones';
  1031 + });
  1032 +
  1033 + boton[0].disable = !val;
  1034 + }
926 1035 }
927 1036 ]);
src/js/controllerComprobante.js
... ... @@ -0,0 +1,57 @@
  1 +angular.module('focaCrearRemito')
  2 + .controller('focaRemitoComprobanteController', [
  3 + '$scope',
  4 + '$uibModalInstance',
  5 + 'crearRemitoService',
  6 + '$window',
  7 + '$filter',
  8 + 'parametros',
  9 + 'FileSaver',
  10 + 'Blob',
  11 + function(
  12 + $scope, $uibModalInstance, crearRemitoService, $window, $filter,
  13 + parametros, FileSaver, Blob
  14 + ) {
  15 + $scope.correoEnviado = false;
  16 + $scope.correoNoEnviado = false;
  17 + $scope.esperando = false;
  18 + $scope.remito = parametros.remito;
  19 +
  20 + $scope.aceptar = function() {
  21 + $uibModalInstance.close();
  22 + };
  23 +
  24 + $scope.imprimir = function () {
  25 + crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then(
  26 + function(res) {
  27 + var data = new Blob([res.data], {type: 'application/pdf'});
  28 +
  29 + FileSaver.saveAs(
  30 + data,
  31 + $filter('comprobante')([
  32 + parametros.remito.sucursal,
  33 + parametros.remito.numeroRemito
  34 + ]) + '.pdf'
  35 + );
  36 + }
  37 + );
  38 + };
  39 +
  40 + $scope.enviarCorreo = function(key) {
  41 + if(key !== 13) return;
  42 + $scope.esperando = true;
  43 + var options = {
  44 + para: $scope.remito.cliente.MAIL,
  45 + remito: $scope.remito.id
  46 + };
  47 +
  48 + crearRemitoService.enviarCorreo(options).then(function() {
  49 + $scope.correoEnviado = true;
  50 + $scope.esperando = false;
  51 + }, function() {
  52 + $scope.esperando = false;
  53 + $scope.correoNoEnviado = true;
  54 + });
  55 + };
  56 + }
  57 + ]);
... ... @@ -56,6 +56,19 @@ angular.module(&#39;focaCrearRemito&#39;)
56 56 getNumeroRemito: function() {
57 57 return $http.get(route + '/remito/numero-siguiente');
58 58 },
  59 + imprimirRemitoByIdRemito: function(idRemito, original) {
  60 + var tipo = original ? '/original' : '';
  61 + return $http.get(route + '/remito/comprobante/' + idRemito + tipo, {
  62 + responseType: 'arraybuffer'
  63 + });
  64 + },
  65 + getPuntosDescargaByClienDom: function(idDomicilio, idCliente) {
  66 + return $http.get(API_ENDPOINT.URL + '/punto-descarga/' +
  67 + idDomicilio + '/' + idCliente);
  68 + },
  69 + enviarCorreo: function(options) {
  70 + return $http.post(API_ENDPOINT.URL + '/remito/mail', options);
  71 + },
59 72 getBotonera: function() {
60 73 return [
61 74 {
... ... @@ -89,6 +102,11 @@ angular.module(&#39;focaCrearRemito&#39;)
89 102 {
90 103 label: 'Productos',
91 104 image: 'productos.png'
  105 + },
  106 + {
  107 + label: 'Observaciones',
  108 + image: 'productos.png',
  109 + disable: true
92 110 }
93 111 ];
94 112 }
src/views/remito-comprobante.html
... ... @@ -0,0 +1,42 @@
  1 +<div class="modal-header">
  2 + <h5>Comprobante de remito Nº
  3 + <span
  4 + ng-bind="[remito.numeroRemito, remito.sucursal] | comprobante">
  5 + </span>
  6 + </h5>
  7 +</div>
  8 +<div class="modal-body">
  9 + <div class="col-12">
  10 + <label
  11 + class="col-12 bg-success text-white"
  12 + ng-show="correoEnviado">Correo enviado con éxito</label>
  13 + <label
  14 + class="col-12 bg-danger text-white"
  15 + ng-show="correoNoEnviado">Hubo un error al enviar el correo</label>
  16 + <label>Enviar correo a </label>
  17 + <input
  18 + class="form-control"
  19 + ng-model="remito.cliente.MAIL"
  20 + ng-click="enviarCorreo($event.keyCode)"/>
  21 + </div>
  22 +</div>
  23 +<div class="modal-footer">
  24 + <button
  25 + type="button"
  26 + class="btn btn-info"
  27 + ng-click="imprimir()"
  28 + ladda="esperando"
  29 + >Imprimir</button>
  30 + <button
  31 + type="button"
  32 + class="btn btn-primary"
  33 + ng-click="aceptar()"
  34 + ladda="esperando"
  35 + >Aceptar</button>
  36 + <button
  37 + type="button"
  38 + class="btn btn-primary"
  39 + ng-click="enviarCorreo(13)"
  40 + ladda="esperando"
  41 + >Enviar</button>
  42 +</div>