From d94e2900d0e4795a96f6c2ed3e9e6afa4942924d Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 27 Oct 2021 12:16:37 +0200 Subject: [PATCH] feat(ticket-request): send rocket message when ticket-reques is denied --- loopback/locale/es.json | 1 + .../ticket/back/methods/ticket-request/deny.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index cdf15c674..afa349684 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -133,6 +133,7 @@ "reserved": "reservado", "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", + "Deny buy request":"Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 5b79a57cb..6d7df32aa 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -24,6 +24,8 @@ module.exports = Self => { }); Self.deny = async(ctx, options) => { + const models = Self.app.models; + const $t = ctx.req.__; // $translate const myOptions = {}; let tx; @@ -48,6 +50,20 @@ module.exports = Self => { const request = await Self.app.models.TicketRequest.findById(ctx.args.id, null, myOptions); await request.updateAttributes(params, myOptions); + // const salesPerson = ticket.client().salesPersonUser(); + // if (salesPerson) { + // const origin = ctx.req.headers.origin; + const origin = ctx.req.headers.origin; + + const message = $t('Deny buy request', { + ticketId: request.ticketFk, + url: `${origin}/#!/ticket/${request.ticketFk}/request/index`, + observation: params.response + }); + // await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); + await models.Chat.send(ctx, '@vicent', message, myOptions); + // } + if (tx) await tx.commit(); return request;