This commit is contained in:
parent
fbe4441eda
commit
8dd360bf1e
|
@ -1,7 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
fdescribe('Ticket services path', () => {
|
describe('Ticket services path', () => {
|
||||||
let browser;
|
let browser;
|
||||||
let page;
|
let page;
|
||||||
const invoicedTicketId = '1';
|
const invoicedTicketId = '1';
|
||||||
|
|
|
@ -10,6 +10,11 @@ module.exports = Self => {
|
||||||
{
|
{
|
||||||
arg: 'servicesIds',
|
arg: 'servicesIds',
|
||||||
type: ['number']
|
type: ['number']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'withWarehouse',
|
||||||
|
type: 'boolean',
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
@ -22,7 +27,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.refund = async(ctx, salesIds, servicesIds, options) => {
|
Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
let tx;
|
let tx;
|
||||||
|
@ -67,7 +72,7 @@ module.exports = Self => {
|
||||||
const [firstTicketId] = ticketsIds;
|
const [firstTicketId] = ticketsIds;
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions);
|
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions);
|
||||||
|
|
||||||
for (const sale of sales) {
|
for (const sale of sales) {
|
||||||
const createdSale = await models.Sale.create({
|
const createdSale = await models.Sale.create({
|
||||||
|
@ -130,7 +135,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) {
|
async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
|
||||||
const filter = {include: {relation: 'address'}};
|
const filter = {include: {relation: 'address'}};
|
||||||
|
@ -142,6 +147,7 @@ module.exports = Self => {
|
||||||
addressFk: ticket.address().id,
|
addressFk: ticket.address().id,
|
||||||
agencyModeFk: refundAgencyMode.id,
|
agencyModeFk: refundAgencyMode.id,
|
||||||
nickname: ticket.address().nickname,
|
nickname: ticket.address().nickname,
|
||||||
|
warehouseFk: withWarehouse ? ticket.warehouseFk : null,
|
||||||
companyFk: ticket.companyFk,
|
companyFk: ticket.companyFk,
|
||||||
landed: now,
|
landed: now,
|
||||||
zoneFk: refoundZoneId
|
zoneFk: refoundZoneId
|
||||||
|
|
Loading…
Reference in New Issue