diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 48ec17535..a9b91a509 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -228,5 +228,7 @@ "InvoiceIn is already booked": "InvoiceIn is already booked", "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", - "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" + } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 169b4bc01..80261afc7 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -360,5 +360,6 @@ "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", "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" } diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 2bb23c3fc..d3b69169f 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -357,5 +357,6 @@ "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", "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é" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 1ebcfa3de..9b5cf61bb 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -357,5 +357,6 @@ "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", "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" } diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js index f5530d772..0c86e5810 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js @@ -66,6 +66,7 @@ module.exports = Self => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; let invoiceId; + let refundId; let tx; if (typeof options == 'object') @@ -110,7 +111,7 @@ module.exports = Self => { }; 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) invoiceId = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, null, myOptions); @@ -123,10 +124,15 @@ module.exports = Self => { if (tx && makeInvoice) { try { - await models.InvoiceOut.makePdfList(ctx, invoiceId, null); + await models.InvoiceOut.makePdfList(ctx, invoiceId); } catch (e) { 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; };