diff --git a/services/claim/common/methods/claim-beginning/importToNewRefundTicket.js b/services/claim/common/methods/claim-beginning/importToNewRefundTicket.js index dcdd0e914..971f83933 100644 --- a/services/claim/common/methods/claim-beginning/importToNewRefundTicket.js +++ b/services/claim/common/methods/claim-beginning/importToNewRefundTicket.js @@ -121,6 +121,7 @@ module.exports = Self => { insertIntoClaimEnd(createdSales, id, worker.id, {transaction: transaction}); await Self.rawSql('CALL vn.ticketCalculateClon(?)', [newRefundTicket], {transaction: transaction}); await transaction.commit(); + return newRefundTicket; } catch (e) { await transaction.rollback(); throw e; diff --git a/services/db/tests/vn/logAddWithUser.spec.js b/services/db/tests/vn/logAddWithUser.spec.js new file mode 100644 index 000000000..da85168e2 --- /dev/null +++ b/services/db/tests/vn/logAddWithUser.spec.js @@ -0,0 +1,31 @@ +const app = require(`../../../ticket/server/server`); + +describe('logAddWithUser()', () => { + it('should log any action taken by the user in a table ending in Log', async() => { + let params = { + ticketFk: 1, + userId: 9, + actionCode: 'update', + targetEntity: 'ticket', + description: 'we are testing stuff' + }; + + let query = ` + START TRANSACTION; + CALL vn.logAddWithUser(?, ?, ?, ?, ?); + SELECT * FROM vn.ticketLog WHERE description = ?; + ROLLBACK;`; + let result = await app.models.Ticket.rawSql(query, [ + params.ticketFk, + params.userId, + params.actionCode, + params.targetEntity, + params.description, + params.description + ]); + + savedDescription = result[2][0].description; + + expect(savedDescription).toEqual(params.description); + }); +});