Commit 5100750a0d3efff21c17f37a9fddece1a11793fd
Exists in
master
Merge branch 'develop' into 'master'
Develop See merge request !59
Showing
6 changed files
Show diff stats
src/js/businessService.js
1 | angular.module('focaCrearHojaRuta') | 1 | angular.module('focaCrearHojaRuta') |
2 | .factory('hojaRutaBusinessService', [ | 2 | .factory('hojaRutaBusinessService', [ |
3 | 'crearHojaRutaService', | 3 | 'focaCrearHojaRutaService', |
4 | function(crearHojaRutaService) { | 4 | function(crearHojaRutaService) { |
5 | return { | 5 | return { |
6 | addArticulos: function(articulosHojaRuta, idHojaRuta, cotizacion) { | 6 | addArticulos: function(articulosHojaRuta, idRemito, cotizacion) { |
7 | for(var i = 0; i < articulosHojaRuta.length; i++) { | 7 | for(var i = 0; i < articulosHojaRuta.length; i++) { |
8 | delete articulosHojaRuta[i].editCantidad; | 8 | delete articulosHojaRuta[i].editCantidad; |
9 | delete articulosHojaRuta[i].editPrecio; | 9 | delete articulosHojaRuta[i].editPrecio; |
10 | articulosHojaRuta[i].idHojaRuta = idHojaRuta; | 10 | delete articulosHojaRuta[i].sectorCodigo; |
11 | articulosHojaRuta[i].idRemito = idRemito; | ||
11 | articulosHojaRuta[i].precio = articulosHojaRuta[i].precio * cotizacion; | 12 | articulosHojaRuta[i].precio = articulosHojaRuta[i].precio * cotizacion; |
12 | crearHojaRutaService.crearArticulosParaHojaRuta(articulosHojaRuta[i]); | 13 | crearHojaRutaService.crearArticulosParaHojaRuta(articulosHojaRuta[i]); |
13 | } | 14 | } |
14 | }, | 15 | }, |
15 | addEstado: function(idHojaRuta, idVendedor) { | 16 | addEstado: function(idHojaRuta, idVendedor) { |
16 | var date = new Date(); | 17 | var date = new Date(); |
17 | var estado = { | 18 | var estado = { |
18 | idHojaRuta: idHojaRuta, | 19 | idHojaRuta: idHojaRuta, |
19 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 20 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
20 | .toISOString().slice(0, 19).replace('T', ' '), | 21 | .toISOString().slice(0, 19).replace('T', ' '), |
21 | estado: 0, | 22 | estado: 0, |
22 | idVendedor: idVendedor | 23 | idVendedor: idVendedor |
23 | }; | 24 | }; |
24 | crearHojaRutaService.crearEstadoParaHojaRuta(estado); | 25 | crearHojaRutaService.crearEstadoParaHojaRuta(estado); |
25 | } | 26 | }, |
26 | }; | 27 | }; |
27 | }]); | 28 | }]); |
28 | 29 |
src/js/controller.js
1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 1 | angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
2 | [ | 2 | [ |
3 | '$scope', | 3 | '$scope', |
4 | '$uibModal', | 4 | '$uibModal', |
5 | '$location', | 5 | '$location', |
6 | '$filter', | 6 | '$filter', |
7 | '$timeout', | 7 | '$timeout', |
8 | 'focaCrearHojaRutaService', | 8 | 'focaCrearHojaRutaService', |
9 | 'focaModalService', | 9 | 'focaModalService', |
10 | 'focaBotoneraLateralService', | 10 | 'focaBotoneraLateralService', |
11 | 'focaLoginService', | 11 | 'focaLoginService', |
12 | '$localStorage', | 12 | '$localStorage', |
13 | function($scope, $uibModal, $location, $filter, $timeout, | 13 | 'hojaRutaBusinessService', |
14 | '$cookies', | ||
15 | function ($scope, $uibModal, $location, $filter, $timeout, | ||
14 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, | 16 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, |
15 | focaLoginSrv, $localStorage) | 17 | focaLoginSrv, $localStorage, hojaRutaBusinessService, $cookies) { |
16 | { | ||
17 | config(); | 18 | config(); |
18 | 19 | ||
19 | function config() { | 20 | function config() { |
20 | $scope.botonera = focaCrearHojaRutaService.getBotonera(); | 21 | |
22 | $scope.botoneraPrincipal = focaCrearHojaRutaService.getBotones(); | ||
23 | $scope.botonera = []; | ||
21 | $scope.datepickerAbierto = false; | 24 | $scope.datepickerAbierto = false; |
22 | $scope.show = false; | 25 | $scope.show = false; |
26 | $scope.cisternaCargas = []; | ||
23 | $scope.cargando = true; | 27 | $scope.cargando = true; |
28 | $scope.articulos = []; | ||
29 | $scope.remito = { | ||
30 | id: '', | ||
31 | numeroRemito: '' | ||
32 | }; | ||
24 | $scope.now = new Date(); | 33 | $scope.now = new Date(); |
25 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 34 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
26 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 35 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
27 | 36 | ||
28 | //SETEO BOTONERA LATERAL | 37 | //SETEO BOTONERA LATERAL |
29 | $timeout(function() { | 38 | $timeout(function () { |
30 | focaBotoneraLateralService.showSalir(false); | 39 | focaBotoneraLateralService.showSalir(false); |
31 | focaBotoneraLateralService.showPausar(true); | 40 | focaBotoneraLateralService.showPausar(true); |
32 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); | 41 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); |
33 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 42 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
34 | }); | 43 | }); |
35 | 44 | ||
36 | focaCrearHojaRutaService.getParametros().then(function(res) { | 45 | focaCrearHojaRutaService.getParametros().then(function (res) { |
37 | 46 | ||
38 | var parametros = JSON.parse(res.data[0].jsonText); | 47 | var parametros = JSON.parse(res.data[0].jsonText); |
39 | 48 | ||
40 | if ($localStorage.hojaRuta) { | 49 | if ($localStorage.hojaRuta) { |
41 | $timeout(function() {getLSHojaRuta();}); | 50 | $timeout(function () { getLSHojaRuta(); }); |
42 | } else { | 51 | } else { |
43 | 52 | for (var property in parametros) { | |
44 | for(var property in parametros) { | ||
45 | $scope.hojaRuta[property] = parametros[property]; | 53 | $scope.hojaRuta[property] = parametros[property]; |
46 | $scope.inicial[property] = parametros[property]; | 54 | $scope.inicial[property] = parametros[property]; |
47 | } | 55 | } |
48 | 56 | //Setear Hoja de Ruta | |
49 | setearHojaRuta($scope.hojaRuta); | 57 | //setearHojaRuta($scope.hojaRuta); |
50 | } | 58 | } |
51 | }); | 59 | }); |
52 | init(); | 60 | init(); |
53 | } | 61 | } |
54 | |||
55 | function init() { | 62 | function init() { |
56 | $scope.$broadcast('cleanCabecera'); | 63 | $scope.$broadcast('cleanCabecera'); |
57 | 64 | ||
58 | $scope.hojaRuta = { | 65 | $scope.hojaRuta = { |
59 | fecha: new Date(), | 66 | fecha: new Date(), |
60 | litros: 0, | 67 | litros: 0, |
61 | chofer: {}, | 68 | chofer: {}, |
62 | vehiculo: { | 69 | vehiculo: { |
63 | capacidad: 0 | 70 | capacidad: 0 |
64 | }, | 71 | }, |
65 | transportista: {}, | 72 | transportista: {}, |
66 | remitosTabla: [] | 73 | remitosTabla: [] |
67 | }; | 74 | }; |
68 | $scope.idLista = undefined; | 75 | $scope.idLista = undefined; |
69 | 76 | ||
70 | focaCrearHojaRutaService.getNumeroHojaRuta().then( | 77 | focaCrearHojaRutaService.getNumeroHojaRuta().then( |
71 | function(res) { | 78 | function (res) { |
72 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); | 79 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); |
73 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); | 80 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); |
74 | }, | 81 | }, |
75 | function(err) { | 82 | function (err) { |
76 | focaModalService.alert('La terminal no esta configurada correctamente'); | 83 | focaModalService.alert('La terminal no esta configurada correctamente'); |
77 | console.info(err); | 84 | console.info(err); |
78 | } | 85 | } |
79 | ); | 86 | ); |
80 | setearFecha(new Date()); | 87 | setearFecha(new Date()); |
81 | $scope.inicial = angular.copy($scope.hojaRuta); | 88 | $scope.inicial = angular.copy($scope.hojaRuta); |
82 | } | 89 | } |
83 | 90 | ||
84 | $scope.$watch('hojaRuta', function(newValue) { | 91 | // $scope.$watch('hojaRuta', function(newValue) { |
85 | 92 | ||
86 | // Seteo checked en remitos | 93 | // // Seteo checked en remitos |
87 | if ($scope.hojaRuta.remitosTabla.length) { | 94 | // if ($scope.hojaRuta.remitosTabla.length) { |
95 | // $filter('filter')($scope.botonera, { | ||
96 | // label: 'Remitos', | ||
97 | // })[0].checked = true; | ||
98 | // } else { | ||
99 | // $filter('filter')($scope.botonera, { | ||
100 | // label: 'Remitos', | ||
101 | // })[0].checked = false; | ||
102 | // } | ||
103 | |||
104 | // focaBotoneraLateralService.setPausarData({ | ||
105 | // label: 'hojaRuta', | ||
106 | // val: newValue | ||
107 | // }); | ||
108 | // }, true); | ||
109 | |||
110 | $scope.seleccionarRemitoAbierto = function () { | ||
111 | $scope.remitoAbierto = true; | ||
112 | $scope.cargaRemito = false; | ||
113 | $scope.precargado = false; | ||
114 | |||
115 | var isBotoneraDirty = $scope.botonera.find(function (boton) { | ||
116 | return boton.checked; | ||
117 | }); | ||
88 | 118 | ||
89 | $filter('filter')($scope.botonera, { | 119 | config(); |
90 | label: 'Remitos', | 120 | |
121 | if (isBotoneraDirty) { | ||
122 | $scope.$broadcast('cleanCabecera'); | ||
123 | focaModalService.confirm('Se perderan los cambios') | ||
124 | .then(function () { | ||
125 | limpiarBotonera($scope.botonera); | ||
126 | limpiarBotonera($scope.botoneraPrincipal); | ||
127 | $filter('filter')($scope.botoneraPrincipal, { | ||
128 | label: 'Remito Abierto', | ||
129 | })[0].checked = true; | ||
130 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
131 | |||
132 | }); | ||
133 | } else { | ||
134 | $scope.$broadcast('cleanCabecera'); | ||
135 | limpiarBotonera($scope.botoneraPrincipal); | ||
136 | $filter('filter')($scope.botoneraPrincipal, { | ||
137 | label: 'Remito Abierto', | ||
91 | })[0].checked = true; | 138 | })[0].checked = true; |
139 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
140 | |||
141 | } | ||
142 | |||
143 | $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto(); | ||
144 | }; | ||
145 | |||
146 | $scope.seleccionarCargarRemitos = function () { | ||
147 | $scope.cargaRemito = true; | ||
148 | $scope.remitoAbierto = false; | ||
149 | $scope.precargado = false; | ||
150 | |||
151 | var isBotoneraDirty = $scope.botonera.find(function (boton) { | ||
152 | return boton.checked; | ||
153 | }); | ||
154 | |||
155 | config(); | ||
156 | |||
157 | if (isBotoneraDirty) { | ||
158 | $scope.$broadcast('cleanCabecera'); | ||
159 | focaModalService.confirm('Se perderan los cambios') | ||
160 | .then(function () { | ||
161 | limpiarBotonera($scope.botonera); | ||
162 | limpiarBotonera($scope.botoneraPrincipal); | ||
163 | $scope.preCargados = false; | ||
164 | $filter('filter')($scope.botoneraPrincipal, { | ||
165 | label: 'Cargar Remitos', | ||
166 | })[0].checked = true; | ||
167 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
168 | }); | ||
92 | } else { | 169 | } else { |
93 | $filter('filter')($scope.botonera, { | 170 | $scope.$broadcast('cleanCabecera'); |
94 | label: 'Remitos', | 171 | limpiarBotonera($scope.botoneraPrincipal); |
95 | })[0].checked = false; | 172 | $filter('filter')($scope.botoneraPrincipal, { |
173 | label: 'Cargar Remitos', | ||
174 | })[0].checked = true; | ||
175 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
96 | } | 176 | } |
177 | $scope.precargado = false; | ||
178 | }; | ||
97 | 179 | ||
98 | focaBotoneraLateralService.setPausarData({ | 180 | $scope.seleccionarPrecargados = function () { |
99 | label: 'hojaRuta', | 181 | $scope.precargado = true; |
100 | val: newValue | 182 | $scope.cargaRemito = false; |
183 | $scope.remitoAbierto = false; | ||
184 | var isBotoneraDirty = $scope.botonera.find(function (boton) { | ||
185 | return boton.checked; | ||
101 | }); | 186 | }); |
102 | }, true); | ||
103 | 187 | ||
104 | $scope.crearHojaRuta = function() { | 188 | config(); |
105 | if (!$scope.hojaRuta.remitosTabla.length) { | 189 | |
106 | focaModalService.alert('Ingrese Remitos'); | 190 | if (isBotoneraDirty) { |
107 | return; | 191 | focaModalService.confirm('Se perderan los cambios') |
192 | .then(function () { | ||
193 | $scope.$broadcast('cleanCabecera'); | ||
194 | limpiarBotonera($scope.botonera); | ||
195 | limpiarBotonera($scope.botoneraPrincipal); | ||
196 | $filter('filter')($scope.botoneraPrincipal, { | ||
197 | label: 'Precargado', | ||
198 | })[0].checked = true; | ||
199 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
200 | }); | ||
201 | } else { | ||
202 | $scope.$broadcast('cleanCabecera'); | ||
203 | limpiarBotonera($scope.botoneraPrincipal); | ||
204 | $filter('filter')($scope.botoneraPrincipal, { | ||
205 | label: 'Precargado', | ||
206 | })[0].checked = true; | ||
207 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
108 | } | 208 | } |
109 | if (!$scope.hojaRuta.chofer.id) { | 209 | }; |
110 | focaModalService.alert('Ingrese Chofer'); | 210 | |
111 | return; | 211 | $scope.quitarArticulo = function (key ,articulo) { |
212 | $scope.articulos.splice(key, 1); | ||
213 | }; | ||
214 | |||
215 | function validarHojaRuta() { | ||
216 | if ($scope.precargado) { | ||
217 | if (!$scope.hojaRuta.chofer.id) { | ||
218 | focaModalService.alert('Ingrese Chofer'); | ||
219 | return false; | ||
220 | } | ||
221 | if (!$scope.hojaRuta.vehiculo.id) { | ||
222 | focaModalService.alert('Ingrese Vehiculo'); | ||
223 | return false; | ||
224 | } | ||
225 | if (!$scope.hojaRuta.transportista.COD) { | ||
226 | focaModalService.alert('Ingrese Transportista'); | ||
227 | return false; | ||
228 | } | ||
229 | if (!$scope.hojaRuta.datosExtra) { | ||
230 | focaModalService.alert('Ingrese Datos extra'); | ||
231 | return false; | ||
232 | } | ||
233 | } else if ($scope.cargaRemito) { | ||
234 | if (!$scope.hojaRuta.remitosTabla.length) { | ||
235 | focaModalService.alert('Ingrese Remitos'); | ||
236 | return false; | ||
237 | } else if (!$scope.hojaRuta.chofer.id) { | ||
238 | focaModalService.alert('Ingrese Chofer'); | ||
239 | return false; | ||
240 | } | ||
241 | if (!$scope.hojaRuta.vehiculo.id) { | ||
242 | focaModalService.alert('Ingrese Vehiculo'); | ||
243 | return false; | ||
244 | } | ||
245 | if (!$scope.hojaRuta.transportista.COD) { | ||
246 | focaModalService.alert('Ingrese Transportista'); | ||
247 | return false; | ||
248 | } | ||
249 | if (!$scope.hojaRuta.datosExtra) { | ||
250 | focaModalService.alert('Ingrese Datos extra'); | ||
251 | return false; | ||
252 | } | ||
253 | } else if ($scope.remitoAbierto) { | ||
254 | if (!$scope.hojaRuta.transportista.COD) { | ||
255 | focaModalService.alert('Ingrese Transportista'); | ||
256 | return false; | ||
257 | } else if (!$scope.hojaRuta.vehiculo.id) { | ||
258 | focaModalService.alert('Ingrese Vehiculo'); | ||
259 | return false; | ||
260 | } else if (!$scope.hojaRuta.chofer.id) { | ||
261 | focaModalService.alert('Ingrese Chofer'); | ||
262 | return false; | ||
263 | } else if (!$scope.hojaRuta.proveedor.COD) { | ||
264 | focaModalService.alert('Ingrese Proveedor'); | ||
265 | return false; | ||
266 | } else if (!$scope.hojaRuta.cliente.COD) { | ||
267 | focaModalService.alert('Ingrese un Cliente'); | ||
268 | return; | ||
269 | } | ||
112 | } | 270 | } |
113 | if (!$scope.hojaRuta.vehiculo.id) { | 271 | return true; |
114 | focaModalService.alert('Ingrese Vehiculo'); | 272 | |
273 | } | ||
274 | |||
275 | function getImporte(propiedad) { | ||
276 | var importe = 0; | ||
277 | |||
278 | $scope.articulos.forEach(function (articulo) { | ||
279 | |||
280 | if (articulo[propiedad]) { | ||
281 | importe += articulo[propiedad] * articulo.cantidad; | ||
282 | } | ||
115 | return; | 283 | return; |
284 | |||
285 | }); | ||
286 | |||
287 | return importe; | ||
288 | } | ||
289 | |||
290 | function guardarRemitoAbierto() { | ||
291 | //guardar nuevo objeto (?) | ||
292 | var date = new Date(); | ||
293 | if ($scope.hojaRuta !== null) { | ||
294 | focaBotoneraLateralService.startGuardar(); | ||
295 | var save = { | ||
296 | remito: { | ||
297 | id: 0, | ||
298 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | ||
299 | idCliente: $scope.hojaRuta.cliente.COD, | ||
300 | nombreCliente: $scope.hojaRuta.cliente.NOM, | ||
301 | cuitCliente: $scope.hojaRuta.cliente.CUIT, | ||
302 | idVendedor: $cookies.get('vendedorCobrador'), | ||
303 | idProveedor: $scope.hojaRuta.proveedor.COD, | ||
304 | idDomicilio: $scope.hojaRuta.idDomicilio || $scope.hojaRuta.domicilio.id, | ||
305 | idCotizacion: $scope.hojaRuta.cotizacion.ID, | ||
306 | domicilioStamp: $scope.hojaRuta.domicilioStamp, | ||
307 | observaciones: $scope.hojaRuta.observaciones, | ||
308 | idListaPrecio: $scope.hojaRuta.cliente.MOD.trim(), | ||
309 | total: getImporte('total') || 0, | ||
310 | descuento: 0,//TODO, | ||
311 | importeNeto: getImporte('netoUnitario') || 0, //TODO: arreglar, | ||
312 | importeExento: getImporte('exentoUnitario'), | ||
313 | importeIva: getImporte('ivaUnitario') || 0, //TODO: arreglar | ||
314 | importeIvaServicios: 0,//TODO | ||
315 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), | ||
316 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), | ||
317 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), | ||
318 | percepcion: 0,//TODO | ||
319 | percepcionIva: 0,//TODO | ||
320 | redondeo: 0,//TODO | ||
321 | anulado: false, | ||
322 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), | ||
323 | lugar: parseInt($scope.puntoVenta), | ||
324 | cuentaMadre: 0,//TODO | ||
325 | cuentaContable: 0,//TODO | ||
326 | asiento: 0,//TODO | ||
327 | e_hd: '',//TODO | ||
328 | c_hd: '', | ||
329 | numeroLiquidoProducto: 0,//TODO | ||
330 | estado: 0, | ||
331 | destinoVenta: 0,//TODO | ||
332 | operacionTipo: 0, //TODO | ||
333 | }, | ||
334 | notaPedido: { | ||
335 | id: 0 | ||
336 | } | ||
337 | }; | ||
338 | focaCrearHojaRutaService.crearRemito(save).then( | ||
339 | function (data) { | ||
340 | focaBotoneraLateralService.endGuardar(true); | ||
341 | $scope.saveLoading = false; | ||
342 | |||
343 | $scope.remito.id = data.data.id; | ||
344 | |||
345 | focaCrearHojaRutaService.guardarCisternas({ | ||
346 | cisternaCargas: $scope.cisternaCargas, | ||
347 | cisternaMovimientos: $scope.cisternaMovimientos, | ||
348 | fechaReparto: $scope.hojaRuta.fechaReparto, | ||
349 | idVehiculo: $scope.hojaRuta.vehiculo.id | ||
350 | }, data.data.id); | ||
351 | $scope.remito.numeroRemito = data.data.numero; | ||
352 | |||
353 | // if ($scope.remito.remitoPuntoDescarga.length > 0) { | ||
354 | // remitoBusinessService.addPuntosDescarga(data.data.id, | ||
355 | // $scope.remito.remitoPuntoDescarga); | ||
356 | // } | ||
357 | |||
358 | hojaRutaBusinessService.addArticulos($scope.articulosRecibidos, | ||
359 | data.data.id, $scope.hojaRuta.cotizacion.VENDEDOR); | ||
360 | |||
361 | guardarHojaRuta(data.data.id); | ||
362 | |||
363 | }, function (error) { | ||
364 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); | ||
365 | focaBotoneraLateralService.endGuardar(); | ||
366 | $scope.saveLoading = false; | ||
367 | console.info(error); | ||
368 | } | ||
369 | ); | ||
370 | |||
371 | function guardarHojaRuta(idRemito) { | ||
372 | |||
373 | var save2 = { | ||
374 | hojaRuta: { | ||
375 | id: 0, | ||
376 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | ||
377 | .replace('T', ' '), | ||
378 | idTransportista: $scope.hojaRuta.transportista.COD, | ||
379 | idChofer: $scope.hojaRuta.chofer.id, | ||
380 | idVehiculo: $scope.hojaRuta.vehiculo.id, | ||
381 | proveedor: $scope.hojaRuta.proveedor.id, | ||
382 | fechaReparto: | ||
383 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | ||
384 | estado: 0, | ||
385 | abierta: 1 | ||
386 | }, | ||
387 | remitos: [{id: idRemito}] | ||
388 | } | ||
389 | save2.hojaRuta = angular.extend({}, save2.hojaRuta, $scope.hojaRuta.datosExtra); | ||
390 | focaCrearHojaRutaService.crearHojaRuta(save2).then( | ||
391 | function (data) { | ||
392 | var remitoNumero; | ||
393 | data.data.remitos.forEach(function(idRemitos) { | ||
394 | remitoNumero = idRemitos; | ||
395 | }); | ||
396 | focaModalService.alert( | ||
397 | 'Hoja ruta creada Nยบ: ' + | ||
398 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | ||
399 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) + | ||
400 | '\nRemito Abierto Nยบ: ' + | ||
401 | $filter('rellenarDigitos')(remitoNumero.sucursal, 4) + '-' + | ||
402 | $filter('rellenarDigitos')(remitoNumero.numeroRemito,8) | ||
403 | ); | ||
404 | |||
405 | config(); | ||
406 | }, | ||
407 | function (error) { | ||
408 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); | ||
409 | console.info(error); | ||
410 | } | ||
411 | ); | ||
412 | } | ||
116 | } | 413 | } |
117 | if (!$scope.hojaRuta.transportista.COD) { | 414 | } |
118 | focaModalService.alert('Ingrese Transportista'); | 415 | |
416 | $scope.seleccionarCliente = function () { | ||
417 | var modalInstance = $uibModal.open( | ||
418 | { | ||
419 | ariaLabelledBy: 'Busqueda de Cliente', | ||
420 | templateUrl: 'foca-busqueda-cliente-modal.html', | ||
421 | controller: 'focaBusquedaClienteModalController', | ||
422 | resolve: { | ||
423 | vendedor: function () { return null; }, | ||
424 | cobrador: function () { return null; } | ||
425 | }, | ||
426 | size: 'lg' | ||
427 | } | ||
428 | ); | ||
429 | modalInstance.result.then( | ||
430 | function (cliente) { | ||
431 | $scope.abrirModalDomicilios(cliente); | ||
432 | $scope.cliente = cliente; | ||
433 | }, function () { | ||
434 | } | ||
435 | ); | ||
436 | }; | ||
437 | |||
438 | $scope.abrirModalDomicilios = function (cliente) { | ||
439 | var modalInstanceDomicilio = $uibModal.open( | ||
440 | { | ||
441 | ariaLabelledBy: 'Busqueda de Domicilios', | ||
442 | templateUrl: 'modal-domicilio.html', | ||
443 | controller: 'focaModalDomicilioController', | ||
444 | size: 'lg', | ||
445 | resolve: { | ||
446 | idCliente: function () { return cliente.cod; }, | ||
447 | esNuevo: function () { return cliente.esNuevo; } | ||
448 | } | ||
449 | } | ||
450 | ); | ||
451 | modalInstanceDomicilio.result.then( | ||
452 | function (domicilio) { | ||
453 | $scope.hojaRuta.domicilio = domicilio; | ||
454 | $scope.hojaRuta.cliente = { | ||
455 | COD: cliente.cod, | ||
456 | CUIT: cliente.cuit, | ||
457 | NOM: cliente.nom, | ||
458 | MAIL: cliente.mail, | ||
459 | MOD: cliente.mod, | ||
460 | IVA: cliente.iva, | ||
461 | VEN: cliente.ven | ||
462 | }; | ||
463 | focaCrearHojaRutaService.getVendedorById($scope.hojaRuta.cliente.VEN) | ||
464 | .then(function (res) { | ||
465 | if (res.data !== '') { | ||
466 | $scope.hojaRuta.vendedor = res.data; | ||
467 | $scope.$broadcast('addCabecera', { | ||
468 | label: 'Vendedor:', | ||
469 | valor: $filter('rellenarDigitos')($scope.hojaRuta.vendedor | ||
470 | .NUM, 3) +' - ' + $scope.hojaRuta.vendedor.NOM | ||
471 | }); | ||
472 | } | ||
473 | var domicilioStamp = | ||
474 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | ||
475 | domicilio.Localidad + ', ' + domicilio.Provincia; | ||
476 | $scope.hojaRuta.domicilioStamp = domicilioStamp; | ||
477 | $scope.$broadcast('addCabecera', { | ||
478 | label: 'Cliente:', | ||
479 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + | ||
480 | ' - ' + cliente.nom | ||
481 | }); | ||
482 | $scope.$broadcast('addCabecera', { | ||
483 | label: 'Domicilio:', | ||
484 | valor: domicilioStamp | ||
485 | }); | ||
486 | |||
487 | if (domicilio.verPuntos) { | ||
488 | delete $scope.hojaRuta.domicilio.verPuntos; | ||
489 | $scope.seleccionarPuntosDeDescarga(); | ||
490 | } else { | ||
491 | focaCrearHojaRutaService | ||
492 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | ||
493 | .then(function (res) { | ||
494 | if (res.data.length) { | ||
495 | $scope.seleccionarPuntosDeDescarga(); | ||
496 | } | ||
497 | }); | ||
498 | } | ||
499 | |||
500 | $filter('filter')($scope.botonera, { | ||
501 | label: 'Cliente', | ||
502 | })[0].checked = true; | ||
503 | }) | ||
504 | .catch(function (e) { console.log(e); }); | ||
505 | }, function () { | ||
506 | $scope.seleccionarCliente(true); | ||
507 | return; | ||
508 | } | ||
509 | ); | ||
510 | }; | ||
511 | |||
512 | $scope.seleccionarPuntosDeDescarga = function () { | ||
513 | if (!$scope.hojaRuta.cliente.COD || !$scope.hojaRuta.domicilio.id) { | ||
514 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | ||
119 | return; | 515 | return; |
516 | } else { | ||
517 | var modalInstance = $uibModal.open( | ||
518 | { | ||
519 | ariaLabelledBy: 'Bรบsqueda de Puntos de descarga', | ||
520 | templateUrl: 'modal-punto-descarga.html', | ||
521 | controller: 'focaModalPuntoDescargaController', | ||
522 | size: 'lg', | ||
523 | resolve: { | ||
524 | filters: { | ||
525 | idDomicilio: $scope.remito.domicilio.id, | ||
526 | idCliente: $scope.remito.cliente.COD, | ||
527 | articulos: $scope.remito.articulosRemito, | ||
528 | puntosDescarga: $scope.remito.remitoPuntoDescarga, | ||
529 | domicilio: $scope.remito.domicilio | ||
530 | } | ||
531 | } | ||
532 | } | ||
533 | ); | ||
534 | modalInstance.result.then( | ||
535 | function(puntosDescarga) { | ||
536 | |||
537 | puntosDescarga.forEach(function(punto) { | ||
538 | $scope.hojaRuta.remitoPuntoDescarga.push( | ||
539 | { | ||
540 | puntoDescarga: punto | ||
541 | } | ||
542 | ); | ||
543 | }); | ||
544 | |||
545 | $scope.$broadcast('addCabecera', { | ||
546 | label: 'Puntos de descarga:', | ||
547 | valor: getCabeceraPuntoDescarga(puntosDescarga) | ||
548 | }); | ||
549 | }, function () { | ||
550 | $scope.abrirModalDomicilios($scope.cliente); | ||
551 | } | ||
552 | ); | ||
120 | } | 553 | } |
121 | if (!$scope.hojaRuta.tarifario) { | 554 | }; |
122 | focaModalService.alert('Ingrese Tarifario'); | 555 | |
556 | $scope.seleccionarDetalleDeCarga = function () { | ||
557 | if ($scope.hojaRuta.vehiculo.capacidad === 0) { | ||
558 | focaModalService.alert('Debe ingresar vehiculo'); | ||
123 | return; | 559 | return; |
560 | } else { | ||
561 | $scope.mostrarDetalle($scope.hojaRuta); | ||
124 | } | 562 | } |
125 | if (!$scope.hojaRuta.datosExtra) { | 563 | }; |
126 | focaModalService.alert('Ingrese Datos extra'); | 564 | |
565 | function getCabeceraPuntoDescarga(puntosDescarga) { | ||
566 | var puntosStamp = ''; | ||
567 | puntosDescarga.forEach(function (punto, idx, arr) { | ||
568 | puntosStamp += punto.descripcion; | ||
569 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | ||
570 | }); | ||
571 | return puntosStamp; | ||
572 | } | ||
573 | |||
574 | $scope.crearHojaRuta = function () { | ||
575 | |||
576 | var continuar = validarHojaRuta(); | ||
577 | if (!continuar) { | ||
578 | return; | ||
579 | } else if ($scope.remitoAbierto) { | ||
580 | guardarRemitoAbierto(); | ||
127 | return; | 581 | return; |
128 | } | 582 | } |
129 | var date = new Date(); | 583 | var date = new Date(); |
130 | var save = { | 584 | var save = { |
131 | hojaRuta: { | 585 | hojaRuta: { |
132 | id: 0, | 586 | id: 0, |
133 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | 587 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) |
134 | .replace('T', ' '), | 588 | .replace('T', ' '), |
135 | idTransportista: $scope.hojaRuta.transportista.COD, | 589 | idTransportista: $scope.hojaRuta.transportista.COD, |
136 | idChofer: $scope.hojaRuta.chofer.id, | 590 | idChofer: $scope.hojaRuta.chofer.id, |
137 | idVehiculo: $scope.hojaRuta.vehiculo.id, | 591 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
138 | tarifaFlete: $scope.hojaRuta.tarifario, | 592 | tarifaFlete: $scope.hojaRuta.tarifario, |
139 | fechaReparto: | 593 | fechaReparto: |
140 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | 594 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), |
141 | estado: 0 | 595 | estado: 0 |
142 | }, | 596 | }, |
143 | remitos: $scope.hojaRuta.remitosTabla | 597 | remitos: $scope.hojaRuta.remitosTabla |
144 | }; | 598 | }; |
599 | |||
145 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); | 600 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); |
146 | focaCrearHojaRutaService.crearHojaRuta(save).then( | 601 | focaCrearHojaRutaService.crearHojaRuta(save).then( |
147 | function(data) { | 602 | function (data) { |
148 | focaModalService.alert( | 603 | focaModalService.alert( |
149 | 'Hoja ruta creada Nยบ: ' + | 604 | 'Hoja ruta creada Nยบ: ' + |
150 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | 605 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + |
151 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) | 606 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) |
152 | ); | 607 | ); |
153 | 608 | ||
154 | config(); | 609 | config(); |
155 | }, | 610 | }, |
156 | function(error) { | 611 | function (error) { |
157 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); | 612 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); |
158 | console.info(error); | 613 | console.info(error); |
159 | } | 614 | } |
160 | ); | 615 | ); |
161 | }; | 616 | }; |
162 | 617 | ||
163 | $scope.seleccionarTransportista = function() { | 618 | $scope.seleccionarProveedor = function () { |
619 | var parametrosModal = { | ||
620 | titulo: 'Bรบsqueda de Proveedor', | ||
621 | query: '/proveedor', | ||
622 | columnas: [ | ||
623 | { | ||
624 | nombre: 'Cรณdigo', | ||
625 | propiedad: 'COD', | ||
626 | filtro: { | ||
627 | nombre: 'rellenarDigitos', | ||
628 | parametro: 5 | ||
629 | } | ||
630 | }, | ||
631 | { | ||
632 | nombre: 'Nombre', | ||
633 | propiedad: 'NOM' | ||
634 | }, | ||
635 | { | ||
636 | nombre: 'CUIT', | ||
637 | propiedad: 'CUIT' | ||
638 | } | ||
639 | ], | ||
640 | tipo: 'POST', | ||
641 | json: { razonCuitCod: '' } | ||
642 | }; | ||
643 | focaModalService.modal(parametrosModal).then( | ||
644 | function (proveedor) { | ||
645 | $filter('filter')($scope.botonera, { | ||
646 | label: 'Proveedor', | ||
647 | })[0].checked = true; | ||
648 | |||
649 | $scope.$broadcast('addCabecera', { | ||
650 | label: 'Proveedor:', | ||
651 | valor: proveedor.COD + ' - ' + proveedor.NOM | ||
652 | }); | ||
653 | $scope.hojaRuta.proveedor = proveedor; | ||
654 | }, function () { } | ||
655 | ); | ||
656 | }; | ||
657 | |||
658 | $scope.seleccionarTransportista = function () { | ||
164 | if (eligioPreConfirmado()) return; | 659 | if (eligioPreConfirmado()) return; |
165 | var parametrosModal = { | 660 | var parametrosModal = { |
166 | titulo: 'Bรบsqueda de transportista', | 661 | titulo: 'Bรบsqueda de transportista', |
167 | query: '/transportista', | 662 | query: '/transportista', |
168 | columnas: [ | 663 | columnas: [ |
169 | { | 664 | { |
170 | nombre: 'Cรณdigo', | 665 | nombre: 'Cรณdigo', |
171 | propiedad: 'COD' | 666 | propiedad: 'COD' |
172 | }, | 667 | }, |
173 | { | 668 | { |
174 | nombre: 'Nombre', | 669 | nombre: 'Nombre', |
175 | propiedad: 'NOM' | 670 | propiedad: 'NOM' |
176 | }, | 671 | }, |
177 | { | 672 | { |
178 | nombre: 'CUIT', | 673 | nombre: 'CUIT', |
179 | propiedad: 'CUIT' | 674 | propiedad: 'CUIT' |
180 | } | 675 | } |
181 | ] | 676 | ] |
182 | }; | 677 | }; |
183 | focaModalService.modal(parametrosModal).then( | 678 | focaModalService.modal(parametrosModal).then( |
184 | function(proveedor) { | 679 | function (proveedor) { |
185 | $scope.hojaRuta.transportista = proveedor; | 680 | $scope.hojaRuta.transportista = proveedor; |
186 | $scope.$broadcast('addCabecera', { | 681 | $scope.$broadcast('addCabecera', { |
187 | label: 'Transportista:', | 682 | label: 'Transportista:', |
188 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 683 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
189 | proveedor.NOM | 684 | proveedor.NOM |
190 | }); | 685 | }); |
191 | 686 | ||
192 | $filter('filter')($scope.botonera, { | 687 | $filter('filter')($scope.botonera, { |
193 | label: 'Transportista', | 688 | label: 'Transportista', |
194 | })[0].checked = true; | 689 | })[0].checked = true; |
195 | }, function() { | 690 | }, function () { |
196 | 691 | ||
197 | } | 692 | } |
198 | ); | 693 | ); |
199 | }; | 694 | }; |
200 | 695 | ||
201 | $scope.seleccionarChofer = function() { | 696 | $scope.seleccionarChofer = function () { |
202 | var parametrosModal = { | 697 | var parametrosModal = { |
203 | titulo: 'Bรบsqueda de Chofer', | 698 | titulo: 'Bรบsqueda de Chofer', |
204 | query: '/chofer', | 699 | query: '/chofer', |
205 | columnas: [ | 700 | columnas: [ |
206 | { | 701 | { |
207 | propiedad: 'id', | 702 | propiedad: 'id', |
208 | nombre: 'Cรณdigo', | 703 | nombre: 'Cรณdigo', |
209 | filtro: { | 704 | filtro: { |
210 | nombre: 'rellenarDigitos', | 705 | nombre: 'rellenarDigitos', |
211 | parametro: 3 | 706 | parametro: 3 |
212 | } | 707 | } |
213 | }, | 708 | }, |
214 | { | 709 | { |
215 | propiedad: 'nombre', | 710 | propiedad: 'nombre', |
216 | nombre: 'Nombre' | 711 | nombre: 'Nombre' |
217 | }, | 712 | }, |
218 | { | 713 | { |
219 | propiedad: 'dni', | 714 | propiedad: 'dni', |
220 | nombre: 'DNI' | 715 | nombre: 'DNI' |
221 | }, | 716 | }, |
222 | { | 717 | { |
223 | propiedad: 'telefono', | 718 | propiedad: 'telefono', |
224 | nombre: 'Telรฉfono' | 719 | nombre: 'Telรฉfono' |
225 | } | 720 | } |
226 | ] | 721 | ] |
227 | }; | 722 | }; |
228 | focaModalService.modal(parametrosModal).then( | 723 | focaModalService.modal(parametrosModal).then( |
229 | function(chofer) { | 724 | function (chofer) { |
230 | $scope.hojaRuta.chofer = chofer; | 725 | $scope.hojaRuta.chofer = chofer; |
231 | $scope.$broadcast('addCabecera', { | 726 | $scope.$broadcast('addCabecera', { |
232 | label: 'Chofer:', | 727 | label: 'Chofer:', |
233 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre | 728 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre |
234 | }); | 729 | }); |
235 | 730 | ||
236 | $filter('filter')($scope.botonera, { | 731 | $filter('filter')($scope.botonera, { |
237 | label: 'Chofer', | 732 | label: 'Chofer', |
238 | })[0].checked = true; | 733 | })[0].checked = true; |
239 | }, function() { | 734 | }, function () { |
240 | // funcion ejecutada cuando se cancela el modal | 735 | // funcion ejecutada cuando se cancela el modal |
241 | } | 736 | } |
242 | ); | 737 | ); |
243 | }; | 738 | }; |
244 | 739 | ||
245 | $scope.seleccionarVehiculo = function() { | 740 | $scope.seleccionarVehiculo = function () { |
246 | if (!eligioFecha() || eligioPreConfirmado()) return; | 741 | if (!eligioFecha() || eligioPreConfirmado()) return; |
247 | modalVehiculos(); | 742 | modalVehiculos(); |
248 | }; | 743 | }; |
249 | 744 | ||
250 | $scope.seleccionarTarifario = function() { | 745 | $scope.seleccionarTarifario = function () { |
251 | focaModalService | 746 | focaModalService |
252 | .prompt({ | 747 | .prompt({ |
253 | titulo: 'Tarifa flete', | 748 | titulo: 'Tarifa flete', |
254 | value: $scope.hojaRuta.tarifario | 749 | value: $scope.hojaRuta.tarifario |
255 | }) | 750 | }) |
256 | .then(function(costo) { | 751 | .then(function (costo) { |
257 | if (isNaN(costo)) { | 752 | if (isNaN(costo)) { |
258 | focaModalService | 753 | focaModalService |
259 | .alert('Ingrese un valor vรกlido') | 754 | .alert('Ingrese un valor vรกlido') |
260 | .then(function() { | 755 | .then(function () { |
261 | $scope.seleccionarTarifario(); | 756 | $scope.seleccionarTarifario(); |
262 | }); | 757 | }); |
263 | 758 | ||
264 | return; | 759 | return; |
265 | } | 760 | } |
266 | 761 | ||
267 | $scope.hojaRuta.tarifario = costo; | 762 | $scope.hojaRuta.tarifario = costo; |
268 | $scope.$broadcast('addCabecera', { | 763 | $scope.$broadcast('addCabecera', { |
269 | label: 'Tarifario:', | 764 | label: 'Tarifario:', |
270 | valor: costo | 765 | valor: costo |
271 | }); | 766 | }); |
272 | 767 | ||
273 | $filter('filter')($scope.botonera, { | 768 | $filter('filter')($scope.botonera, { |
274 | label: 'Tarifario', | 769 | label: 'Tarifario', |
275 | })[0].checked = true; | 770 | })[0].checked = true; |
276 | }); | 771 | }); |
277 | }; | 772 | }; |
278 | 773 | ||
279 | $scope.seleccionarRemitos = function() { | 774 | $scope.seleccionarRemitos = function () { |
280 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; | 775 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; |
281 | var modalInstance = $uibModal.open( | 776 | var modalInstance = $uibModal.open( |
282 | { | 777 | { |
283 | ariaLabelledBy: 'Busqueda de Remito', | 778 | ariaLabelledBy: 'Busqueda de Remito', |
284 | templateUrl: 'foca-modal-remito.html', | 779 | templateUrl: 'foca-modal-remito.html', |
285 | controller: 'focaModalRemitoController', | 780 | controller: 'focaModalRemitoController', |
286 | size: 'lg', | 781 | size: 'lg', |
287 | resolve: {usadoPor: function() {return 'hojaRuta';}} | 782 | resolve: { usadoPor: function () { return 'hojaRuta'; } } |
288 | } | 783 | } |
289 | ); | 784 | ); |
290 | modalInstance.result.then( | 785 | modalInstance.result.then( |
291 | function(remito) { | 786 | function (remito) { |
292 | // TODO: borrar cuando no se use definitivamente | 787 | // TODO: borrar cuando no se use definitivamente |
293 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { | 788 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { |
294 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { | 789 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { |
295 | // focaModalService.alert('Remito ya incluido'); | 790 | // focaModalService.alert('Remito ya incluido'); |
296 | // return; | 791 | // return; |
297 | // } | 792 | // } |
298 | // } | 793 | // } |
299 | 794 | ||
300 | // var litros = 0; | 795 | // var litros = 0; |
301 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { | 796 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { |
302 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); | 797 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); |
303 | // } | 798 | // } |
304 | 799 | ||
305 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | 800 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { |
306 | // focaModalService.alert( | 801 | // focaModalService.alert( |
307 | // 'Debe ingresar toda la informaciรณn para el transporte' | 802 | // 'Debe ingresar toda la informaciรณn para el transporte' |
308 | // ); | 803 | // ); |
309 | // return; | 804 | // return; |
310 | // } | 805 | // } |
311 | 806 | ||
312 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | 807 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) |
313 | // { | 808 | // { |
314 | // var litrostotales = litros; | 809 | // var litrostotales = litros; |
315 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | 810 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; |
316 | // focaModalService.alert( | 811 | // focaModalService.alert( |
317 | // 'La carga excede la capacidad disponible del vehiculo. ' + | 812 | // 'La carga excede la capacidad disponible del vehiculo. ' + |
318 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | 813 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' |
319 | // ); | 814 | // ); |
320 | // } | 815 | // } |
321 | 816 | ||
322 | // remito.litros = litros; | 817 | // remito.litros = litros; |
323 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | 818 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
324 | $scope.cargarCisterna(remito.id).then(function() { | 819 | $scope.cargarCisterna(remito.id).then(function () { |
325 | $scope.hojaRuta.remitosTabla.push(remito); | 820 | $scope.hojaRuta.remitosTabla.push(remito); |
326 | }, function(error) { | 821 | $filter('filter')($scope.botonera, { |
327 | 822 | label: 'Remitos', | |
328 | if (error && error !== 'backdrop click') { | 823 | })[0].checked = true; |
329 | |||
330 | focaModalService | ||
331 | .alert(error || 'Ha ocurrido un error') | ||
332 | .then(function() { | ||
333 | $scope.seleccionarRemitos(); | ||
334 | }); | ||
335 | 824 | ||
336 | } else { | 825 | }, function (error) { |
337 | 826 | error.then($scope.seleccionarRemitos); | |
338 | $scope.seleccionarRemitos(); | ||
339 | |||
340 | } | ||
341 | }); | 827 | }); |
342 | }, function() { | 828 | }, function () { |
343 | // funcion ejecutada cuando se cancela el modal | 829 | // funcion ejecutada cuando se cancela el modal |
344 | } | 830 | } |
345 | ); | 831 | ); |
346 | }; | 832 | }; |
347 | 833 | ||
348 | $scope.seleccionarVehiculosPrecargados = function() { | 834 | $scope.seleccionarVehiculosPrecargados = function () { |
349 | if (!eligioFecha()) return; | 835 | if (!eligioFecha()) return; |
350 | modalVehiculos(true); | 836 | modalVehiculos(true); |
351 | }; | 837 | }; |
352 | 838 | ||
353 | $scope.cargarCisterna = function(idRemito) { | 839 | $scope.cargarCisterna = function (idRemito) { |
354 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; | 840 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; |
355 | var modalInstance = $uibModal.open( | 841 | var modalInstance = $uibModal.open( |
356 | { | 842 | { |
357 | ariaLabelledBy: 'Busqueda de Vehiculo', | 843 | ariaLabelledBy: 'Busqueda de Vehiculo', |
358 | templateUrl: 'foca-detalle-vehiculo.html', | 844 | templateUrl: 'foca-detalle-vehiculo.html', |
359 | controller: 'focaDetalleVehiculo', | 845 | controller: 'focaDetalleVehiculo', |
360 | size: 'lg', | 846 | size: 'lg', |
361 | resolve: { | 847 | resolve: { |
362 | idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, | 848 | idVehiculo: function () { return $scope.hojaRuta.vehiculo.id; }, |
363 | idRemito: function() {return idRemito;}, | 849 | idRemito: function () { return idRemito; }, |
364 | fechaReparto: function() {return $scope.hojaRuta.fechaReparto;} | 850 | fechaReparto: function () { return $scope.hojaRuta.fechaReparto; } |
365 | } | 851 | } |
366 | } | 852 | } |
367 | ); | 853 | ); |
368 | return modalInstance.result; | 854 | return modalInstance.result; |
369 | }; | 855 | }; |
370 | 856 | ||
371 | $scope.seleccionarFechaEntrega = function() { | 857 | $scope.seleccionarFechaEntrega = function () { |
858 | |||
372 | var confirmacion = false; | 859 | var confirmacion = false; |
373 | var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; | 860 | |
374 | var hasTarifario = $scope.hojaRuta.tarifario !== null; | 861 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { |
375 | var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; | ||
376 | var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; | ||
377 | var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; | ||
378 | |||
379 | if (hasVehiculoId || hasTarifario || hasTransportista || | ||
380 | hasChofer || hasDatosExtra) { | ||
381 | confirmacion = true; | 862 | confirmacion = true; |
382 | if (confirmacion) { | 863 | } |
383 | focaModalService | 864 | |
865 | if (confirmacion) { | ||
866 | focaModalService | ||
384 | .confirm('Si cambia la fecha se perderรกn los datos actuales') | 867 | .confirm('Si cambia la fecha se perderรกn los datos actuales') |
385 | .then(function(data) { | 868 | .then(function (data) { |
386 | if(data) { | 869 | if (data) { |
387 | $scope.hojaRuta.vehiculo.id = undefined; | 870 | $scope.hojaRuta.vehiculo.id = undefined; |
388 | $scope.hojaRuta.tarifario = null; | 871 | $scope.hojaRuta.tarifario = null; |
389 | $scope.hojaRuta.transportista = {}; | 872 | $scope.hojaRuta.transportista = {}; |
390 | $scope.hojaRuta.chofer = {}; | 873 | $scope.hojaRuta.chofer = {}; |
391 | $scope.hojaRuta.datosExtra = undefined; | 874 | $scope.hojaRuta.datosExtra = undefined; |
392 | elegirFecha(); | 875 | elegirFecha(); |
393 | } | 876 | } |
394 | }, function() { | 877 | }, function () { |
395 | return ; | 878 | return; |
396 | }); | 879 | }); |
397 | } | ||
398 | } else { | 880 | } else { |
399 | elegirFecha(); | 881 | elegirFecha(); |
400 | } | 882 | } |
401 | }; | 883 | }; |
402 | 884 | ||
403 | function setearFecha(fecha) { | 885 | function setearFecha(fecha) { |
404 | $timeout(function() { | 886 | $timeout(function () { |
405 | $scope.$broadcast('addCabecera', { | 887 | $scope.$broadcast('addCabecera', { |
406 | label: 'Fecha de entrega: ', | 888 | label: 'Fecha de entrega: ', |
407 | valor: fecha.toLocaleDateString() | 889 | valor: fecha.toLocaleDateString() |
408 | }); | 890 | }); |
409 | $scope.hojaRuta.fechaReparto = fecha; | 891 | $scope.hojaRuta.fechaReparto = fecha; |
410 | $scope.inicial.fechaReparto = fecha; | 892 | $scope.inicial.fechaReparto = fecha; |
411 | }); | 893 | }); |
412 | } | 894 | } |
413 | 895 | ||
414 | $scope.seleccionarDatosExtra = function() { | 896 | $scope.seleccionarDatosExtra = function () { |
415 | var datosHojaRuta = $scope.hojaRuta.datosExtra; | 897 | var datosHojaRuta = $scope.hojaRuta.datosExtra; |
416 | var modalInstance = $uibModal.open( | 898 | var modalInstance = $uibModal.open( |
417 | { | 899 | { |
418 | templateUrl: 'foca-modal-datos-hoja-ruta.html', | 900 | templateUrl: 'foca-modal-datos-hoja-ruta.html', |
419 | controller: 'focaModalDatosHojaRutaCtrl', | 901 | controller: 'focaModalDatosHojaRutaCtrl', |
420 | size: 'lg', | 902 | size: 'lg', |
421 | resolve: { | 903 | resolve: { |
422 | parametrosDatos: function() { | 904 | parametrosDatos: function () { |
423 | return { | 905 | return { |
424 | datosHojaRuta: datosHojaRuta | 906 | datosHojaRuta: datosHojaRuta |
425 | }; | 907 | }; |
426 | } | 908 | } |
427 | } | 909 | } |
428 | } | 910 | } |
429 | ); | 911 | ); |
430 | return modalInstance.result.then(function(datosExtra) { | 912 | return modalInstance.result.then(function (datosExtra) { |
431 | 913 | ||
432 | $filter('filter')($scope.botonera, { | 914 | $filter('filter')($scope.botonera, { |
433 | label: 'Datos extra', | 915 | label: 'Datos extra', |
434 | })[0].checked = true; | 916 | })[0].checked = true; |
435 | 917 | ||
436 | $scope.hojaRuta.datosExtra = datosExtra; | 918 | $scope.hojaRuta.datosExtra = datosExtra; |
437 | }, function() { | 919 | }, function () { |
438 | //se ejecuta cuando se cancela el modal | 920 | //se ejecuta cuando se cancela el modal |
439 | }); | 921 | }); |
440 | }; | 922 | }; |
441 | 923 | ||
442 | $scope.desasociarRemito = function(key, idRemito) { | 924 | $scope.desasociarRemito = function (key, idRemito) { |
443 | var idsRemito = [idRemito]; | 925 | var idsRemito = [idRemito]; |
444 | focaModalService.confirm('ยฟEstรก seguro que desea desasociar este remito del' + | 926 | focaModalService.confirm('ยฟEstรก seguro que desea desasociar este remito del' + |
445 | ' vehรญculo?').then(function() { | 927 | ' vehรญculo?').then(function () { |
446 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, | 928 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, |
447 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) | 929 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) |
448 | .then(function() { | 930 | .then(function () { |
449 | $scope.hojaRuta.remitosTabla.splice(key, 1); | 931 | $scope.hojaRuta.remitosTabla.splice(key, 1); |
450 | focaModalService.alert('Remito desasociado con รฉxito'); | 932 | focaModalService.alert('Remito desasociado con รฉxito'); |
451 | }); | 933 | }); |
452 | }); | 934 | }); |
453 | }; | 935 | }; |
454 | 936 | ||
455 | $scope.verProductosRemito = function(idRemito) { | 937 | $scope.verProductosRemito = function (idRemito) { |
456 | var parametrosModal = { | 938 | var parametrosModal = { |
457 | titulo: 'Articulos remito', | 939 | titulo: 'Articulos remito', |
458 | query: '/articulos/remito/' + idRemito, | 940 | query: '/articulos/remito/' + idRemito, |
459 | soloMostrar: true, | 941 | soloMostrar: true, |
460 | columnas: [ | 942 | columnas: [ |
461 | { | 943 | { |
462 | nombre: 'Cรณdigo', | 944 | nombre: 'Cรณdigo', |
463 | propiedad: 'codigo' | 945 | propiedad: 'codigo' |
464 | }, | 946 | }, |
465 | { | 947 | { |
466 | nombre: 'Descripciรณn', | 948 | nombre: 'Descripciรณn', |
467 | propiedad: 'descripcion' | 949 | propiedad: 'descripcion' |
468 | }, | 950 | }, |
469 | { | 951 | { |
470 | nombre: 'Cantidad', | 952 | nombre: 'Cantidad', |
471 | propiedad: 'cantidad' | 953 | propiedad: 'cantidad' |
472 | } | 954 | } |
473 | ] | 955 | ] |
474 | }; | 956 | }; |
475 | focaModalService.modal(parametrosModal).then(); | 957 | focaModalService.modal(parametrosModal).then(); |
476 | }; | 958 | }; |
477 | 959 | ||
960 | $scope.mostrarDetalle = function (hojasRutas) { | ||
961 | var modalInstance =$uibModal.open( | ||
962 | { | ||
963 | ariaLabelledBy: '', | ||
964 | templateUrl: 'modal-detalle-carga.html', | ||
965 | controller: 'focaModalDetalleController', | ||
966 | resolve: { | ||
967 | hojasRutas: function () { return hojasRutas; } | ||
968 | }, | ||
969 | size: 'lg', | ||
970 | backdrop: false | ||
971 | } | ||
972 | ); | ||
973 | return modalInstance.result.then(function (res) { | ||
974 | res.cisternas.forEach( function (cisterna) { | ||
975 | $scope.cisternaCargas.push(cisterna.cisternaCarga); | ||
976 | }); | ||
977 | $scope.cisternaMovimientos = res.movimientos; | ||
978 | $scope.articulosRecibidos = res.articulos; | ||
979 | $scope.articulos = res.articulos; | ||
980 | $filter('filter')($scope.botonera, { | ||
981 | label: 'Detalle de Carga', | ||
982 | })[0].checked = true; | ||
983 | }, function () { | ||
984 | //se ejecuta cuando se cancela el modal | ||
985 | }); | ||
986 | }; | ||
987 | |||
478 | function elegirFecha() { | 988 | function elegirFecha() { |
479 | var fechaEntrega = { | 989 | var fechaEntrega = { |
480 | titulo: 'Fecha de entrega', | 990 | titulo: 'Fecha de entrega', |
481 | minDate: new Date() | 991 | minDate: new Date() |
482 | }; | 992 | }; |
483 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { | 993 | focaModalService.modalFecha(fechaEntrega).then(function (fecha) { |
484 | 994 | ||
485 | $scope.hojaRuta.fechaReparto = fecha; | 995 | $scope.hojaRuta.fechaReparto = fecha; |
486 | 996 | ||
487 | $scope.$broadcast('addCabecera', { | 997 | $scope.$broadcast('addCabecera', { |
488 | label: 'Fecha de entrega: ', | 998 | label: 'Fecha de entrega: ', |
489 | valor: fecha.toLocaleDateString() | 999 | valor: fecha.toLocaleDateString() |
490 | }); | 1000 | }); |
1001 | //habilitar los otros botones | ||
1002 | var temp = []; | ||
1003 | if ($scope.botonera.length > 1) { | ||
1004 | limpiarBotonera($scope.botonera); | ||
1005 | } else if ($scope.precargado) { | ||
1006 | temp = focaCrearHojaRutaService.getBotoneraPrecargado(); | ||
1007 | modalVehiculos(true); | ||
1008 | } else if ($scope.cargaRemito && $scope.precargado === false) { | ||
1009 | temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); | ||
1010 | } else { | ||
1011 | temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); | ||
1012 | modalVehiculos(true); | ||
1013 | } | ||
1014 | temp.forEach(function (e) { | ||
1015 | $scope.botonera.push(e); | ||
1016 | }); | ||
491 | 1017 | ||
492 | $filter('filter')($scope.botonera, { | 1018 | $filter('filter')($scope.botonera, { |
493 | label: 'Fecha Entrega', | 1019 | label: 'Fecha Entrega', |
494 | })[0].checked = true; | 1020 | })[0].checked = true; |
495 | }); | 1021 | }); |
496 | } | 1022 | } |
497 | 1023 | ||
498 | function eligioPreConfirmado() { | 1024 | function eligioPreConfirmado() { |
499 | if ($scope.eligioPreConfirmado) { | 1025 | if ($scope.eligioPreConfirmado) { |
500 | focaModalService.alert('No puede elegir si eligiรณ un vehiculo pre cargado'); | 1026 | focaModalService.alert('No puede elegir si eligiรณ un vehiculo pre cargado'); |
501 | return true; | 1027 | return true; |
502 | } | 1028 | } |
503 | return false; | 1029 | return false; |
504 | } | 1030 | } |
505 | 1031 | ||
506 | function eligioFecha() { | 1032 | function eligioFecha() { |
507 | if (!$scope.hojaRuta.fechaReparto) { | 1033 | if (!$scope.hojaRuta.fechaReparto) { |
508 | focaModalService.alert('Primero seleccione fecha de reparto'); | 1034 | focaModalService.alert('Primero seleccione fecha de reparto'); |
509 | return false; | 1035 | return false; |
510 | } | 1036 | } |
511 | return true; | 1037 | return true; |
512 | } | 1038 | } |
513 | 1039 | ||
514 | function eligioVehiculo() { | 1040 | function eligioVehiculo() { |
515 | if (!$scope.hojaRuta.vehiculo.id) { | 1041 | if (!$scope.hojaRuta.vehiculo.id) { |
516 | focaModalService.alert('Primero seleccione vehiculo'); | 1042 | focaModalService.alert('Primero seleccione vehiculo'); |
517 | return false; | 1043 | return false; |
518 | } | 1044 | } |
519 | return true; | 1045 | return true; |
520 | } | 1046 | } |
521 | 1047 | ||
522 | function modalVehiculos(preCargados) { | 1048 | function modalVehiculos(preCargados) { |
523 | var parametrosModal = {}; | 1049 | var parametrosModal = {}; |
524 | if (preCargados) { | 1050 | if (preCargados) { |
525 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + | 1051 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + |
526 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); | 1052 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); |
527 | parametrosModal.titulo = 'Bรบsqueda de vehiculos pre confirmados'; | 1053 | parametrosModal.titulo = 'Bรบsqueda de vehiculos precargados'; |
528 | } else { | 1054 | } else { |
529 | parametrosModal.query = '/vehiculo'; | 1055 | parametrosModal.query = '/vehiculo'; |
530 | parametrosModal.titulo = 'Bรบsqueda de vehรญculos'; | 1056 | parametrosModal.titulo = 'Bรบsqueda de vehรญculos'; |
531 | } | 1057 | } |
532 | parametrosModal.columnas = [ | 1058 | parametrosModal.columnas = [ |
533 | { | 1059 | { |
534 | propiedad: 'codigo', | 1060 | propiedad: 'codigo', |
535 | nombre: 'Cรณdigo' | 1061 | nombre: 'Cรณdigo' |
536 | }, | 1062 | }, |
537 | { | 1063 | { |
538 | propiedad: 'tractor', | 1064 | propiedad: 'tractor', |
539 | nombre: 'tractor' | 1065 | nombre: 'tractor' |
540 | }, | 1066 | }, |
541 | { | 1067 | { |
542 | propiedad: 'semi', | 1068 | propiedad: 'semi', |
543 | nombre: 'Semi' | 1069 | nombre: 'Semi' |
544 | } | 1070 | } |
545 | ]; | 1071 | ]; |
546 | focaModalService.modal(parametrosModal).then(function(vehiculo) { | 1072 | focaModalService.modal(parametrosModal).then(function (vehiculo) { |
547 | if (!preCargados && vehiculoEnUso(vehiculo)) return; | 1073 | if (!preCargados && vehiculoEnUso(vehiculo)) return; |
548 | $scope.hojaRuta.vehiculo = vehiculo; | 1074 | $scope.hojaRuta.vehiculo = vehiculo; |
549 | $scope.hojaRuta.transportista = vehiculo.transportista; | 1075 | $scope.hojaRuta.transportista = vehiculo.transportista; |
1076 | // mostrarDetalle(vehiculo); | ||
550 | if (preCargados) { | 1077 | if (preCargados) { |
551 | $scope.eligioPreConfirmado = true; | 1078 | $scope.eligioPreConfirmado = true; |
552 | $scope.hojaRuta.vehiculo = vehiculo; | 1079 | $scope.hojaRuta.vehiculo = vehiculo; |
553 | $scope.$broadcast('addCabecera', { | 1080 | $scope.$broadcast('addCabecera', { |
554 | label: 'Transportista:', | 1081 | label: 'Transportista:', |
555 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + | 1082 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + |
556 | ' - ' + vehiculo.transportista.NOM | 1083 | ' - ' + vehiculo.transportista.NOM |
557 | }); | 1084 | }); |
558 | focaCrearHojaRutaService | 1085 | focaCrearHojaRutaService |
559 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) | 1086 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) |
560 | .then(function(res) { | 1087 | .then(function (res) { |
561 | |||
562 | $filter('filter')($scope.botonera, { | 1088 | $filter('filter')($scope.botonera, { |
563 | label: 'Vehiculos precargados', | 1089 | label: 'Transportista', |
1090 | })[0].checked = true; | ||
1091 | |||
1092 | $filter('filter')($scope.botonera, { | ||
1093 | label: 'Vehiculo', | ||
564 | })[0].checked = true; | 1094 | })[0].checked = true; |
565 | 1095 | ||
566 | $scope.hojaRuta.remitosTabla = res.data; | 1096 | $scope.hojaRuta.remitosTabla = res.data; |
567 | }); | 1097 | }); |
568 | } else { | 1098 | } else { |
569 | focaCrearHojaRutaService | 1099 | focaCrearHojaRutaService |
570 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) | 1100 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) |
571 | .then(function(res) { | 1101 | .then(function (res) { |
572 | 1102 | ||
573 | $filter('filter')($scope.botonera, { | 1103 | $filter('filter')($scope.botonera, { |
574 | label: 'Vehiculo', | 1104 | label: 'Vehiculo', |
575 | })[0].checked = true; | 1105 | })[0].checked = true; |
576 | 1106 | ||
577 | $scope.hojaRuta.remitosTabla = res.data; | 1107 | $scope.hojaRuta.remitosTabla = res.data; |
578 | }); | 1108 | }); |
579 | } | 1109 | } |
580 | $scope.$broadcast('addCabecera', { | 1110 | $scope.$broadcast('addCabecera', { |
581 | label: 'Tractor:', | 1111 | label: 'Tractor:', |
582 | valor: vehiculo.tractor | 1112 | valor: vehiculo.tractor |
583 | }); | 1113 | }); |
584 | $scope.$broadcast('addCabecera', { | 1114 | $scope.$broadcast('addCabecera', { |
585 | label: 'Semi:', | 1115 | label: 'Semi:', |
586 | valor: vehiculo.semi | 1116 | valor: vehiculo.semi |
587 | }); | 1117 | }); |
588 | $scope.$broadcast('addCabecera', { | 1118 | $scope.$broadcast('addCabecera', { |
589 | label: 'Capacidad:', | 1119 | label: 'Capacidad:', |
590 | valor: vehiculo.capacidad | 1120 | valor: vehiculo.capacidad |
591 | }); | 1121 | }); |
592 | 1122 | ||
593 | }); | 1123 | }); |
594 | } | 1124 | } |
595 | 1125 | ||
596 | function vehiculoEnUso(vehiculo) { | 1126 | function vehiculoEnUso(vehiculo) { |
597 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; | 1127 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; |
598 | for (var i = 0; i < vehiculo.cisternas.length; i++) { | 1128 | for (var i = 0; i < vehiculo.cisternas.length; i++) { |
599 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 1129 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
600 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 1130 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
601 | if (cisternaCarga.fechaReparto.substring(0, 10) === | 1131 | if (cisternaCarga.fechaReparto.substring(0, 10) === |
602 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && | 1132 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && |
603 | cisternaCarga.idUsuarioProceso && | 1133 | cisternaCarga.idUsuarioProceso && |
604 | cisternaCarga.idUsuarioProceso !== idUsuario) | 1134 | cisternaCarga.idUsuarioProceso !== idUsuario) { |
605 | { | ||
606 | focaModalService.alert('El vehรญculo estรก siendo usado por otro' + | 1135 | focaModalService.alert('El vehรญculo estรก siendo usado por otro' + |
607 | ' usuario'); | 1136 | ' usuario'); |
608 | return true; | 1137 | return true; |
609 | } | 1138 | } |
610 | } | 1139 | } |
611 | } | 1140 | } |
612 | return false; | 1141 | return false; |
613 | } | 1142 | } |
614 | 1143 | ||
615 | function salir() { | 1144 | function salir() { |
616 | var confirmacion = false; | 1145 | var confirmacion = false; |
617 | 1146 | ||
618 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { | 1147 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { |
619 | confirmacion = true; | 1148 | confirmacion = true; |
620 | } | 1149 | } |
621 | 1150 | ||
622 | if (confirmacion) { | 1151 | if (confirmacion) { |
623 | focaModalService.confirm( | 1152 | focaModalService.confirm( |
624 | 'ยฟEstรก seguro de que desea salir? Se perderรกn todos los datos cargados.' | 1153 | 'ยฟEstรก seguro de que desea salir? Se perderรกn todos los datos cargados.' |
625 | ).then(function(data) { | 1154 | ).then(function (data) { |
626 | if (data) { | 1155 | if (data) { |
627 | $location.path('/'); | 1156 | $location.path('/'); |
628 | } | 1157 | } |
629 | }); | 1158 | }); |
630 | } else { | 1159 | } else { |
631 | $location.path('/'); | 1160 | $location.path('/'); |
632 | } | 1161 | } |
633 | } | 1162 | } |
634 | 1163 | ||
1164 | function limpiarBotonera(botonera) { | ||
1165 | botonera.forEach(function (boton) { | ||
1166 | boton.checked = false; | ||
1167 | }); | ||
1168 | } | ||
635 | function setearHojaRuta(hojaRuta) { | 1169 | function setearHojaRuta(hojaRuta) { |
636 | $scope.$broadcast('cleanCabecera'); | 1170 | $scope.$broadcast('cleanCabecera'); |
637 | 1171 | ||
638 | var cabeceras = []; | 1172 | var cabeceras = []; |
639 | if (hojaRuta.fechaReparto) { | 1173 | if (hojaRuta.fechaReparto) { |
640 | cabeceras.push({ | 1174 | cabeceras.push({ |
641 | label: 'Fecha de entrega:', | 1175 | label: 'Fecha de entrega:', |
642 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') | 1176 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') |
643 | }); | 1177 | }); |
644 | 1178 | ||
645 | $filter('filter')( $scope.botonera, { | 1179 | $filter('filter')($scope.botonera, { |
646 | label: 'Fecha Entrega' | 1180 | label: 'Fecha Entrega' |
647 | })[0].checked = true; | 1181 | })[0].checked = true; |
648 | } | 1182 | } |
649 | if (hojaRuta.transportista.COD) { | 1183 | if (hojaRuta.transportista.COD) { |
650 | cabeceras.push({ | 1184 | cabeceras.push({ |
651 | label: 'Transportista:', | 1185 | label: 'Transportista:', |
652 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + | 1186 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + |
653 | hojaRuta.transportista.NOM | 1187 | hojaRuta.transportista.NOM |
654 | }); | 1188 | }); |
655 | 1189 | ||
656 | $filter('filter')( $scope.botonera, { | 1190 | $filter('filter')($scope.botonera, { |
657 | label: 'Transportista' | 1191 | label: 'Transportista' |
658 | })[0].checked = true; | 1192 | })[0].checked = true; |
659 | } | 1193 | } |
660 | if (hojaRuta.chofer.id) { | 1194 | if (hojaRuta.chofer.id) { |
661 | cabeceras.push({ | 1195 | cabeceras.push({ |
662 | label: 'Chofer:', | 1196 | label: 'Chofer:', |
663 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + | 1197 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + |
664 | ' - ' + hojaRuta.chofer.nombre | 1198 | ' - ' + hojaRuta.chofer.nombre |
665 | }); | 1199 | }); |
666 | 1200 | ||
667 | $filter('filter')( $scope.botonera, { | 1201 | $filter('filter')($scope.botonera, { |
668 | label: 'Chofer' | 1202 | label: 'Chofer' |
669 | })[0].checked = true; | 1203 | })[0].checked = true; |
670 | } | 1204 | } |
671 | if (hojaRuta.vehiculo.id) { | 1205 | if (hojaRuta.vehiculo.id) { |
672 | cabeceras.push({ | 1206 | cabeceras.push({ |
673 | label: 'Tractor:', | 1207 | label: 'Tractor:', |
674 | valor: hojaRuta.vehiculo.tractor | 1208 | valor: hojaRuta.vehiculo.tractor |
675 | }); | 1209 | }); |
676 | cabeceras.push({ | 1210 | cabeceras.push({ |
677 | label: 'Semi:', | 1211 | label: 'Semi:', |
678 | valor: hojaRuta.vehiculo.semi | 1212 | valor: hojaRuta.vehiculo.semi |
679 | }); | 1213 | }); |
680 | cabeceras.push({ | 1214 | cabeceras.push({ |
681 | label: 'Capacidad:', | 1215 | label: 'Capacidad:', |
682 | valor: hojaRuta.vehiculo.capacidad | 1216 | valor: hojaRuta.vehiculo.capacidad |
683 | }); | 1217 | }); |
684 | 1218 | ||
685 | $filter('filter')( $scope.botonera, { | 1219 | $filter('filter')($scope.botonera, { |
686 | label: 'Vehiculo' | 1220 | label: 'Vehiculo' |
687 | })[0].checked = true; | 1221 | })[0].checked = true; |
688 | } | 1222 | } |
689 | if (hojaRuta.tarifario) { | 1223 | if (hojaRuta.tarifario) { |
690 | cabeceras.push({ | 1224 | cabeceras.push({ |
691 | label: 'Tarifario:', | 1225 | label: 'Tarifario:', |
692 | valor: hojaRuta.tarifario | 1226 | valor: hojaRuta.tarifario |
693 | }); | 1227 | }); |
694 | 1228 | ||
695 | $filter('filter')( $scope.botonera, { | 1229 | $filter('filter')($scope.botonera, { |
696 | label: 'Tarifario' | 1230 | label: 'Tarifario' |
697 | })[0].checked = true; | 1231 | })[0].checked = true; |
698 | } | 1232 | } |
699 | 1233 |
src/js/controllerDetalles.js
File was created | 1 | angular.module('focaCrearHojaRuta') | |
2 | .controller('focaModalDetalleController', [ | ||
3 | '$scope', '$timeout', '$uibModalInstance', 'focaModalService', | ||
4 | 'focaCrearHojaRutaService', 'hojasRutas', '$uibModal', '$filter', | ||
5 | function ($scope, $timeout, $uibModalInstance, focaModalService, | ||
6 | focaCrearHojaRutaService, hojasRutas, $uibModal, $filter) { | ||
7 | |||
8 | $scope.mostrar = false; | ||
9 | $scope.articulos = []; | ||
10 | $scope.cisternaMovimientos = []; | ||
11 | |||
12 | init(); | ||
13 | function init() { | ||
14 | $scope.hojasRutas = hojasRutas; | ||
15 | |||
16 | $scope.hojasRutas.vehiculo.cisternas = $scope.hojasRutas.vehiculo.cisternas.filter( | ||
17 | function (cisterna) { | ||
18 | return !cisterna.desactivado; | ||
19 | } | ||
20 | ); | ||
21 | focaCrearHojaRutaService.getArticulos() | ||
22 | .then(function (articulos) { | ||
23 | $scope.articulos = articulos.data; | ||
24 | }); | ||
25 | } | ||
26 | |||
27 | $scope.validarCisternaDisponible = function (cisterna) { | ||
28 | if (parseInt(cisterna.disponible) > cisterna.capacidad) { | ||
29 | focaModalService.alert('No se puede ingresar una capacidad disponible ' + | ||
30 | 'superior a la ' + 'capacidad del vehiculo '); | ||
31 | cisterna.disponible = cisterna.capacidad; | ||
32 | return; | ||
33 | } | ||
34 | }; | ||
35 | |||
36 | $scope.seleccionarProductos = function (key, cisterna) { | ||
37 | focaModalService.modal({ | ||
38 | titulo: 'Productos', | ||
39 | data: $scope.articulos, | ||
40 | size: 'md', | ||
41 | columnas: [ | ||
42 | { | ||
43 | propiedad: 'CodRub', | ||
44 | nombre: 'Codigo' | ||
45 | }, | ||
46 | { | ||
47 | propiedad: 'descripcion', | ||
48 | nombre: 'Nombre' | ||
49 | }, | ||
50 | ], | ||
51 | }).then(function (res) { | ||
52 | cisterna.disponible = cisterna.capacidad; | ||
53 | var newArt = | ||
54 | { | ||
55 | id: 0, | ||
56 | idRemito: 0, | ||
57 | codigo: res.codigo, | ||
58 | sector: res.sector, | ||
59 | sectorCodigo: res.sector + '-' + res.codigo, | ||
60 | descripcion: res.descripcion, | ||
61 | item: key + 1, | ||
62 | nombre: res.descripcion, | ||
63 | precio: parseFloat(res.precio).toFixed(4), | ||
64 | costoUnitario: res.costo, | ||
65 | editCantidad: false, | ||
66 | editPrecio: false, | ||
67 | rubro: res.CodRub, | ||
68 | ivaUnitario: res.IMPIVA, | ||
69 | impuestoInternoUnitario: res.ImpInt, | ||
70 | impuestoInterno1Unitario: res.ImpInt2, | ||
71 | impuestoInterno2Unitario: res.ImpInt3, | ||
72 | precioLista: res.precio, | ||
73 | combustible: 1, | ||
74 | facturado: 0, | ||
75 | idArticulo: res.id, | ||
76 | tasaIva: res.tasaIVA | ||
77 | }; | ||
78 | |||
79 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : res.neto; | ||
80 | newArt.netoUnitario = newArt.ivaUnitario ? res.neto : 0; | ||
81 | |||
82 | cisterna.articuloSeleccionado = newArt; | ||
83 | cisterna.nombreArticulo = res.descripcion; | ||
84 | }).catch(function (e) { | ||
85 | console.log(e); | ||
86 | }); | ||
87 | }; | ||
88 | |||
89 | $scope.guardar = function () { | ||
90 | |||
91 | var cisternasFilter = validarArticulos(); | ||
92 | |||
93 | var articulos = []; | ||
94 | if (cisternasFilter === undefined) { | ||
95 | return; | ||
96 | } | ||
97 | cisternasFilter.forEach(function (cisterna) { | ||
98 | |||
99 | var fechaReparto = $scope.hojasRutas.fechaReparto; | ||
100 | |||
101 | var filtroCisternaCarga = cisterna.cisternasCarga.filter(function(carga) { | ||
102 | return carga.fechaReparto === fechaReparto; | ||
103 | }); | ||
104 | |||
105 | if (filtroCisternaCarga.length) { | ||
106 | cisterna.cisternaCarga = filtroCisternaCarga[0]; | ||
107 | } else { | ||
108 | cisterna.cisternaCarga = { | ||
109 | confirmado: null, | ||
110 | fechaReparto: fechaReparto, | ||
111 | idCisterna: cisterna.id, | ||
112 | }; | ||
113 | } | ||
114 | |||
115 | //cargar | ||
116 | if (cisterna.cisternaCarga.cantidad) { | ||
117 | cisterna.cisternaCarga.cantidad += cisterna.disponible; | ||
118 | } else { | ||
119 | cisterna.cisternaCarga.cantidad = cisterna.disponible; | ||
120 | cisterna.cisternaCarga.idProducto = | ||
121 | cisterna.articuloSeleccionado.idArticulo; | ||
122 | } | ||
123 | |||
124 | //Guardar | ||
125 | var now = new Date(); | ||
126 | var cisternaMovimiento = { | ||
127 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | ||
128 | cantidad: cisterna.disponible, | ||
129 | metodo: 'carga', | ||
130 | idCisternaCarga: cisterna.cisternaCarga.id, | ||
131 | }; | ||
132 | |||
133 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | ||
134 | cisterna.articuloSeleccionado.cantidad = cisterna.disponible; | ||
135 | articulos.push(cisterna.articuloSeleccionado); | ||
136 | $scope.cisternaMovimientos.push(cisternaMovimiento); | ||
137 | }); | ||
138 | |||
139 | $uibModalInstance.close({ | ||
140 | cisternas: cisternasFilter, | ||
141 | movimientos: $scope.cisternaMovimientos, | ||
142 | articulos: articulos | ||
143 | }); | ||
144 | }; | ||
145 | |||
146 | $scope.cancel = function () { | ||
147 | var validarCisternas = validarArticulos(); | ||
148 | if (validarCisternas !== undefined) { | ||
149 | $uibModalInstance.dismiss(null); | ||
150 | } | ||
151 | }; | ||
152 | |||
153 | function validarArticulos () { | ||
154 | var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas.filter(function (cisterna) { | ||
155 | return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado; | ||
156 | }); | ||
157 | |||
158 | var cisternasIncompletas = cisternasFilter.filter(function(cisterna) { | ||
159 | return (cisterna.articuloSeleccionado && !cisterna.disponible) || | ||
160 | (!cisterna.articuloSeleccionado && cisterna.disponible); | ||
161 | }); | ||
162 | |||
163 | if (cisternasIncompletas.length || !cisternasFilter.length) { | ||
164 | focaModalService.alert('Ingrese todos los campos para completar el remito'); | ||
165 | cisternasFilter = undefined; | ||
166 | } | ||
167 | return cisternasFilter; | ||
168 | } | ||
169 | } | ||
170 | ]); | ||
171 |
src/js/service.js
1 | angular.module('focaCrearHojaRuta') | 1 | angular.module('focaCrearHojaRuta') |
2 | .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', | 2 | .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', '$cookies', |
3 | function($http, API_ENDPOINT) { | 3 | function($http, API_ENDPOINT, $cookies) { |
4 | var route = API_ENDPOINT.URL; | 4 | var route = API_ENDPOINT.URL; |
5 | return { | 5 | return { |
6 | idUsuario: $cookies.get('vendedorCobrador'), | ||
6 | crearHojaRuta: function(hojaRuta) { | 7 | crearHojaRuta: function(hojaRuta) { |
7 | return $http.post(route + '/hoja-ruta', hojaRuta); | 8 | return $http.post(route + '/hoja-ruta', hojaRuta); |
8 | }, | 9 | }, |
10 | crearRemito: function(remito) { | ||
11 | console.log('Crear remito-----: ', remito); | ||
12 | // TODO: Cambiar para usar el servicio /remito | ||
13 | return $http.post(route + '/remito', remito); | ||
14 | }, | ||
9 | obtenerHojaRuta: function() { | 15 | obtenerHojaRuta: function() { |
10 | return $http.get(route +'/hoja-ruta'); | 16 | return $http.get(route +'/hoja-ruta'); |
11 | }, | 17 | }, |
12 | setHojaRuta: function(hojaRuta) { | 18 | setHojaRuta: function(hojaRuta) { |
13 | this.hojaRuta = hojaRuta; | 19 | this.hojaRuta = hojaRuta; |
14 | }, | 20 | }, |
15 | clearHojaRuta: function() { | 21 | clearHojaRuta: function() { |
16 | this.hojaRuta = undefined; | 22 | this.hojaRuta = undefined; |
17 | }, | 23 | }, |
18 | getHojaRuta: function() { | 24 | getHojaRuta: function() { |
19 | return this.hojaRuta; | 25 | return this.hojaRuta; |
20 | }, | 26 | }, |
21 | getArticulosByIdHojaRuta: function(id) { | 27 | getArticulosByIdHojaRuta: function(id) { |
22 | return $http.get(route+'/articulos/hoja-ruta/'+id); | 28 | return $http.get(route+'/articulos/hoja-ruta/'+id); |
23 | }, | 29 | }, |
24 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { | 30 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { |
25 | return $http.post(route + '/articulos/hoja-ruta', | 31 | return $http.post(route + '/articulos/remito', |
26 | {articuloHojaRuta: articuloHojaRuta}); | 32 | {articuloRemito: articuloHojaRuta}); |
27 | }, | 33 | }, |
28 | getDomiciliosByIdHojaRuta: function(id) { | 34 | getDomiciliosByIdHojaRuta: function(id) { |
29 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); | 35 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); |
30 | }, | 36 | }, |
31 | getDomiciliosByIdCliente: function(id) { | 37 | getDomiciliosByIdCliente: function(id) { |
32 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 38 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
33 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 39 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
34 | }, | 40 | }, |
35 | getPrecioCondicion: function() { | 41 | getPrecioCondicion: function() { |
36 | return $http.get(route + '/precio-condicion'); | 42 | return $http.get(route + '/precio-condicion'); |
37 | }, | 43 | }, |
38 | getPrecioCondicionById: function(id) { | 44 | getPrecioCondicionById: function(id) { |
39 | return $http.get(route + '/precio-condicion/' + id); | 45 | return $http.get(route + '/precio-condicion/' + id); |
40 | }, | 46 | }, |
41 | getPlazoPagoByPrecioCondicion: function(id) { | 47 | getPlazoPagoByPrecioCondicion: function(id) { |
42 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); | 48 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); |
43 | }, | 49 | }, |
44 | crearFlete: function(flete) { | 50 | crearFlete: function(flete) { |
45 | return $http.post(route + '/flete', {flete : flete}); | 51 | return $http.post(route + '/flete', {flete : flete}); |
46 | }, | 52 | }, |
47 | crearPlazosParaHojaRuta: function(plazos) { | 53 | crearPlazosParaHojaRuta: function(plazos) { |
48 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); | 54 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); |
49 | }, | 55 | }, |
50 | getCotizacionByIdMoneda: function(id) { | 56 | getCotizacionByIdMoneda: function(id) { |
51 | return $http.get(route + '/moneda/' + id); | 57 | return $http.get(route + '/moneda/' + id); |
52 | }, | 58 | }, |
53 | crearEstadoParaHojaRuta: function(estado) { | 59 | crearEstadoParaHojaRuta: function(estado) { |
54 | return $http.post(route + '/estado', {estado: estado}); | 60 | return $http.post(route + '/estado', {estado: estado}); |
55 | }, | 61 | }, |
56 | getNumeroHojaRuta: function() { | 62 | getNumeroHojaRuta: function() { |
57 | return $http.get(route + '/hoja-ruta/numero-siguiente'); | 63 | return $http.get(route + '/hoja-ruta/numero-siguiente'); |
58 | }, | 64 | }, |
59 | getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) { | 65 | getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) { |
60 | var noCofirmados = sinConfirmar ? '/sinConfirmar' : ''; | 66 | var noCofirmados = sinConfirmar ? '/sinConfirmar' : ''; |
61 | return $http.get(route + '/vehiculo/obtener/remitos/' + | 67 | return $http.get(route + '/vehiculo/obtener/remitos/' + |
62 | idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados); | 68 | idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados); |
63 | }, | 69 | }, |
64 | desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) { | 70 | desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) { |
65 | return $http.post(route + '/vehiculo/desasociar-remitos', | 71 | return $http.post(route + '/vehiculo/desasociar-remitos', |
66 | { | 72 | { |
67 | idsRemitos: idsRemitos, | 73 | idsRemitos: idsRemitos, |
68 | idVehiculo: idVehiculo, | 74 | idVehiculo: idVehiculo, |
69 | vehiculoSinRemitos: sinRemitos | 75 | vehiculoSinRemitos: sinRemitos |
70 | }); | 76 | }); |
71 | }, | 77 | }, |
72 | getParametros: function() { | 78 | getParametros: function() { |
73 | return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta'); | 79 | return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta'); |
74 | }, | 80 | }, |
75 | getBotonera: function() { | 81 | getBotonera: function() { |
76 | return [ | 82 | return [ |
77 | { | 83 | { |
78 | label: 'Fecha Entrega', | 84 | label: 'Fecha Entrega', |
79 | image: 'FechaEntrega.png' | 85 | image: 'FechaEntrega.png' |
80 | }, | 86 | }, |
81 | { | 87 | { |
82 | label: 'Transportista', | 88 | label: 'Transportista', |
83 | image: 'transportista.png' | 89 | image: 'transportista.png' |
84 | }, | 90 | }, |
85 | { | 91 | { |
86 | label: 'Chofer', | 92 | label: 'Chofer', |
87 | image: 'chofer.png' | 93 | image: 'chofer.png' |
88 | }, | 94 | }, |
89 | { | 95 | { |
90 | label: 'Vehiculo', | 96 | label: 'Vehiculo', |
91 | image: 'vehiculos.png' | 97 | image: 'vehiculos.png' |
92 | }, | 98 | }, |
93 | { | 99 | { |
94 | label: 'Tarifario', | 100 | label: 'Tarifario', |
95 | image: 'tarifario.png' | 101 | image: 'tarifario.png' |
96 | }, | 102 | }, |
97 | { | 103 | { |
98 | label: 'Remitos', | 104 | label: 'Remitos', |
99 | image: 'remito.png' | 105 | image: 'remito.png' |
100 | }, | 106 | }, |
101 | { | 107 | { |
102 | label: 'Vehiculos precargados', | 108 | label: 'Vehiculos precargados', |
103 | image: 'vehiculos.png' | 109 | image: 'vehiculos.png' |
104 | }, | 110 | }, |
105 | { | 111 | { |
106 | label: 'Datos extra', | 112 | label: 'Datos extra', |
107 | image: 'tarifario.png' | 113 | image: 'tarifario.png' |
108 | } | 114 | } |
109 | ]; | 115 | ]; |
116 | }, | ||
117 | getBotones: function () { | ||
118 | return [ | ||
119 | { | ||
120 | label: 'Precargados', | ||
121 | image: 'vehiculos.png' | ||
122 | }, | ||
123 | { | ||
124 | label: 'Cargar Remitos', | ||
125 | image: 'remito.png' | ||
126 | }, | ||
127 | { | ||
128 | label: 'Remito Abierto', | ||
129 | image: 'remitoabierto.png' | ||
130 | } | ||
131 | ]; | ||
132 | }, | ||
133 | getRemitoAbierto: function () { | ||
134 | return [ | ||
135 | { | ||
136 | label: 'Fecha Entrega', | ||
137 | image: 'FechaEntrega.png' | ||
138 | }, | ||
139 | { | ||
140 | label: 'Transportista', | ||
141 | image: 'transportista.png' | ||
142 | }, | ||
143 | { | ||
144 | label: 'Vehiculo', | ||
145 | image: 'vehiculos.png' | ||
146 | }, | ||
147 | { | ||
148 | label: 'Chofer', | ||
149 | image: 'chofer.png' | ||
150 | }, | ||
151 | { | ||
152 | label: 'Proveedor', | ||
153 | image: 'proveedor.png' | ||
154 | }, | ||
155 | { | ||
156 | label: 'Tarifario', | ||
157 | image: 'tarifario.png' | ||
158 | }, | ||
159 | { | ||
160 | label: 'Cliente', | ||
161 | image: 'cliente.png' | ||
162 | }, | ||
163 | { | ||
164 | label: 'Detalle de Carga', | ||
165 | image: 'detalleDeCarga.png' | ||
166 | } | ||
167 | ]; | ||
168 | }, | ||
169 | getArticulos : function () { | ||
170 | return $http.get(API_ENDPOINT.URL + '/articulos'); | ||
171 | }, | ||
172 | getVendedorById : function (idVendedor) { | ||
173 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + idVendedor); | ||
174 | }, | ||
175 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | ||
176 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | ||
177 | idDomicilio + '/' + idCliente); | ||
178 | }, | ||
179 | getBotonFecha : function () { | ||
180 | return [ | ||
181 | { | ||
182 | label: 'Fecha Entrega', | ||
183 | image: 'FechaEntrega.png' | ||
184 | }, | ||
185 | ]; | ||
186 | }, | ||
187 | getBotoneraPrecargado: function () { | ||
188 | return [ | ||
189 | |||
190 | { | ||
191 | label: 'Transportista', | ||
192 | image: 'transportista.png' | ||
193 | }, | ||
194 | { | ||
195 | label: 'Chofer', | ||
196 | image: 'chofer.png' | ||
197 | }, | ||
198 | { | ||
199 | label: 'Vehiculo', | ||
200 | image: 'vehiculos.png' | ||
201 | }, | ||
202 | { | ||
203 | label: 'Tarifario', | ||
204 | image: 'tarifario.png' | ||
205 | }, | ||
206 | { | ||
207 | label: 'Datos extra', | ||
208 | image: 'tarifario.png' | ||
209 | } | ||
210 | ]; | ||
211 | }, | ||
212 | getBotoneraCargarRemito: function () { | ||
213 | return [ | ||
214 | { | ||
215 | label: 'Transportista', | ||
216 | image: 'transportista.png' | ||
217 | }, | ||
218 | { | ||
219 | label: 'Chofer', | ||
220 | image: 'chofer.png' | ||
221 | }, | ||
222 | { | ||
223 | label: 'Vehiculo', | ||
224 | image: 'flete.png' | ||
225 | }, | ||
226 | { | ||
227 | label: 'Remitos', | ||
228 | image: 'remito.png' | ||
229 | }, | ||
230 | { | ||
231 | label: 'Tarifario', | ||
232 | image: 'tarifario.png' | ||
233 | }, | ||
234 | { | ||
235 | label: 'Datos extra', | ||
236 | image: 'tarifario.png' | ||
237 | } | ||
238 | ]; | ||
239 | }, | ||
240 | guardarCisternas: function(cisterna, idRemito) { | ||
241 | |||
242 | cisterna.cisternaMovimientos.forEach(function(cisternaMovimiento) { | ||
243 | cisternaMovimiento.idRemito = idRemito; | ||
244 | }); | ||
245 | |||
246 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | ||
247 | this.idUsuario + '/' + idRemito, cisterna); | ||
248 | }, | ||
249 | crearArticulosParaRemito: function(articuloRemito) { | ||
250 | return $http.post(route + '/articulos/remito', | ||
251 | {articuloRemito: articuloRemito}); | ||
110 | } | 252 | } |
111 | }; | 253 | }; |
112 | }]); | 254 | }]); |
113 | 255 |
src/views/hoja-ruta.html
1 | <div class="crear-hoja-ruta foca-crear row"> | 1 | <div class="crear-hoja-ruta foca-crear row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Hoja de ruta'" | 3 | titulo="'Hoja de ruta'" |
4 | numero="puntoVenta + '-' + comprobante" | 4 | numero="puntoVenta + '-' + comprobante" |
5 | fecha="now" | 5 | fecha="now" |
6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
7 | ></foca-cabecera-facturador> | 7 | ></foca-cabecera-facturador> |
8 | <div class="col-lg-12"> | 8 | <div class="col-lg-12"> |
9 | <div class="row mt-4"> | 9 | <div class="row mt-4"> |
10 | <div class="col-12 col-md-10 border border-light rounded"> | 10 | <div class="col-12 col-md-10 border border-light rounded"> |
11 | <div class="row px-5 py-2 botonera-secundaria"> | 11 | <div class="row px-5 py-2 botonera-secundaria"> |
12 | <div class="col-12"> | 12 | <div class="col"> |
13 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> | 13 | <foca-botonera-facturador botones="botoneraPrincipal" max="botoneraPrincipal.length" class="row"></foca-botonera-facturador> |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
16 | <!-- PC --> | 16 | </div> |
17 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 17 | </div> |
18 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 18 | <div class="row mt-2"> |
19 | <thead> | 19 | <div class="col-12 col-md-10 border border-light rounded"> |
20 | <tr class="d-flex"> | 20 | <div class="row px-5 py-2 botonera-secundaria"> |
21 | <th class="col-auto">#</th> | 21 | <div class="col"> |
22 | <th class="col-2">Remito</th> | 22 | <foca-botonera-facturador botones="botonera" max="botonera.length" class="row"></foca-botonera-facturador> |
23 | <th class="col">Cliente</th> | 23 | </div> |
24 | <th class="col">Direcciรณn</th> | 24 | </div> |
25 | <th class="col-auto"></th> | 25 | <div class="row"> |
26 | <th class="col-auto"> | 26 | <div class="col"> |
27 | <button | 27 | <!-- PC --> |
28 | class="btn btn-outline-light selectable" | 28 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
29 | ng-click="show = !show; masMenos()" | 29 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
30 | > | 30 | <thead> |
31 | <i | 31 | <tr class="d-flex"> |
32 | class="fa fa-chevron-down" | 32 | <th class="">#</th> |
33 | ng-show="show" | 33 | <th class="col">Cรณdigo</th> |
34 | aria-hidden="true" | 34 | <th class="col-4">Descripciรณn</th> |
35 | > | 35 | <th class="col text-right">Cantidad</th> |
36 | </i> | 36 | <th class="col text-right">Precio Unitario</th> |
37 | <i | 37 | <th class="col text-right">SubTotal</th> |
38 | class="fa fa-chevron-up" | 38 | <th class="text-right"> |
39 | ng-hide="show" | 39 | <button |
40 | aria-hidden="true"> | 40 | class="btn btn-outline-light selectable" |
41 | </i> | 41 | ng-click="show = !show; masMenos()" |
42 | </button> | 42 | > |
43 | </th> | 43 | <i |
44 | </tr> | 44 | class="fa fa-chevron-down" |
45 | </thead> | 45 | ng-show="show" |
46 | <tbody class="tabla-articulo-body"> | 46 | aria-hidden="true" |
47 | <tr | 47 | > |
48 | ng-repeat="(key, remito) in hojaRuta.remitosTabla" | 48 | </i> |
49 | class="d-flex" | 49 | <i |
50 | ng-show="show || key == hojaRuta.remitosTabla.length - 1" | 50 | class="fa fa-chevron-up" |
51 | > | 51 | ng-hide="show" |
52 | <td ng-bind="key + 1" class="col-auto"></td> | 52 | aria-hidden="true"> |
53 | <td | 53 | </i> |
54 | class="col-2" | 54 | </button> |
55 | >{{remito.sucursal | rellenarDigitos: 4}}-{{remito.numeroRemito | rellenarDigitos: 8}}</td> | 55 | </th> |
56 | <th class="col" ng-bind="remito.nombreCliente"></th> | 56 | </tr> |
57 | <th class="col" ng-bind="remito.domicilioStamp"></th> | 57 | </thead> |
58 | <td class="text-center col-auto"> | 58 | <tbody class="tabla-articulo-body"> |
59 | <button | 59 | <tr |
60 | class="btn btn-outline-light" | 60 | ng-repeat="(key, articulo) in articulos" |
61 | ng-click="verProductosRemito(remito.id)" | 61 | ng-show="show || key == (articulos.length - 1)" |
62 | title="Ver productos" | 62 | class="d-flex" |
63 | > | ||
64 | <i class="fa fa-eye"></i> | ||
65 | </button> | ||
66 | </td> | ||
67 | <td class="text-center col-auto"> | ||
68 | <button | ||
69 | class="btn btn-outline-light" | ||
70 | ng-click="desasociarRemito(key, remito.id)" | ||
71 | title="Eliminar" | ||
72 | > | 63 | > |
73 | <i class="fa fa-trash"></i> | 64 | <td ng-bind="key + 1"></td> |
74 | </button> | 65 | <td |
75 | </td> | 66 | class="col" |
76 | </tr> | 67 | ng-bind="articulo.sector + '-' + articulo.codigo" |
77 | </tbody> | 68 | ></td> |
78 | <tfoot> | 69 | <td |
79 | <tr class="d-flex"> | 70 | class="col-4" |
80 | <td class="col-auto px-1"> | 71 | ng-bind="articulo.descripcion" |
81 | <strong>Remitos:</strong> | 72 | ></td> |
82 | <a ng-bind="hojaRuta.remitosTabla.length"></a> | 73 | <td class="col text-right"> |
83 | </td> | 74 | <input |
84 | <td class="col"></td> | 75 | ng-show="articulo.editCantidad" |
85 | <td class="col-auto px-1"> | 76 | ng-model="tmpCantidad" |
86 | <strong>Cantidad:</strong> | 77 | class="form-control" |
87 | <a ng-bind="hojaRuta.litros"></a> | 78 | foca-tipo-input |
88 | </td> | 79 | min="1" |
89 | </tr> | 80 | foca-focus="articulo.editCantidad" |
90 | </tfoot> | 81 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
91 | </table> | 82 | esc-key="cancelarEditar(articulo)" |
83 | ng-focus="selectFocus($event); | ||
84 | tmpCantidad = articulo.cantidad; | ||
85 | tmpPrecio = 0" | ||
86 | teclado-virtual | ||
87 | > | ||
88 | <i | ||
89 | class="selectable" | ||
90 | ng-click="cambioEdit(articulo, 'cantidad')" | ||
91 | ng-hide="articulo.editCantidad" | ||
92 | ng-bind="articulo.cantidad"> | ||
93 | </i> | ||
94 | </td> | ||
95 | <td class="col text-right"> | ||
96 | <i | ||
97 | class="selectable" | ||
98 | ng-bind="0 | number: 4"> | ||
99 | </i> | ||
100 | </td> | ||
101 | <td | ||
102 | class="col text-right" | ||
103 | ng-bind="0 | number: 2"> | ||
104 | </td> | ||
105 | <td class="text-center"> | ||
106 | <button | ||
107 | class="btn btn-outline-light" | ||
108 | ng-click="quitarArticulo(key, articulo)" | ||
109 | > | ||
110 | <i class="fa fa-trash"></i> | ||
111 | </button> | ||
112 | </td> | ||
113 | </tr> | ||
114 | </tbody> | ||
115 | <tfoot> | ||
116 | <tr ng-show="!cargando" class="d-flex"> | ||
117 | <td | ||
118 | class="align-middle" | ||
119 | ng-bind="articulosFiltro.length + 1" | ||
120 | ></td> | ||
121 | <td class="col"> | ||
122 | <input | ||
123 | class="form-control" | ||
124 | ng-model="articuloACargar.sectorCodigo" | ||
125 | readonly | ||
126 | > | ||
127 | </td> | ||
128 | <td class="col-4 tabla-articulo-descripcion"> | ||
129 | <input | ||
130 | class="form-control" | ||
131 | ng-model="articuloACargar.descripcion" | ||
132 | readonly | ||
133 | > | ||
134 | </td> | ||
135 | <td class="col text-right"> | ||
136 | <input | ||
137 | class="form-control" | ||
138 | foca-tipo-input | ||
139 | min="1" | ||
140 | ng-model="articuloACargar.cantidad" | ||
141 | foca-focus="!cargando" | ||
142 | esc-key="resetFilter()" | ||
143 | ng-keypress="agregarATabla($event.keyCode)" | ||
144 | teclado-virtual | ||
145 | > | ||
146 | </td> | ||
147 | <td class="col text-right"> | ||
148 | <input | ||
149 | class="form-control" | ||
150 | ng-model="articuloACargar.precio" | ||
151 | ng-show="idLista != -1" | ||
152 | ng-keypress="agregarATabla($event.keyCode)" | ||
153 | > | ||
154 | <input | ||
155 | class="form-control" | ||
156 | foca-tipo-input | ||
157 | step="0.0001" | ||
158 | ng-model="articuloACargar.precio" | ||
159 | esc-key="resetFilter()" | ||
160 | ng-keypress="agregarATabla($event.keyCode)" | ||
161 | ng-show="idLista == -1" | ||
162 | teclado-virtual | ||
163 | > | ||
164 | </td> | ||
165 | <td class="col text-right"> | ||
166 | <input | ||
167 | class="form-control" | ||
168 | ng-value="getSubTotal() | number: 2" | ||
169 | readonly | ||
170 | > | ||
171 | </td> | ||
172 | </tr> | ||
173 | |||
174 | <tr class="d-flex"> | ||
175 | <td colspan="4" class="no-border-top"> | ||
176 | <strong>Items:</strong> | ||
177 | <a ng-bind="articulos.length"></a> | ||
178 | </td> | ||
179 | <td class="text-right ml-auto table-celda-total no-border-top"> | ||
180 | <h3>Total:</h3> | ||
181 | </td> | ||
182 | <td class="table-celda-total text-right no-border-top" colspan="1"> | ||
183 | <h3>{{getTotal() | currency: hojaRuta.cotizacion.moneda.SIMBOLO}}</h3> | ||
184 | </td> | ||
185 | <td class="text-right no-border-top"> | ||
186 | <button | ||
187 | type="button" | ||
188 | class="btn btn-sm" | ||
189 | > | ||
190 | Totales | ||
191 | </button> | ||
192 | </td> | ||
193 | </tr> | ||
194 | </tfoot> |
src/views/modal-detalle-carga.html
File was created | 1 | <div class="modal-header py-1"> | |
2 | <div class="row w-100"> | ||
3 | <div class="col-lg-6"> | ||
4 | <h5 class="modal-title my-1">Detalle de Carga</h5> | ||
5 | </div> | ||
6 | </div> | ||
7 | </div> | ||
8 | <div class="row"> | ||
9 | <div class="col ml-3 mt-2"> | ||
10 | <span class=" text-left"> | ||
11 | Transportista <b>{{hojasRutas.idTransportista}} {{hojasRutas.transportista.NOM}}</b> | ||
12 | Unidad <b>{{hojasRutas.vehiculo.codigo}}</b> Tractor <b>{{hojasRutas.vehiculo.tractor}}</b> | ||
13 | </span> | ||
14 | |||
15 | </div> | ||
16 | </div> | ||
17 | <div class="row"> | ||
18 | <div class="col ml-3"> | ||
19 | <span class=" text-left">Fecha <b>{{hojasRutas.fecha | date:'yyyy-MM-dd':'-0300'}}</b></span> | ||
20 | </div> | ||
21 | </div> | ||
22 | <div class="modal-body" id="modal-body"> | ||
23 | <table class="table table-hover table-sm table-striped"> | ||
24 | <thead> | ||
25 | <tr> | ||
26 | <th>Cisterna</th> | ||
27 | <th>Capacidad</th> | ||
28 | <th>Disponibles</th> | ||
29 | <th>Articulo Cargado</th> | ||
30 | </tr> | ||
31 | </thead> | ||
32 | <tbody> | ||
33 | <tr | ||
34 | ng-repeat="(key, cisterna) in hojasRutas.vehiculo.cisternas" | ||
35 | > | ||
36 | <td ng-bind="cisterna.id"></td> | ||
37 | <td ng-bind="cisterna.capacidad"></td> | ||
38 | <td class="w-50"> | ||
39 | <input | ||
40 | ng-focus="$event.target.select();" | ||
41 | ng-model="cisterna.disponible" | ||
42 | ng-keyup="validarCisternaDisponible(cisterna)" | ||
43 | class="form-control" | ||
44 | solo-positivos | ||
45 | foca-tipo-input | ||
46 | /> | ||
47 | </td> | ||
48 | <td class="w-25"> | ||
49 | <div class="input-group "> | ||
50 | <input | ||
51 | ng-model="cisterna.nombreArticulo" | ||
52 | class="form-control" | ||
53 | ng-click="seleccionarProductos(key, cisterna)" | ||
54 | readonly | ||
55 | /> | ||
56 | <div class="input-group-append"> | ||
57 | <button | ||
58 | ladda="searchLoading" | ||
59 | class="btn btn-outline-secondary form-control" | ||
60 | type="button" | ||
61 | ng-click="seleccionarProductos(key, cisterna)" | ||
62 | > | ||
63 | <i class="fa fa-search" aria-hidden="true"></i> | ||
64 | </button> | ||
65 | </div> | ||
66 | </div> | ||
67 | </td> | ||
68 | </tr> | ||
69 | </tbody> | ||
70 | </table> | ||
71 | </div> | ||
72 | <div class="modal-footer py-1"> | ||
73 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
74 | <button class="btn btn-sm btn-primary" type="button" ng-click="guardar()">Guardar</button> | ||
75 | </div> | ||
76 | </div> |