diff --git a/services/client/common/models/credit-insurance.js b/services/client/common/models/credit-insurance.js index 2c92ad1d1..264e85cc6 100644 --- a/services/client/common/models/credit-insurance.js +++ b/services/client/common/models/credit-insurance.js @@ -69,6 +69,8 @@ module.exports = function(Self) { let ctx = {req: {accessToken: accessToken}}; let insurance = await Self.findById(data.id, filter); let customer = insurance.classification().customer(); + + if (!customer.salesPerson()) return; let salesPerson = customer.salesPerson().user().name; let grade = data.grade ? `(Grado ${data.grade})` : '(Sin grado)'; let message = { @@ -78,7 +80,7 @@ module.exports = function(Self) { Self.app.models.Message.send(salesPerson, message, ctx); }; - // Update from transaction misses ctx accessToken. + // Update from transaction misses ctx accessToken. // Fixed passing accessToken from method messageSend() Self.observe('after save', async function(ctx) { if (ctx.options.accessToken)