Commit 94d7eca48618b703235fc13ddebd4e36e0d50802
1 parent
99dd25f66b
Exists in
master
servicio desasociar remitos
Showing
1 changed file
with
14 additions
and
1 deletions
Show diff stats
src/js/service.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .service( | 2 | .service( |
3 | 'focaLogisticaPedidoRutaService', [ | 3 | 'focaLogisticaPedidoRutaService', [ |
4 | '$http', | 4 | '$http', |
5 | '$cookies', | 5 | '$cookies', |
6 | 'API_ENDPOINT', | 6 | 'API_ENDPOINT', |
7 | '$filter', | 7 | '$filter', |
8 | function($http, $cookies, API_ENDPOINT, $filter) { | 8 | function($http, $cookies, API_ENDPOINT, $filter) { |
9 | return { | 9 | return { |
10 | idUsuario: $cookies.get('idUsuario'), | 10 | idUsuario: $cookies.get('idUsuario'), |
11 | obtenerActividad: function(parametros) { | 11 | obtenerActividad: function(parametros) { |
12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); | 12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); |
13 | }, | 13 | }, |
14 | obtenerVehiculoById: function(idVehiculo) { | 14 | obtenerVehiculoById: function(idVehiculo) { |
15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); | 15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); |
16 | }, | 16 | }, |
17 | obtenerRemitoById: function(idRemito) { | 17 | obtenerRemitoById: function(idRemito) { |
18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); | 18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); |
19 | }, | 19 | }, |
20 | guardarCisternas: function(cisterna, idRemito) { | 20 | guardarCisternas: function(cisterna, idRemito) { |
21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | 21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + |
22 | this.idUsuario + '/' + idRemito,cisterna); | 22 | this.idUsuario + '/' + idRemito,cisterna); |
23 | }, | 23 | }, |
24 | numeroHojaRuta: function() { | 24 | numeroHojaRuta: function() { |
25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); | 25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); |
26 | }, | 26 | }, |
27 | getRemitos: function(idVehiculo) { | 27 | getRemitos: function(idVehiculo) { |
28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); | 28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); |
29 | }, | 29 | }, |
30 | crearHojaRuta: function(hojaRuta) { | 30 | crearHojaRuta: function(hojaRuta) { |
31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); | 31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); |
32 | }, | 32 | }, |
33 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { | ||
34 | var idsRemitos = []; | ||
35 | for (var i = 0; i < remitos.length; i++) { | ||
36 | idsRemitos.push(remitos[i].id); | ||
37 | } | ||
38 | return $http.post(API_ENDPOINT.URL + '/vehiculo/desasociar-remitos', | ||
39 | { | ||
40 | idsRemitos: idsRemitos, | ||
41 | idVehiculo: idVehiculo, | ||
42 | vehiculoSinRemitos: sinRemitos | ||
43 | }); | ||
44 | }, | ||
33 | obtenerRemitosDeCarga: function(remitos) { | 45 | obtenerRemitosDeCarga: function(remitos) { |
34 | var remitosRes = []; | 46 | var remitosRes = []; |
35 | for(var i = 0; i < remitos.cisternas.length; i++) { | 47 | for(var i = 0; i < remitos.cisternas.length; i++) { |
36 | procesoCistena(remitos.cisternas[i]); | 48 | procesoCistena(remitos.cisternas[i]); |
37 | } | 49 | } |
38 | function procesoCistena(cisterna) { | 50 | function procesoCistena(cisterna) { |
39 | for(var j = 0; j < cisterna.cisternaCarga.cisternaMovimientos.length; | 51 | for(var j = 0; j < cisterna.cisternaCarga.cisternaMovimientos.length; |
40 | j++) { | 52 | j++) { |
41 | procesoMovimiento( | 53 | procesoMovimiento( |
42 | cisterna.cisternaCarga.cisternaMovimientos[j]); | 54 | cisterna.cisternaCarga.cisternaMovimientos[j]); |
43 | } | 55 | } |
44 | } | 56 | } |
45 | function procesoMovimiento(movimiento) { | 57 | function procesoMovimiento(movimiento) { |
46 | if(movimiento.remito && !movimiento.remito.idHojaRuta) { | 58 | if(!movimiento.anulado && movimiento.remito && |
59 | !movimiento.remito.idHojaRuta) { | ||
47 | var remito = movimiento.remito; | 60 | var remito = movimiento.remito; |
48 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | 61 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); |
49 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | 62 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { |
50 | remitosRes.push(remito); | 63 | remitosRes.push(remito); |
51 | } | 64 | } |
52 | } | 65 | } |
53 | } | 66 | } |
54 | return remitosRes; | 67 | return remitosRes; |
55 | } | 68 | } |
56 | }; | 69 | }; |
57 | }]); | 70 | }]); |
58 | 71 |