This commit is contained in:
parent
f78aad0874
commit
681f82a3ae
|
@ -37,7 +37,7 @@ module.exports = Self => {
|
|||
const tickets = await models.Ticket.find({
|
||||
where: {refFk: invoiceOut.ref}
|
||||
}, myOptions);
|
||||
|
||||
|
||||
const [bookEntry] = await models.Xdiario.find({
|
||||
where: {
|
||||
SERIE: invoiceOut.ref[0],
|
||||
|
@ -55,13 +55,13 @@ module.exports = Self => {
|
|||
if (bookEntry) {
|
||||
if (bookEntry.enlazadoSage) {
|
||||
const params = {
|
||||
bookEntry: bookEntry.ASIEN,
|
||||
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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue