angular.module('focaCrearNotaPedido') .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { var route = API_ENDPOINT.URL; return { crearNotaPedido: function(notaPedido) { return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); }, obtenerNotaPedido: function() { return $http.get(route +'/nota-pedido'); }, setNotaPedido: function(notaPedido) { this.notaPedido = notaPedido; }, clearNotaPedido: function() { this.notaPedido = undefined; }, getNotaPedido: function() { return this.notaPedido; }, getArticulosByIdNotaPedido: function(id) { return $http.get(route+'/articulos/nota-pedido/'+id); }, crearArticulosParaNotaPedido: function(articuloNotaPedido) { return $http.post(route + '/articulos/nota-pedido', {articuloNotaPedido: articuloNotaPedido}); }, getDomiciliosByIdNotaPedido: function(id) { return $http.get(route +'/nota-pedido/'+id+'/domicilios'); }, getDomiciliosByIdCliente: function(id) { var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); }, getPrecioCondicion: function() { return $http.get(route + '/precio-condicion'); }, getPrecioCondicionById: function(id) { return $http.get(route + '/precio-condicion/' + id); }, getPlazoPagoByPrecioCondicion: function(id) { return $http.get(route + '/plazo-pago/precio-condicion/'+ id); }, crearFlete: function(flete) { return $http.post(route + '/flete', {flete : flete}); }, crearPlazosParaNotaPedido: function(plazos) { return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos}); }, getCotizacionByIdMoneda: function(id) { return $http.get(route + '/moneda/' + id); }, crearEstadoParaNotaPedido: function(estado) { return $http.post(route + '/estado', {estado: estado}); }, getNumeroNotaPedido: function() { return $http.get(route + '/nota-pedido/numero-siguiente'); }, getBotonera: function(vendedor) { var result = [ { label: 'Cliente', image: 'cliente.png' }, { label: 'Proveedor', image: 'proveedor.png' }, { label: 'Moneda', image: 'moneda.png' }, { label: 'Precios y condiciones', image: 'precios-condiciones.png' }, { label: 'Flete', image: 'flete.png' }, { label: 'Productos', image: 'productos.png' }, { label: 'Observaciones', image: 'productos.png' } ]; if(!vendedor) { var botonVendedor = { label: 'Vendedor', image: 'vendedor.png' }; result.unshift(botonVendedor); } return result; }, crearPuntosDescarga: function(puntosDescarga) { return $http.post(route + '/puntos-descarga/nota-pedido', {puntosDescarga: puntosDescarga}); }, getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + idDomicilio + '/' + idCliente); }, getVendedorById: function(id) { return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); } }; }]);