feat(transferInvoice): makePdf of refund
gitea/salix/pipeline/pr-master There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2024-06-05 12:44:28 +02:00
parent 788f334e70
commit a33f14ffa5
5 changed files with 17 additions and 6 deletions

View File

@ -228,5 +228,7 @@
"InvoiceIn is already booked": "InvoiceIn is already booked", "InvoiceIn is already booked": "InvoiceIn is already booked",
"This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency",
"You can only have one PDA": "You can only have one PDA", "You can only have one PDA": "You can only have one PDA",
"It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated" "It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated",
"It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated"
} }

View File

@ -360,5 +360,6 @@
"ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)",
"This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
"You can only have one PDA": "Solo puedes tener un PDA", "You can only have one PDA": "Solo puedes tener un PDA",
"It has been invoiced but the PDF could not be generated": "Se ha facturado pero no se ha podido generar el PDF" "It has been invoiced but the PDF could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono"
} }

View File

@ -357,5 +357,6 @@
"This workCenter is already assigned to this agency": "Ce centre de travail est déjà assigné à cette agence", "This workCenter is already assigned to this agency": "Ce centre de travail est déjà assigné à cette agence",
"Select ticket or client": "Choisissez un ticket ou un client", "Select ticket or client": "Choisissez un ticket ou un client",
"It was not able to create the invoice": "Il n'a pas été possible de créer la facture", "It was not able to create the invoice": "Il n'a pas été possible de créer la facture",
"It has been invoiced but the PDF could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré" "It has been invoiced but the PDF could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré",
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré"
} }

View File

@ -357,5 +357,6 @@
"This workCenter is already assigned to this agency": "Este centro de trabalho já está atribuído a esta agência", "This workCenter is already assigned to this agency": "Este centro de trabalho já está atribuído a esta agência",
"Select ticket or client": "Selecione um ticket ou cliente", "Select ticket or client": "Selecione um ticket ou cliente",
"It was not able to create the invoice": "Não foi possível criar a fatura", "It was not able to create the invoice": "Não foi possível criar a fatura",
"It has been invoiced but the PDF could not be generated": "Foi faturado, mas o PDF não pôde ser gerado" "It has been invoiced but the PDF could not be generated": "Foi faturado, mas o PDF não pôde ser gerado",
"It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso"
} }

View File

@ -66,6 +66,7 @@ module.exports = Self => {
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 invoiceId; let invoiceId;
let refundId;
let tx; let tx;
if (typeof options == 'object') if (typeof options == 'object')
@ -110,7 +111,7 @@ module.exports = Self => {
}; };
const refundTicketIds = refundTickets.map(ticket => ticket.id); const refundTicketIds = refundTickets.map(ticket => ticket.id);
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions); refundId = await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
if (makeInvoice) if (makeInvoice)
invoiceId = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, null, myOptions); invoiceId = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, null, myOptions);
@ -123,10 +124,15 @@ module.exports = Self => {
if (tx && makeInvoice) { if (tx && makeInvoice) {
try { try {
await models.InvoiceOut.makePdfList(ctx, invoiceId, null); await models.InvoiceOut.makePdfList(ctx, invoiceId);
} catch (e) { } catch (e) {
throw new UserError('It has been invoiced but the PDF could not be generated'); throw new UserError('It has been invoiced but the PDF could not be generated');
} }
try {
await models.InvoiceOut.makePdfList(ctx, refundId);
} catch (e) {
throw new UserError('It has been invoiced but the PDF of refund not be generated');
}
} }
return invoiceId; return invoiceId;
}; };