Commit 188a500a9b502791a972aea139d3ac4524b904e4
Exists in
master
Merge branch 'develop' into 'master'
Develop See merge request !119
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -30,6 +30,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
30 | 30 | $scope.datepickerAbierto = false; |
31 | 31 | $scope.show = false; |
32 | 32 | $scope.cargando = true; |
33 | + $scope.cabeceras = []; | |
33 | 34 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
34 | 35 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
35 | 36 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
... | ... | @@ -171,7 +172,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
171 | 172 | idProveedor: $scope.notaPedido.proveedor.COD, |
172 | 173 | idDomicilio: $scope.notaPedido.domicilio.id, |
173 | 174 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
174 | - idListaPrecio: $scope.notaPedido.idPrecioCondicion, | |
175 | + idListaPrecio: $scope.idLista, | |
175 | 176 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
176 | 177 | flete: $scope.notaPedido.flete, |
177 | 178 | fob: $scope.notaPedido.fob, |
... | ... | @@ -195,7 +196,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
195 | 196 | notaPedidoBusinessService.addArticulos( |
196 | 197 | $scope.notaPedido.articulosNotaPedido, |
197 | 198 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
198 | - | |
199 | + | |
199 | 200 | if ($scope.notaPedido.notaPedidoPuntoDescarga.length > 0) { |
200 | 201 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
201 | 202 | $scope.notaPedido.notaPedidoPuntoDescarga); |
... | ... | @@ -247,7 +248,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
247 | 248 | } |
248 | 249 | } |
249 | 250 | ); |
250 | - modalInstance.result.then(function(notaPedido) { | |
251 | + modalInstance.result.then(function (notaPedido) { | |
251 | 252 | |
252 | 253 | notaPedido.articulosNotaPedido.forEach(function (articulo) { |
253 | 254 | articulo.precio = |
... | ... | @@ -259,7 +260,6 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
259 | 260 | }; |
260 | 261 | |
261 | 262 | $scope.seleccionarProductos = function () { |
262 | - | |
263 | 263 | if ($scope.idLista === undefined) { |
264 | 264 | focaModalService.alert('Primero seleccione una lista de precio y condición'); |
265 | 265 | return; |
... | ... | @@ -484,7 +484,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
484 | 484 | templateUrl: 'foca-busqueda-cliente-modal.html', |
485 | 485 | controller: 'focaBusquedaClienteModalController', |
486 | 486 | resolve: { |
487 | - vendedor: function () { return { id: $scope.idVendedor} }, | |
487 | + vendedor: function () { return { id: $scope.idVendedor }; }, | |
488 | 488 | cobrador: function () { return null; } |
489 | 489 | }, |
490 | 490 | size: 'lg' |
... | ... | @@ -601,7 +601,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
601 | 601 | $filter('filter')($scope.botonera, |
602 | 602 | { label: 'Cliente' })[0].checked = true; |
603 | 603 | $filter('filter')($scope.botonera, |
604 | - { label: 'Domicilio de Entrega' })[0].checked = true; | |
604 | + { label: 'Domicilio de Entrega' })[0].checked = true; | |
605 | 605 | }) |
606 | 606 | .catch(function (e) { console.log(e); }); |
607 | 607 | }, function () { |
... | ... | @@ -630,26 +630,21 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
630 | 630 | |
631 | 631 | $scope.seleccionarPreciosYCondiciones = function () { |
632 | 632 | |
633 | - if (!validarNotaRemitada()) { | |
634 | - return; | |
635 | - } | |
633 | + if (!validarNotaRemitada()) return; | |
636 | 634 | |
637 | 635 | if (!$scope.notaPedido.cliente.COD) { |
638 | 636 | focaModalService.alert('Primero seleccione un cliente'); |
639 | 637 | return; |
640 | - } | |
641 | - if ($scope.notaPedido.articulosNotaPedido.length !== 0) { | |
642 | - focaModalService.confirm('Se perderan los productos ingresados') | |
643 | - .then(function (data) { | |
644 | - if (data) { | |
645 | - abrirModal(); | |
646 | - } | |
647 | - }); | |
648 | - } else if (validarNotaRemitada()) { | |
638 | + } else { | |
649 | 639 | abrirModal(); |
650 | 640 | } |
641 | + | |
651 | 642 | function abrirModal() { |
652 | - var parametros = { idCliente: $scope.notaPedido.cliente.COD, idListaPrecio : $scope.notaPedido.cliente.MOD}; | |
643 | + var parametros = { | |
644 | + idCliente: $scope.notaPedido.cliente.COD, | |
645 | + idListaPrecio: $scope.notaPedido.cliente.MOD, | |
646 | + notaPedido: $scope.notaPedido | |
647 | + }; | |
653 | 648 | var modalInstance = $uibModal.open( |
654 | 649 | { |
655 | 650 | ariaLabelledBy: 'Busqueda de Precio Condición', |
... | ... | @@ -662,45 +657,46 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
662 | 657 | } |
663 | 658 | ); |
664 | 659 | |
665 | - modalInstance.result | |
666 | - .then(function (precioCondicion) { | |
667 | - var cabecera = ''; | |
668 | - var plazosConcat = ''; | |
669 | - if (!Array.isArray(precioCondicion)) { | |
670 | - $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | |
671 | - $scope.notaPedido.precioCondicion = precioCondicion; | |
672 | - $scope.notaPedido.idPrecioCondicion = precioCondicion.listaPrecio.ID; | |
673 | - $scope.notaPedido.cliente.MOD = precioCondicion.listaPrecio.ID; | |
674 | - $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? | |
675 | - parseInt(precioCondicion.listaPrecio.ID) : -1; | |
676 | - for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
677 | - plazosConcat += precioCondicion.plazoPago[i].dias + ', '; | |
678 | - } | |
679 | - plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); | |
680 | - cabecera = $filter('rellenarDigitos')($scope.idLista, 4) + | |
681 | - ' - ' + precioCondicion.listaPrecio.DES + ' ' + plazosConcat.trim(); | |
682 | - } else { //Cuando se ingresan los plazos manualmente | |
683 | - $scope.notaPedido.idPrecioCondicion = 0; | |
684 | - //-1, el modal productos busca todos los productos | |
685 | - $scope.idLista = -1; | |
686 | - $scope.notaPedido.notaPedidoPlazo = precioCondicion; | |
687 | - for (var j = 0; j < precioCondicion.length; j++) { | |
688 | - plazosConcat += precioCondicion[j].dias + ' '; | |
689 | - } | |
690 | - cabecera = 'Ingreso manual ' + plazosConcat.trim(); | |
660 | + modalInstance.result.then(function (precioCondicion) { | |
661 | + var cabecera = ''; | |
662 | + var plazosConcat = ''; | |
663 | + if (!Array.isArray(precioCondicion)) { | |
664 | + $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | |
665 | + $scope.notaPedido.precioCondicion = precioCondicion; | |
666 | + $scope.notaPedido.cliente.MOD = precioCondicion.listaPrecio.ID; | |
667 | + $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? | |
668 | + parseInt(precioCondicion.listaPrecio.ID) : -1; | |
669 | + for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
670 | + plazosConcat += precioCondicion.plazoPago[i].dias + ', '; | |
691 | 671 | } |
692 | - $scope.notaPedido.articulosNotaPedido = []; | |
693 | - $scope.$broadcast('addCabecera', { | |
694 | - label: 'Precios y condiciones:', | |
695 | - valor: cabecera | |
696 | - }); | |
672 | + plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); | |
673 | + cabecera = $filter('rellenarDigitos')($scope.idLista, 4) + | |
674 | + ' - ' + precioCondicion.listaPrecio.DES + | |
675 | + ' ' + plazosConcat.trim(); | |
676 | + } else { //Cuando se ingresan los plazos manualmente | |
677 | + //-1, el modal productos busca todos los productos | |
678 | + $scope.idLista = -1; | |
679 | + $scope.notaPedido.notaPedidoPlazo = precioCondicion; | |
680 | + for (var j = 0; j < precioCondicion.length; j++) { | |
681 | + plazosConcat += precioCondicion[j].dias + ' '; | |
682 | + } | |
683 | + cabecera = 'Ingreso manual ' + plazosConcat.trim(); | |
684 | + } | |
685 | + $scope.cabeceras.push({ | |
686 | + label: 'Precios y Condiciones:', | |
687 | + valor: $scope.idLista + ' - ' + precioCondicion.listaPrecio.DES + ' ' + | |
688 | + notaPedidoBusinessService.plazoToString(precioCondicion.plazoPago) | |
689 | + }); | |
697 | 690 | |
698 | - $filter('filter')($scope.botonera, | |
699 | - { label: 'Precios y Condiciones' })[0].checked = true; | |
700 | - }) | |
691 | + $filter('filter')($scope.botonera, | |
692 | + { label: 'Precios y Condiciones' })[0].checked = true; | |
693 | + | |
694 | + addArrayCabecera($scope.cabeceras); | |
695 | + | |
696 | + }) | |
701 | 697 | .catch(function (e) { |
702 | 698 | console.log(e); |
703 | - }) | |
699 | + }); | |
704 | 700 | |
705 | 701 | } |
706 | 702 | }; |
... | ... | @@ -915,19 +911,19 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
915 | 911 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
916 | 912 | $scope.$broadcast('cleanCabecera'); |
917 | 913 | |
918 | - var cabeceras = []; | |
914 | + $scope.cabeceras = []; | |
919 | 915 | |
920 | 916 | if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
921 | - cabeceras.push({ | |
917 | + $scope.cabeceras.push({ | |
922 | 918 | label: 'Moneda:', |
923 | 919 | valor: notaPedido.cotizacion.moneda.DETALLE |
924 | 920 | }); |
925 | - cabeceras.push({ | |
921 | + $scope.cabeceras.push({ | |
926 | 922 | label: 'Fecha cotizacion:', |
927 | 923 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
928 | 924 | 'dd/MM/yyyy') |
929 | 925 | }); |
930 | - cabeceras.push({ | |
926 | + $scope.cabeceras.push({ | |
931 | 927 | label: 'Cotizacion:', |
932 | 928 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
933 | 929 | '2') |
... | ... | @@ -939,7 +935,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
939 | 935 | } |
940 | 936 | |
941 | 937 | if (notaPedido.vendedor.NUM) { |
942 | - cabeceras.push({ | |
938 | + $scope.cabeceras.push({ | |
943 | 939 | label: 'Vendedor:', |
944 | 940 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + |
945 | 941 | ' - ' + notaPedido.vendedor.NOM |
... | ... | @@ -947,11 +943,11 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
947 | 943 | } |
948 | 944 | |
949 | 945 | if (notaPedido.cliente.COD) { |
950 | - cabeceras.push({ | |
946 | + $scope.cabeceras.push({ | |
951 | 947 | label: 'Cliente:', |
952 | 948 | valor: notaPedido.cliente.NOM |
953 | 949 | }); |
954 | - cabeceras.push({ | |
950 | + $scope.cabeceras.push({ | |
955 | 951 | label: 'Domicilio:', |
956 | 952 | valor: notaPedido.domicilioStamp |
957 | 953 | }); |
... | ... | @@ -960,7 +956,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
960 | 956 | } |
961 | 957 | |
962 | 958 | if (notaPedido.proveedor.COD) { |
963 | - cabeceras.push({ | |
959 | + $scope.cabeceras.push({ | |
964 | 960 | label: 'Proveedor:', |
965 | 961 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + |
966 | 962 | ' - ' + notaPedido.proveedor.NOM |
... | ... | @@ -970,19 +966,13 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
970 | 966 | } |
971 | 967 | |
972 | 968 | if (notaPedido.notaPedidoPlazo.length) { |
973 | - cabeceras.push({ | |
974 | - label: 'Precios y condiciones:', | |
975 | - valor: valorPrecioCondicion() + ' ' + | |
976 | - notaPedidoBusinessService | |
977 | - .plazoToString(notaPedido.notaPedidoPlazo) | |
978 | - }); | |
979 | - | |
969 | + valorPrecioCondicion(); | |
980 | 970 | $filter('filter')($scope.botonera, |
981 | 971 | { label: 'Precios y condiciones' })[0].checked = true; |
982 | 972 | } |
983 | 973 | |
984 | 974 | if (notaPedido.flete !== undefined) { |
985 | - cabeceras.push({ | |
975 | + $scope.cabeceras.push({ | |
986 | 976 | label: 'Flete:', |
987 | 977 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
988 | 978 | notaPedido.flete === 1 ? 'Si' : 'No') |
... | ... | @@ -990,11 +980,21 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
990 | 980 | } |
991 | 981 | |
992 | 982 | function valorPrecioCondicion() { |
993 | - if (notaPedido.idPrecioCondicion > 0) { | |
994 | - return notaPedido.precioCondicion.nombre; | |
995 | - } else { | |
996 | - return 'Ingreso Manual'; | |
983 | + if (notaPedido.idListaPrecio > 0) { | |
984 | + crearNotaPedidoService | |
985 | + .getPrecioCondicionById(parseInt(notaPedido.idListaPrecio)) | |
986 | + .then(function (res) { | |
987 | + $scope.cabeceras.push({ | |
988 | + label: 'Precios y Condiciones:', | |
989 | + valor: parseInt(res.data[0].ID) + ' - ' + | |
990 | + res.data[0].DES + ' ' + | |
991 | + notaPedidoBusinessService | |
992 | + .plazoToString(notaPedido.notaPedidoPlazo) | |
993 | + }); | |
994 | + addArrayCabecera($scope.cabeceras); | |
995 | + }); | |
997 | 996 | } |
997 | + $scope.idLista = parseInt(notaPedido.idListaPrecio); | |
998 | 998 | } |
999 | 999 | |
1000 | 1000 | if (notaPedido.flete === 1) { |
... | ... | @@ -1007,9 +1007,9 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
1007 | 1007 | label: 'Kilometros:', |
1008 | 1008 | valor: notaPedido.kilometros |
1009 | 1009 | }; |
1010 | - cabeceras.push(cabeceraKilometros); | |
1010 | + $scope.cabeceras.push(cabeceraKilometros); | |
1011 | 1011 | } |
1012 | - cabeceras.push(cabeceraBomba); | |
1012 | + $scope.cabeceras.push(cabeceraBomba); | |
1013 | 1013 | } |
1014 | 1014 | |
1015 | 1015 | if (notaPedido.idPrecioCondicion > 0) { |
... | ... | @@ -1031,13 +1031,13 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
1031 | 1031 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedidoPuntoDescarga) { |
1032 | 1032 | puntos.push(notaPedidoPuntoDescarga.puntoDescarga); |
1033 | 1033 | }); |
1034 | - cabeceras.push({ | |
1034 | + $scope.cabeceras.push({ | |
1035 | 1035 | label: 'Puntos de descarga: ', |
1036 | 1036 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) |
1037 | 1037 | }); |
1038 | 1038 | } |
1039 | 1039 | |
1040 | - addArrayCabecera(cabeceras); | |
1040 | + addArrayCabecera($scope.cabeceras); | |
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | function getCabeceraPuntoDescarga(puntoDescarga) { |
src/js/service.js
... | ... | @@ -35,7 +35,7 @@ angular.module('focaCrearNotaPedido') |
35 | 35 | return $http.get(route + '/precio-condicion'); |
36 | 36 | }, |
37 | 37 | getPrecioCondicionById: function(id) { |
38 | - return $http.get(route + '/precio-condicion/' + id); | |
38 | + return $http.get(route + '/lista-precio/' + id); | |
39 | 39 | }, |
40 | 40 | getPlazoPagoByPrecioCondicion: function(id) { |
41 | 41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |