feat: refs #7569 refs#7569 sendEmailNotification
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
a1e1d4fa72
commit
0340612645
|
@ -249,5 +249,5 @@
|
||||||
"Sales already moved": "Sales already moved",
|
"Sales already moved": "Sales already moved",
|
||||||
"Holidays to past days not available": "Holidays to past days not available",
|
"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 }}",
|
"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}} {{{fullUrl}}} has been delivered out of order. Tickets that have not been delivered in their route are: {{ ticketsToMail }}"
|
"Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order."
|
||||||
}
|
}
|
|
@ -394,5 +394,6 @@
|
||||||
"An item type with the same code already exists": "Un tipo con el mismo código ya existe",
|
"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",
|
||||||
"Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}",
|
"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 sigo entregado en su orden. Los tickets de la ruta que no han sido entregados en su orden son: {{ ticketsToMail }}"
|
"Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden.",
|
||||||
|
"Price cannot be blank": "Price cannot be blank"
|
||||||
}
|
}
|
|
@ -368,5 +368,5 @@
|
||||||
"ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}",
|
"ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}",
|
||||||
"The web user's email already exists": "L'email de l'internaute existe déjà",
|
"The web user's email already exists": "L'email de l'internaute existe déjà",
|
||||||
"Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}",
|
"Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}",
|
||||||
"Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre. Les tickets qui n'ont pas été livrés dans leur itinéraire sont : {{ticketsToMail}}"
|
"Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre."
|
||||||
}
|
}
|
|
@ -367,5 +367,5 @@
|
||||||
"ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}",
|
"ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}",
|
||||||
"The web user's email already exists": "O e-mail do utilizador da web já existe.",
|
"The web user's email already exists": "O e-mail do utilizador da web já existe.",
|
||||||
"Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}",
|
"Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}",
|
||||||
"Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem. Os tickets que não foram entregues na sua rota são: {{ ticketsToMail }}"
|
"Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem."
|
||||||
}
|
}
|
|
@ -162,7 +162,7 @@ module.exports = Self => {
|
||||||
fields: ['id']
|
fields: ['id']
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const ticketsToMail = await Self.rawSql(`
|
const ticketIncorrect = await Self.rawSql(`
|
||||||
SELECT t.id
|
SELECT t.id
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
|
@ -173,10 +173,9 @@ module.exports = Self => {
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
WHERE t.id = ?)`
|
WHERE t.id = ?)`
|
||||||
, [ticket.routeFk, orderState.id, ticket.id], myOptions);
|
, [ticket.routeFk, orderState.id, ticket.id], myOptions);
|
||||||
const ticketIds = ticketsToMail.map(row => row.id);
|
|
||||||
|
|
||||||
if (ticketsToMail)
|
if (ticketIncorrect && ticketIncorrect.length > 0)
|
||||||
await sendMail(ctx, ticket.routeFk, ticket.id, ticket.zone().name, ticketIds);
|
await sendMail(ctx, ticket.routeFk, ticket.id, ticket.zone().name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.$cmrFk) {
|
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.$cmrFk) {
|
||||||
|
@ -192,7 +191,7 @@ module.exports = Self => {
|
||||||
await models.Ticket.sendCmrEmail(ctx, externalTickets);
|
await models.Ticket.sendCmrEmail(ctx, externalTickets);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function sendMail(ctx, route, ticket, zoneName, ticketsToMail) {
|
async function sendMail(ctx, route, ticket, zoneName) {
|
||||||
const $t = ctx.req.__;
|
const $t = ctx.req.__;
|
||||||
const url = await Self.app.models.Url.getUrl();
|
const url = await Self.app.models.Url.getUrl();
|
||||||
const sendTo = 'repartos@verdnatura.es';
|
const sendTo = 'repartos@verdnatura.es';
|
||||||
|
@ -203,8 +202,7 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
const emailBody = $t('Ticket has been delivered out of order', {
|
const emailBody = $t('Ticket has been delivered out of order', {
|
||||||
ticket,
|
ticket,
|
||||||
fullUrl,
|
fullUrl
|
||||||
ticketsToMail,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await Self.app.models.Mail.create({
|
await Self.app.models.Mail.create({
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('Ticket saveSign()', () => {
|
describe('Ticket saveSign()', () => {
|
||||||
let ctx = {req: {
|
let ctx = {req: {
|
||||||
getLocale: () => {
|
getLocale: () => {
|
||||||
return 'en';
|
return 'en';
|
||||||
},
|
},
|
||||||
|
__: () => {},
|
||||||
accessToken: {userId: 9}
|
accessToken: {userId: 9}
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: ctx
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it(`should throw error if the ticket's alert level is lower than 2`, async() => {
|
fit(`should throw error if the ticket's alert level is lower than 2`, async() => {
|
||||||
const tx = await models.TicketDms.beginTransaction({});
|
const tx = await models.TicketDms.beginTransaction({});
|
||||||
const ticketWithOkState = 12;
|
const ticketWithOkState = 12;
|
||||||
let error;
|
let error;
|
||||||
|
@ -27,7 +35,7 @@ describe('Ticket saveSign()', () => {
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change state for ticket', async() => {
|
fit('should change state for ticket', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
const ticketWithPackedState = 7;
|
const ticketWithPackedState = 7;
|
||||||
spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]);
|
spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]);
|
||||||
|
@ -52,7 +60,7 @@ describe('Ticket saveSign()', () => {
|
||||||
expect(ticketTrackingAfter.name).toBe('Entregado en parte');
|
expect(ticketTrackingAfter.name).toBe('Entregado en parte');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send an email to notify that the delivery order is not correct', async() => {
|
fit('should send an email to notify that the delivery order is not correct', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
const ticketFk = 8;
|
const ticketFk = 8;
|
||||||
const priority = 5;
|
const priority = 5;
|
||||||
|
|
Loading…
Reference in New Issue