diff --git a/loopback/locale/en.json b/loopback/locale/en.json index eeb32f545..84435a0fd 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -58,10 +58,10 @@ "Swift / BIC can't be empty": "Swift / BIC can't be empty", "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", - "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}} {{ticketWeekly}}", "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}", + "Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}", "Changes in sales": "the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}*", "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", @@ -253,5 +253,6 @@ "Sales already moved": "Sales already moved", "Holidays to past days not available": "Holidays to past days not available", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", - "Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order." -} \ No newline at end of file + "Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order.", + "clonedFromTicketWeekly": ", that is a cloned sale from ticket {{ ticketWeekly }}" +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index dca19e4a6..d64bb7c30 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -121,10 +121,10 @@ "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", "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}}}", + "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}} {{ticketWeekly}}", "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}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}} ", + "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}", "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*", "State": "Estado", "regular": "normal", @@ -396,6 +396,6 @@ "There are tickets to be invoiced": "La zona tiene tickets por facturar", "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.", - "Price cannot be blank": "El precio no puede estar en blanco" - + "Price cannot be blank": "El precio no puede estar en blanco", + "clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}" } diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index d4f128082..287a6a922 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -113,6 +113,12 @@ module.exports = Self => { const salesPerson = sale.ticket().client().salesPersonUser(); if (salesPerson) { const url = await Self.app.models.Url.getUrl(); + + const saleCloned = await Self.app.models.SaleCloned.findById(sale.id, { + include: 'saleOriginal', + }); + const ticketWeekly = saleCloned?.saleOriginal()?.ticketFk || null; + const message = $t('Changed sale price', { ticketId: sale.ticket().id, itemId: sale.itemFk, @@ -121,7 +127,8 @@ module.exports = Self => { oldPrice: oldPrice, newPrice: newPrice, ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, - itemUrl: `${url}item/${sale.itemFk}/summary` + itemUrl: `${url}item/${sale.itemFk}/summary`, + ticketWeekly: ticketWeekly ? $t('clonedFromTicketWeekly', {ticketWeekly}) : null }); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); } diff --git a/modules/ticket/back/methods/sale/updateQuantity.js b/modules/ticket/back/methods/sale/updateQuantity.js index 4de1bcbd6..5561c77ef 100644 --- a/modules/ticket/back/methods/sale/updateQuantity.js +++ b/modules/ticket/back/methods/sale/updateQuantity.js @@ -72,6 +72,12 @@ module.exports = Self => { const salesPerson = sale.ticket().client().salesPersonUser(); if (salesPerson) { const url = await Self.app.models.Url.getUrl(); + + const saleCloned = await Self.app.models.SaleCloned.findById(sale.id, { + include: 'saleOriginal', + }); + const ticketWeekly = saleCloned?.saleOriginal()?.ticketFk || null; + const change = $t('Changes in sales', { itemId: sale.itemFk, concept: sale.concept, @@ -84,6 +90,7 @@ module.exports = Self => { ticketId: sale.ticket().id, changes: JSON.stringify(change), ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, + ticketWeekly: ticketWeekly ? $t('clonedFromTicketWeekly', {ticketWeekly}) : null }); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 2e8bec27a..0175e43c5 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -166,10 +166,18 @@ module.exports = Self => { const salesPerson = ticket.client().salesPersonUser(); if (salesPerson) { const url = await Self.app.models.Url.getUrl(); + + const saleId = sales[0].id; + const saleCloned = await Self.app.models.SaleCloned.findById(saleId, { + include: 'saleOriginal', + }); + const ticketWeekly = saleCloned?.saleOriginal()?.ticketFk || null; + const message = $t('Changed sale discount', { ticketId: id, ticketUrl: `${url}ticket/${id}/sale`, - changes: changesMade + changes: changesMade, + ticketWeekly: ticketWeekly ? $t('clonedFromTicketWeekly', {ticketWeekly}) : null }); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); }