This commit is contained in:
parent
5529f08ce6
commit
f1deeb69ca
|
@ -1,14 +1,30 @@
|
||||||
|
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('InvoiceOut tranferInvoice()', () => {
|
describe('InvoiceOut tranferInvoice()', () => {
|
||||||
const userId = 5;
|
const activeCtx = {
|
||||||
const ctx = {req: {accessToken: userId}};
|
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() => {
|
it('should return the id of the created issued invoice', async() => {
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
const tx = await models.InvoiceOut.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const args = {
|
const args = {
|
||||||
id: '1',
|
id: '1',
|
||||||
ref: 'T1111111',
|
ref: 'T4444444',
|
||||||
newClientFk: 1,
|
newClientFk: 1,
|
||||||
cplusRectificationId: 1,
|
cplusRectificationId: 1,
|
||||||
cplusInvoiceType477Id: 1,
|
cplusInvoiceType477Id: 1,
|
||||||
|
|
|
@ -105,7 +105,13 @@ module.exports = Self => {
|
||||||
ctx.args.companyId = ticket.companyFk;
|
ctx.args.companyId = ticket.companyFk;
|
||||||
ctx.args.addressId = ticket.addressFk;
|
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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue