This commit is contained in:
parent
689a88b75e
commit
573f5c8d28
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
ALTER TABLE vn.ticketLastState MODIFY COLUMN name varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
|
|
@ -1,5 +1,5 @@
|
||||||
-- Place your SQL code here
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIALLY_DELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
|
INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIAL_DELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ module.exports = Self => {
|
||||||
const [{stateForTicket}] = await Self.rawSql(`
|
const [{stateForTicket}] = await Self.rawSql(`
|
||||||
SELECT
|
SELECT
|
||||||
IF((SUM(CASE WHEN est.code = 'DELIVERED' THEN 1 ELSE 0 END) = COUNT(*)),
|
IF((SUM(CASE WHEN est.code = 'DELIVERED' THEN 1 ELSE 0 END) = COUNT(*)),
|
||||||
'DELIVERED','PARTIALLYDELIVERED') stateForTicket
|
'DELIVERED','PARTIAL_DELIVERED') stateForTicket
|
||||||
FROM vn.expedition e
|
FROM vn.expedition e
|
||||||
JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
||||||
WHERE e.ticketFk = ?;
|
WHERE e.ticketFk = ?;
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe('Ticket saveSign()', () => {
|
||||||
accessToken: {userId: 9}
|
accessToken: {userId: 9}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
fit(`should throw error if the ticket's alert level is lower than 2`, async() => {
|
it(`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,31 +27,35 @@ describe('Ticket saveSign()', () => {
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
fit('should change state for ticket', async() => {
|
it('should change state for ticket', async() => {
|
||||||
const tx = await models.TicketDms.beginTransaction({});
|
const tx = await models.State.beginTransaction({});
|
||||||
const ticketWithOkState = 12;
|
const ticketWithOkState = 7;
|
||||||
const ticketStateId = 16;
|
const ticketStateId = 16;
|
||||||
const ticketCode = 'PARTIALLY_DELIVERED';
|
const ticketCode = 'PARTIAL_DELIVERED';
|
||||||
|
spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]);
|
||||||
|
let ticketTrackingAfter;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const tickets = [ticketWithOkState];
|
const tickets = [ticketWithOkState];
|
||||||
const state = await models.State.findById(ticketStateId);
|
|
||||||
|
const state = await models.State.findById(ticketStateId, null, options);
|
||||||
await state.updateAttributes({
|
await state.updateAttributes({
|
||||||
code: ticketCode
|
code: ticketCode,
|
||||||
}, options);
|
name: ticketCode
|
||||||
const ticketState = await models.TicketTracking.findById(ticketStateId);
|
}, options);
|
||||||
await ticketState.updateAttributes({
|
|
||||||
code: ticketCode
|
await models.Ticket.saveSign(ctx, tickets, null, null, options);
|
||||||
|
ticketTrackingAfter = await models.TicketLastState.findOne({
|
||||||
|
where: {ticketFk: ticketWithOkState}
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
await models.Ticket.saveSign(ctx, tickets, options);
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(ticket.toEqual('DELIVERED'));
|
expect(ticketTrackingAfter.name).toBe('PARTIAL_DELIVERED');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue