ref #5914 add ticketrefund and fix text
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Jorge Penadés 2023-10-24 09:34:04 +02:00
parent 5529f08ce6
commit f1deeb69ca
2 changed files with 26 additions and 4 deletions

View File

@ -1,14 +1,30 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('InvoiceOut tranferInvoice()', () => {
const userId = 5;
const ctx = {req: {accessToken: userId}};
const activeCtx = {
accessToken: {userId: 5},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
const ctx = {req: activeCtx};
beforeEach(() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
});
it('should return the id of the created issued invoice', async() => {
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
const args = {
id: '1',
ref: 'T1111111',
ref: 'T4444444',
newClientFk: 1,
cplusRectificationId: 1,
cplusInvoiceType477Id: 1,

View File

@ -105,7 +105,13 @@ module.exports = Self => {
ctx.args.companyId = ticket.companyFk;
ctx.args.addressId = ticket.addressFk;
return models.Ticket.new(ctx, myOptions);
const newTicket = await models.Ticket.new(ctx, myOptions);
await models.TicketRefund.create({
originalTicketFk: ticketId,
refundTicketFk: newTicket.id
}, myOptions);
return newTicket;
}
};
};