diff --git a/src/js/controller.js b/src/js/controller.js index 2ae6e47..c49d341 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -30,6 +30,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', $scope.datepickerAbierto = false; $scope.show = false; $scope.cargando = true; + $scope.cabeceras = []; $scope.botonera = crearNotaPedidoService.getBotonera(); $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); $scope.comprobante = $filter('rellenarDigitos')(0, 8); @@ -260,7 +261,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', $scope.seleccionarProductos = function () { - if ($scope.idLista === undefined) { + if ($scope.notaPedido.idListaPrecio === undefined) { focaModalService.alert('Primero seleccione una lista de precio y condición'); return; } else if (!validarNotaRemitada()) { @@ -274,7 +275,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', controller: 'modalBusquedaProductosCtrl', resolve: { parametroProducto: { - idLista: $scope.idLista, + idLista: $scope.notaPedido.idListaPrecio, cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO } @@ -637,19 +638,13 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', if (!$scope.notaPedido.cliente.COD) { focaModalService.alert('Primero seleccione un cliente'); return; - } - if ($scope.notaPedido.articulosNotaPedido.length !== 0) { - focaModalService.confirm('Se perderan los productos ingresados') - .then(function (data) { - if (data) { - abrirModal(); - } - }); - } else if (validarNotaRemitada()) { + } else { abrirModal(); } + function abrirModal() { - var parametros = { idCliente: $scope.notaPedido.cliente.COD, idListaPrecio : $scope.notaPedido.cliente.MOD}; + var parametros = { idCliente: $scope.notaPedido.cliente.COD, idListaPrecio : $scope.notaPedido.cliente.MOD, + notaPedido: $scope.notaPedido }; var modalInstance = $uibModal.open( { ariaLabelledBy: 'Busqueda de Precio Condición', @@ -689,14 +684,17 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', } cabecera = 'Ingreso manual ' + plazosConcat.trim(); } - $scope.notaPedido.articulosNotaPedido = []; - $scope.$broadcast('addCabecera', { - label: 'Precios y condiciones:', - valor: cabecera - }); + + $filter('filter')($scope.cabeceras, + { label: 'Precios y Condiciones' })[0].valor = cabecera; + + $scope.notaPedido.precioCondicion = precioCondicion; $filter('filter')($scope.botonera, { label: 'Precios y Condiciones' })[0].checked = true; + + addArrayCabecera($scope.cabeceras); + }) .catch(function (e) { console.log(e); @@ -915,19 +913,19 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', $scope.$broadcast('removeCabecera', 'Kilometros:'); $scope.$broadcast('cleanCabecera'); - var cabeceras = []; + $scope.cabeceras = []; if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { - cabeceras.push({ + $scope.cabeceras.push({ label: 'Moneda:', valor: notaPedido.cotizacion.moneda.DETALLE }); - cabeceras.push({ + $scope.cabeceras.push({ label: 'Fecha cotizacion:', valor: $filter('date')(notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') }); - cabeceras.push({ + $scope.cabeceras.push({ label: 'Cotizacion:', valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, '2') @@ -939,7 +937,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', } if (notaPedido.vendedor.NUM) { - cabeceras.push({ + $scope.cabeceras.push({ label: 'Vendedor:', valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + ' - ' + notaPedido.vendedor.NOM @@ -947,11 +945,11 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', } if (notaPedido.cliente.COD) { - cabeceras.push({ + $scope.cabeceras.push({ label: 'Cliente:', valor: notaPedido.cliente.NOM }); - cabeceras.push({ + $scope.cabeceras.push({ label: 'Domicilio:', valor: notaPedido.domicilioStamp }); @@ -960,7 +958,7 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', } if (notaPedido.proveedor.COD) { - cabeceras.push({ + $scope.cabeceras.push({ label: 'Proveedor:', valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + ' - ' + notaPedido.proveedor.NOM @@ -970,19 +968,13 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', } if (notaPedido.notaPedidoPlazo.length) { - cabeceras.push({ - label: 'Precios y condiciones:', - valor: valorPrecioCondicion() + ' ' + - notaPedidoBusinessService - .plazoToString(notaPedido.notaPedidoPlazo) - }); - + valorPrecioCondicion(); $filter('filter')($scope.botonera, { label: 'Precios y condiciones' })[0].checked = true; } if (notaPedido.flete !== undefined) { - cabeceras.push({ + $scope.cabeceras.push({ label: 'Flete:', valor: notaPedido.fob === 1 ? 'FOB' : ( notaPedido.flete === 1 ? 'Si' : 'No') @@ -990,10 +982,17 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', } function valorPrecioCondicion() { - if (notaPedido.idPrecioCondicion > 0) { - return notaPedido.precioCondicion.nombre; - } else { - return 'Ingreso Manual'; + if (notaPedido.idListaPrecio > 0) { + crearNotaPedidoService.getPrecioCondicionById(parseInt(notaPedido.idListaPrecio)) + .then(function (res) { + $scope.cabeceras.push({ + label: 'Precios y Condiciones:', + valor: parseInt(res.data[0].ID) + ' - ' + res.data[0].DES + ' ' + + notaPedidoBusinessService + .plazoToString(notaPedido.notaPedidoPlazo) + }); + addArrayCabecera($scope.cabeceras); + }); } } @@ -1007,9 +1006,9 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', label: 'Kilometros:', valor: notaPedido.kilometros }; - cabeceras.push(cabeceraKilometros); + $scope.cabeceras.push(cabeceraKilometros); } - cabeceras.push(cabeceraBomba); + $scope.cabeceras.push(cabeceraBomba); } if (notaPedido.idPrecioCondicion > 0) { @@ -1031,13 +1030,13 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedidoPuntoDescarga) { puntos.push(notaPedidoPuntoDescarga.puntoDescarga); }); - cabeceras.push({ + $scope.cabeceras.push({ label: 'Puntos de descarga: ', valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) }); } - addArrayCabecera(cabeceras); + addArrayCabecera($scope.cabeceras); } function getCabeceraPuntoDescarga(puntoDescarga) { diff --git a/src/js/service.js b/src/js/service.js index 0c719fa..4a88b9a 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -35,7 +35,7 @@ angular.module('focaCrearNotaPedido') return $http.get(route + '/precio-condicion'); }, getPrecioCondicionById: function(id) { - return $http.get(route + '/precio-condicion/' + id); + return $http.get(route + '/lista-precio/' + id); }, getPlazoPagoByPrecioCondicion: function(id) { return $http.get(route + '/plazo-pago/precio-condicion/'+ id);