7806_devToTest_2332 #2801
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
ALTER TABLE vn.ticketLastState MODIFY COLUMN name varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
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);
|
|
@ -57,7 +57,7 @@ describe('Ticket List sale path', () => {
|
||||||
let searchValue = 'Melee weapon heavy shield 100cm';
|
let searchValue = 'Melee weapon heavy shield 100cm';
|
||||||
await page.autocompleteSearch(selectors.ticketSales.secondSaleIdAutocomplete, searchValue);
|
await page.autocompleteSearch(selectors.ticketSales.secondSaleIdAutocomplete, searchValue);
|
||||||
await page.waitToClick(selectors.ticketSales.secondSaleQuantityCell);
|
await page.waitToClick(selectors.ticketSales.secondSaleQuantityCell);
|
||||||
await page.type(selectors.ticketSales.secondSaleQuantity, '1');
|
await page.type(selectors.ticketSales.secondSaleQuantity, '8');
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
const message = await page.waitForSnackbar();
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,16 @@ module.exports = Self => {
|
||||||
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
|
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
|
||||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||||
|
|
||||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, 'DELIVERED'], myOptions);
|
const [{stateCode}] = await Self.rawSql(`
|
||||||
|
SELECT
|
||||||
|
IF((SUM(CASE WHEN est.code = 'DELIVERED' THEN 1 ELSE 0 END) = COUNT(*)),
|
||||||
|
'DELIVERED','PARTIAL_DELIVERED') stateCode
|
||||||
|
FROM vn.expedition e
|
||||||
|
JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
||||||
|
WHERE e.ticketFk = ?;
|
||||||
|
`, [ticketId], myOptions);
|
||||||
|
|
||||||
|
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, stateCode], myOptions);
|
||||||
|
|
||||||
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) {
|
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) {
|
||||||
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
|
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
|
||||||
|
|
|
@ -26,4 +26,36 @@ describe('Ticket saveSign()', () => {
|
||||||
|
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should change state for ticket', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
const ticketWithPackedState = 7;
|
||||||
|
const ticketStateId = 16;
|
||||||
|
const ticketCode = 'PARTIAL_DELIVERED';
|
||||||
|
spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]);
|
||||||
|
let ticketTrackingAfter;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const tickets = [ticketWithPackedState];
|
||||||
|
|
||||||
|
const state = await models.State.findById(ticketStateId, null, options);
|
||||||
|
await state.updateAttributes({
|
||||||
|
code: ticketCode,
|
||||||
|
name: ticketCode
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
await models.Ticket.saveSign(ctx, tickets, null, null, options);
|
||||||
|
ticketTrackingAfter = await models.TicketLastState.findOne({
|
||||||
|
where: {ticketFk: ticketWithPackedState}
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(ticketTrackingAfter.name).toBe('PARTIAL_DELIVERED');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -193,9 +193,13 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await user.updateAttribute('email', email, myOptions);
|
await user.updateAttribute('email', email, myOptions);
|
||||||
const {countryFk} = await Self.app.models.Province.findById(provinceFk, {
|
let countryFk;
|
||||||
fields: ['countryFk']
|
if (provinceFk) {
|
||||||
});
|
const province = await Self.app.models.Province.findById(provinceFk, {
|
||||||
|
fields: ['countryFk']
|
||||||
|
});
|
||||||
|
countryFk = province.countryFk;
|
||||||
|
}
|
||||||
await models.Worker.create({
|
await models.Worker.create({
|
||||||
id: user.id,
|
id: user.id,
|
||||||
firstName,
|
firstName,
|
||||||
|
@ -205,7 +209,6 @@ module.exports = Self => {
|
||||||
fi,
|
fi,
|
||||||
birth,
|
birth,
|
||||||
originCountryFk: countryFk
|
originCountryFk: countryFk
|
||||||
|
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
Loading…
Reference in New Issue