7167-testToMaster_2414 #2244

Merged
alexm merged 643 commits from 7167-testToMaster_2414 into master 2024-04-04 05:32:41 +00:00
5 changed files with 17 additions and 14 deletions
Showing only changes of commit 1315bfda88 - Show all commits

View File

@ -3068,14 +3068,6 @@ INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentIns
UPDATE vn.department
SET workerFk = null;
INSERT INTO vn.ticketLog (originFk,userFk,`action`,creationDate,changedModel,newInstance,changedModelId,changedModelValue)
VALUES (9,9,'insert','2000-01-01 11:01:00.000','Ticket','{"isDeleted":true}',45,'Super Man');
UPDATE vn.ticket
SET isDeleted=1
WHERE id=9;
-- NEW WAREHOUSE
INSERT INTO vn.packaging
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0);

View File

@ -9,8 +9,8 @@ describe('ticketLog getChanges()', () => {
it('should return the changes in the sales of a ticket', async() => {
const ticketId = 16;
const changues = await models.TicketLog.getChanges(ctx, ticketId);
const changes = await models.TicketLog.getChanges(ctx, ticketId);
expect(changues).toContain(`Change quantity`);
expect(changes).toContain(`Change quantity`);
});
});

View File

@ -48,10 +48,9 @@ module.exports = Self => {
}, myOptions);
const now = Date.vnNew();
const maxDate = new Date(ticketLog.creationDate);
const maxDate = new Date(ticketLog?.creationDate);
maxDate.setHours(maxDate.getHours() + 1);
if (now > maxDate)
if (!ticketLog || now > maxDate)
throw new UserError(`You can only restore a ticket within the first hour after deletion`);
// Send notification to salesPerson

View File

@ -68,7 +68,7 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(5);
expect(result.length).toEqual(6);
await tx.rollback();
} catch (e) {

View File

@ -30,10 +30,21 @@ describe('ticket restore()', () => {
try {
const options = {transaction: tx};
const ticket = await models.Ticket.findById(ticketId, null, options);
await ticket.updateAttributes({
isDeleted: true,
updated: now
}, options);
await models.TicketLog.create({
originFk: ticketId,
userFk: employeeUser,
action: 'update',
changedModel: 'Ticket',
creationDate: new Date('2001-01-01 10:59:00'),
newInstance: '{"isDeleted":true}'
}, options);
await app.models.Ticket.restore(ctx, ticketId, options);
await tx.rollback();
} catch (e) {
@ -52,6 +63,7 @@ describe('ticket restore()', () => {
const options = {transaction: tx};
const ticketBeforeUpdate = await models.Ticket.findById(ticketId, null, options);
await ticketBeforeUpdate.updateAttributes({
isDeleted: true,
updated: now