service.js 9.18 KB
angular.module('focaCrearHojaRuta')
    .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', '$cookies',
    function($http, API_ENDPOINT, $cookies) {
        var route = API_ENDPOINT.URL;
        return {
            idUsuario: $cookies.get('vendedorCobrador'),
            crearHojaRuta: function(hojaRuta) {
                return $http.post(route + '/hoja-ruta', hojaRuta);
            },
            crearRemito: function(remito) {
                console.log('Crear remito-----: ', remito);
                // TODO: Cambiar para usar el servicio /remito
                return $http.post(route + '/remito', remito);
            },
            obtenerHojaRuta: function() {
                return $http.get(route +'/hoja-ruta');
            },
            setHojaRuta: function(hojaRuta) {
                this.hojaRuta = hojaRuta;
            },
            clearHojaRuta: function() {
                this.hojaRuta = undefined;
            },
            getHojaRuta: function() {
                return this.hojaRuta;
            },
            getArticulosByIdHojaRuta: function(id) {
                return $http.get(route+'/articulos/hoja-ruta/'+id);
            },
            crearArticulosParaHojaRuta: function(articuloHojaRuta) {
                return $http.post(route + '/articulos/remito',
                    {articuloRemito: articuloHojaRuta});
            },
            getDomiciliosByIdHojaRuta: function(id) {
                return $http.get(route +'/hoja-ruta/' + 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});
            },
            crearPlazosParaHojaRuta: function(plazos) {
                return $http.post(route + '/plazo-pago/hoja-ruta', plazos);
            },
            getCotizacionByIdMoneda: function(id) {
                return $http.get(route + '/moneda/' + id);
            },
            crearEstadoParaHojaRuta: function(estado) {
                return $http.post(route + '/estado', {estado: estado});
            },
            getNumeroHojaRuta: function() {
                return $http.get(route + '/hoja-ruta/numero-siguiente');
            },
            getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) {
                var noCofirmados = sinConfirmar ? '/sinConfirmar' : '';
                return $http.get(route + '/vehiculo/obtener/remitos/' +
                    idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados);
            },
            desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) {
                return $http.post(route + '/vehiculo/desasociar-remitos',
                    {
                        idsRemitos: idsRemitos,
                        idVehiculo: idVehiculo,
                        vehiculoSinRemitos: sinRemitos
                    });
            },
            getParametros: function() {
                return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta');
            },
            getBotonera: function() {
                return [
                    {
                        label: 'Fecha Entrega',
                        image: 'FechaEntrega.png'
                    },
                    {
                        label: 'Transportista',
                        image: 'transportista.png'
                    },
                    {
                        label: 'Chofer',
                        image: 'chofer.png'
                    },
                    {
                        label: 'Vehiculo',
                        image: 'vehiculos.png'
                    },
                    {
                        label: 'Tarifario',
                        image: 'tarifario.png'
                    },
                    {
                        label: 'Remitos',
                        image: 'remito.png'
                    },
                    {
                        label: 'Vehiculos precargados',
                        image: 'vehiculos.png'
                    },
                    {
                        label: 'Datos extra',
                        image: 'tarifario.png'
                    }
                ];
            },
            getBotones: function () {
                return [
                    {
                        label: 'Precargados',
                        image: 'vehiculos.png'
                    },
                    {
                        label: 'Cargar Remitos',
                        image: 'remito.png'
                    },
                    {
                        label: 'Remito Abierto',
                        image: 'remitoabierto.png'
                    }
                ];
            },
            getRemitoAbierto: function () {
                return [
                    {
                        label: 'Fecha Entrega',
                        image: 'FechaEntrega.png'
                    },
                    {
                        label: 'Transportista',
                        image: 'transportista.png'
                    },
                    {
                        label: 'Vehiculo',
                        image: 'vehiculos.png'
                    },
                    {
                        label: 'Chofer',
                        image: 'chofer.png'
                    },
                    {
                        label: 'Proveedor',
                        image: 'proveedor.png'
                    },
                    {
                        label: 'Tarifario',
                        image: 'tarifario.png'
                    },
                    {
                        label: 'Cliente',
                        image: 'cliente.png'
                    }
                ];
            },
            getArticulos : function () {
                return $http.get(API_ENDPOINT.URL + '/articulos');
            },
            getVendedorById : function (idVendedor) {
                return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + idVendedor);
            },
            getPuntosDescargaByClienDom: function(idDomicilio, idCliente) {
                return $http.get(API_ENDPOINT.URL + '/punto-descarga/' +
                    idDomicilio + '/' + idCliente);
            },
            getBotonFecha : function () {
                return [
                    {
                        label: 'Fecha Entrega',
                        image: 'FechaEntrega.png'
                    },
                ];
            }, 
            getBotoneraPrecargado: function () {
                return [

                    {
                        label: 'Transportista',
                        image: 'transportista.png'
                    },
                    {
                        label: 'Chofer',
                        image: 'chofer.png'
                    },
                    {
                        label: 'Vehiculo',
                        image: 'vehiculos.png'
                    },
                    {
                        label: 'Tarifario',
                        image: 'tarifario.png'
                    },
                    {
                        label: 'Datos extra',
                        image: 'tarifario.png'
                    }
                ];
            },
            getBotoneraCargarRemito: function () {
                return [
                    {
                        label: 'Transportista',
                        image: 'transportista.png'
                    },
                    {
                        label: 'Chofer',
                        image: 'chofer.png'
                    },
                    {
                        label: 'Vehiculo',
                        image: 'flete.png'
                    },
                    {
                        label: 'Remitos',
                        image: 'remito.png'
                    },
                    {
                        label: 'Tarifario',
                        image: 'tarifario.png'
                    },
                    {
                        label: 'Datos extra',
                        image: 'tarifario.png'
                    }
                ];
            },
            guardarCisternas: function(cisterna, idRemito) {
                return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' +
                    this.idUsuario + '/' + idRemito, cisterna);
            },
            crearArticulosParaRemito: function(articuloRemito) {
                return $http.post(route + '/articulos/remito',
                    {articuloRemito: articuloRemito});
            }
        };
    }]);