Commit 3e41ead8016e7cf005e3c17f149aa3d3ff7f4ee9

Authored by Nicolás Guarnieri
Exists in master

Merge branch 'master' into 'master'

Master

See merge request !43
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 },