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 = {
bookEntry: bookEntry.ASIEN,
invoiceOutRef: invoiceOut.ref
}
};
await Self.rawSql(`SELECT util.notification_send('book-entry-deleted', ?, NULL)`,
[JSON.stringify(params)],
myOptions);
};
}
await models.Xdiario.destroyAll({
ASIEN: bookEntry.ASIEN

View File

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

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
fdescribe('Ticket Closure - closeAll function', () => {
describe('Ticket Closure - closeAll function', () => {
let ctx = {
req: {
getLocale: () => 'es',
@ -17,6 +17,7 @@ fdescribe('Ticket Closure - closeAll function', () => {
beforeEach(async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req});
tx = await models.Ticket.beginTransaction({});
options = {transaction: tx};
originalVnNew = Date.vnNew;
@ -32,34 +33,7 @@ fdescribe('Ticket Closure - closeAll function', () => {
await tx.rollback();
});
xit('should successfully close all tickets 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() => {
it('should set routeFk to NULL when conditions are met', async() => {
const ticketsBefore = await models.Ticket.find({
where: {
routeFk: {neq: null}