From 9fbc404aa15f9d71f92a1ade31a03ef4d007eec1 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Wed, 4 Oct 2017 09:07:14 +0200 Subject: [PATCH] bug fixed in formatCard function --- services/client/common/methods/client/card.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/client/common/methods/client/card.js b/services/client/common/methods/client/card.js index 752f7ce6a..4bfc66005 100644 --- a/services/client/common/methods/client/card.js +++ b/services/client/common/methods/client/card.js @@ -36,10 +36,11 @@ module.exports = function(Client) { function formatCard(card) { let cardFormated = JSON.parse(JSON.stringify(card)); - cardFormated.salesPerson = { - id: card.salesPerson().id, - name: `${card.salesPerson().name} ${card.salesPerson().surname}` - }; + if(cardFormated.salesPersonFk) + cardFormated.salesPerson = { + id: card.salesPerson().id, + name: `${card.salesPerson().name} ${card.salesPerson().surname}` + }; return cardFormated; } };