Commit 8c18bb142a9dc8ef6c81d2cbcd8d2219bf09f671

Authored by Eric Fernandez

Merge branch 'develop' into 'master'

Develop

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