refs #5328 mod funcion createTicketRefund
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2023-05-03 12:30:33 +02:00
parent 34a9b3768c
commit eaf425fb51
1 changed files with 5 additions and 3 deletions

View File

@ -11,7 +11,7 @@ module.exports = Self => {
{ {
arg: 'servicesIds', arg: 'servicesIds',
type: ['number'] type: ['number']
} },
], ],
returns: { returns: {
type: ['number'], type: ['number'],
@ -110,11 +110,13 @@ module.exports = Self => {
} }
}; };
async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) { async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions, vTicketId) {
const models = Self.app.models; const models = Self.app.models;
const filter = {include: {relation: 'address'}}; const filter = {include: {relation: 'address'}};
const ticket = await models.Ticket.findById(ticketId, filter, myOptions); const ticket = await models.Ticket.findById(ticketId, filter, myOptions);
const query = `CALL vn.ticket_recalc(?)`;
const [result] = await Self.rawSql(query, [vTicketId]);
const refundTicket = await models.Ticket.create({ const refundTicket = await models.Ticket.create({
clientFk: ticket.clientFk, clientFk: ticket.clientFk,
@ -131,7 +133,7 @@ module.exports = Self => {
await models.TicketRefund.create({ await models.TicketRefund.create({
refundTicketFk: refundTicket.id, refundTicketFk: refundTicket.id,
originalTicketFk: ticket.id, originalTicketFk: ticket.id,
}, myOptions); }, myOptions, [result]);
return refundTicket; return refundTicket;
} }