diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 68514b9f36..9136d3d01d 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -123,7 +123,7 @@ "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) {{ticketClone}} ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) {{ticketWeekly}} ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})", "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*", "State": "Estado", @@ -393,5 +393,7 @@ "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "Price cannot be blank": "Price cannot be blank", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", - "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles" + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", + "Is cloned": "Is cloned", + "Is cloned from": "Is cloned from" } diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index b6276c99a0..f1568380b4 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -113,7 +113,8 @@ module.exports = Self => { const salesPerson = sale.ticket().client().salesPersonUser(); if (salesPerson) { const url = await Self.app.models.Url.getUrl(); - const ticketWeekly = await models.Sale.ticketClone(sale.id); + const ticketWeekly = await models.Sale.ticketWeekly(sale.id); + const message = $t('Changed sale price', { ticketId: sale.ticket().id, itemId: sale.itemFk, @@ -123,7 +124,7 @@ module.exports = Self => { newPrice: newPrice, ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, itemUrl: `${url}item/${sale.itemFk}/summary`, - ticketCloned: ticketWeekly && $t('Is cloned', ticketWeekly) + ticketWeekly: ticketWeekly ? `Is cloned from ticket ${ticketWeekly} de ` : null }); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); } diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 2550d76b46..d916794d4b 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -137,11 +137,19 @@ module.exports = Self => { throw new UserError('The price of the item changed'); }); - Self.isCloned = async function(saleId) { - // let userId = ctx.req.accessToken.userId; - // return await Self.findById(userId, { - // fields: ['id', 'name', 'nickname'] - // }); - // return ticketId + Self.ticketWeekly = async function(saleId) { + const SaleCloned = Self.app.models.SaleCloned; + + const saleCloned2 = await SaleCloned.findOne({ + where: { + saleClonedFk: saleId + }, + include: { + relation: 'saleOriginal' + } + }); + + return saleCloned2.saleOriginal()?.ticketFk; }; }; +