From 9986d4eb03a26be0e0c9e899a9121f164775d4c2 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 19 Oct 2021 13:46:17 +0200 Subject: [PATCH 1/2] feat(closure): should mail the PDF invoice invoiceable clients Refs: 3211 --- db/dump/fixtures.sql | 3 ++- print/methods/closure.js | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 1635335c4..b0ea0b599 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -485,7 +485,8 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF VALUES ('A', 'Global nacional', 1, 'NATIONAL', 0), ('T', 'Española rapida', 1, 'NATIONAL', 0), - ('V', 'Intracomunitaria global', 0, 'CEE', 1); + ('V', 'Intracomunitaria global', 0, 'CEE', 1), + ('M', 'Múltiple nacional', 1, 'NATIONAL', 0); INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES diff --git a/print/methods/closure.js b/print/methods/closure.js index daa2d5e7c..450bd0ed2 100644 --- a/print/methods/closure.js +++ b/print/methods/closure.js @@ -190,8 +190,7 @@ module.exports = app => { try { await db.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id]); - const hasToInvoice = ticket.hasToInvoice && ticket.hasDailyInvoice; - if (!ticket.salesPersonFk || !ticket.isToBeMailed || hasToInvoice) continue; + if (!ticket.salesPersonFk || !ticket.isToBeMailed) continue; if (!ticket.recipient) { const body = `No se ha podido enviar el albarán ${ticket.id} @@ -206,15 +205,35 @@ module.exports = app => { continue; } - const args = Object.assign({ - ticketId: ticket.id, - recipientId: ticket.clientFk, - recipient: ticket.recipient, - replyTo: ticket.salesPersonEmail - }, reqArgs); + const hasToInvoice = ticket.hasToInvoice && ticket.hasDailyInvoice; + if (hasToInvoice) { + const invoiceId = await db.findValue(` + SELECT io.id + FROM ticket t + JOIN invoiceOut io ON io.ref = t.refFk + WHERE t.id = ? + `, [ticket.id]); - const email = new Email('delivery-note-link', args); - await email.send(); + const args = Object.assign({ + invoiceId: invoiceId, + recipientId: ticket.clientFk, + recipient: ticket.recipient, + replyTo: ticket.salesPersonEmail + }, reqArgs); + + const email = new Email('invoice', args); + await email.send(); + } else { + const args = Object.assign({ + ticketId: ticket.id, + recipientId: ticket.clientFk, + recipient: ticket.recipient, + replyTo: ticket.salesPersonEmail + }, reqArgs); + + const email = new Email('delivery-note-link', args); + await email.send(); + } } catch (error) { // Domain not found if (error.responseCode == 450) From 5ea014aeffa6753f2629002932f1aee01eaec9e0 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 20 Oct 2021 14:40:08 +0200 Subject: [PATCH 2/2] feat(monitors): added auto-refresh feature to ticket monitors --- modules/monitor/front/index/index.html | 2 +- modules/monitor/front/index/index.js | 15 +++++++- modules/monitor/front/index/index.spec.js | 38 +++++++++++++++++++ modules/monitor/front/index/locale/es.yml | 4 +- .../monitor/front/index/tickets/index.html | 5 +++ modules/monitor/front/index/tickets/index.js | 9 +++++ 6 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 modules/monitor/front/index/index.spec.js diff --git a/modules/monitor/front/index/index.html b/modules/monitor/front/index/index.html index 7b393e722..85987ac20 100644 --- a/modules/monitor/front/index/index.html +++ b/modules/monitor/front/index/index.html @@ -1,4 +1,4 @@ - + diff --git a/modules/monitor/front/index/index.js b/modules/monitor/front/index/index.js index 2e1b3b1a1..72ca9dae9 100644 --- a/modules/monitor/front/index/index.js +++ b/modules/monitor/front/index/index.js @@ -3,14 +3,25 @@ import Section from 'salix/components/section'; import './style.scss'; export default class Controller extends Section { + constructor($element, $) { + super($element, $); + + const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden'); + if (isTopPanelHidden === 'true') + this.isTopPanelHidden = true; + } + toggle() { const monitor = this.element.querySelector('vn-horizontal'); const isHidden = monitor.classList.contains('hidden'); - if (!isHidden) + if (!isHidden) { monitor.classList.add('hidden'); - else + localStorage.setItem('ticketTopPanelHidden', true); + } else { monitor.classList.remove('hidden'); + localStorage.setItem('ticketTopPanelHidden', false); + } } } diff --git a/modules/monitor/front/index/index.spec.js b/modules/monitor/front/index/index.spec.js new file mode 100644 index 000000000..506e75720 --- /dev/null +++ b/modules/monitor/front/index/index.spec.js @@ -0,0 +1,38 @@ +import './index.js'; +describe('Component vnMonitorIndex', () => { + let controller; + let $element; + + beforeEach(ngModule('monitor')); + + beforeEach(inject(($compile, $rootScope) => { + $element = $compile('')($rootScope); + controller = $element.controller('vnMonitorIndex'); + })); + + describe('toggle()', () => { + it('should add the hidden class to the horizontal contaning the panel to hide', () => { + controller.toggle(); + + const targetElement = $element[0].querySelector('vn-horizontal'); + const firstClass = targetElement.classList[0]; + + const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden'); + + expect(firstClass).toEqual('hidden'); + expect(isTopPanelHidden).toEqual('true'); + }); + + it('should remove the hidden class to the horizontal contaning the panel to hide', () => { + const targetElement = $element[0].querySelector('vn-horizontal'); + targetElement.classList.add('hidden'); + controller.toggle(); + const firstClass = targetElement.classList[0]; + + const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden'); + + expect(firstClass).toBeUndefined(); + expect(isTopPanelHidden).toEqual('false'); + }); + }); +}); diff --git a/modules/monitor/front/index/locale/es.yml b/modules/monitor/front/index/locale/es.yml index 4eef3c93f..b17861e9f 100644 --- a/modules/monitor/front/index/locale/es.yml +++ b/modules/monitor/front/index/locale/es.yml @@ -8,4 +8,6 @@ Component lack: Faltan componentes Minimize/Maximize: Minimizar/Maximizar Problems: Problemas Theoretical: Teórica -Practical: Práctica \ No newline at end of file +Practical: Práctica +Auto-refresh: Auto-refresco +Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos \ No newline at end of file diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index ff378adda..93117d970 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -22,6 +22,11 @@ Tickets monitor + + this.$.model.refresh(), 120000); + else { + clearInterval(this.refreshTimer); + this.refreshTimer = null; + } + } } ngModule.vnComponent('vnMonitorSalesTickets', {