Commit 9b31d344c5d541d397679374b3fa511dda49382a

Authored by Jose Pinto
1 parent 99532cb1a9
Exists in master and in 1 other branch develop

Auto stash before merge of "master" and "upstream/master"

Showing 2 changed files with 187 additions and 172 deletions   Show diff stats
src/js/controller.js
... ... @@ -13,11 +13,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
13 13 'focaSeguimientoService',
14 14 'APP',
15 15 'focaLoginService',
  16 + '$localStorage',
16 17 function(
17 18 $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService,
18 19 focaBotoneraLateralService, focaModalService, notaPedidoBusinessService,
19   - $rootScope, focaSeguimientoService, APP, focaLoginService)
20   - {
  20 + $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage)
  21 + {
21 22 config();
22 23  
23 24 function config() {
... ... @@ -26,7 +27,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
26 27 $scope.datepickerAbierto = false;
27 28 $scope.show = false;
28 29 $scope.cargando = true;
29   - $scope.now = new Date();
30 30 $scope.puntoVenta = $filter('rellenarDigitos')(0, 4);
31 31 $scope.comprobante = $filter('rellenarDigitos')(0, 8);
32 32 $scope.dateOptions = {
... ... @@ -49,14 +49,21 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
49 49 } else {
50 50 $scope.botonera = crearNotaPedidoService.getBotonera();
51 51 }
52   -
  52 +
53 53 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
  54 + var monedaPorDefecto;
54 55 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
55   - $scope.monedaDefecto = res.data[0];
56   - $scope.cotizacionDefecto = $scope.monedaDefecto.cotizaciones[0];
  56 + monedaPorDefecto = res.data[0];
57 57  
58   - init();
  58 + $scope.notaPedido.cotizacion = Object.assign(
  59 + {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0]
  60 + );
  61 + $scope.inicial.cotizacion = $scope.notaPedido.cotizacion;
59 62 });
  63 +
  64 + init();
  65 + $timeout(function() {getLSNotaPedido();});
  66 +
60 67 }
61 68  
62 69 function init() {
... ... @@ -68,11 +75,11 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
68 75 proveedor: {},
69 76 domicilio: {dom: ''},
70 77 vendedor: {},
71   - moneda: $scope.monedaDefecto,
72   - cotizacion: $scope.cotizacionDefecto
  78 + fechaCarga: new Date(),
  79 + cotizacion: {}
73 80 };
74   -
75   - $scope.articulosTabla = [];
  81 +
  82 + $scope.notaPedido.articulosNotaPedido = [];
76 83 $scope.idLista = undefined;
77 84  
78 85 crearNotaPedidoService.getNumeroNotaPedido().then(
... ... @@ -107,13 +114,16 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
107 114 );
108 115 }
109 116  
110   - $scope.inicial = {
111   - notaPedido: angular.copy($scope.notaPedido),
112   - articulosTabla: angular.copy($scope.articulosTabla),
113   - idLista: angular.copy($scope.idLista)
114   - };
  117 + $scope.inicial = angular.copy($scope.notaPedido);
115 118 }
116 119  
  120 + $scope.$watch('notaPedido', function(newValue, oldValue) {
  121 + focaBotoneraLateralService.setPausarData({
  122 + label: 'notaPedido',
  123 + val: newValue
  124 + });
  125 + }, true);
  126 +
117 127 $scope.crearNotaPedido = function() {
118 128 if(!$scope.notaPedido.vendedor.id) {
119 129 focaModalService.alert('Ingrese Vendedor');
... ... @@ -124,13 +134,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
124 134 } else if(!$scope.notaPedido.proveedor.COD) {
125 135 focaModalService.alert('Ingrese Proveedor');
126 136 return;
127   - } else if(!$scope.notaPedido.moneda.ID) {
  137 + } else if(!$scope.notaPedido.cotizacion.moneda.ID) {
128 138 focaModalService.alert('Ingrese Moneda');
129 139 return;
130 140 } else if(!$scope.notaPedido.cotizacion.ID) {
131 141 focaModalService.alert('Ingrese Cotización');
132 142 return;
133   - } else if(!$scope.plazosPagos) {
  143 + } else if(!$scope.notaPedido.notaPedidoPlazo) {
134 144 focaModalService.alert('Ingrese Precios y Condiciones');
135 145 return;
136 146 } else if(
... ... @@ -141,7 +151,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
141 151 } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto
142 152 focaModalService.alert('Ingrese Domicilio');
143 153 return;
144   - } else if($scope.articulosTabla.length === 0) {
  154 + } else if($scope.notaPedido.articulosNotaPedido.length === 0) {
145 155 focaModalService.alert('Debe cargar al menos un articulo');
146 156 return;
147 157 }
... ... @@ -149,13 +159,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
149 159 $scope.saveLoading = true;
150 160 var notaPedido = {
151 161 id: $scope.notaPedido.id,
152   - fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
  162 + fechaCarga: new Date($scope.notaPedido.fechaCarga).toISOString().slice(0, 19).replace('T', ' '),
153 163 idVendedor: $scope.notaPedido.vendedor.id,
154 164 idCliente: $scope.notaPedido.cliente.COD,
155 165 nombreCliente: $scope.notaPedido.cliente.NOM,
156 166 cuitCliente: $scope.notaPedido.cliente.CUIT,
157 167 idProveedor: $scope.notaPedido.proveedor.COD,
158   - idDomicilio: $scope.notaPedido.domicilio.id,
  168 + idDomicilio: $scope.notaPedido.idDomicilio || $scope.notaPedido.domicilio.id,
159 169 idCotizacion: $scope.notaPedido.cotizacion.ID,
160 170 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion,
161 171 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
... ... @@ -178,15 +188,15 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
178 188 data.data.id,
179 189 ''
180 190 );
181   - notaPedidoBusinessService.addArticulos($scope.articulosTabla,
  191 + notaPedidoBusinessService.addArticulos($scope.notaPedido.articulosNotaPedido,
182 192 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
183 193  
184   - if($scope.notaPedido.puntosDescarga) {
  194 + if($scope.notaPedido.notaPedidoPuntoDescarga) {
185 195 notaPedidoBusinessService.addPuntosDescarga(data.data.id,
186   - $scope.notaPedido.puntosDescarga);
  196 + $scope.notaPedido.notaPedidoPuntoDescarga);
187 197 }
188 198  
189   - var plazos = $scope.plazosPagos;
  199 + var plazos = $scope.notaPedido.notaPedidoPlazo;
190 200 var plazosACrear = [];
191 201 plazos.forEach(function(plazo) {
192 202 plazosACrear.push({
... ... @@ -233,111 +243,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
233 243 }
234 244 }
235 245 );
236   - modalInstance.result.then(
237   - function(notaPedido) {
238   - $scope.now = new Date(notaPedido.fechaCarga);
239   - //añado cabeceras
240   - $scope.notaPedido.id = notaPedido.id;
241   - $scope.$broadcast('removeCabecera', 'Bomba:');
242   - $scope.$broadcast('removeCabecera', 'Kilometros:');
243   - var cabeceras = [
244   - {
245   - label: 'Moneda:',
246   - valor: notaPedido.cotizacion.moneda.DETALLE
247   - },
248   - {
249   - label: 'Fecha cotizacion:',
250   - valor: $filter('date')(notaPedido.cotizacion.FECHA,
251   - 'dd/MM/yyyy')
252   - },
253   - {
254   - label: 'Cotizacion:',
255   - valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
256   - '2')
257   - },
258   - {
259   - label: 'Cliente:',
260   - valor: notaPedido.cliente.NOM
261   - },
262   - {
263   - label: 'Domicilio:',
264   - valor: notaPedido.domicilioStamp
265   - },
266   - {
267   - label: 'Vendedor:',
268   - valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) +
269   - ' - ' + notaPedido.vendedor.NOM
270   - },
271   - {
272   - label: 'Proveedor:',
273   - valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) +
274   - ' - ' + notaPedido.proveedor.NOM
275   - },
276   - {
277   - label: 'Precios y condiciones:',
278   - valor: valorPrecioCondicion() + ' ' +
279   - notaPedidoBusinessService
280   - .plazoToString(notaPedido.notaPedidoPlazo)
281   - },
282   - {
283   - label: 'Flete:',
284   - valor: notaPedido.fob === 1 ? 'FOB' : (
285   - notaPedido.flete === 1 ? 'Si' : 'No')
286   - }
287   - ];
288   -
289   - function valorPrecioCondicion() {
290   - if(notaPedido.idPrecioCondicion > 0) {
291   - return notaPedido.precioCondicion.nombre;
292   - } else {
293   - return 'Ingreso Manual';
294   - }
295   - }
296   -
297   - if(notaPedido.flete === 1) {
298   - var cabeceraBomba = {
299   - label: 'Bomba:',
300   - valor: notaPedido.bomba === 1 ? 'Si' : 'No'
301   - };
302   - if(notaPedido.kilometros) {
303   - var cabeceraKilometros = {
304   - label: 'Kilometros:',
305   - valor: notaPedido.kilometros
306   - };
307   - cabeceras.push(cabeceraKilometros);
308   - }
309   - cabeceras.push(cabeceraBomba);
310   - }
311   -
312   - $scope.articulosTabla = notaPedido.articulosNotaPedido;
313   - notaPedidoBusinessService.calcularArticulos($scope.articulosTabla,
314   - notaPedido.cotizacion.VENDEDOR);
315   -
316   - if(notaPedido.idPrecioCondicion > 0) {
317   - $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
318   - } else {
319   - $scope.idLista = -1;
320   - }
321   -
322   - $scope.puntoVenta = $filter('rellenarDigitos')(
323   - notaPedido.sucursal, 4
324   - );
325   -
326   - $scope.comprobante = $filter('rellenarDigitos')(
327   - notaPedido.numeroNotaPedido, 8
328   - );
329   -
330   - $scope.notaPedido = notaPedido;
331   - $scope.notaPedido.moneda = notaPedido.cotizacion.moneda;
332   - $scope.plazosPagos = notaPedido.notaPedidoPlazo;
333   - $scope.notaPedido.puntosDescarga =
334   - formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga);
335   - addArrayCabecera(cabeceras);
336   -
337   - }, function() {
338   - // funcion ejecutada cuando se cancela el modal
339   - }
340   - );
  246 + modalInstance.result.then(setearNotaPedido);
341 247 };
342 248  
343 249 $scope.seleccionarProductos = function() {
... ... @@ -355,7 +261,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
355 261 parametroProducto: {
356 262 idLista: $scope.idLista,
357 263 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
358   - simbolo: $scope.notaPedido.moneda.SIMBOLO
  264 + simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO
359 265 }
360 266 },
361 267 size: 'lg'
... ... @@ -370,7 +276,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
370 276 sector: producto.sector,
371 277 sectorCodigo: producto.sector + '-' + producto.codigo,
372 278 descripcion: producto.descripcion,
373   - item: $scope.articulosTabla.length + 1,
  279 + item: $scope.notaPedido.articulosNotaPedido.length + 1,
374 280 nombre: producto.descripcion,
375 281 precio: parseFloat(producto.precio.toFixed(4)),
376 282 costoUnitario: producto.costo,
... ... @@ -410,15 +316,15 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
410 316 filters: {
411 317 idDomicilio: $scope.notaPedido.domicilio.id,
412 318 idCliente: $scope.notaPedido.cliente.COD,
413   - articulos: $scope.articulosTabla,
414   - puntosDescarga: $scope.notaPedido.puntosDescarga
  319 + articulos: $scope.notaPedido.articulosNotaPedido,
  320 + puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga
415 321 }
416 322 }
417 323 }
418 324 );
419 325 modalInstance.result.then(
420 326 function(puntosDescarga) {
421   - $scope.notaPedido.puntosDescarga = puntosDescarga;
  327 + $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga;
422 328  
423 329 //AGREGO PUNTOS DE DESCARGA A CABECERA
424 330 var puntosStamp = '';
... ... @@ -567,7 +473,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
567 473 domicilio.Localidad + ', ' + domicilio.Provincia;
568 474 $scope.notaPedido.domicilioStamp = domicilioStamp;
569 475  
570   - $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga;
  476 + $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntosDescarga;
571 477  
572 478 $scope.$broadcast('addCabecera', {
573 479 label: 'Cliente:',
... ... @@ -596,12 +502,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
596 502  
597 503 $scope.getTotal = function() {
598 504 var total = 0;
599   -
600   - if ($scope.articulosTabla) {
601   - var arrayTempArticulos = $scope.articulosTabla;
602   - for (var i = 0; i < arrayTempArticulos.length; i++) {
603   - total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
604   - }
  505 + var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido;
  506 + for (var i = 0; i < arrayTempArticulos.length; i++) {
  507 + total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
605 508 }
606 509  
607 510 return parseFloat(total.toFixed(2));
... ... @@ -628,8 +531,9 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
628 531 var cabecera = '';
629 532 var plazosConcat = '';
630 533 if(!Array.isArray(precioCondicion)) {
  534 + $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago;
  535 + $scope.notaPedido.precioCondicion = precioCondicion;
631 536 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
632   - $scope.plazosPagos = precioCondicion.plazoPago;
633 537 $scope.idLista = precioCondicion.idListaPrecio;
634 538 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
635 539 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
... ... @@ -640,13 +544,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
640 544 $scope.notaPedido.idPrecioCondicion = 0;
641 545 //-1, el modal productos busca todos los productos
642 546 $scope.idLista = -1;
643   - $scope.plazosPagos = precioCondicion;
  547 + $scope.notaPedido.notaPedidoPlazo = precioCondicion;
644 548 for(var j = 0; j < precioCondicion.length; j++) {
645 549 plazosConcat += precioCondicion[j].dias + ' ';
646 550 }
647 551 cabecera = 'Ingreso manual ' + plazosConcat.trim();
648 552 }
649   - $scope.articulosTabla = [];
  553 + $scope.notaPedido.articulosNotaPedido = [];
650 554 $scope.$broadcast('addCabecera', {
651 555 label: 'Precios y condiciones:',
652 556 valor: cabecera
... ... @@ -766,21 +670,16 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
766 670 );
767 671 modalInstance.result.then(
768 672 function(cotizacion) {
769   - var articulosTablaTemp = $scope.articulosTabla;
770   -
  673 + var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido;
771 674 for(var i = 0; i < articulosTablaTemp.length; i++) {
772 675 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
773 676 $scope.notaPedido.cotizacion.VENDEDOR;
774 677 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
775 678 cotizacion.VENDEDOR;
776 679 }
777   -
778   - $scope.articulosTabla = articulosTablaTemp;
779   - $scope.notaPedido.moneda = moneda;
780   - $scope.monedaDefecto = moneda;
781   - $scope.cotizacionDefecto = cotizacion;
  680 + $scope.notaPedido.articulosNotaPedido = articulosTablaTemp;
782 681 $scope.notaPedido.cotizacion = cotizacion;
783   -
  682 + $scope.notaPedido.cotizacion.moneda = moneda;
784 683 if(moneda.DETALLE === 'PESOS ARGENTINOS') {
785 684 $scope.$broadcast('removeCabecera', 'Moneda:');
786 685 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
... ... @@ -814,13 +713,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
814 713 return;
815 714 }
816 715 delete $scope.articuloACargar.sectorCodigo;
817   - $scope.articulosTabla.push($scope.articuloACargar);
  716 + $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar);
818 717 $scope.cargando = true;
819 718 }
820 719 };
821 720  
822 721 $scope.quitarArticulo = function(key) {
823   - $scope.articulosTabla.splice(key, 1);
  722 + $scope.notaPedido.articulosNotaPedido.splice(key, 1);
824 723 };
825 724  
826 725 $scope.editarArticulo = function(key, articulo) {
... ... @@ -873,6 +772,116 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
873 772 articulo.precio = parseFloat(articulo.precio);
874 773 };
875 774  
  775 + function setearNotaPedido(notaPedido) {
  776 + //añado cabeceras
  777 + $scope.notaPedido = notaPedido;
  778 + $scope.$broadcast('removeCabecera', 'Bomba:');
  779 + $scope.$broadcast('removeCabecera', 'Kilometros:');
  780 +
  781 + var cabeceras = [];
  782 +
  783 + if (notaPedido.cotizacion) {
  784 + cabeceras.push({
  785 + label: 'Moneda:',
  786 + valor: notaPedido.cotizacion.moneda.DETALLE
  787 + });
  788 + cabeceras.push({
  789 + label: 'Fecha cotizacion:',
  790 + valor: $filter('date')(notaPedido.cotizacion.FECHA,
  791 + 'dd/MM/yyyy')
  792 + });
  793 + cabeceras.push({
  794 + label: 'Cotizacion:',
  795 + valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
  796 + '2')
  797 + });
  798 + }
  799 + if (notaPedido.cliente.COD) {
  800 + cabeceras.push({
  801 + label: 'Cliente:',
  802 + valor: notaPedido.cliente.NOM
  803 + });
  804 + cabeceras.push({
  805 + label: 'Domicilio:',
  806 + valor: notaPedido.domicilioStamp
  807 + });
  808 + }
  809 + if (notaPedido.vendedor.NUM) {
  810 + cabeceras.push({
  811 + label: 'Vendedor:',
  812 + valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) +
  813 + ' - ' + notaPedido.vendedor.NOM
  814 + });
  815 + }
  816 + if (notaPedido.proveedor.COD) {
  817 + cabeceras.push({
  818 + label: 'Proveedor:',
  819 + valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) +
  820 + ' - ' + notaPedido.proveedor.NOM
  821 + });
  822 + }
  823 + if (notaPedido.notaPedidoPlazo) {
  824 + cabeceras.push({
  825 + label: 'Precios y condiciones:',
  826 + valor: valorPrecioCondicion() + ' ' +
  827 + notaPedidoBusinessService
  828 + .plazoToString(notaPedido.notaPedidoPlazo)
  829 + });
  830 + }
  831 + if (notaPedido.flete !== undefined) {
  832 + cabeceras.push({
  833 + label: 'Flete:',
  834 + valor: notaPedido.fob === 1 ? 'FOB' : (
  835 + notaPedido.flete === 1 ? 'Si' : 'No')
  836 + });
  837 + }
  838 +
  839 +
  840 + function valorPrecioCondicion() {
  841 + if(notaPedido.idPrecioCondicion > 0) {
  842 + return notaPedido.precioCondicion.nombre;
  843 + } else {
  844 + return 'Ingreso Manual';
  845 + }
  846 + }
  847 +
  848 + if(notaPedido.flete === 1) {
  849 + var cabeceraBomba = {
  850 + label: 'Bomba:',
  851 + valor: notaPedido.bomba === 1 ? 'Si' : 'No'
  852 + };
  853 + if(notaPedido.kilometros) {
  854 + var cabeceraKilometros = {
  855 + label: 'Kilometros:',
  856 + valor: notaPedido.kilometros
  857 + };
  858 + cabeceras.push(cabeceraKilometros);
  859 + }
  860 + cabeceras.push(cabeceraBomba);
  861 + }
  862 +
  863 + notaPedidoBusinessService.calcularArticulos($scope.notaPedido.articulosNotaPedido,
  864 + notaPedido.cotizacion.VENDEDOR);
  865 +
  866 + if(notaPedido.idPrecioCondicion > 0) {
  867 + $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
  868 + } else {
  869 + $scope.idLista = -1;
  870 + }
  871 +
  872 + $scope.puntoVenta = $filter('rellenarDigitos')(
  873 + notaPedido.sucursal, 4
  874 + );
  875 +
  876 + $scope.comprobante = $filter('rellenarDigitos')(
  877 + notaPedido.numeroNotaPedido, 8
  878 + );
  879 +
  880 + $scope.notaPedido.notaPedidoPuntoDescarga =
  881 + formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga || []);
  882 + addArrayCabecera(cabeceras);
  883 + }
  884 +
876 885 function addArrayCabecera(array) {
877 886 for(var i = 0; i < array.length; i++) {
878 887 $scope.$broadcast('addCabecera', {
... ... @@ -899,13 +908,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
899 908 return resultPunto.id === el.idPuntoDescarga;
900 909 });
901 910  
902   - if(puntoDescarga.length) {
  911 + if (puntoDescarga.length) {
903 912 puntoDescarga[0].articulosAgregados.push({
904 913 cantidad: el.cantidad,
905 914 descripcion: el.producto.descripcion,
906 915 id: el.producto.id
907 916 });
908   - }else {
  917 + } else {
909 918 result.push({
910 919 id: el.puntoDescarga.id,
911 920 id_cliente: el.puntoDescarga.id_cliente,
... ... @@ -929,11 +938,9 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
929 938 function salir() {
930 939 var confirmacion = false;
931 940  
932   - angular.forEach($scope.inicial, function(valor, key) {
933   - if (!angular.equals($scope[key], $scope.inicial[key])) {
934   - confirmacion = true;
935   - }
936   - });
  941 + if (!angular.equals($scope.notaPedido, $scope.inicial)) {
  942 + confirmacion = true;
  943 + }
937 944  
938 945 if (confirmacion) {
939 946 focaModalService.confirm(
... ... @@ -947,5 +954,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
947 954 $location.path('/');
948 955 }
949 956 }
  957 +
  958 + function getLSNotaPedido() {
  959 + var notaPedido = JSON.parse($localStorage.notaPedido || null);
  960 + if (notaPedido) {
  961 + setearNotaPedido(notaPedido);
  962 + delete $localStorage.notaPedido;
  963 + }
  964 + }
950 965 }
951 966 ]);
src/views/nota-pedido.html
... ... @@ -2,7 +2,7 @@
2 2 <foca-cabecera-facturador
3 3 titulo="'Nota de pedido'"
4 4 numero="puntoVenta + '-' + comprobante"
5   - fecha="now"
  5 + fecha="notaPedido.fechaCarga"
6 6 class="mb-0 col-lg-12"
7 7 busqueda="seleccionarNotaPedido"
8 8 ></foca-cabecera-facturador>
... ... @@ -47,8 +47,8 @@
47 47 </thead>
48 48 <tbody class="tabla-articulo-body">
49 49 <tr
50   - ng-repeat="(key, articulo) in articulosTabla"
51   - ng-show="show || key == (articulosTabla.length - 1)"
  50 + ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido"
  51 + ng-show="show || key == (notaPedido.articulosNotaPedido.length - 1)"
52 52 class="d-flex"
53 53 >
54 54 <td ng-bind="key + 1"></td>
... ... @@ -127,7 +127,7 @@
127 127 <tr ng-show="!cargando" class="d-flex">
128 128 <td
129 129 class="align-middle"
130   - ng-bind="articulosTabla.length + 1"
  130 + ng-bind="notaPedido.articulosNotaPedido.length + 1"
131 131 ></td>
132 132 <td class="col">
133 133 <input
... ... @@ -193,7 +193,7 @@
193 193 <tr class="d-flex">
194 194 <td colspan="4" class="no-border-top">
195 195 <strong>Items:</strong>
196   - <a ng-bind="articulosTabla.length"></a>
  196 + <a ng-bind="notaPedido.articulosNotaPedido.length"></a>
197 197 </td>
198 198 <td class="text-right ml-auto table-celda-total no-border-top">
199 199 <h3>Total:</h3>
... ... @@ -237,8 +237,8 @@
237 237 </thead>
238 238 <tbody>
239 239 <tr
240   - ng-repeat="(key, articulo) in articulosTabla"
241   - ng-show="show || key == articulosTabla.length - 1"
  240 + ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido"
  241 + ng-show="show || key == notaPedido.articulosNotaPedido.length - 1"
242 242 >
243 243 <td class="w-100 align-middle d-flex p-0">
244 244 <div class="align-middle p-1">
... ... @@ -309,7 +309,7 @@
309 309 <tr ng-show="!cargando" class="d-flex">
310 310 <td
311 311 class="align-middle p-1"
312   - ng-bind="articulosTabla.length + 1"
  312 + ng-bind="notaPedido.articulosNotaPedido.length + 1"
313 313 ></td>
314 314 <td class="col p-0">
315 315 <div class="d-flex">
... ... @@ -363,7 +363,7 @@
363 363 <button
364 364 class="btn btn-outline-light selectable w-100"
365 365 ng-click="show = !show; masMenos()"
366   - ng-show="articulosTabla.length > 0"
  366 + ng-show="notaPedido.articulosNotaPedido.length > 0"
367 367 >
368 368 <i
369 369 class="fa fa-chevron-down"
... ... @@ -383,7 +383,7 @@
383 383 <tr class="d-flex">
384 384 <td class="align-middle no-border-top" colspan="2">
385 385 <strong>Cantidad Items:</strong>
386   - <a ng-bind="articulosTabla.length"></a>
  386 + <a ng-bind="notaPedido.articulosNotaPedido.length"></a>
387 387 </td>
388 388 <td class="text-right ml-auto table-celda-total no-border-top">
389 389 <h3>Total:</h3>