diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 56ee14a73..ab4d39d51 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -97,18 +97,19 @@ module.exports = Self => { const query = `CALL vn.sale_calculateComponent(?, NULL)`; await Self.rawSql(query, [sale.id], myOptions); - const url = await Self.app.models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; - const message = $t('Bought units from buy request', { - quantity: sale.quantity, - concept: sale.concept, - itemId: sale.itemFk, - ticketId: sale.ticketFk, - url: `${url}ticket/${sale.ticketFk}/summary`, - urlItem: `${url}item/${sale.itemFk}/summary` - }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); - + if (requesterId) { + const url = await Self.app.models.Url.getUrl(); + const message = $t('Bought units from buy request', { + quantity: sale.quantity, + concept: sale.concept, + itemId: sale.itemFk, + ticketId: sale.ticketFk, + url: `${url}ticket/${sale.ticketFk}/summary`, + urlItem: `${url}item/${sale.itemFk}/summary` + }); + await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + } if (tx) await tx.commit(); return sale; diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index b96d8a244..5c9f87dde 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -65,16 +65,18 @@ module.exports = Self => { } }, myOptions); - const url = await models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; - const message = $t('Deny buy request', { - ticketId: request.ticketFk, - url: `${url}ticket/${request.ticketFk}/request/index`, - observation: params.response - }); + if (requesterId) { + const url = await models.Url.getUrl(); + const message = $t('Deny buy request', { + ticketId: request.ticketFk, + url: `${url}ticket/${request.ticketFk}/request/index`, + observation: params.response + }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); - await request.updateAttributes(params, myOptions); + await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await request.updateAttributes(params, myOptions); + } if (tx) await tx.commit();