diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 568916bef..059da6356 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -203,5 +203,7 @@ "Cannot past travels with entries": "Cannot past travels with entries", "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", "Incorrect pin": "Incorrect pin.", - "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified" + "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", + "Fecha fuera de rango": "Fecha fuera de rango", + "There is no zone for these parameters 34": "There is no zone for these parameters 34" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 83222a4ee..706da6f39 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -108,6 +108,23 @@ module.exports = function(Self) { await Self.rawSql('CALL invoiceOutBooking(?)', [resultInvoice.id], myOptions); + const client = await models.Client.findById(clientId, + {fields: ['hasElectronicInvoice', 'name', 'email']}, myOptions); + if (client.hasElectronicInvoice) { + const url = await models.Url.getUrl(); + await models.NotificationQueue.create({ + notificationFk: 'invoice-electronic', + authorFk: client.id, + params: JSON.stringify( + { + 'name': client.name, + 'email': client.email, + 'ticketId': ticketsIds.join(','), + 'url': url + 'ticket/index?q=' + encodeURIComponent(JSON.stringify({clientFk: clientId})) + }) + }, myOptions); + } + if (tx) await tx.commit(); return resultInvoice.id; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 297d8ee1b..e71913267 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -248,23 +248,6 @@ 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/invoiceTicketsAndPdf`, {ticketsIds: [this.id]}) .then(() => this.reload()) .then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced'))); diff --git a/print/templates/email/invoice-electronic/invoice-electronic.js b/print/templates/email/invoice-electronic/invoice-electronic.js index 2e1e739ac..1ec6d1374 100644 --- a/print/templates/email/invoice-electronic/invoice-electronic.js +++ b/print/templates/email/invoice-electronic/invoice-electronic.js @@ -10,7 +10,7 @@ module.exports = { required: true }, ticketId: { - type: [Number], + type: [String], required: true }, url: {