service.js 2.46 KB
angular.module('focaCrearNotaPedido')
    .service('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);
            },
            getCotizacionByIdMoneda: function(id) {
                return $http.get(route + '/moneda/' + id);
            },
            crearEstadoParaNotaPedido: function(estado) {
                return $http.post(route + '/estado', {estado: estado});
            }
        };
    }]);