This commit is contained in:
parent
41fbae7eec
commit
1315bfda88
|
@ -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);
|
||||
|
||||
|
|
|
@ -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`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue