diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 83222a4ee..1fcbd4130 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -110,7 +110,14 @@ module.exports = function(Self) { if (tx) await tx.commit(); - return resultInvoice.id; + const notificationInfo = { + clientName: firstTicket.clientFk.name, + clientEmail: firstTicket.clientFk.email, + ticketId: resultInvoice.id, + url: ctx.req.headers.referer + }; + + return {invoiceId: resultInvoice.id, notificationInfo}; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index cd819e623..4e33d2c43 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -248,26 +248,30 @@ class Controller extends Section { if (this.ticket.address.incotermsFk && !this.ticket.weight && !force) return this.$.withoutWeightConfirmation.show(); - const client = this.ticket.client; - if (client.hasElectronicInvoice) { - this.$http.post(`NotificationQueues`, { - notificationFk: 'invoice-electronic', - authorFk: client.id, - params: JSON.stringify( - { - 'name': client.name, - 'email': client.email, - 'ticketId': this.id, - 'url': window.location.href - }) - }).then(() => { - this.vnApp.showSuccess(this.$t('Invoice sent')); - }); - } - return this.$http.post(`Tickets/invoiceTickets`, {ticketsIds: [this.id]}) .then(() => this.reload()) - .then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced'))); + .then(() => { + const client = this.ticket.client; + + if (client.hasElectronicInvoice) { + const notificationData = { + name: client.name, + email: client.email, + ticketId: this.id, + url: window.location.href + }; + + this.$http.post(`NotificationQueues`, { + notificationFk: 'invoice-electronic', + authorFk: client.id, + params: JSON.stringify(notificationData) + }).then(() => { + this.vnApp.showSuccess(this.$t('Invoice sent')); + }); + } + + this.vnApp.showSuccess(this.$t('Ticket invoiced')); + }); } createPdfInvoice() {