This commit is contained in:
parent
9b8c58ba7d
commit
509d5cea14
|
@ -108,16 +108,26 @@ module.exports = function(Self) {
|
||||||
|
|
||||||
await Self.rawSql('CALL invoiceOutBooking(?)', [resultInvoice.id], myOptions);
|
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();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
const notificationInfo = {
|
return resultInvoice.id;
|
||||||
clientName: firstTicket.clientFk.name,
|
|
||||||
clientEmail: firstTicket.clientFk.email,
|
|
||||||
ticketId: resultInvoice.id,
|
|
||||||
url: ctx.req.headers.referer
|
|
||||||
};
|
|
||||||
|
|
||||||
return {invoiceId: resultInvoice.id, notificationInfo};
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -250,28 +250,7 @@ class Controller extends Section {
|
||||||
|
|
||||||
return this.$http.post(`Tickets/invoiceTickets`, {ticketsIds: [this.id]})
|
return this.$http.post(`Tickets/invoiceTickets`, {ticketsIds: [this.id]})
|
||||||
.then(() => this.reload())
|
.then(() => this.reload())
|
||||||
.then(() => {
|
.then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced')));
|
||||||
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() {
|
createPdfInvoice() {
|
||||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
ticketId: {
|
ticketId: {
|
||||||
type: [Number],
|
type: [String],
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
url: {
|
url: {
|
||||||
|
|
Loading…
Reference in New Issue