diff --git a/db/changes/10502-november/00-ACL_notification_InvoiceE.sql b/db/changes/10502-november/00-ACL_notification_InvoiceE.sql new file mode 100644 index 0000000000..bc13dd8da9 --- /dev/null +++ b/db/changes/10502-november/00-ACL_notification_InvoiceE.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('notificationQueue','*','*','ALLOW','ROLE','invoicing'); diff --git a/db/changes/10502-november/00-insert_notification_invoiceE.sql b/db/changes/10502-november/00-insert_notification_invoiceE.sql new file mode 100644 index 0000000000..1d416c1969 --- /dev/null +++ b/db/changes/10502-november/00-insert_notification_invoiceE.sql @@ -0,0 +1 @@ +insert into `util`.`notification` (`id`, `name`,`description`) values (2, 'invoiceElectronic', 'A electronic invoice has been generated'); \ No newline at end of file diff --git a/db/changes/10502-november/00-update-client-invoiceE.sql b/db/changes/10502-november/00-update-client-invoiceE.sql new file mode 100644 index 0000000000..c07167b38c --- /dev/null +++ b/db/changes/10502-november/00-update-client-invoiceE.sql @@ -0,0 +1,3 @@ +UPDATE `vn`.`client` +set hasInvoiceElectronic = TRUE +where buisnessTypeFk = 'officialOrganism' \ No newline at end of file diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 1667d33570..26db525afb 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -161,16 +161,10 @@ module.exports = Self => { delete args.ctx; delete args.id; - console.log(args); - const updatedClient = await client.updateAttributes(args, myOptions); - console.log('10'); - if (tx) await tx.commit(); - console.log('11'); - return updatedClient; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index f73aae721b..d323043221 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -224,8 +224,21 @@ class Controller extends Section { this.$.sms.open(); } - makeInvoice() { + async makeInvoice() { const params = {ticketsIds: [this.id]}; + + const clientData = await this.$http.get(`Clients/${this.ticket.client.id}`); + + console.log('invoiceE', clientData); + + if (clientData.data.hasInvoiceElectronic) { + this.$http.post(`NotificationQueuesAdd`, { + notificationFk: 'invoiceElectronic' + }); + /* This should call the notification sistem to insert a new notification + in te queue, yet to check how to handle user permissions */ + } + return this.$http.post(`Tickets/makeInvoice`, params) .then(() => this.reload()) .then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced')));