26 lines
883 B
JavaScript
26 lines
883 B
JavaScript
module.exports = async function createTicketRefund(models, ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) {
|
|
// const models = Self.app.models;
|
|
|
|
const filter = {include: {relation: 'address'}};
|
|
const ticket = await models.Ticket.findById(ticketId, filter, myOptions);
|
|
|
|
const refundTicket = await models.Ticket.create({
|
|
clientFk: ticket.clientFk,
|
|
shipped: now,
|
|
addressFk: ticket.address().id,
|
|
agencyModeFk: refundAgencyMode.id,
|
|
nickname: ticket.address().nickname,
|
|
warehouseFk: withWarehouse ? ticket.warehouseFk : null,
|
|
companyFk: ticket.companyFk,
|
|
landed: now,
|
|
zoneFk: refoundZoneId
|
|
}, myOptions);
|
|
|
|
await models.TicketRefund.create({
|
|
refundTicketFk: refundTicket.id,
|
|
originalTicketFk: ticket.id,
|
|
}, myOptions);
|
|
|
|
return refundTicket;
|
|
};
|