diff --git a/src/js/controller.js b/src/js/controller.js index 0d011f6..4484af6 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -19,7 +19,7 @@ angular.module('focaCrearNotaPedido') $scope.precioCondiciones = res.data; } ); - if (notaPedidoTemp != undefined) { + if (notaPedidoTemp !== undefined) { notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); $scope.notaPedido = notaPedidoTemp; $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); @@ -35,26 +35,26 @@ angular.module('focaCrearNotaPedido') function(res) { $scope.notaPedido.domicilio = res.data; } - ) + ); } else { $scope.notaPedido.fechaCarga = new Date(); - $scope.notaPedido.domicilio = [{ id: 0 }] + $scope.notaPedido.domicilio = [{ id: 0 }]; $scope.notaPedido.bomba = '1'; $scope.notaPedido.flete = '1'; idLista = undefined; } $scope.addNewDom = function() { $scope.notaPedido.domicilio.push({ 'id': 0 }); - } + }; $scope.removeNewChoice = function(choice) { if ($scope.notaPedido.domicilio.length > 1) { $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( function(c) { - return c.$$hashKey == choice.$$hashKey; + return c.$$hashKey === choice.$$hashKey; } - ), 1) + ), 1); } - } + }; $scope.crearNotaPedido = function() { var notaPedido = { id: 0, @@ -71,29 +71,30 @@ angular.module('focaCrearNotaPedido') costoFinanciacion: $scope.notaPedido.costoFinanciacion, flete: $scope.notaPedido.flete, costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, - total : $scope.articulosTabla[0].subTotal - } + total: $scope.articulosTabla[0].subTotal + }; crearNotaPedidoService.crearNotaPedido(notaPedido).then( - function(res) { + function() { alert('Nota pedido creada'); $location.path('/venta-nota-pedido'); } - ) + ); var articulosNotaPedido = $scope.articulosTabla; for(var i = 0; i< articulosNotaPedido.length;i++) { - crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( - function(res) { - return; - } - ) + crearNotaPedidoService + .crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( + function() { + return; + } + ); } - } + }; $scope.siguienteTab = function() { $scope.active = 1; - } + }; $scope.seleccionarArticulo = function() { - if (idLista == undefined) { + if (idLista === undefined) { alert('primero seleccione una lista de precio y condicion'); return; } @@ -102,10 +103,10 @@ angular.module('focaCrearNotaPedido') ariaLabelledBy: 'Busqueda de Productos', templateUrl: 'modal-busqueda-productos.html', controller: 'modalBusquedaProductosCtrl', - resolve: { idLista: function() { return idLista } }, + resolve: { idLista: function() { return idLista; } }, size: 'lg' } - ) + ); modalInstance.result.then( function(producto) { var newArt = @@ -117,13 +118,13 @@ angular.module('focaCrearNotaPedido') precio: producto.precio, costoUnitario: producto.costo, cantidad: 1 - } + }; $scope.articulosTabla.unshift(newArt); }, function() { // funcion ejecutada cuando se cancela el modal } ); - } + }; $scope.seleccionarVendedor = function() { var modalInstance = $uibModal.open( { @@ -132,7 +133,7 @@ angular.module('focaCrearNotaPedido') controller: 'modalVendedoresCtrl', size: 'lg' } - ) + ); modalInstance.result.then( function(vendedor) { $scope.notaPedido.vendedor = vendedor.NomVen; @@ -140,7 +141,7 @@ angular.module('focaCrearNotaPedido') } ); - } + }; $scope.seleccionarPetrolera = function() { var modalInstance = $uibModal.open( { @@ -149,7 +150,7 @@ angular.module('focaCrearNotaPedido') controller: 'modalPetrolerasCtrl', size: 'lg' } - ) + ); modalInstance.result.then( function(petrolera) { $scope.notaPedido.petrolera = petrolera.NOM; @@ -157,7 +158,7 @@ angular.module('focaCrearNotaPedido') } ); - } + }; $scope.seleccionarCliente = function() { var modalInstance = $uibModal.open( { @@ -166,7 +167,7 @@ angular.module('focaCrearNotaPedido') controller: 'focaBusquedaClienteModalController', size: 'lg' } - ) + ); modalInstance.result.then( function(cliente) { $scope.notaPedido.cliente = cliente.nom; @@ -174,14 +175,14 @@ angular.module('focaCrearNotaPedido') } ); - } + }; $scope.obtenerDomicilios = function(id) { crearNotaPedidoService.getDomicilios(id).then( function(res) { $scope.notaPedido.domicilio = res.data; } - ) - } + ); + }; $scope.getSubTotal = function(item) { var subTotal = 0; var array = $scope.articulosTabla.filter( @@ -190,14 +191,14 @@ angular.module('focaCrearNotaPedido') } ); for (var i = 0; i < array.length; i++) { - subTotal += array[i].precio * array[i].cantidad + subTotal += array[i].precio * array[i].cantidad; } return subTotal.toFixed(2); - } + }; $scope.cargarArticulos = function() { idLista = $scope.notaPedido.precioCondicion; $scope.articulosTabla = []; - } + }; } ] ) @@ -212,10 +213,10 @@ angular.module('focaCrearNotaPedido') $scope.editar = function(notaPedido) { crearNotaPedidoService.setNotaPedido(notaPedido); $location.path('/venta-nota-pedido/abm/'); - } + }; $scope.crearPedido = function() { crearNotaPedidoService.clearNotaPedido(); $location.path('/venta-nota-pedido/abm/'); - } + }; } - ]) + ]); diff --git a/src/js/service.js b/src/js/service.js index 57755d7..eba9c51 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -1,7 +1,7 @@ angular.module('focaCrearNotaPedido') .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { var route = API_ENDPOINT.URL; - var notaPedido; + var notaPedido = undefined; return { crearNotaPedido: function(notaPedido) { return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); @@ -22,7 +22,8 @@ angular.module('focaCrearNotaPedido') return $http.get(route+'/articulos/nota-pedido/'+id); }, crearArticulosParaNotaPedido: function(articuloNotaPedido) { - return $http.post(route + '/articulos/nota-pedido', {articuloNotaPedido: articuloNotaPedido}); + return $http.post(route + '/articulos/nota-pedido', + {articuloNotaPedido: articuloNotaPedido}); }, getDomiciliosByIdNotaPedido: function(id) { return $http.get(route +'/nota-pedido/'+id+'/domicilios'); @@ -43,17 +44,17 @@ angular.module('focaCrearNotaPedido') id: 3, dom: 'SALTA 796' } - ] + ]; return domicilio; }, getPrecioCondicion: function() { - return $http.get(route + '/precio-condicion') + return $http.get(route + '/precio-condicion'); }, getPrecioCondicionById: function(id) { - return $http.get(route + '/precio-condicion/' + id) + return $http.get(route + '/precio-condicion/' + id); }, getPlazoPagoByPrecioCondicion: function(id) { - return $http.get(route + '/plazo-pago/precio-condicion/'+ id) + return $http.get(route + '/plazo-pago/precio-condicion/'+ id); } - } - }]) + }; + }]);