7744-closeAllTest #3114

Merged
jgallego merged 3 commits from 7744-closeAllTest into dev 2024-10-21 06:29:18 +00:00
3 changed files with 8 additions and 35 deletions
Showing only changes of commit 681f82a3ae - Show all commits

View File

@ -57,11 +57,11 @@ module.exports = Self => {
const params = { const params = {
bookEntry: bookEntry.ASIEN, bookEntry: bookEntry.ASIEN,
invoiceOutRef: invoiceOut.ref invoiceOutRef: invoiceOut.ref
} };
await Self.rawSql(`SELECT util.notification_send('book-entry-deleted', ?, NULL)`, await Self.rawSql(`SELECT util.notification_send('book-entry-deleted', ?, NULL)`,
[JSON.stringify(params)], [JSON.stringify(params)],
myOptions); myOptions);
}; }
await models.Xdiario.destroyAll({ await models.Xdiario.destroyAll({
ASIEN: bookEntry.ASIEN ASIEN: bookEntry.ASIEN

View File

@ -19,8 +19,7 @@ module.exports = async function(ctx, Self, tickets, options) {
const failedtickets = []; const failedtickets = [];
for (const ticket of tickets) { for (const ticket of tickets) {
try { try {
await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}, await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], myOptions);
myOptions);
await Self.app.models.InvoiceOut.getSerial( await Self.app.models.InvoiceOut.getSerial(
ticket.clientFk, ticket.clientFk,

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const LoopBackContext = require('loopback-context');
fdescribe('Ticket Closure - closeAll function', () => { describe('Ticket Closure - closeAll function', () => {
let ctx = { let ctx = {
req: { req: {
getLocale: () => 'es', getLocale: () => 'es',
@ -17,6 +17,7 @@ fdescribe('Ticket Closure - closeAll function', () => {
beforeEach(async() => { beforeEach(async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req});
tx = await models.Ticket.beginTransaction({}); tx = await models.Ticket.beginTransaction({});
options = {transaction: tx}; options = {transaction: tx};
originalVnNew = Date.vnNew; originalVnNew = Date.vnNew;
@ -32,34 +33,7 @@ fdescribe('Ticket Closure - closeAll function', () => {
await tx.rollback(); await tx.rollback();
}); });
xit('should successfully close all tickets when conditions are met', async() => { it('should set routeFk to NULL when conditions are met', async() => {
const ticketsBefore = await models.Ticket.find({
where: {
packages: {neq: 0}
}
}, options);
const packedTicketsIds = ticketsBefore.map(ticket => ticket.id);
const packedTicketsBefore = await models.TicketLastState.find({
where: {
ticketFk: {inq: packedTicketsIds},
lastState: 'Encajado'
}
}, options);
await models.Ticket.closeAll(ctx, options);
const packedTicketsAfter = await models.TicketLastState.find({
where: {
ticketFk: {inq: packedTicketsIds},
lastState: 'Encajado'
}
}, options);
expect(packedTicketsBefore.length).toBeGreaterThan(packedTicketsAfter.length);
});
fit('should set routeFk to NULL when conditions are met', async() => {
const ticketsBefore = await models.Ticket.find({ const ticketsBefore = await models.Ticket.find({
where: { where: {
routeFk: {neq: null} routeFk: {neq: null}