This commit is contained in:
parent
291578d86a
commit
d9c63e3bc0
|
@ -13,7 +13,6 @@ describe('Claim action path', () => {
|
|||
|
||||
it('should import the claim', async() => {
|
||||
const result = await nightmare
|
||||
.wait(1000)
|
||||
.waitToClick(selectors.claimAction.importClaimButton)
|
||||
.waitForLastSnackbar();
|
||||
|
||||
|
@ -22,7 +21,6 @@ describe('Claim action path', () => {
|
|||
|
||||
it('should import the second importable ticket', async() => {
|
||||
const result = await nightmare
|
||||
.wait(1000)
|
||||
.waitToClick(selectors.claimAction.importTicketButton)
|
||||
.waitToClick(selectors.claimAction.secondImportableTicket)
|
||||
.waitForLastSnackbar();
|
||||
|
|
|
@ -21,9 +21,9 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.delete = async id => {
|
||||
const tx = await Self.beginTransaction({});
|
||||
const transaction = await Self.beginTransaction({});
|
||||
try {
|
||||
let options = {transaction: tx};
|
||||
let options = {transaction: transaction};
|
||||
|
||||
let invoiceOut = await Self.findById(id);
|
||||
let tickets = await Self.app.models.Ticket.find({where: {refFk: invoiceOut.ref}});
|
||||
|
@ -35,10 +35,10 @@ module.exports = Self => {
|
|||
|
||||
await Promise.all(promises);
|
||||
await invoiceOut.destroy(options);
|
||||
await tx.commit();
|
||||
await transaction.commit();
|
||||
return tickets;
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
await transaction.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,19 +22,24 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.delete = async(ctx, params) => {
|
||||
let claimOfATicket = await Self.app.models.Claim.findOne({where: {ticketFk: params.id}});
|
||||
if (claimOfATicket)
|
||||
throw new UserError('You must delete the claim id %d first', 'DELETE_CLAIM_FIRST', claimOfATicket.id);
|
||||
const transaction = await Self.beginTransaction({});
|
||||
try {
|
||||
let claimOfATicket = await Self.app.models.Claim.findOne({where: {ticketFk: params.id}});
|
||||
if (claimOfATicket)
|
||||
throw new UserError('You must delete the claim id %d first', 'DELETE_CLAIM_FIRST', claimOfATicket.id);
|
||||
|
||||
let currentTicket = await Self.app.models.Ticket.findById(params.id);
|
||||
await currentTicket.updateAttributes({isDeleted: true});
|
||||
let currentTicket = await Self.app.models.Ticket.findById(params.id);
|
||||
await currentTicket.updateAttributes({isDeleted: true});
|
||||
|
||||
let userId = ctx.req.accessToken.userId;
|
||||
let worker = await Self.app.models.Worker.findOne({where: {userFk: userId}});
|
||||
params.workerFk = worker.id;
|
||||
let state = await Self.app.models.State.findOne({where: {code: 'ERASED'}});
|
||||
let userId = ctx.req.accessToken.userId;
|
||||
let worker = await Self.app.models.Worker.findOne({where: {userFk: userId}});
|
||||
params.workerFk = worker.id;
|
||||
let state = await Self.app.models.State.findOne({where: {code: 'ERASED'}});
|
||||
|
||||
|
||||
return await Self.app.models.TicketTracking.create({ticketFk: params.id, stateFk: state.id, workerFk: params.workerFk});
|
||||
return await Self.app.models.TicketTracking.create({ticketFk: params.id, stateFk: state.id, workerFk: params.workerFk});
|
||||
} catch (e) {
|
||||
await transaction.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue