Commit 8b001ef5cf2095bdc62c068b26d03926f7192829
1 parent
fb875b22e1
Exists in
master
comprobar si existen productos para puntos de descarga
Showing
1 changed file
with
13 additions
and
9 deletions
Show diff stats
src/js/businessService.js
... | ... | @@ -26,16 +26,20 @@ angular.module('focaCrearNotaPedido') |
26 | 26 | addPuntosDescarga: function(idNotaPedido, puntosDescarga) { |
27 | 27 | var puntos = []; |
28 | 28 | |
29 | - puntosDescarga.forEach(function(punto) { | |
30 | - punto.articulosAgregados.forEach(function(articulo) { | |
31 | - puntos.push({ | |
32 | - idPuntoDescarga: punto.id, | |
33 | - idNotaPedido: idNotaPedido, | |
34 | - idProducto: articulo.id, | |
35 | - cantidad: articulo.cantidad | |
36 | - }); | |
29 | + if (puntosDescarga && puntosDescarga.length > 0) { | |
30 | + puntosDescarga.forEach(function(punto) { | |
31 | + if (puntos.articulosAgregados && puntos.articulosAgregados.length > 0) { | |
32 | + punto.articulosAgregados.forEach(function(articulo) { | |
33 | + puntos.push({ | |
34 | + idPuntoDescarga: punto.id, | |
35 | + idNotaPedido: idNotaPedido, | |
36 | + idProducto: articulo.id, | |
37 | + cantidad: articulo.cantidad | |
38 | + }); | |
39 | + }); | |
40 | + } | |
37 | 41 | }); |
38 | - }); | |
42 | + } | |
39 | 43 | |
40 | 44 | return crearNotaPedidoService.crearPuntosDescarga(puntos); |
41 | 45 | }, |