2282 - Change stowaway state to FIXING
gitea/salix/pipeline/head Something is wrong with the build of this commit
Details
gitea/salix/pipeline/head Something is wrong with the build of this commit
Details
This commit is contained in:
parent
b411f49805
commit
052c51cee5
|
@ -83,7 +83,7 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
const ticket = await models.Ticket.findById(id, {
|
||||
include: {
|
||||
include: [{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'salesPersonFk'],
|
||||
|
@ -97,9 +97,27 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
relation: 'ship'
|
||||
}, {
|
||||
relation: 'stowaway'
|
||||
}]
|
||||
});
|
||||
|
||||
// Change state to "fixing" if contains an stowaway
|
||||
let otherTicketId;
|
||||
if (ticket.stowaway())
|
||||
otherTicketId = ticket.stowaway().shipFk;
|
||||
else if (ticket.ship())
|
||||
otherTicketId = ticket.ship().id;
|
||||
|
||||
if (otherTicketId) {
|
||||
models.TicketTracking.changeState(ctx, {
|
||||
ticketFk: otherTicketId,
|
||||
code: 'FIXING'
|
||||
});
|
||||
}
|
||||
|
||||
// Send notification to salesPerson
|
||||
const salesPerson = ticket.client().salesPerson();
|
||||
if (salesPerson) {
|
||||
|
|
|
@ -103,4 +103,27 @@ describe('ticket deleted()', () => {
|
|||
expect(error.translateArgs[0]).toEqual(2);
|
||||
expect(error.message).toEqual('You must delete the claim id %d first');
|
||||
});
|
||||
|
||||
fit('should delete the ticket and change the state to "FIXING" to the stowaway ticket', async() => {
|
||||
const ticketId = 16;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 106},
|
||||
headers: {
|
||||
origin: 'http://localhost:5000'
|
||||
},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
let error;
|
||||
|
||||
try {
|
||||
await app.models.Ticket.setDeleted(ctx, ticketId);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.translateArgs[0]).toEqual(2);
|
||||
expect(error.message).toEqual('You must delete the claim id %d first');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue