7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +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 UPDATE vn.department
SET workerFk = null; 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 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); 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() => { it('should return the changes in the sales of a ticket', async() => {
const ticketId = 16; 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); }, myOptions);
const now = Date.vnNew(); const now = Date.vnNew();
const maxDate = new Date(ticketLog.creationDate); const maxDate = new Date(ticketLog?.creationDate);
maxDate.setHours(maxDate.getHours() + 1); 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`); throw new UserError(`You can only restore a ticket within the first hour after deletion`);
// Send notification to salesPerson // Send notification to salesPerson

View File

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

View File

@ -30,10 +30,21 @@ describe('ticket restore()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const ticket = await models.Ticket.findById(ticketId, null, options); const ticket = await models.Ticket.findById(ticketId, null, options);
await ticket.updateAttributes({ await ticket.updateAttributes({
isDeleted: true, isDeleted: true,
updated: now updated: now
}, options); }, 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 app.models.Ticket.restore(ctx, ticketId, options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -52,6 +63,7 @@ describe('ticket restore()', () => {
const options = {transaction: tx}; const options = {transaction: tx};
const ticketBeforeUpdate = await models.Ticket.findById(ticketId, null, options); const ticketBeforeUpdate = await models.Ticket.findById(ticketId, null, options);
await ticketBeforeUpdate.updateAttributes({ await ticketBeforeUpdate.updateAttributes({
isDeleted: true, isDeleted: true,
updated: now updated: now