From c5fb565484532e955e30cd7b1f3e54dc3fceaf85 Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Tue, 15 Nov 2022 10:25:33 +0100 Subject: [PATCH 01/28] refs #4503 message added --- back/methods/chat/sendCheckingPresence.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3bc022429c..075591969b 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -43,6 +43,9 @@ module.exports = Self => { if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); + if (process.env.NODE_ENV == 'test') + message = `[Test:Environment to user ${userId}] ` + message; + await models.Chat.create({ senderFk: sender.id, recipient: `@${recipient.name}`, From 4e97d931f7f9a057b72956fe753d8d6a5a4980cd Mon Sep 17 00:00:00 2001 From: Pau Navarro <pau@verdnatura.es> Date: Mon, 21 Nov 2022 08:45:45 +0100 Subject: [PATCH 02/28] refs #4791 @2h --- front/core/components/index.js | 1 + .../core/components/sendSms}/index.html | 0 front/core/components/sendSms/index.js | 52 +++++++++++++ .../core/components/sendSms}/locale/es.yml | 0 .../core/components/sendSms}/style.scss | 0 modules/client/front/descriptor/index.html | 8 +- modules/client/front/descriptor/index.js | 5 +- modules/client/front/index.js | 1 - modules/client/front/sms/index.js | 49 ------------ modules/client/front/sms/index.spec.js | 74 ------------------- .../ticket/front/descriptor-menu/index.html | 4 +- modules/ticket/front/descriptor-menu/index.js | 3 +- modules/ticket/front/index.js | 1 - modules/ticket/front/sms/index.html | 45 ----------- modules/ticket/front/sms/index.js | 47 ------------ modules/ticket/front/sms/index.spec.js | 71 ------------------ modules/ticket/front/sms/locale/es.yml | 9 --- modules/ticket/front/sms/style.scss | 5 -- 18 files changed, 65 insertions(+), 310 deletions(-) rename {modules/client/front/sms => front/core/components/sendSms}/index.html (100%) create mode 100644 front/core/components/sendSms/index.js rename {modules/client/front/sms => front/core/components/sendSms}/locale/es.yml (100%) rename {modules/client/front/sms => front/core/components/sendSms}/style.scss (100%) delete mode 100644 modules/client/front/sms/index.js delete mode 100644 modules/client/front/sms/index.spec.js delete mode 100644 modules/ticket/front/sms/index.html delete mode 100644 modules/ticket/front/sms/index.js delete mode 100644 modules/ticket/front/sms/index.spec.js delete mode 100644 modules/ticket/front/sms/locale/es.yml delete mode 100644 modules/ticket/front/sms/style.scss diff --git a/front/core/components/index.js b/front/core/components/index.js index 86ab892122..723b39bafe 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -53,3 +53,4 @@ import './datalist'; import './contextmenu'; import './rating'; import './smart-table'; +import './sendSms'; diff --git a/modules/client/front/sms/index.html b/front/core/components/sendSms/index.html similarity index 100% rename from modules/client/front/sms/index.html rename to front/core/components/sendSms/index.html diff --git a/front/core/components/sendSms/index.js b/front/core/components/sendSms/index.js new file mode 100644 index 0000000000..3d67627dd5 --- /dev/null +++ b/front/core/components/sendSms/index.js @@ -0,0 +1,52 @@ +import ngModule from '../../module'; +import './style.scss'; + +export default class sendSmsDialog { + constructor($element, $scope, $http, $translate, vnApp) { + this.$element = $element; + this.$scope = $scope; + this.$http = $http; + this.$t = $translate; + this.vnApp = vnApp; + } + + open(route) { + this.route = route; + this.$scope.SMSDialog.show(); + } + + charactersRemaining() { + const element = this.sms.message; + const maxLength = 160; + return maxLength - element.length; + } + + onResponse() { + try { + if (!this.sms.destination) + throw new Error(`The destination can't be empty`); + if (!this.sms.message) + throw new Error(`The message can't be empty`); + if (this.charactersRemaining() < 0) + throw new Error(`The message it's too long`); + + this.$http.post(this.route, this.sms).then(res => { + this.vnApp.showMessage(this.$t.instant('SMS sent!')); + }); + } catch (e) { + this.vnApp.showError(this.$t.instant(e.message)); + return false; + } + return true; + } +} + +sendSmsDialog.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp']; + +ngModule.vnComponent('vnSmsDialog', { + template: require('./index.html'), + controller: sendSmsDialog, + bindings: { + sms: '<', + } +}); diff --git a/modules/client/front/sms/locale/es.yml b/front/core/components/sendSms/locale/es.yml similarity index 100% rename from modules/client/front/sms/locale/es.yml rename to front/core/components/sendSms/locale/es.yml diff --git a/modules/client/front/sms/style.scss b/front/core/components/sendSms/style.scss similarity index 100% rename from modules/client/front/sms/style.scss rename to front/core/components/sendSms/style.scss diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index cad2264169..9973a64717 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -113,10 +113,10 @@ </div> </slot-body> </vn-descriptor-content> -<vn-client-sms - vn-id="sms" - sms="$ctrl.newSMS"> -</vn-client-sms> +<vn-sms-dialog +vn-id="sms" +sms="$ctrl.newSMS"> +</vn-sms-dialog> <vn-worker-descriptor-popover vn-id="workerDescriptor"> </vn-worker-descriptor-popover> diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 4a0d1cd2ab..0051afe946 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -37,7 +37,10 @@ class Controller extends Descriptor { destination: this.$params.phone || client.mobile || client.phone, message: this.$params.message || '' }; - this.$.sms.open(); + + const route = `Clients/${this.id}/sendSms`; + + this.$.sms.open(route); } } diff --git a/modules/client/front/index.js b/modules/client/front/index.js index a5782c7892..ff767bc9ec 100644 --- a/modules/client/front/index.js +++ b/modules/client/front/index.js @@ -35,7 +35,6 @@ import './sample/index'; import './sample/create'; import './web-payment'; import './log'; -import './sms'; import './postcode'; import './postcode/province'; import './postcode/city'; diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js deleted file mode 100644 index 701ee39af6..0000000000 --- a/modules/client/front/sms/index.js +++ /dev/null @@ -1,49 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - open() { - this.$.SMSDialog.show(); - } - - charactersRemaining() { - const element = this.$.message; - const value = element.input.value; - - const maxLength = 160; - const textAreaLength = new Blob([value]).size; - return maxLength - textAreaLength; - } - - onResponse() { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); - - this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$t('SMS sent!')); - - if (res.data) this.emit('send', {response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; - } -} - -Controller.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp']; - -ngModule.vnComponent('vnClientSms', { - template: require('./index.html'), - controller: Controller, - bindings: { - sms: '<', - } -}); diff --git a/modules/client/front/sms/index.spec.js b/modules/client/front/sms/index.spec.js deleted file mode 100644 index 793c80d6eb..0000000000 --- a/modules/client/front/sms/index.spec.js +++ /dev/null @@ -1,74 +0,0 @@ -import './index'; - -describe('Client', () => { - describe('Component vnClientSms', () => { - let controller; - let $httpBackend; - let $element; - - beforeEach(ngModule('client')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - let $scope = $rootScope.$new(); - $element = angular.element('<vn-dialog></vn-dialog>'); - controller = $componentController('vnClientSms', {$element, $scope}); - controller.client = {id: 1101}; - controller.$params = {id: 1101}; - controller.$.message = { - input: { - value: 'My SMS' - } - }; - })); - - describe('onResponse()', () => { - it('should perform a POST query and show a success snackbar', () => { - let params = {destinationFk: 1101, destination: 111111111, message: 'My SMS'}; - controller.sms = {destinationFk: 1101, destination: 111111111, message: 'My SMS'}; - - jest.spyOn(controller.vnApp, 'showMessage'); - $httpBackend.expect('POST', `Clients/1101/sendSms`, params).respond(200, params); - - controller.onResponse(); - $httpBackend.flush(); - - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); - }); - - it('should call onResponse without the destination and show an error snackbar', () => { - controller.sms = {destinationFk: 1101, message: 'My SMS'}; - - jest.spyOn(controller.vnApp, 'showError'); - - controller.onResponse('accept'); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`); - }); - - it('should call onResponse without the message and show an error snackbar', () => { - controller.sms = {destinationFk: 1101, destination: 222222222}; - - jest.spyOn(controller.vnApp, 'showError'); - - controller.onResponse('accept'); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`); - }); - }); - - describe('charactersRemaining()', () => { - it('should return the characters remaining in a element', () => { - controller.$.message = { - input: { - value: 'My message 0€' - } - }; - - let result = controller.charactersRemaining(); - - expect(result).toEqual(145); - }); - }); - }); -}); diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index 0c04b42fb9..eb15901d63 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -280,10 +280,10 @@ </vn-dialog> <!-- Send SMS popup --> -<vn-ticket-sms +<vn-sms-dialog vn-id="sms" sms="$ctrl.newSMS"> -</vn-ticket-sms> +</vn-sms-dialog> <!-- Make invoice confirmation dialog --> <vn-confirm diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index e0e7ea849d..0a00bf7edb 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -225,6 +225,7 @@ class Controller extends Section { } showSMSDialog(params) { + const route = `Tickets/${this.id}/sendSms`; const address = this.ticket.address; const client = this.ticket.client; const phone = this.$params.phone @@ -238,7 +239,7 @@ class Controller extends Section { destinationFk: this.ticket.clientFk, destination: phone }, params); - this.$.sms.open(); + this.$.sms.open(route); } makeInvoice() { diff --git a/modules/ticket/front/index.js b/modules/ticket/front/index.js index 0558d251d1..4e659e74a5 100644 --- a/modules/ticket/front/index.js +++ b/modules/ticket/front/index.js @@ -32,5 +32,4 @@ import './weekly'; import './dms/index'; import './dms/create'; import './dms/edit'; -import './sms'; import './boxing'; diff --git a/modules/ticket/front/sms/index.html b/modules/ticket/front/sms/index.html deleted file mode 100644 index 97bdfef14f..0000000000 --- a/modules/ticket/front/sms/index.html +++ /dev/null @@ -1,45 +0,0 @@ -<vn-dialog - vn-id="SMSDialog" - on-accept="$ctrl.onResponse()" - message="Send SMS"> - <tpl-body> - <section class="SMSDialog"> - <vn-horizontal> - <vn-textfield - vn-one - label="Destination" - ng-model="$ctrl.sms.destination" - required="true" - rule> - </vn-textfield> - </vn-horizontal> - <vn-horizontal > - <vn-textarea vn-one - vn-id="message" - label="Message" - ng-model="$ctrl.sms.message" - info="Special characters like accents counts as a multiple" - rows="5" - required="true" - rule> - </vn-textarea> - </vn-horizontal> - <vn-horizontal> - <span> - {{'Characters remaining' | translate}}: - <vn-chip translate-attr="{title: 'Packing'}" ng-class="{ - 'colored': $ctrl.charactersRemaining() > 25, - 'warning': $ctrl.charactersRemaining() <= 25, - 'alert': $ctrl.charactersRemaining() < 0, - }"> - {{$ctrl.charactersRemaining()}} - </vn-chip> - </span> - </vn-horizontal> - </section> - </tpl-body> - <tpl-buttons> - <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/> - <button response="accept" translate>Send</button> - </tpl-buttons> -</vn-dialog> \ No newline at end of file diff --git a/modules/ticket/front/sms/index.js b/modules/ticket/front/sms/index.js deleted file mode 100644 index 6bc252dc12..0000000000 --- a/modules/ticket/front/sms/index.js +++ /dev/null @@ -1,47 +0,0 @@ -import ngModule from '../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - open() { - this.$.SMSDialog.show(); - } - - charactersRemaining() { - const element = this.$.message; - const value = element.input.value; - - const maxLength = 160; - const textAreaLength = new Blob([value]).size; - return maxLength - textAreaLength; - } - - onResponse() { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); - - this.$http.post(`Tickets/${this.sms.ticketId}/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$t('SMS sent!')); - - if (res.data) this.emit('send', {response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; - } -} - -ngModule.vnComponent('vnTicketSms', { - template: require('./index.html'), - controller: Controller, - bindings: { - sms: '<', - } -}); diff --git a/modules/ticket/front/sms/index.spec.js b/modules/ticket/front/sms/index.spec.js deleted file mode 100644 index b133db04dd..0000000000 --- a/modules/ticket/front/sms/index.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -import './index'; - -describe('Ticket', () => { - describe('Component vnTicketSms', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('ticket')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - let $scope = $rootScope.$new(); - const $element = angular.element('<vn-dialog></vn-dialog>'); - controller = $componentController('vnTicketSms', {$element, $scope}); - controller.$.message = { - input: { - value: 'My SMS' - } - }; - })); - - describe('onResponse()', () => { - it('should perform a POST query and show a success snackbar', () => { - let params = {ticketId: 11, destinationFk: 1101, destination: 111111111, message: 'My SMS'}; - controller.sms = {ticketId: 11, destinationFk: 1101, destination: 111111111, message: 'My SMS'}; - - jest.spyOn(controller.vnApp, 'showMessage'); - $httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params); - - controller.onResponse(); - $httpBackend.flush(); - - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); - }); - - it('should call onResponse without the destination and show an error snackbar', () => { - controller.sms = {destinationFk: 1101, message: 'My SMS'}; - - jest.spyOn(controller.vnApp, 'showError'); - - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`); - }); - - it('should call onResponse without the message and show an error snackbar', () => { - controller.sms = {destinationFk: 1101, destination: 222222222}; - - jest.spyOn(controller.vnApp, 'showError'); - - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`); - }); - }); - - describe('charactersRemaining()', () => { - it('should return the characters remaining in a element', () => { - controller.$.message = { - input: { - value: 'My message 0€' - } - }; - - let result = controller.charactersRemaining(); - - expect(result).toEqual(145); - }); - }); - }); -}); diff --git a/modules/ticket/front/sms/locale/es.yml b/modules/ticket/front/sms/locale/es.yml deleted file mode 100644 index 64c3fcca67..0000000000 --- a/modules/ticket/front/sms/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Send SMS: Enviar SMS -Destination: Destinatario -Message: Mensaje -SMS sent!: ¡SMS enviado! -Characters remaining: Carácteres restantes -The destination can't be empty: El destinatario no puede estar vacio -The message can't be empty: El mensaje no puede estar vacio -The message it's too long: El mensaje es demasiado largo -Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file diff --git a/modules/ticket/front/sms/style.scss b/modules/ticket/front/sms/style.scss deleted file mode 100644 index 84571a5f42..0000000000 --- a/modules/ticket/front/sms/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "variables"; - -.SMSDialog { - min-width: 400px -} \ No newline at end of file From 153f5f56fa4c2a82b43942f0b5485578738f6cdb Mon Sep 17 00:00:00 2001 From: Pau Navarro <pau@verdnatura.es> Date: Mon, 21 Nov 2022 09:11:17 +0100 Subject: [PATCH 03/28] fix test refs #4791 @30min --- modules/ticket/front/descriptor-menu/index.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 1716e36f6f..6e690464ed 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -261,11 +261,12 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { describe('showSMSDialog()', () => { it('should set the destionationFk and destination properties and then call the sms open() method', () => { controller.$.sms = {open: () => {}}; + let route = `Tickets/${ticket.id}/sendSms`; jest.spyOn(controller.$.sms, 'open'); controller.showSMSDialog(); - expect(controller.$.sms.open).toHaveBeenCalledWith(); + expect(controller.$.sms.open).toHaveBeenCalledWith(route); expect(controller.newSMS).toEqual({ destinationFk: ticket.clientFk, destination: ticket.address.mobile, From 4bd643143bf94cc1fb2432ef7556057651db8687 Mon Sep 17 00:00:00 2001 From: Pau Navarro <pau@verdnatura.es> Date: Tue, 22 Nov 2022 07:59:18 +0100 Subject: [PATCH 04/28] requested changes refs #4791 @1h --- front/core/components/sendSms/index.js | 28 +++++++++---------- modules/client/front/descriptor/index.html | 4 +-- modules/client/front/descriptor/index.js | 4 ++- modules/ticket/front/descriptor-menu/index.js | 5 +++- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/front/core/components/sendSms/index.js b/front/core/components/sendSms/index.js index 3d67627dd5..69975e7f7b 100644 --- a/front/core/components/sendSms/index.js +++ b/front/core/components/sendSms/index.js @@ -1,18 +1,20 @@ import ngModule from '../../module'; import './style.scss'; +import Dialog from '../dialog'; -export default class sendSmsDialog { +export default class sendSmsDialog extends Dialog { constructor($element, $scope, $http, $translate, vnApp) { - this.$element = $element; - this.$scope = $scope; - this.$http = $http; - this.$t = $translate; - this.vnApp = vnApp; - } + super($element, $scope, $http, $translate, vnApp); - open(route) { - this.route = route; - this.$scope.SMSDialog.show(); + new CustomEvent('openSmsDialog', { + detail: { + this: this + } + }); + document.addEventListener('openSmsDialog', e => { + this.route = e.detail.route; + this.$.SMSDialog.show(); + }); } charactersRemaining() { @@ -31,18 +33,16 @@ export default class sendSmsDialog { throw new Error(`The message it's too long`); this.$http.post(this.route, this.sms).then(res => { - this.vnApp.showMessage(this.$t.instant('SMS sent!')); + this.vnApp.showMessage(this.$t('SMS sent!')); }); } catch (e) { - this.vnApp.showError(this.$t.instant(e.message)); + this.vnApp.showError(this.$t(e.message)); return false; } return true; } } -sendSmsDialog.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp']; - ngModule.vnComponent('vnSmsDialog', { template: require('./index.html'), controller: sendSmsDialog, diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 9973a64717..8b8fd8f18b 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -114,8 +114,8 @@ </slot-body> </vn-descriptor-content> <vn-sms-dialog -vn-id="sms" -sms="$ctrl.newSMS"> + vn-id="sms" + sms="$ctrl.newSMS"> </vn-sms-dialog> <vn-worker-descriptor-popover vn-id="workerDescriptor"> diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 0051afe946..473c752f37 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -40,7 +40,9 @@ class Controller extends Descriptor { const route = `Clients/${this.id}/sendSms`; - this.$.sms.open(route); + document.dispatchEvent(new CustomEvent('openSmsDialog', { + detail: {route} + })); } } diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 0a00bf7edb..e29e43a2da 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -239,7 +239,10 @@ class Controller extends Section { destinationFk: this.ticket.clientFk, destination: phone }, params); - this.$.sms.open(route); + + document.dispatchEvent(new CustomEvent('openSmsDialog', { + detail: {route} + })); } makeInvoice() { From 0b6d7eaffc233fa3af9da4fdedb83f11e46aabe3 Mon Sep 17 00:00:00 2001 From: Pau Navarro <pau@verdnatura.es> Date: Wed, 23 Nov 2022 08:20:12 +0100 Subject: [PATCH 05/28] refs #4791 @30min fix broken test --- modules/ticket/front/descriptor-menu/index.spec.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 6e690464ed..f3d8ea3b35 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -261,12 +261,8 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { describe('showSMSDialog()', () => { it('should set the destionationFk and destination properties and then call the sms open() method', () => { controller.$.sms = {open: () => {}}; - let route = `Tickets/${ticket.id}/sendSms`; - jest.spyOn(controller.$.sms, 'open'); - controller.showSMSDialog(); - expect(controller.$.sms.open).toHaveBeenCalledWith(route); expect(controller.newSMS).toEqual({ destinationFk: ticket.clientFk, destination: ticket.address.mobile, From d47e7ffb16b9daef2f1642ff1573c21ef4ee3740 Mon Sep 17 00:00:00 2001 From: Pau Navarro <pau@verdnatura.es> Date: Fri, 25 Nov 2022 08:23:57 +0100 Subject: [PATCH 06/28] change component location --- front/core/components/index.js | 1 - front/salix/components/index.js | 1 + front/salix/components/sendSms/index.html | 45 +++++++++++++++++ front/salix/components/sendSms/index.js | 52 ++++++++++++++++++++ front/salix/components/sendSms/locale/es.yml | 9 ++++ front/salix/components/sendSms/style.scss | 5 ++ 6 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 front/salix/components/sendSms/index.html create mode 100644 front/salix/components/sendSms/index.js create mode 100644 front/salix/components/sendSms/locale/es.yml create mode 100644 front/salix/components/sendSms/style.scss diff --git a/front/core/components/index.js b/front/core/components/index.js index 723b39bafe..86ab892122 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -53,4 +53,3 @@ import './datalist'; import './contextmenu'; import './rating'; import './smart-table'; -import './sendSms'; diff --git a/front/salix/components/index.js b/front/salix/components/index.js index ce4ad585aa..d712a8a40d 100644 --- a/front/salix/components/index.js +++ b/front/salix/components/index.js @@ -16,3 +16,4 @@ import './user-popover'; import './upload-photo'; import './bank-entity'; import './log'; +import './sendSms'; diff --git a/front/salix/components/sendSms/index.html b/front/salix/components/sendSms/index.html new file mode 100644 index 0000000000..6915942c2d --- /dev/null +++ b/front/salix/components/sendSms/index.html @@ -0,0 +1,45 @@ +<vn-dialog + vn-id="SMSDialog" + on-accept="$ctrl.onResponse()"> + <tpl-body> + <section class="SMSDialog"> + <h5 class="vn-py-sm" translate>Send SMS</h5> + <vn-horizontal> + <vn-textfield + vn-one + label="Destination" + ng-model="$ctrl.sms.destination" + required="true" + rule> + </vn-textfield> + </vn-horizontal> + <vn-horizontal> + <vn-textarea vn-one + vn-id="message" + label="Message" + ng-model="$ctrl.sms.message" + info="Special characters like accents counts as a multiple" + rows="5" + required="true" + rule> + </vn-textarea> + </vn-horizontal> + <vn-horizontal> + <span> + {{'Characters remaining' | translate}}: + <vn-chip translate-attr="{title: 'Packing'}" ng-class="{ + 'colored': $ctrl.charactersRemaining() > 25, + 'warning': $ctrl.charactersRemaining() <= 25, + 'alert': $ctrl.charactersRemaining() < 0, + }"> + {{$ctrl.charactersRemaining()}} + </vn-chip> + </span> + </vn-horizontal> + </section> + </tpl-body> + <tpl-buttons> + <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/> + <button response="accept" translate>Send</button> + </tpl-buttons> +</vn-dialog> \ No newline at end of file diff --git a/front/salix/components/sendSms/index.js b/front/salix/components/sendSms/index.js new file mode 100644 index 0000000000..ab57d3acad --- /dev/null +++ b/front/salix/components/sendSms/index.js @@ -0,0 +1,52 @@ +import ngModule from '../../module'; +import './style.scss'; +import Dialog from '../../../core/components/dialog'; + +export default class sendSmsDialog extends Dialog { + constructor($element, $scope, $http, $translate, vnApp) { + super($element, $scope, $http, $translate, vnApp); + + new CustomEvent('openSmsDialog', { + detail: { + this: this + } + }); + document.addEventListener('openSmsDialog', e => { + this.route = e.detail.route; + this.$.SMSDialog.show(); + }); + } + + charactersRemaining() { + const element = this.sms.message; + const maxLength = 160; + return maxLength - element.length; + } + + onResponse() { + try { + if (!this.sms.destination) + throw new Error(`The destination can't be empty`); + if (!this.sms.message) + throw new Error(`The message can't be empty`); + if (this.charactersRemaining() < 0) + throw new Error(`The message it's too long`); + + this.$http.post(this.route, this.sms).then(res => { + this.vnApp.showMessage(this.$t('SMS sent!')); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; + } + return true; + } +} + +ngModule.vnComponent('vnSmsDialog', { + template: require('./index.html'), + controller: sendSmsDialog, + bindings: { + sms: '<', + } +}); diff --git a/front/salix/components/sendSms/locale/es.yml b/front/salix/components/sendSms/locale/es.yml new file mode 100644 index 0000000000..64c3fcca67 --- /dev/null +++ b/front/salix/components/sendSms/locale/es.yml @@ -0,0 +1,9 @@ +Send SMS: Enviar SMS +Destination: Destinatario +Message: Mensaje +SMS sent!: ¡SMS enviado! +Characters remaining: Carácteres restantes +The destination can't be empty: El destinatario no puede estar vacio +The message can't be empty: El mensaje no puede estar vacio +The message it's too long: El mensaje es demasiado largo +Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file diff --git a/front/salix/components/sendSms/style.scss b/front/salix/components/sendSms/style.scss new file mode 100644 index 0000000000..84571a5f42 --- /dev/null +++ b/front/salix/components/sendSms/style.scss @@ -0,0 +1,5 @@ +@import "variables"; + +.SMSDialog { + min-width: 400px +} \ No newline at end of file From 8f980829105b66a6f7dde0dd30f986cd4c4b72cc Mon Sep 17 00:00:00 2001 From: Pau Navarro <pau@verdnatura.es> Date: Fri, 25 Nov 2022 09:59:02 +0100 Subject: [PATCH 07/28] refs #4791 @2h --- front/salix/components/sendSms/index.js | 14 ++++++-------- modules/client/front/descriptor/index.html | 1 + modules/client/front/descriptor/index.js | 10 +++++----- modules/ticket/front/descriptor-menu/index.html | 1 + modules/ticket/front/descriptor-menu/index.js | 10 ++++++---- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/front/salix/components/sendSms/index.js b/front/salix/components/sendSms/index.js index ab57d3acad..0947550b07 100644 --- a/front/salix/components/sendSms/index.js +++ b/front/salix/components/sendSms/index.js @@ -11,10 +11,10 @@ export default class sendSmsDialog extends Dialog { this: this } }); - document.addEventListener('openSmsDialog', e => { - this.route = e.detail.route; - this.$.SMSDialog.show(); - }); + } + + open() { + this.$.SMSDialog.show(); } charactersRemaining() { @@ -32,14 +32,11 @@ export default class sendSmsDialog extends Dialog { if (this.charactersRemaining() < 0) throw new Error(`The message it's too long`); - this.$http.post(this.route, this.sms).then(res => { - this.vnApp.showMessage(this.$t('SMS sent!')); - }); + return this.onSend({$sms: this.sms}); } catch (e) { this.vnApp.showError(this.$t(e.message)); return false; } - return true; } } @@ -48,5 +45,6 @@ ngModule.vnComponent('vnSmsDialog', { controller: sendSmsDialog, bindings: { sms: '<', + onSend: '&', } }); diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 8b8fd8f18b..ef5c2997ff 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -115,6 +115,7 @@ </vn-descriptor-content> <vn-sms-dialog vn-id="sms" + on-send="$ctrl.onSmsSend($sms)" sms="$ctrl.newSMS"> </vn-sms-dialog> <vn-worker-descriptor-popover diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 473c752f37..4d8d70edf6 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -37,12 +37,12 @@ class Controller extends Descriptor { destination: this.$params.phone || client.mobile || client.phone, message: this.$params.message || '' }; + this.$.sms.open(); + } - const route = `Clients/${this.id}/sendSms`; - - document.dispatchEvent(new CustomEvent('openSmsDialog', { - detail: {route} - })); + onSmsSend(sms) { + return this.$http.post(`Clients/${this.id}/sendSms`, sms) + .then(() => this.vnApp.showSuccess(this.$t('SMS sent'))); } } diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index eb15901d63..1f0ae83625 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -282,6 +282,7 @@ <!-- Send SMS popup --> <vn-sms-dialog vn-id="sms" + on-send="$ctrl.onSmsSend($sms)" sms="$ctrl.newSMS"> </vn-sms-dialog> diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index f8f672f59d..3790e3d712 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -226,7 +226,6 @@ class Controller extends Section { } showSMSDialog(params) { - const route = `Tickets/${this.id}/sendSms`; const address = this.ticket.address; const client = this.ticket.client; const phone = this.$params.phone @@ -241,9 +240,7 @@ class Controller extends Section { destination: phone }, params); - document.dispatchEvent(new CustomEvent('openSmsDialog', { - detail: {route} - })); + this.$.sms.open(); } makeInvoice() { @@ -298,6 +295,11 @@ class Controller extends Section { this.$state.go('ticket.card.sale', {id: refundTicket.id}); }); } + + onSmsSend(sms) { + return this.$http.post(`Tickets/${this.id}/sendSms`, sms) + .then(() => this.vnApp.showSuccess(this.$t('SMS sent'))); + } } Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; From 02598ced922ef835c3d609f213ae8f45e3b89265 Mon Sep 17 00:00:00 2001 From: Pau Navarro <pau@verdnatura.es> Date: Wed, 30 Nov 2022 07:12:26 +0100 Subject: [PATCH 08/28] solve merge conficts --- .../route/back/methods/route/getTickets.js | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 72df911586..708644c1a2 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -32,37 +32,37 @@ module.exports = Self => { Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT DISTINCT - t.id, - t.packages, - t.warehouseFk, - t.nickname, - t.clientFk, - t.priority, - t.addressFk, - st.code AS ticketStateCode, - st.name AS ticketStateName, - wh.name AS warehouseName, - tob.description AS ticketObservation, - a.street, - a.postalCode, - a.city, - am.name AS agencyModeName, - u.nickname AS userNickname, - vn.ticketTotalVolume(t.id) AS volume, - tob.description - FROM route r - JOIN ticket t ON t.routeFk = r.id - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - LEFT JOIN warehouse wh ON wh.id = t.warehouseFk - LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id - LEFT JOIN observationType ot ON tob.observationTypeFk = ot.id - AND ot.code = 'delivery' - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN account.user u ON u.id = r.workerFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk` + `SELECT + t.id, + t.packages, + t.warehouseFk, + t.nickname, + t.clientFk, + t.priority, + t.addressFk, + st.code AS ticketStateCode, + st.name AS ticketStateName, + wh.name AS warehouseName, + tob.description AS ticketObservation, + a.street, + a.postalCode, + a.city, + am.name AS agencyModeName, + u.nickname AS userNickname, + vn.ticketTotalVolume(t.id) AS volume, + tob.description + FROM vn.route r + JOIN ticket t ON t.routeFk = r.id + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + LEFT JOIN warehouse wh ON wh.id = t.warehouseFk + LEFT JOIN observationType ot ON ot.code = 'delivery' + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = ot.id + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN account.user u ON u.id = r.workerFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk` ); if (!filter.where) filter.where = {}; From 9ed9c1a82c1ed016e763a359ac2dde3297ba2d64 Mon Sep 17 00:00:00 2001 From: Pau Navarro <pau@verdnatura.es> Date: Wed, 30 Nov 2022 13:13:06 +0100 Subject: [PATCH 09/28] Delete sendsms from core/components --- front/core/components/sendSms/index.html | 45 ------------------ front/core/components/sendSms/index.js | 52 --------------------- front/core/components/sendSms/locale/es.yml | 9 ---- front/core/components/sendSms/style.scss | 5 -- 4 files changed, 111 deletions(-) delete mode 100644 front/core/components/sendSms/index.html delete mode 100644 front/core/components/sendSms/index.js delete mode 100644 front/core/components/sendSms/locale/es.yml delete mode 100644 front/core/components/sendSms/style.scss diff --git a/front/core/components/sendSms/index.html b/front/core/components/sendSms/index.html deleted file mode 100644 index 6915942c2d..0000000000 --- a/front/core/components/sendSms/index.html +++ /dev/null @@ -1,45 +0,0 @@ -<vn-dialog - vn-id="SMSDialog" - on-accept="$ctrl.onResponse()"> - <tpl-body> - <section class="SMSDialog"> - <h5 class="vn-py-sm" translate>Send SMS</h5> - <vn-horizontal> - <vn-textfield - vn-one - label="Destination" - ng-model="$ctrl.sms.destination" - required="true" - rule> - </vn-textfield> - </vn-horizontal> - <vn-horizontal> - <vn-textarea vn-one - vn-id="message" - label="Message" - ng-model="$ctrl.sms.message" - info="Special characters like accents counts as a multiple" - rows="5" - required="true" - rule> - </vn-textarea> - </vn-horizontal> - <vn-horizontal> - <span> - {{'Characters remaining' | translate}}: - <vn-chip translate-attr="{title: 'Packing'}" ng-class="{ - 'colored': $ctrl.charactersRemaining() > 25, - 'warning': $ctrl.charactersRemaining() <= 25, - 'alert': $ctrl.charactersRemaining() < 0, - }"> - {{$ctrl.charactersRemaining()}} - </vn-chip> - </span> - </vn-horizontal> - </section> - </tpl-body> - <tpl-buttons> - <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/> - <button response="accept" translate>Send</button> - </tpl-buttons> -</vn-dialog> \ No newline at end of file diff --git a/front/core/components/sendSms/index.js b/front/core/components/sendSms/index.js deleted file mode 100644 index 69975e7f7b..0000000000 --- a/front/core/components/sendSms/index.js +++ /dev/null @@ -1,52 +0,0 @@ -import ngModule from '../../module'; -import './style.scss'; -import Dialog from '../dialog'; - -export default class sendSmsDialog extends Dialog { - constructor($element, $scope, $http, $translate, vnApp) { - super($element, $scope, $http, $translate, vnApp); - - new CustomEvent('openSmsDialog', { - detail: { - this: this - } - }); - document.addEventListener('openSmsDialog', e => { - this.route = e.detail.route; - this.$.SMSDialog.show(); - }); - } - - charactersRemaining() { - const element = this.sms.message; - const maxLength = 160; - return maxLength - element.length; - } - - onResponse() { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); - - this.$http.post(this.route, this.sms).then(res => { - this.vnApp.showMessage(this.$t('SMS sent!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; - } -} - -ngModule.vnComponent('vnSmsDialog', { - template: require('./index.html'), - controller: sendSmsDialog, - bindings: { - sms: '<', - } -}); diff --git a/front/core/components/sendSms/locale/es.yml b/front/core/components/sendSms/locale/es.yml deleted file mode 100644 index 64c3fcca67..0000000000 --- a/front/core/components/sendSms/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Send SMS: Enviar SMS -Destination: Destinatario -Message: Mensaje -SMS sent!: ¡SMS enviado! -Characters remaining: Carácteres restantes -The destination can't be empty: El destinatario no puede estar vacio -The message can't be empty: El mensaje no puede estar vacio -The message it's too long: El mensaje es demasiado largo -Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file diff --git a/front/core/components/sendSms/style.scss b/front/core/components/sendSms/style.scss deleted file mode 100644 index 84571a5f42..0000000000 --- a/front/core/components/sendSms/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "variables"; - -.SMSDialog { - min-width: 400px -} \ No newline at end of file From 95967a29dbb13869aabc76cdb5fa265830dcb150 Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Tue, 13 Dec 2022 11:50:17 +0100 Subject: [PATCH 10/28] refs #4928 email template added and proc modified --- db/changes/224702/00-notificationProc.sql | 7 +-- db/changes/225001/.gitkeep | 1 - .../225001/00-supplier_beforeUpdate.sql | 48 +++++++++++++++++++ .../assets/css/import.js | 11 +++++ .../supplier-pay-method-update/locale/en.yml | 3 ++ .../supplier-pay-method-update/locale/es.yml | 3 ++ .../supplier-pay-method-update.html | 8 ++++ .../supplier-pay-method-update.js | 23 +++++++++ 8 files changed, 97 insertions(+), 7 deletions(-) delete mode 100644 db/changes/225001/.gitkeep create mode 100644 db/changes/225001/00-supplier_beforeUpdate.sql create mode 100644 print/templates/email/supplier-pay-method-update/assets/css/import.js create mode 100644 print/templates/email/supplier-pay-method-update/locale/en.yml create mode 100644 print/templates/email/supplier-pay-method-update/locale/es.yml create mode 100644 print/templates/email/supplier-pay-method-update/supplier-pay-method-update.html create mode 100755 print/templates/email/supplier-pay-method-update/supplier-pay-method-update.js diff --git a/db/changes/224702/00-notificationProc.sql b/db/changes/224702/00-notificationProc.sql index 475b2e3892..2cf11b4f1d 100644 --- a/db/changes/224702/00-notificationProc.sql +++ b/db/changes/224702/00-notificationProc.sql @@ -12,14 +12,9 @@ BEGIN * @param vAuthorFk The notification author or %NULL if there is no author * @return The notification id */ - DECLARE vNotificationFk INT; - - SELECT id INTO vNotificationFk - FROM `notification` - WHERE `name` = vNotificationName; INSERT INTO notificationQueue - SET notificationFk = vNotificationFk, + SET notificationFk = vNotificationName, params = vParams, authorFk = vAuthorFk; diff --git a/db/changes/225001/.gitkeep b/db/changes/225001/.gitkeep deleted file mode 100644 index 7a4187c024..0000000000 --- a/db/changes/225001/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -Delete this file diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225001/00-supplier_beforeUpdate.sql new file mode 100644 index 0000000000..857d3206f1 --- /dev/null +++ b/db/changes/225001/00-supplier_beforeUpdate.sql @@ -0,0 +1,48 @@ +DROP TRIGGER IF EXISTS vn.supplier_beforeUpdate; +USE vn; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate` + BEFORE UPDATE ON `supplier` + FOR EACH ROW +BEGIN + DECLARE vHasChange BOOL DEFAULT FALSE; + DECLARE vPayMethodHasVerified BOOL; + DECLARE vParams JSON; + DECLARE vOldPayMethodName VARCHAR(20); + DECLARE vNewPayMethodName VARCHAR(20); + + SELECT hasVerified INTO vPayMethodHasVerified + FROM payMethod + WHERE id = NEW.payMethodFk; + + SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk); + + IF !vHasChange THEN + SELECT name INTO vOldPayMethodName + FROM payMethod + WHERE id = OLD.payMethodFk; + SELECT name INTO vNewPayMethodName + FROM payMethod + WHERE id = NEW.payMethodFk; + SET vParams = JSON_OBJECT( + 'name', NEW.name, + 'oldPayMethod', vOldPayMethodName, + 'newPayMethod', vNewPayMethodName + ); + SELECT util.notification_send('supplier-pay-method-update', vParams, NULL) INTO @id; + END IF; + + SET vHasChange = (NEW.payDemFk <=> OLD.payDemFk) OR (NEW.payDay <=> OLD.payDay); + + IF vPayMethodHasVerified AND !vHasChange THEN + SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk); + END IF; + + IF vHasChange THEN + SET NEW.isPayMethodChecked = FALSE; + END IF; + +END$$ +DELIMITER ; diff --git a/print/templates/email/supplier-pay-method-update/assets/css/import.js b/print/templates/email/supplier-pay-method-update/assets/css/import.js new file mode 100644 index 0000000000..4b4bb70869 --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/assets/css/import.js @@ -0,0 +1,11 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/supplier-pay-method-update/locale/en.yml b/print/templates/email/supplier-pay-method-update/locale/en.yml new file mode 100644 index 0000000000..f04ccc5ce8 --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/locale/en.yml @@ -0,0 +1,3 @@ +subject: Pay method updated +title: Pay method updated +description: The pay method of the supplier {0} has been updated from {1} to {2} diff --git a/print/templates/email/supplier-pay-method-update/locale/es.yml b/print/templates/email/supplier-pay-method-update/locale/es.yml new file mode 100644 index 0000000000..59ee0e02f4 --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/locale/es.yml @@ -0,0 +1,3 @@ +subject: Método de pago actualizado +title: Método de pago actualizado +description: Se ha actualizado el método de pago del proveedor {0} de {1} a {2} diff --git a/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.html b/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.html new file mode 100644 index 0000000000..df8543cd92 --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.html @@ -0,0 +1,8 @@ +<email-body v-bind="$props"> + <div class="grid-row"> + <div class="grid-block vn-pa-ml"> + <h1>{{ $t('title') }}</h1> + <p v-html="$t('description', [name, oldPayMethod, newPayMethod])"></p> + </div> + </div> +</email-body> diff --git a/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.js b/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.js new file mode 100755 index 0000000000..283b2689c5 --- /dev/null +++ b/print/templates/email/supplier-pay-method-update/supplier-pay-method-update.js @@ -0,0 +1,23 @@ +const Component = require(`vn-print/core/component`); +const emailBody = new Component('email-body'); + +module.exports = { + name: 'supplier-pay-method-update', + components: { + 'email-body': emailBody.build(), + }, + props: { + name: { + type: String, + required: true + }, + oldPayMethod: { + type: String, + required: true + }, + newPayMethod: { + type: String, + required: true + } + } +}; From f00fdcff7cb20524141e9a704473c62ac2ea5abb Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Wed, 14 Dec 2022 08:06:02 +0100 Subject: [PATCH 11/28] refactor sql --- .../225001/00-supplier_beforeUpdate.sql | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225001/00-supplier_beforeUpdate.sql index 857d3206f1..08af8666b1 100644 --- a/db/changes/225001/00-supplier_beforeUpdate.sql +++ b/db/changes/225001/00-supplier_beforeUpdate.sql @@ -1,5 +1,5 @@ -DROP TRIGGER IF EXISTS vn.supplier_beforeUpdate; -USE vn; +DROP TRIGGER IF EXISTS `vn`.`supplier_beforeUpdate`; +USE `vn`; DELIMITER $$ $$ @@ -7,7 +7,8 @@ CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate` BEFORE UPDATE ON `supplier` FOR EACH ROW BEGIN - DECLARE vHasChange BOOL DEFAULT FALSE; + DECLARE vHasChange BOOL; + DECLARE vPayMethodChanged BOOL; DECLARE vPayMethodHasVerified BOOL; DECLARE vParams JSON; DECLARE vOldPayMethodName VARCHAR(20); @@ -17,15 +18,16 @@ BEGIN FROM payMethod WHERE id = NEW.payMethodFk; - SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk); + SET vPayMethodChanged = NOT(NEW.payMethodFk <=> OLD.payMethodFk); - IF !vHasChange THEN + IF vPayMethodChanged THEN SELECT name INTO vOldPayMethodName FROM payMethod WHERE id = OLD.payMethodFk; SELECT name INTO vNewPayMethodName FROM payMethod WHERE id = NEW.payMethodFk; + SET vParams = JSON_OBJECT( 'name', NEW.name, 'oldPayMethod', vOldPayMethodName, @@ -34,13 +36,9 @@ BEGIN SELECT util.notification_send('supplier-pay-method-update', vParams, NULL) INTO @id; END IF; - SET vHasChange = (NEW.payDemFk <=> OLD.payDemFk) OR (NEW.payDay <=> OLD.payDay); + SET vHasChange = NOT(NEW.payDemFk <=> OLD.payDemFk AND NEW.payDay <=> OLD.payDay) OR vPayMethodChanged; - IF vPayMethodHasVerified AND !vHasChange THEN - SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk); - END IF; - - IF vHasChange THEN + IF vHasChange AND vPayMethodHasVerified THEN SET NEW.isPayMethodChecked = FALSE; END IF; From dc33a46eee3c3124adab35f9685993fe5d4fbdf9 Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Wed, 14 Dec 2022 12:17:12 +0100 Subject: [PATCH 12/28] refs #4926 ticket tour future refactor --- db/changes/225001/.gitkeep | 0 .../225001/00-ticket_canbePostponed.sql | 73 +++++++ e2e/helpers/selectors.js | 10 +- .../{20_future.spec.js => 21_future.spec.js} | 56 ------ modules/ticket/back/locale/ticket/en.yml | 1 + modules/ticket/back/locale/ticket/es.yml | 1 + .../methods/ticket-future/getTicketsFuture.js | 107 +++++----- .../spec/getTicketsFuture.spec.js | 185 ++++-------------- modules/ticket/back/methods/ticket/merge.js | 17 +- .../front/future-search-panel/index.html | 35 +--- .../ticket/front/future-search-panel/index.js | 3 +- .../front/future-search-panel/locale/en.yml | 8 - .../front/future-search-panel/locale/es.yml | 9 - modules/ticket/front/future/index.html | 24 +-- modules/ticket/front/future/index.js | 38 ++-- modules/ticket/front/future/index.spec.js | 8 +- modules/ticket/front/future/locale/en.yml | 4 - modules/ticket/front/future/locale/es.yml | 10 +- 18 files changed, 226 insertions(+), 363 deletions(-) delete mode 100644 db/changes/225001/.gitkeep create mode 100644 db/changes/225001/00-ticket_canbePostponed.sql rename e2e/paths/05-ticket/{20_future.spec.js => 21_future.spec.js} (77%) diff --git a/db/changes/225001/.gitkeep b/db/changes/225001/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/db/changes/225001/00-ticket_canbePostponed.sql b/db/changes/225001/00-ticket_canbePostponed.sql new file mode 100644 index 0000000000..b1206799de --- /dev/null +++ b/db/changes/225001/00-ticket_canbePostponed.sql @@ -0,0 +1,73 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticket_canbePostponed`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro + * + * @param vOriginDated Fecha en cuestión + * @param vFutureDated Fecha en el futuro a sondear + * @param vWarehouseFk Identificador de vn.warehouse + */ + DROP TEMPORARY TABLE IF EXISTS tmp.filter; + CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT sv.ticketFk id, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, + st.name state, + sub2.id ticketFuture, + sub2.iptd tfIpt, + sub2.state tfState, + t.clientFk, + t.warehouseFk, + ts.alertLevel, + t.shipped, + sub2.shipped tfShipped, + t.workerFk, + st.code stateCode, + sub2.code tfStateCode + FROM vn.saleVolume sv + JOIN vn.sale s ON s.id = sv.saleFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticket t ON t.id = sv.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.alertLevel al ON al.id = ts.alertLevel + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN ( + SELECT * + FROM ( + SELECT + t.addressFk , + t.id, + t.shipped, + st.name state, + st.code code, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd + FROM vn.ticket t + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + WHERE t.shipped BETWEEN vFutureDated + AND util.dayend(vFutureDated) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) sub + GROUP BY sub.addressFk + ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id + WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated) + AND t.warehouseFk = vWarehouseFk + AND al.code = 'FREE' + AND tp.ticketFk IS NULL + GROUP BY sv.ticketFk + HAVING ticketFuture; +END$$ +DELIMITER ; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f550e3a9da..e485259d8c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -735,10 +735,8 @@ export default { }, ticketFuture: { openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', - originDated: 'vn-date-picker[label="Origin ETD"]', - futureDated: 'vn-date-picker[label="Destination ETD"]', - shipped: 'vn-date-picker[label="Origin date"]', - tfShipped: 'vn-date-picker[label="Destination date"]', + originDated: 'vn-date-picker[label="Origin date"]', + futureDated: 'vn-date-picker[label="Destination date"]', linesMax: 'vn-textfield[label="Max Lines"]', litersMax: 'vn-textfield[label="Max Liters"]', ipt: 'vn-autocomplete[label="Origin IPT"]', @@ -756,8 +754,8 @@ export default { multiCheck: 'vn-multi-check', tableId: 'vn-textfield[name="id"]', tableTfId: 'vn-textfield[name="ticketFuture"]', - tableLiters: 'vn-textfield[name="litersMax"]', - tableLines: 'vn-textfield[name="linesMax"]', + tableLiters: 'vn-textfield[name="liters"]', + tableLines: 'vn-textfield[name="lines"]', submit: 'vn-submit[label="Search"]', table: 'tbody > tr:not(.empty-rows)' }, diff --git a/e2e/paths/05-ticket/20_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js similarity index 77% rename from e2e/paths/05-ticket/20_future.spec.js rename to e2e/paths/05-ticket/21_future.spec.js index 6db2bf4f00..d4dbffc942 100644 --- a/e2e/paths/05-ticket/20_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -16,9 +16,6 @@ describe('Ticket Future path', () => { await browser.close(); }); - const now = new Date(); - const tomorrow = new Date(now.getDate() + 1); - it('should show errors snackbar because of the required data', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.warehouseFk); @@ -27,20 +24,6 @@ describe('Ticket Future path', () => { expect(message.text).toContain('warehouseFk is a required argument'); - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.litersMax); - await page.waitToClick(selectors.ticketFuture.submit); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('litersMax is a required argument'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.linesMax); - await page.waitToClick(selectors.ticketFuture.submit); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('linesMax is a required argument'); - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.futureDated); await page.waitToClick(selectors.ticketFuture.submit); @@ -62,40 +45,9 @@ describe('Ticket Future path', () => { await page.waitForNumberOfElements(selectors.ticketFuture.table, 4); }); - it('should search with the origin shipped today', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.pickDate(selectors.ticketFuture.shipped, now); - await page.waitToClick(selectors.ticketFuture.submit); - await page.waitForNumberOfElements(selectors.ticketFuture.table, 4); - }); - - it('should search with the origin shipped tomorrow', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.pickDate(selectors.ticketFuture.shipped, tomorrow); - await page.waitToClick(selectors.ticketFuture.submit); - await page.waitForNumberOfElements(selectors.ticketFuture.table, 0); - }); - - it('should search with the destination shipped today', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.pickDate(selectors.ticketFuture.tfShipped, now); - await page.waitToClick(selectors.ticketFuture.submit); - await page.waitForNumberOfElements(selectors.ticketFuture.table, 4); - }); - - it('should search with the destination shipped tomorrow', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.pickDate(selectors.ticketFuture.tfShipped, tomorrow); - await page.waitToClick(selectors.ticketFuture.submit); - await page.waitForNumberOfElements(selectors.ticketFuture.table, 0); - }); - it('should search with the origin IPT', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); @@ -109,8 +61,6 @@ describe('Ticket Future path', () => { it('should search with the destination IPT', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); @@ -124,8 +74,6 @@ describe('Ticket Future path', () => { it('should search with the origin grouped state', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); @@ -139,8 +87,6 @@ describe('Ticket Future path', () => { it('should search with the destination grouped state', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); @@ -151,8 +97,6 @@ describe('Ticket Future path', () => { await page.waitForNumberOfElements(selectors.ticketFuture.table, 0); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); diff --git a/modules/ticket/back/locale/ticket/en.yml b/modules/ticket/back/locale/ticket/en.yml index 4e97f5d8cb..c4ad84232f 100644 --- a/modules/ticket/back/locale/ticket/en.yml +++ b/modules/ticket/back/locale/ticket/en.yml @@ -20,3 +20,4 @@ routeFk: route companyFk: company agencyModeFk: agency ticketFk: ticket +mergedTicket: merged ticket diff --git a/modules/ticket/back/locale/ticket/es.yml b/modules/ticket/back/locale/ticket/es.yml index a570f1f118..2c524a74f2 100644 --- a/modules/ticket/back/locale/ticket/es.yml +++ b/modules/ticket/back/locale/ticket/es.yml @@ -20,3 +20,4 @@ routeFk: ruta companyFk: empresa agencyModeFk: agencia ticketFk: ticket +mergedTicket: ticket fusionado diff --git a/modules/ticket/back/methods/ticket-future/getTicketsFuture.js b/modules/ticket/back/methods/ticket-future/getTicketsFuture.js index 0fcc211822..aa726deeaf 100644 --- a/modules/ticket/back/methods/ticket-future/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket-future/getTicketsFuture.js @@ -20,18 +20,6 @@ module.exports = Self => { description: 'The date to probe', required: true }, - { - arg: 'litersMax', - type: 'number', - description: 'Maximum volume of tickets to catapult', - required: true - }, - { - arg: 'linesMax', - type: 'number', - description: 'Maximum number of lines of tickets to catapult', - required: true - }, { arg: 'warehouseFk', type: 'number', @@ -39,15 +27,15 @@ module.exports = Self => { required: true }, { - arg: 'shipped', - type: 'date', - description: 'Origin shipped', + arg: 'liters', + type: 'number', + description: 'Maximum volume of tickets to catapult', required: false }, { - arg: 'tfShipped', - type: 'date', - description: 'Destination shipped', + arg: 'lines', + type: 'number', + description: 'Maximum number of lines of tickets to catapult', required: false }, { @@ -108,7 +96,7 @@ module.exports = Self => { } }); - Self.getTicketsFuture = async (ctx, options) => { + Self.getTicketsFuture = async(ctx, options) => { const args = ctx.args; const conn = Self.dataSource.connector; const myOptions = {}; @@ -118,32 +106,32 @@ module.exports = Self => { const where = buildFilter(ctx.args, (param, value) => { switch (param) { - case 'id': - return { 'f.id': value }; - case 'tfId': - return { 'f.ticketFuture': value }; - case 'shipped': - return { 'f.shipped': value }; - case 'tfShipped': - return { 'f.tfShipped': value }; - case 'ipt': - return { 'f.ipt': value }; - case 'tfIpt': - return { 'f.tfIpt': value }; - case 'state': - return { 'f.code': { like: `%${value}%` } }; - case 'tfState': - return { 'f.tfCode': { like: `%${value}%` } }; + case 'id': + return {'f.id': value}; + case 'lines': + return {'f.lines': {lte: value}}; + case 'liters': + return {'f.liters': {lte: value}}; + case 'tfId': + return {'f.ticketFuture': value}; + case 'ipt': + return {'f.ipt': value}; + case 'tfIpt': + return {'f.tfIpt': value}; + case 'state': + return {'f.stateCode': {like: `%${value}%`}}; + case 'tfState': + return {'f.tfStateCode': {like: `%${value}%`}}; } }); - let filter = mergeFilters(ctx.args.filter, { where }); + let filter = mergeFilters(ctx.args.filter, {where}); const stmts = []; let stmt; stmt = new ParameterizedSQL( - `CALL vn.ticket_canbePostponed(?,?,?,?,?)`, - [args.originDated, args.futureDated, args.litersMax, args.linesMax, args.warehouseFk]); + `CALL vn.ticket_canbePostponed(?,?,?)`, + [args.originDated, args.futureDated, args.warehouseFk]); stmts.push(stmt); @@ -153,7 +141,7 @@ module.exports = Self => { CREATE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY - SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped + SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)`); @@ -174,35 +162,34 @@ module.exports = Self => { let range; let hasWhere; switch (args.problems) { - case true: - condition = `or`; - hasProblem = true; - range = { neq: null }; - hasWhere = true; - break; + case true: + condition = `or`; + hasProblem = true; + range = {neq: null}; + hasWhere = true; + break; - case false: - condition = `and`; - hasProblem = null; - range = null; - hasWhere = true; - break; + case false: + condition = `and`; + hasProblem = null; + range = null; + hasWhere = true; + break; } const problems = { [condition]: [ - { 'tp.isFreezed': hasProblem }, - { 'tp.risk': hasProblem }, - { 'tp.hasTicketRequest': hasProblem }, - { 'tp.itemShortage': range }, - { 'tp.hasComponentLack': hasProblem }, - { 'tp.isTooLittle': hasProblem } + {'tp.isFreezed': hasProblem}, + {'tp.risk': hasProblem}, + {'tp.hasTicketRequest': hasProblem}, + {'tp.itemShortage': range}, + {'tp.hasComponentLack': hasProblem}, + {'tp.isTooLittle': hasProblem} ] }; - if (hasWhere) { - filter = mergeFilters(filter, { where: problems }); - } + if (hasWhere) + filter = mergeFilters(filter, {where: problems}); stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makeOrderBy(filter.order)); diff --git a/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js index 502ea3074d..459c2eb1ee 100644 --- a/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js +++ b/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js @@ -5,11 +5,11 @@ describe('TicketFuture getTicketsFuture()', () => { today.setHours(0, 0, 0, 0); const tomorrow = new Date(today.getDate() + 1); - it('should return the tickets passing the required data', async () => { + it('should return the tickets passing the required data', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -19,7 +19,7 @@ describe('TicketFuture getTicketsFuture()', () => { warehouseFk: 1, }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -30,11 +30,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the problems on true', async () => { + it('should return the tickets matching the problems on true', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -45,7 +45,7 @@ describe('TicketFuture getTicketsFuture()', () => { problems: true }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -57,11 +57,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the problems on false', async () => { + it('should return the tickets matching the problems on false', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -72,7 +72,7 @@ describe('TicketFuture getTicketsFuture()', () => { problems: false }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(0); @@ -84,11 +84,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the problems on null', async () => { + it('should return the tickets matching the problems on null', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -99,7 +99,7 @@ describe('TicketFuture getTicketsFuture()', () => { problems: null }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -111,11 +111,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the correct origin shipped', async () => { + it('should return the tickets matching the OK State in origin date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -123,118 +123,10 @@ describe('TicketFuture getTicketsFuture()', () => { litersMax: 9999, linesMax: 9999, warehouseFk: 1, - shipped: today + state: 'OK' }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; - const result = await models.Ticket.getTicketsFuture(ctx, options); - - expect(result.length).toEqual(4); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return the tickets matching the an incorrect origin shipped', async () => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = { transaction: tx }; - - const args = { - originDated: today, - futureDated: today, - litersMax: 9999, - linesMax: 9999, - warehouseFk: 1, - shipped: tomorrow - }; - - const ctx = { req: { accessToken: { userId: 9 } }, args }; - const result = await models.Ticket.getTicketsFuture(ctx, options); - - expect(result.length).toEqual(0); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return the tickets matching the correct destination shipped', async () => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = { transaction: tx }; - - const args = { - originDated: today, - futureDated: today, - litersMax: 9999, - linesMax: 9999, - warehouseFk: 1, - tfShipped: today - }; - - const ctx = { req: { accessToken: { userId: 9 } }, args }; - const result = await models.Ticket.getTicketsFuture(ctx, options); - - expect(result.length).toEqual(4); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return the tickets matching the an incorrect destination shipped', async () => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = { transaction: tx }; - - const args = { - originDated: today, - futureDated: today, - litersMax: 9999, - linesMax: 9999, - warehouseFk: 1, - tfShipped: tomorrow - }; - - const ctx = { req: { accessToken: { userId: 9 } }, args }; - const result = await models.Ticket.getTicketsFuture(ctx, options); - - expect(result.length).toEqual(0); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return the tickets matching the OK State in origin date', async () => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = { transaction: tx }; - - const args = { - originDated: today, - futureDated: today, - litersMax: 9999, - linesMax: 9999, - warehouseFk: 1, - state: "OK" - }; - - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(1); @@ -246,11 +138,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the OK State in destination date', async () => { + it('should return the tickets matching the OK State in destination date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -258,10 +150,10 @@ describe('TicketFuture getTicketsFuture()', () => { litersMax: 9999, linesMax: 9999, warehouseFk: 1, - tfState: "OK" + tfState: 'OK' }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -273,11 +165,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the correct IPT in origin date', async () => { + it('should return the tickets matching the correct IPT in origin date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -288,7 +180,7 @@ describe('TicketFuture getTicketsFuture()', () => { ipt: null }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -300,11 +192,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the incorrect IPT in origin date', async () => { + it('should return the tickets matching the incorrect IPT in origin date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -315,7 +207,7 @@ describe('TicketFuture getTicketsFuture()', () => { ipt: 0 }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(0); @@ -327,11 +219,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the correct IPT in destination date', async () => { + it('should return the tickets matching the correct IPT in destination date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -342,7 +234,7 @@ describe('TicketFuture getTicketsFuture()', () => { tfIpt: null }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -354,11 +246,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the incorrect IPT in destination date', async () => { + it('should return the tickets matching the incorrect IPT in destination date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -369,7 +261,7 @@ describe('TicketFuture getTicketsFuture()', () => { tfIpt: 0 }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(0); @@ -381,11 +273,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the ID in origin date', async () => { + it('should return the tickets matching the ID in origin date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -396,7 +288,7 @@ describe('TicketFuture getTicketsFuture()', () => { id: 13 }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(1); @@ -408,11 +300,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the ID in destination date', async () => { + it('should return the tickets matching the ID in destination date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -423,7 +315,7 @@ describe('TicketFuture getTicketsFuture()', () => { tfId: 12 }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -434,5 +326,4 @@ describe('TicketFuture getTicketsFuture()', () => { throw e; } }); - }); diff --git a/modules/ticket/back/methods/ticket/merge.js b/modules/ticket/back/methods/ticket/merge.js index 04f8d83aff..8a86eff6fa 100644 --- a/modules/ticket/back/methods/ticket/merge.js +++ b/modules/ticket/back/methods/ticket/merge.js @@ -43,14 +43,27 @@ module.exports = Self => { const fullPath = `${origin}/#!/ticket/${ticket.id}/summary`; const fullPathFuture = `${origin}/#!/ticket/${ticket.ticketFuture}/summary`; const message = $t('Ticket merged', { - originDated: dateUtil.toString(new Date(ticket.originETD)), - futureDated: dateUtil.toString(new Date(ticket.destETD)), + originDated: dateUtil.toString(new Date(ticket.shipped)), + futureDated: dateUtil.toString(new Date(ticket.tfShipped)), id: ticket.id, tfId: ticket.ticketFuture, fullPath, fullPathFuture }); if (!ticket.id || !ticket.ticketFuture) continue; + + const ticketFutureLogRecord = { + originFk: ticket.ticketFuture, + userFk: ctx.req.accessToken.userId, + action: 'update', + changedModel: 'Ticket', + changedModelId: ticket.ticketFuture, + changedModelValue: ticket.ticketFuture, + oldInstance: {}, + newInstance: {mergedTicket: ticket.id} + }; + + await models.TicketLog.create(ticketFutureLogRecord, myOptions); await models.Sale.updateAll({ticketFk: ticket.id}, {ticketFk: ticket.ticketFuture}, myOptions); await models.Ticket.setDeleted(ctx, ticket.id, myOptions); await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message); diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index 1b3ae453e4..93e0462363 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -4,43 +4,26 @@ <vn-date-picker vn-one label="Origin date" - ng-model="filter.shipped" - on-change="$ctrl.from = value"> + ng-model="filter.originDated" + required="true"> </vn-date-picker> <vn-date-picker vn-one label="Destination date" - ng-model="filter.tfShipped"> - </vn-date-picker> - </vn-horizontal> - <vn-horizontal class="vn-px-lg"> - <vn-date-picker - vn-one - label="Origin ETD" - ng-model="filter.originDated" - required="true" - info="ETD"> - </vn-date-picker> - <vn-date-picker - vn-one - label="Destination ETD" ng-model="filter.futureDated" - required="true" - info="ETD"> + required="true"> </vn-date-picker> </vn-horizontal> <vn-horizontal class="vn-px-lg"> <vn-textfield vn-one label="Max Lines" - ng-model="filter.linesMax" - required="true"> + ng-model="filter.lines"> </vn-textfield> <vn-textfield vn-one label="Max Liters" - ng-model="filter.litersMax" - required="true"> + ng-model="filter.liters"> </vn-textfield> </vn-horizontal> <vn-horizontal class="vn-px-lg"> @@ -48,22 +31,22 @@ data="$ctrl.itemPackingTypes" label="Origin IPT" value-field="code" - show-field="name" + show-field="description" ng-model="filter.ipt" info="IPT"> <tpl-item> - {{name}} + {{description}} </tpl-item> </vn-autocomplete> <vn-autocomplete vn-one data="$ctrl.itemPackingTypes" label="Destination IPT" value-field="code" - show-field="name" + show-field="description" ng-model="filter.tfIpt" info="IPT"> <tpl-item> - {{name}} + {{description}} </tpl-item> </vn-autocomplete> </vn-horizontal> diff --git a/modules/ticket/front/future-search-panel/index.js b/modules/ticket/front/future-search-panel/index.js index 1a1f0e4c58..d7e7b3a5ea 100644 --- a/modules/ticket/front/future-search-panel/index.js +++ b/modules/ticket/front/future-search-panel/index.js @@ -28,9 +28,8 @@ class Controller extends SearchPanel { this.$http.get('ItemPackingTypes').then(res => { for (let ipt of res.data) { itemPackingTypes.push({ - id: ipt.id, + description: this.$t(ipt.description), code: ipt.code, - name: this.$t(ipt.code) }); } this.itemPackingTypes = itemPackingTypes; diff --git a/modules/ticket/front/future-search-panel/locale/en.yml b/modules/ticket/front/future-search-panel/locale/en.yml index fe71865cba..767c20152c 100644 --- a/modules/ticket/front/future-search-panel/locale/en.yml +++ b/modules/ticket/front/future-search-panel/locale/en.yml @@ -1,9 +1 @@ Future tickets: Tickets a futuro -FREE: Free -DELIVERED: Delivered -ON_PREPARATION: On preparation -PACKED: Packed -F: Fruits and vegetables -V: Vertical -H: Horizontal -P: Feed diff --git a/modules/ticket/front/future-search-panel/locale/es.yml b/modules/ticket/front/future-search-panel/locale/es.yml index 82deba538c..9d72c5b069 100644 --- a/modules/ticket/front/future-search-panel/locale/es.yml +++ b/modules/ticket/front/future-search-panel/locale/es.yml @@ -11,13 +11,4 @@ With problems: Con problemas Warehouse: Almacén Origin Grouped State: Estado agrupado origen Destination Grouped State: Estado agrupado destino -FREE: Libre -DELIVERED: Servido -ON_PREPARATION: En preparacion -PACKED: Encajado -F: Frutas y verduras -V: Vertical -H: Horizontal -P: Pienso -ETD: Tiempo estimado de entrega IPT: Encajado diff --git a/modules/ticket/front/future/index.html b/modules/ticket/front/future/index.html index d30cbaf198..0b19120845 100644 --- a/modules/ticket/front/future/index.html +++ b/modules/ticket/front/future/index.html @@ -44,31 +44,31 @@ <th field="id"> <span translate>Origin ID</span> </th> - <th field="originETD"> - <span translate>Origin ETD</span> + <th field="shipped"> + <span translate>Origin Date</span> </th> <th field="state"> <span translate>Origin State</span> </th> - <th field="ipt"> + <th field="ipt" title="Item Packing Type"> <span>IPT</span> </th> - <th field="litersMax"> + <th field="liters"> <span translate>Liters</span> </th> - <th field="linesMax"> + <th field="lines"> <span translate>Available Lines</span> </th> <th field="ticketFuture"> <span translate>Destination ID</span> </th> - <th field="destETD"> - <span translate>Destination ETD</span> + <th field="tfShipped"> + <span translate>Destination Date</span> </th> <th field="tfState"> <span translate>Destination State</span> </th> - <th field="tfIpt"> + <th field="tfIpt" title="Item Packing Type"> <span>IPT</span> </th> </tr> @@ -125,8 +125,8 @@ {{::ticket.id}} </span></td> <td shrink-date> - <span class="chip {{$ctrl.compareDate(ticket.originETD)}}"> - {{::ticket.originETD | date: 'dd/MM/yyyy'}} + <span class="chip {{$ctrl.compareDate(ticket.shipped)}}"> + {{::ticket.shipped | date: 'dd/MM/yyyy'}} </span> </td> <td> @@ -146,8 +146,8 @@ </span> </td> <td shrink-date> - <span class="chip {{$ctrl.compareDate(ticket.destETD)}}"> - {{::ticket.destETD | date: 'dd/MM/yyyy'}} + <span class="chip {{$ctrl.compareDate(ticket.tfShipped)}}"> + {{::ticket.tfShipped | date: 'dd/MM/yyyy'}} </span> </td> <td> diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index 311b9c3070..918ed79b50 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -15,11 +15,11 @@ export default class Controller extends Section { searchable: false }, { - field: 'originETD', + field: 'shipped', searchable: false }, { - field: 'destETD', + field: 'tfShipped', searchable: false }, { @@ -35,7 +35,7 @@ export default class Controller extends Section { autocomplete: { url: 'ItemPackingTypes', showField: 'description', - valueField: 'code' + valueField: 'description' } }, { @@ -43,7 +43,7 @@ export default class Controller extends Section { autocomplete: { url: 'ItemPackingTypes', showField: 'description', - valueField: 'code' + valueField: 'description' } }, ] @@ -57,9 +57,7 @@ export default class Controller extends Section { this.filterParams = { originDated: today, futureDated: today, - linesMax: '9999', - litersMax: '9999', - warehouseFk: 1 + warehouseFk: this.vnConfig.warehouseFk }; } @@ -113,7 +111,7 @@ export default class Controller extends Section { } moveTicketsFuture() { - let params = { tickets: this.checked }; + let params = {tickets: this.checked}; return this.$http.post('Tickets/merge', params) .then(() => { this.$.model.refresh(); @@ -123,18 +121,18 @@ export default class Controller extends Section { exprBuilder(param, value) { switch (param) { - case 'id': - return { 'id': value }; - case 'ticketFuture': - return { 'ticketFuture': value }; - case 'litersMax': - return { 'liters': value }; - case 'linesMax': - return { 'lines': value }; - case 'ipt': - return { 'ipt': value }; - case 'tfIpt': - return { 'tfIpt': value }; + case 'id': + return {'id': value}; + case 'ticketFuture': + return {'ticketFuture': value}; + case 'liters': + return {'liters': value}; + case 'lines': + return {'lines': value}; + case 'ipt': + return {'ipt': value}; + case 'tfIpt': + return {'tfIpt': value}; } } } diff --git a/modules/ticket/front/future/index.spec.js b/modules/ticket/front/future/index.spec.js index 63deebc4f8..9c6b97c8be 100644 --- a/modules/ticket/front/future/index.spec.js +++ b/modules/ticket/front/future/index.spec.js @@ -13,16 +13,16 @@ describe('Component vnTicketFuture', () => { $httpBackend = _$httpBackend_; $window = _$window_; const $element = angular.element('<vn-ticket-future></vn-ticket-future>'); - controller = $componentController('vnTicketFuture', { $element }); + controller = $componentController('vnTicketFuture', {$element}); controller.$.model = crudModel; controller.$.model.data = [{ id: 1, checked: true, - state: "OK" + state: 'OK' }, { id: 2, checked: true, - state: "Libre" + state: 'Libre' }]; })); @@ -67,6 +67,7 @@ describe('Component vnTicketFuture', () => { it('should return success to the OK tickets', () => { const ok = controller.stateColor(controller.$.model.data[0].state); const notOk = controller.stateColor(controller.$.model.data[1].state); + expect(ok).toEqual('success'); expect(notOk).not.toEqual('success'); }); @@ -74,6 +75,7 @@ describe('Component vnTicketFuture', () => { it('should return success to the FREE tickets', () => { const notFree = controller.stateColor(controller.$.model.data[0].state); const free = controller.stateColor(controller.$.model.data[1].state); + expect(free).toEqual('notice'); expect(notFree).not.toEqual('notice'); }); diff --git a/modules/ticket/front/future/locale/en.yml b/modules/ticket/front/future/locale/en.yml index 66d3ce2698..4400e69926 100644 --- a/modules/ticket/front/future/locale/en.yml +++ b/modules/ticket/front/future/locale/en.yml @@ -1,6 +1,2 @@ Move confirmation: Do you want to move {{checked}} tickets to the future? -FREE: Free -DELIVERED: Delivered -ON_PREPARATION: On preparation -PACKED: Packed Success: Tickets moved successfully! diff --git a/modules/ticket/front/future/locale/es.yml b/modules/ticket/front/future/locale/es.yml index 9be0be6a47..9fceea111c 100644 --- a/modules/ticket/front/future/locale/es.yml +++ b/modules/ticket/front/future/locale/es.yml @@ -3,20 +3,14 @@ Search tickets: Buscar tickets Search future tickets by date: Buscar tickets por fecha Problems: Problemas Origin ID: ID origen -Closing: Cierre Origin State: Estado origen Destination State: Estado destino Liters: Litros Available Lines: Líneas disponibles Destination ID: ID destino -Destination ETD: ETD Destino -Origin ETD: ETD Origen Move tickets: Mover tickets Move confirmation: ¿Desea mover {{checked}} tickets hacia el futuro? Success: Tickets movidos correctamente -ETD: Tiempo estimado de entrega IPT: Encajado -FREE: Libre -DELIVERED: Servido -ON_PREPARATION: En preparacion -PACKED: Encajado +Origin Date: Fecha origen +Destination Date: Fecha destino From 2baa4a19544c0c83d5dbcddba5b8dd2c5bf32040 Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Wed, 14 Dec 2022 12:17:12 +0100 Subject: [PATCH 13/28] refs #4962 ticket tour future refactor --- db/changes/225001/.gitkeep | 0 .../225001/00-ticket_canbePostponed.sql | 73 +++++++ e2e/helpers/selectors.js | 10 +- .../{20_future.spec.js => 21_future.spec.js} | 56 ------ modules/ticket/back/locale/ticket/en.yml | 1 + modules/ticket/back/locale/ticket/es.yml | 1 + .../methods/ticket-future/getTicketsFuture.js | 107 +++++----- .../spec/getTicketsFuture.spec.js | 185 ++++-------------- modules/ticket/back/methods/ticket/merge.js | 17 +- .../front/future-search-panel/index.html | 35 +--- .../ticket/front/future-search-panel/index.js | 3 +- .../front/future-search-panel/locale/en.yml | 8 - .../front/future-search-panel/locale/es.yml | 9 - modules/ticket/front/future/index.html | 24 +-- modules/ticket/front/future/index.js | 38 ++-- modules/ticket/front/future/index.spec.js | 8 +- modules/ticket/front/future/locale/en.yml | 4 - modules/ticket/front/future/locale/es.yml | 10 +- 18 files changed, 226 insertions(+), 363 deletions(-) delete mode 100644 db/changes/225001/.gitkeep create mode 100644 db/changes/225001/00-ticket_canbePostponed.sql rename e2e/paths/05-ticket/{20_future.spec.js => 21_future.spec.js} (77%) diff --git a/db/changes/225001/.gitkeep b/db/changes/225001/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/db/changes/225001/00-ticket_canbePostponed.sql b/db/changes/225001/00-ticket_canbePostponed.sql new file mode 100644 index 0000000000..b1206799de --- /dev/null +++ b/db/changes/225001/00-ticket_canbePostponed.sql @@ -0,0 +1,73 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticket_canbePostponed`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro + * + * @param vOriginDated Fecha en cuestión + * @param vFutureDated Fecha en el futuro a sondear + * @param vWarehouseFk Identificador de vn.warehouse + */ + DROP TEMPORARY TABLE IF EXISTS tmp.filter; + CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT sv.ticketFk id, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, + st.name state, + sub2.id ticketFuture, + sub2.iptd tfIpt, + sub2.state tfState, + t.clientFk, + t.warehouseFk, + ts.alertLevel, + t.shipped, + sub2.shipped tfShipped, + t.workerFk, + st.code stateCode, + sub2.code tfStateCode + FROM vn.saleVolume sv + JOIN vn.sale s ON s.id = sv.saleFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticket t ON t.id = sv.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.alertLevel al ON al.id = ts.alertLevel + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN ( + SELECT * + FROM ( + SELECT + t.addressFk , + t.id, + t.shipped, + st.name state, + st.code code, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd + FROM vn.ticket t + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + WHERE t.shipped BETWEEN vFutureDated + AND util.dayend(vFutureDated) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) sub + GROUP BY sub.addressFk + ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id + WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated) + AND t.warehouseFk = vWarehouseFk + AND al.code = 'FREE' + AND tp.ticketFk IS NULL + GROUP BY sv.ticketFk + HAVING ticketFuture; +END$$ +DELIMITER ; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f550e3a9da..e485259d8c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -735,10 +735,8 @@ export default { }, ticketFuture: { openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', - originDated: 'vn-date-picker[label="Origin ETD"]', - futureDated: 'vn-date-picker[label="Destination ETD"]', - shipped: 'vn-date-picker[label="Origin date"]', - tfShipped: 'vn-date-picker[label="Destination date"]', + originDated: 'vn-date-picker[label="Origin date"]', + futureDated: 'vn-date-picker[label="Destination date"]', linesMax: 'vn-textfield[label="Max Lines"]', litersMax: 'vn-textfield[label="Max Liters"]', ipt: 'vn-autocomplete[label="Origin IPT"]', @@ -756,8 +754,8 @@ export default { multiCheck: 'vn-multi-check', tableId: 'vn-textfield[name="id"]', tableTfId: 'vn-textfield[name="ticketFuture"]', - tableLiters: 'vn-textfield[name="litersMax"]', - tableLines: 'vn-textfield[name="linesMax"]', + tableLiters: 'vn-textfield[name="liters"]', + tableLines: 'vn-textfield[name="lines"]', submit: 'vn-submit[label="Search"]', table: 'tbody > tr:not(.empty-rows)' }, diff --git a/e2e/paths/05-ticket/20_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js similarity index 77% rename from e2e/paths/05-ticket/20_future.spec.js rename to e2e/paths/05-ticket/21_future.spec.js index 6db2bf4f00..d4dbffc942 100644 --- a/e2e/paths/05-ticket/20_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -16,9 +16,6 @@ describe('Ticket Future path', () => { await browser.close(); }); - const now = new Date(); - const tomorrow = new Date(now.getDate() + 1); - it('should show errors snackbar because of the required data', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.warehouseFk); @@ -27,20 +24,6 @@ describe('Ticket Future path', () => { expect(message.text).toContain('warehouseFk is a required argument'); - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.litersMax); - await page.waitToClick(selectors.ticketFuture.submit); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('litersMax is a required argument'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.linesMax); - await page.waitToClick(selectors.ticketFuture.submit); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('linesMax is a required argument'); - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.futureDated); await page.waitToClick(selectors.ticketFuture.submit); @@ -62,40 +45,9 @@ describe('Ticket Future path', () => { await page.waitForNumberOfElements(selectors.ticketFuture.table, 4); }); - it('should search with the origin shipped today', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.pickDate(selectors.ticketFuture.shipped, now); - await page.waitToClick(selectors.ticketFuture.submit); - await page.waitForNumberOfElements(selectors.ticketFuture.table, 4); - }); - - it('should search with the origin shipped tomorrow', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.pickDate(selectors.ticketFuture.shipped, tomorrow); - await page.waitToClick(selectors.ticketFuture.submit); - await page.waitForNumberOfElements(selectors.ticketFuture.table, 0); - }); - - it('should search with the destination shipped today', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.pickDate(selectors.ticketFuture.tfShipped, now); - await page.waitToClick(selectors.ticketFuture.submit); - await page.waitForNumberOfElements(selectors.ticketFuture.table, 4); - }); - - it('should search with the destination shipped tomorrow', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.pickDate(selectors.ticketFuture.tfShipped, tomorrow); - await page.waitToClick(selectors.ticketFuture.submit); - await page.waitForNumberOfElements(selectors.ticketFuture.table, 0); - }); - it('should search with the origin IPT', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); @@ -109,8 +61,6 @@ describe('Ticket Future path', () => { it('should search with the destination IPT', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); @@ -124,8 +74,6 @@ describe('Ticket Future path', () => { it('should search with the origin grouped state', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); @@ -139,8 +87,6 @@ describe('Ticket Future path', () => { it('should search with the destination grouped state', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); @@ -151,8 +97,6 @@ describe('Ticket Future path', () => { await page.waitForNumberOfElements(selectors.ticketFuture.table, 0); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.shipped); - await page.clearInput(selectors.ticketFuture.tfShipped); await page.clearInput(selectors.ticketFuture.ipt); await page.clearInput(selectors.ticketFuture.tfIpt); await page.clearInput(selectors.ticketFuture.state); diff --git a/modules/ticket/back/locale/ticket/en.yml b/modules/ticket/back/locale/ticket/en.yml index 4e97f5d8cb..c4ad84232f 100644 --- a/modules/ticket/back/locale/ticket/en.yml +++ b/modules/ticket/back/locale/ticket/en.yml @@ -20,3 +20,4 @@ routeFk: route companyFk: company agencyModeFk: agency ticketFk: ticket +mergedTicket: merged ticket diff --git a/modules/ticket/back/locale/ticket/es.yml b/modules/ticket/back/locale/ticket/es.yml index a570f1f118..2c524a74f2 100644 --- a/modules/ticket/back/locale/ticket/es.yml +++ b/modules/ticket/back/locale/ticket/es.yml @@ -20,3 +20,4 @@ routeFk: ruta companyFk: empresa agencyModeFk: agencia ticketFk: ticket +mergedTicket: ticket fusionado diff --git a/modules/ticket/back/methods/ticket-future/getTicketsFuture.js b/modules/ticket/back/methods/ticket-future/getTicketsFuture.js index 0fcc211822..aa726deeaf 100644 --- a/modules/ticket/back/methods/ticket-future/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket-future/getTicketsFuture.js @@ -20,18 +20,6 @@ module.exports = Self => { description: 'The date to probe', required: true }, - { - arg: 'litersMax', - type: 'number', - description: 'Maximum volume of tickets to catapult', - required: true - }, - { - arg: 'linesMax', - type: 'number', - description: 'Maximum number of lines of tickets to catapult', - required: true - }, { arg: 'warehouseFk', type: 'number', @@ -39,15 +27,15 @@ module.exports = Self => { required: true }, { - arg: 'shipped', - type: 'date', - description: 'Origin shipped', + arg: 'liters', + type: 'number', + description: 'Maximum volume of tickets to catapult', required: false }, { - arg: 'tfShipped', - type: 'date', - description: 'Destination shipped', + arg: 'lines', + type: 'number', + description: 'Maximum number of lines of tickets to catapult', required: false }, { @@ -108,7 +96,7 @@ module.exports = Self => { } }); - Self.getTicketsFuture = async (ctx, options) => { + Self.getTicketsFuture = async(ctx, options) => { const args = ctx.args; const conn = Self.dataSource.connector; const myOptions = {}; @@ -118,32 +106,32 @@ module.exports = Self => { const where = buildFilter(ctx.args, (param, value) => { switch (param) { - case 'id': - return { 'f.id': value }; - case 'tfId': - return { 'f.ticketFuture': value }; - case 'shipped': - return { 'f.shipped': value }; - case 'tfShipped': - return { 'f.tfShipped': value }; - case 'ipt': - return { 'f.ipt': value }; - case 'tfIpt': - return { 'f.tfIpt': value }; - case 'state': - return { 'f.code': { like: `%${value}%` } }; - case 'tfState': - return { 'f.tfCode': { like: `%${value}%` } }; + case 'id': + return {'f.id': value}; + case 'lines': + return {'f.lines': {lte: value}}; + case 'liters': + return {'f.liters': {lte: value}}; + case 'tfId': + return {'f.ticketFuture': value}; + case 'ipt': + return {'f.ipt': value}; + case 'tfIpt': + return {'f.tfIpt': value}; + case 'state': + return {'f.stateCode': {like: `%${value}%`}}; + case 'tfState': + return {'f.tfStateCode': {like: `%${value}%`}}; } }); - let filter = mergeFilters(ctx.args.filter, { where }); + let filter = mergeFilters(ctx.args.filter, {where}); const stmts = []; let stmt; stmt = new ParameterizedSQL( - `CALL vn.ticket_canbePostponed(?,?,?,?,?)`, - [args.originDated, args.futureDated, args.litersMax, args.linesMax, args.warehouseFk]); + `CALL vn.ticket_canbePostponed(?,?,?)`, + [args.originDated, args.futureDated, args.warehouseFk]); stmts.push(stmt); @@ -153,7 +141,7 @@ module.exports = Self => { CREATE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY - SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped + SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)`); @@ -174,35 +162,34 @@ module.exports = Self => { let range; let hasWhere; switch (args.problems) { - case true: - condition = `or`; - hasProblem = true; - range = { neq: null }; - hasWhere = true; - break; + case true: + condition = `or`; + hasProblem = true; + range = {neq: null}; + hasWhere = true; + break; - case false: - condition = `and`; - hasProblem = null; - range = null; - hasWhere = true; - break; + case false: + condition = `and`; + hasProblem = null; + range = null; + hasWhere = true; + break; } const problems = { [condition]: [ - { 'tp.isFreezed': hasProblem }, - { 'tp.risk': hasProblem }, - { 'tp.hasTicketRequest': hasProblem }, - { 'tp.itemShortage': range }, - { 'tp.hasComponentLack': hasProblem }, - { 'tp.isTooLittle': hasProblem } + {'tp.isFreezed': hasProblem}, + {'tp.risk': hasProblem}, + {'tp.hasTicketRequest': hasProblem}, + {'tp.itemShortage': range}, + {'tp.hasComponentLack': hasProblem}, + {'tp.isTooLittle': hasProblem} ] }; - if (hasWhere) { - filter = mergeFilters(filter, { where: problems }); - } + if (hasWhere) + filter = mergeFilters(filter, {where: problems}); stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makeOrderBy(filter.order)); diff --git a/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js index 502ea3074d..459c2eb1ee 100644 --- a/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js +++ b/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js @@ -5,11 +5,11 @@ describe('TicketFuture getTicketsFuture()', () => { today.setHours(0, 0, 0, 0); const tomorrow = new Date(today.getDate() + 1); - it('should return the tickets passing the required data', async () => { + it('should return the tickets passing the required data', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -19,7 +19,7 @@ describe('TicketFuture getTicketsFuture()', () => { warehouseFk: 1, }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -30,11 +30,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the problems on true', async () => { + it('should return the tickets matching the problems on true', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -45,7 +45,7 @@ describe('TicketFuture getTicketsFuture()', () => { problems: true }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -57,11 +57,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the problems on false', async () => { + it('should return the tickets matching the problems on false', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -72,7 +72,7 @@ describe('TicketFuture getTicketsFuture()', () => { problems: false }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(0); @@ -84,11 +84,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the problems on null', async () => { + it('should return the tickets matching the problems on null', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -99,7 +99,7 @@ describe('TicketFuture getTicketsFuture()', () => { problems: null }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -111,11 +111,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the correct origin shipped', async () => { + it('should return the tickets matching the OK State in origin date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -123,118 +123,10 @@ describe('TicketFuture getTicketsFuture()', () => { litersMax: 9999, linesMax: 9999, warehouseFk: 1, - shipped: today + state: 'OK' }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; - const result = await models.Ticket.getTicketsFuture(ctx, options); - - expect(result.length).toEqual(4); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return the tickets matching the an incorrect origin shipped', async () => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = { transaction: tx }; - - const args = { - originDated: today, - futureDated: today, - litersMax: 9999, - linesMax: 9999, - warehouseFk: 1, - shipped: tomorrow - }; - - const ctx = { req: { accessToken: { userId: 9 } }, args }; - const result = await models.Ticket.getTicketsFuture(ctx, options); - - expect(result.length).toEqual(0); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return the tickets matching the correct destination shipped', async () => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = { transaction: tx }; - - const args = { - originDated: today, - futureDated: today, - litersMax: 9999, - linesMax: 9999, - warehouseFk: 1, - tfShipped: today - }; - - const ctx = { req: { accessToken: { userId: 9 } }, args }; - const result = await models.Ticket.getTicketsFuture(ctx, options); - - expect(result.length).toEqual(4); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return the tickets matching the an incorrect destination shipped', async () => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = { transaction: tx }; - - const args = { - originDated: today, - futureDated: today, - litersMax: 9999, - linesMax: 9999, - warehouseFk: 1, - tfShipped: tomorrow - }; - - const ctx = { req: { accessToken: { userId: 9 } }, args }; - const result = await models.Ticket.getTicketsFuture(ctx, options); - - expect(result.length).toEqual(0); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return the tickets matching the OK State in origin date', async () => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = { transaction: tx }; - - const args = { - originDated: today, - futureDated: today, - litersMax: 9999, - linesMax: 9999, - warehouseFk: 1, - state: "OK" - }; - - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(1); @@ -246,11 +138,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the OK State in destination date', async () => { + it('should return the tickets matching the OK State in destination date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -258,10 +150,10 @@ describe('TicketFuture getTicketsFuture()', () => { litersMax: 9999, linesMax: 9999, warehouseFk: 1, - tfState: "OK" + tfState: 'OK' }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -273,11 +165,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the correct IPT in origin date', async () => { + it('should return the tickets matching the correct IPT in origin date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -288,7 +180,7 @@ describe('TicketFuture getTicketsFuture()', () => { ipt: null }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -300,11 +192,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the incorrect IPT in origin date', async () => { + it('should return the tickets matching the incorrect IPT in origin date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -315,7 +207,7 @@ describe('TicketFuture getTicketsFuture()', () => { ipt: 0 }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(0); @@ -327,11 +219,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the correct IPT in destination date', async () => { + it('should return the tickets matching the correct IPT in destination date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -342,7 +234,7 @@ describe('TicketFuture getTicketsFuture()', () => { tfIpt: null }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -354,11 +246,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the incorrect IPT in destination date', async () => { + it('should return the tickets matching the incorrect IPT in destination date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -369,7 +261,7 @@ describe('TicketFuture getTicketsFuture()', () => { tfIpt: 0 }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(0); @@ -381,11 +273,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the ID in origin date', async () => { + it('should return the tickets matching the ID in origin date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -396,7 +288,7 @@ describe('TicketFuture getTicketsFuture()', () => { id: 13 }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(1); @@ -408,11 +300,11 @@ describe('TicketFuture getTicketsFuture()', () => { } }); - it('should return the tickets matching the ID in destination date', async () => { + it('should return the tickets matching the ID in destination date', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const args = { originDated: today, @@ -423,7 +315,7 @@ describe('TicketFuture getTicketsFuture()', () => { tfId: 12 }; - const ctx = { req: { accessToken: { userId: 9 } }, args }; + const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(4); @@ -434,5 +326,4 @@ describe('TicketFuture getTicketsFuture()', () => { throw e; } }); - }); diff --git a/modules/ticket/back/methods/ticket/merge.js b/modules/ticket/back/methods/ticket/merge.js index 04f8d83aff..8a86eff6fa 100644 --- a/modules/ticket/back/methods/ticket/merge.js +++ b/modules/ticket/back/methods/ticket/merge.js @@ -43,14 +43,27 @@ module.exports = Self => { const fullPath = `${origin}/#!/ticket/${ticket.id}/summary`; const fullPathFuture = `${origin}/#!/ticket/${ticket.ticketFuture}/summary`; const message = $t('Ticket merged', { - originDated: dateUtil.toString(new Date(ticket.originETD)), - futureDated: dateUtil.toString(new Date(ticket.destETD)), + originDated: dateUtil.toString(new Date(ticket.shipped)), + futureDated: dateUtil.toString(new Date(ticket.tfShipped)), id: ticket.id, tfId: ticket.ticketFuture, fullPath, fullPathFuture }); if (!ticket.id || !ticket.ticketFuture) continue; + + const ticketFutureLogRecord = { + originFk: ticket.ticketFuture, + userFk: ctx.req.accessToken.userId, + action: 'update', + changedModel: 'Ticket', + changedModelId: ticket.ticketFuture, + changedModelValue: ticket.ticketFuture, + oldInstance: {}, + newInstance: {mergedTicket: ticket.id} + }; + + await models.TicketLog.create(ticketFutureLogRecord, myOptions); await models.Sale.updateAll({ticketFk: ticket.id}, {ticketFk: ticket.ticketFuture}, myOptions); await models.Ticket.setDeleted(ctx, ticket.id, myOptions); await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message); diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index 1b3ae453e4..93e0462363 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -4,43 +4,26 @@ <vn-date-picker vn-one label="Origin date" - ng-model="filter.shipped" - on-change="$ctrl.from = value"> + ng-model="filter.originDated" + required="true"> </vn-date-picker> <vn-date-picker vn-one label="Destination date" - ng-model="filter.tfShipped"> - </vn-date-picker> - </vn-horizontal> - <vn-horizontal class="vn-px-lg"> - <vn-date-picker - vn-one - label="Origin ETD" - ng-model="filter.originDated" - required="true" - info="ETD"> - </vn-date-picker> - <vn-date-picker - vn-one - label="Destination ETD" ng-model="filter.futureDated" - required="true" - info="ETD"> + required="true"> </vn-date-picker> </vn-horizontal> <vn-horizontal class="vn-px-lg"> <vn-textfield vn-one label="Max Lines" - ng-model="filter.linesMax" - required="true"> + ng-model="filter.lines"> </vn-textfield> <vn-textfield vn-one label="Max Liters" - ng-model="filter.litersMax" - required="true"> + ng-model="filter.liters"> </vn-textfield> </vn-horizontal> <vn-horizontal class="vn-px-lg"> @@ -48,22 +31,22 @@ data="$ctrl.itemPackingTypes" label="Origin IPT" value-field="code" - show-field="name" + show-field="description" ng-model="filter.ipt" info="IPT"> <tpl-item> - {{name}} + {{description}} </tpl-item> </vn-autocomplete> <vn-autocomplete vn-one data="$ctrl.itemPackingTypes" label="Destination IPT" value-field="code" - show-field="name" + show-field="description" ng-model="filter.tfIpt" info="IPT"> <tpl-item> - {{name}} + {{description}} </tpl-item> </vn-autocomplete> </vn-horizontal> diff --git a/modules/ticket/front/future-search-panel/index.js b/modules/ticket/front/future-search-panel/index.js index 1a1f0e4c58..d7e7b3a5ea 100644 --- a/modules/ticket/front/future-search-panel/index.js +++ b/modules/ticket/front/future-search-panel/index.js @@ -28,9 +28,8 @@ class Controller extends SearchPanel { this.$http.get('ItemPackingTypes').then(res => { for (let ipt of res.data) { itemPackingTypes.push({ - id: ipt.id, + description: this.$t(ipt.description), code: ipt.code, - name: this.$t(ipt.code) }); } this.itemPackingTypes = itemPackingTypes; diff --git a/modules/ticket/front/future-search-panel/locale/en.yml b/modules/ticket/front/future-search-panel/locale/en.yml index fe71865cba..767c20152c 100644 --- a/modules/ticket/front/future-search-panel/locale/en.yml +++ b/modules/ticket/front/future-search-panel/locale/en.yml @@ -1,9 +1 @@ Future tickets: Tickets a futuro -FREE: Free -DELIVERED: Delivered -ON_PREPARATION: On preparation -PACKED: Packed -F: Fruits and vegetables -V: Vertical -H: Horizontal -P: Feed diff --git a/modules/ticket/front/future-search-panel/locale/es.yml b/modules/ticket/front/future-search-panel/locale/es.yml index 82deba538c..9d72c5b069 100644 --- a/modules/ticket/front/future-search-panel/locale/es.yml +++ b/modules/ticket/front/future-search-panel/locale/es.yml @@ -11,13 +11,4 @@ With problems: Con problemas Warehouse: Almacén Origin Grouped State: Estado agrupado origen Destination Grouped State: Estado agrupado destino -FREE: Libre -DELIVERED: Servido -ON_PREPARATION: En preparacion -PACKED: Encajado -F: Frutas y verduras -V: Vertical -H: Horizontal -P: Pienso -ETD: Tiempo estimado de entrega IPT: Encajado diff --git a/modules/ticket/front/future/index.html b/modules/ticket/front/future/index.html index d30cbaf198..0b19120845 100644 --- a/modules/ticket/front/future/index.html +++ b/modules/ticket/front/future/index.html @@ -44,31 +44,31 @@ <th field="id"> <span translate>Origin ID</span> </th> - <th field="originETD"> - <span translate>Origin ETD</span> + <th field="shipped"> + <span translate>Origin Date</span> </th> <th field="state"> <span translate>Origin State</span> </th> - <th field="ipt"> + <th field="ipt" title="Item Packing Type"> <span>IPT</span> </th> - <th field="litersMax"> + <th field="liters"> <span translate>Liters</span> </th> - <th field="linesMax"> + <th field="lines"> <span translate>Available Lines</span> </th> <th field="ticketFuture"> <span translate>Destination ID</span> </th> - <th field="destETD"> - <span translate>Destination ETD</span> + <th field="tfShipped"> + <span translate>Destination Date</span> </th> <th field="tfState"> <span translate>Destination State</span> </th> - <th field="tfIpt"> + <th field="tfIpt" title="Item Packing Type"> <span>IPT</span> </th> </tr> @@ -125,8 +125,8 @@ {{::ticket.id}} </span></td> <td shrink-date> - <span class="chip {{$ctrl.compareDate(ticket.originETD)}}"> - {{::ticket.originETD | date: 'dd/MM/yyyy'}} + <span class="chip {{$ctrl.compareDate(ticket.shipped)}}"> + {{::ticket.shipped | date: 'dd/MM/yyyy'}} </span> </td> <td> @@ -146,8 +146,8 @@ </span> </td> <td shrink-date> - <span class="chip {{$ctrl.compareDate(ticket.destETD)}}"> - {{::ticket.destETD | date: 'dd/MM/yyyy'}} + <span class="chip {{$ctrl.compareDate(ticket.tfShipped)}}"> + {{::ticket.tfShipped | date: 'dd/MM/yyyy'}} </span> </td> <td> diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index 311b9c3070..918ed79b50 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -15,11 +15,11 @@ export default class Controller extends Section { searchable: false }, { - field: 'originETD', + field: 'shipped', searchable: false }, { - field: 'destETD', + field: 'tfShipped', searchable: false }, { @@ -35,7 +35,7 @@ export default class Controller extends Section { autocomplete: { url: 'ItemPackingTypes', showField: 'description', - valueField: 'code' + valueField: 'description' } }, { @@ -43,7 +43,7 @@ export default class Controller extends Section { autocomplete: { url: 'ItemPackingTypes', showField: 'description', - valueField: 'code' + valueField: 'description' } }, ] @@ -57,9 +57,7 @@ export default class Controller extends Section { this.filterParams = { originDated: today, futureDated: today, - linesMax: '9999', - litersMax: '9999', - warehouseFk: 1 + warehouseFk: this.vnConfig.warehouseFk }; } @@ -113,7 +111,7 @@ export default class Controller extends Section { } moveTicketsFuture() { - let params = { tickets: this.checked }; + let params = {tickets: this.checked}; return this.$http.post('Tickets/merge', params) .then(() => { this.$.model.refresh(); @@ -123,18 +121,18 @@ export default class Controller extends Section { exprBuilder(param, value) { switch (param) { - case 'id': - return { 'id': value }; - case 'ticketFuture': - return { 'ticketFuture': value }; - case 'litersMax': - return { 'liters': value }; - case 'linesMax': - return { 'lines': value }; - case 'ipt': - return { 'ipt': value }; - case 'tfIpt': - return { 'tfIpt': value }; + case 'id': + return {'id': value}; + case 'ticketFuture': + return {'ticketFuture': value}; + case 'liters': + return {'liters': value}; + case 'lines': + return {'lines': value}; + case 'ipt': + return {'ipt': value}; + case 'tfIpt': + return {'tfIpt': value}; } } } diff --git a/modules/ticket/front/future/index.spec.js b/modules/ticket/front/future/index.spec.js index 63deebc4f8..9c6b97c8be 100644 --- a/modules/ticket/front/future/index.spec.js +++ b/modules/ticket/front/future/index.spec.js @@ -13,16 +13,16 @@ describe('Component vnTicketFuture', () => { $httpBackend = _$httpBackend_; $window = _$window_; const $element = angular.element('<vn-ticket-future></vn-ticket-future>'); - controller = $componentController('vnTicketFuture', { $element }); + controller = $componentController('vnTicketFuture', {$element}); controller.$.model = crudModel; controller.$.model.data = [{ id: 1, checked: true, - state: "OK" + state: 'OK' }, { id: 2, checked: true, - state: "Libre" + state: 'Libre' }]; })); @@ -67,6 +67,7 @@ describe('Component vnTicketFuture', () => { it('should return success to the OK tickets', () => { const ok = controller.stateColor(controller.$.model.data[0].state); const notOk = controller.stateColor(controller.$.model.data[1].state); + expect(ok).toEqual('success'); expect(notOk).not.toEqual('success'); }); @@ -74,6 +75,7 @@ describe('Component vnTicketFuture', () => { it('should return success to the FREE tickets', () => { const notFree = controller.stateColor(controller.$.model.data[0].state); const free = controller.stateColor(controller.$.model.data[1].state); + expect(free).toEqual('notice'); expect(notFree).not.toEqual('notice'); }); diff --git a/modules/ticket/front/future/locale/en.yml b/modules/ticket/front/future/locale/en.yml index 66d3ce2698..4400e69926 100644 --- a/modules/ticket/front/future/locale/en.yml +++ b/modules/ticket/front/future/locale/en.yml @@ -1,6 +1,2 @@ Move confirmation: Do you want to move {{checked}} tickets to the future? -FREE: Free -DELIVERED: Delivered -ON_PREPARATION: On preparation -PACKED: Packed Success: Tickets moved successfully! diff --git a/modules/ticket/front/future/locale/es.yml b/modules/ticket/front/future/locale/es.yml index 9be0be6a47..9fceea111c 100644 --- a/modules/ticket/front/future/locale/es.yml +++ b/modules/ticket/front/future/locale/es.yml @@ -3,20 +3,14 @@ Search tickets: Buscar tickets Search future tickets by date: Buscar tickets por fecha Problems: Problemas Origin ID: ID origen -Closing: Cierre Origin State: Estado origen Destination State: Estado destino Liters: Litros Available Lines: Líneas disponibles Destination ID: ID destino -Destination ETD: ETD Destino -Origin ETD: ETD Origen Move tickets: Mover tickets Move confirmation: ¿Desea mover {{checked}} tickets hacia el futuro? Success: Tickets movidos correctamente -ETD: Tiempo estimado de entrega IPT: Encajado -FREE: Libre -DELIVERED: Servido -ON_PREPARATION: En preparacion -PACKED: Encajado +Origin Date: Fecha origen +Destination Date: Fecha destino From f80f851e8d480eedc3502531240c2bbd0991ef12 Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Wed, 14 Dec 2022 13:10:33 +0100 Subject: [PATCH 14/28] refs #4962 model TicketFuture deleted --- modules/ticket/back/model-config.json | 3 --- modules/ticket/back/models/ticket-future.json | 12 ------------ 2 files changed, 15 deletions(-) delete mode 100644 modules/ticket/back/models/ticket-future.json diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index baaca595e4..17bd729490 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -94,8 +94,5 @@ }, "TicketConfig": { "dataSource": "vn" - }, - "TicketFuture": { - "dataSource": "vn" } } diff --git a/modules/ticket/back/models/ticket-future.json b/modules/ticket/back/models/ticket-future.json deleted file mode 100644 index 00277ab8a1..0000000000 --- a/modules/ticket/back/models/ticket-future.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "TicketFuture", - "base": "PersistedModel", - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "employee", - "permission": "ALLOW" - } - ] - } From 8d7757ddbe5db19c7785948f8638e807c3b592cb Mon Sep 17 00:00:00 2001 From: alexm <alexm@verdnatura.es> Date: Thu, 15 Dec 2022 07:40:51 +0100 Subject: [PATCH 15/28] add reset-password --- front/salix/components/app/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/salix/components/app/app.js b/front/salix/components/app/app.js index 20f0ad969b..91a8d22152 100644 --- a/front/salix/components/app/app.js +++ b/front/salix/components/app/app.js @@ -21,7 +21,7 @@ export default class App extends Component { get showLayout() { const state = this.$state.current.name || this.$location.$$path.substring(1).replace('/', '.'); - const outLayout = ['login', 'recoverPassword', 'resetPassword']; + const outLayout = ['login', 'recoverPassword', 'resetPassword', 'reset-password']; return state && !outLayout.some(ol => ol == state); } From 33196acac6b4ed31400ce63c38f4a30314744a8d Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Thu, 15 Dec 2022 08:31:47 +0100 Subject: [PATCH 16/28] refs #4928 fixture notification, fix test supplier --- .../225001/00-supplier_beforeUpdate.sql | 3 + .../back/models/specs/supplier.spec.js | 127 +++++++++++------- 2 files changed, 84 insertions(+), 46 deletions(-) diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225001/00-supplier_beforeUpdate.sql index 08af8666b1..e874156592 100644 --- a/db/changes/225001/00-supplier_beforeUpdate.sql +++ b/db/changes/225001/00-supplier_beforeUpdate.sql @@ -44,3 +44,6 @@ BEGIN END$$ DELIMITER ; + +INSERT INTO `util`.`notification` (`id`, `name`,`description`) + VALUES (3, 'supplier-pay-method-update', 'A supplier pay method has been updated'); diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 3140981c34..effb70e358 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -2,13 +2,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('loopback model Supplier', () => { - let supplierOne; - let supplierTwo; - beforeAll(async() => { - supplierOne = await models.Supplier.findById(1); - supplierTwo = await models.Supplier.findById(442); - const activeCtx = { accessToken: {userId: 9}, http: { @@ -23,71 +17,112 @@ describe('loopback model Supplier', () => { }); }); - afterAll(async() => { - await supplierOne.updateAttribute('payMethodFk', supplierOne.payMethodFk); - await supplierTwo.updateAttribute('payMethodFk', supplierTwo.payMethodFk); - }); - describe('payMethodFk', () => { it('should throw an error when attempting to set an invalid payMethod id in the supplier', async() => { - let error; - const expectedError = 'You can not select this payment method without a registered bankery account'; - const supplier = await models.Supplier.findById(1); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - await supplier.updateAttribute('payMethodFk', 8) - .catch(e => { - error = e; + try { + let error; + const expectedError = 'You can not select this payment method without a registered bankery account'; + const supplier = await models.Supplier.findOne({where: {id: 1}}, options); - expect(error.message).toContain(expectedError); - }); + await supplier.updateAttribute('payMethodFk', 8, options) + .catch(e => { + error = e; - expect(error).toBeDefined(); + expect(error.message).toContain(expectedError); + }); + + expect(error).toBeDefined(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should not throw if the payMethod id is valid', async() => { - let error; - const supplier = await models.Supplier.findById(442); - await supplier.updateAttribute('payMethodFk', 4) - .catch(e => { - error = e; - }); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - expect(error).not.toBeDefined(); + try { + let error; + const supplier = await models.Supplier.findOne({where: {id: 442}}, options); + await supplier.updateAttribute('payMethodFk', 4, options) + .catch(e => { + error = e; + }); + + expect(error).not.toBeDefined(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should have checked isPayMethodChecked for payMethod hasVerfified is false', async() => { - const supplier = await models.Supplier.findById(442); - await supplier.updateAttribute('isPayMethodChecked', true); - await supplier.updateAttribute('payMethodFk', 5); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - const result = await models.Supplier.findById(442); + try { + const supplier = await models.Supplier.findOne({where: {id: 442}}, options); + await supplier.updateAttribute('isPayMethodChecked', true, options); + await supplier.updateAttribute('payMethodFk', 5, options); - expect(result.isPayMethodChecked).toEqual(true); + const result = await models.Supplier.findOne({where: {id: 442}}, options); + + expect(result.isPayMethodChecked).toEqual(true); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should have unchecked isPayMethodChecked for payMethod hasVerfified is true', async() => { - const supplier = await models.Supplier.findById(442); - await supplier.updateAttribute('isPayMethodChecked', true); - await supplier.updateAttribute('payMethodFk', 2); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - const result = await models.Supplier.findById(442); + try { + const supplier = await models.Supplier.findOne({where: {id: 442}}, options); + await supplier.updateAttribute('isPayMethodChecked', true, options); + await supplier.updateAttribute('payMethodFk', 2, options); - expect(result.isPayMethodChecked).toEqual(false); + const result = await models.Supplier.findOne({where: {id: 442}}, options); + + expect(result.isPayMethodChecked).toEqual(false); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); it('should have unchecked isPayMethodChecked for payDay and peyDemFk', async() => { - const supplier = await models.Supplier.findById(442); + const tx = await models.Supplier.beginTransaction({}); + const options = {transaction: tx}; - await supplier.updateAttribute('isPayMethodChecked', true); - await supplier.updateAttribute('payDay', 5); - const firstResult = await models.Supplier.findById(442); + try { + const supplier = await models.Supplier.findOne({where: {id: 442}}, options); + await supplier.updateAttribute('payMethodFk', 2, options); - await supplier.updateAttribute('isPayMethodChecked', true); - await supplier.updateAttribute('payDemFk', 1); - const secondResult = await models.Supplier.findById(442); + await supplier.updateAttribute('isPayMethodChecked', true, options); + await supplier.updateAttribute('payDay', 5, options); + const firstResult = await models.Supplier.findOne({where: {id: 442}}, options); - expect(firstResult.isPayMethodChecked).toEqual(false); - expect(secondResult.isPayMethodChecked).toEqual(false); + await supplier.updateAttribute('isPayMethodChecked', true, options); + await supplier.updateAttribute('payDemFk', 1, options); + const secondResult = await models.Supplier.findOne({where: {id: 442}}, options); + + expect(firstResult.isPayMethodChecked).toEqual(false); + expect(secondResult.isPayMethodChecked).toEqual(false); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); }); }); From 522000cd04f06d05f19d3cc640df16960aaa77bb Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Thu, 15 Dec 2022 09:52:34 +0100 Subject: [PATCH 17/28] refs #4928 fix fixtures --- .../225001/00-supplier_beforeUpdate.sql | 3 -- db/dump/fixtures.sql | 4 ++- .../back/models/specs/supplier.spec.js | 33 +++++++++---------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225001/00-supplier_beforeUpdate.sql index e874156592..08af8666b1 100644 --- a/db/changes/225001/00-supplier_beforeUpdate.sql +++ b/db/changes/225001/00-supplier_beforeUpdate.sql @@ -44,6 +44,3 @@ BEGIN END$$ DELIMITER ; - -INSERT INTO `util`.`notification` (`id`, `name`,`description`) - VALUES (3, 'supplier-pay-method-update', 'A supplier pay method has been updated'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5b37338e49..68e2f7a8b6 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2689,7 +2689,8 @@ INSERT INTO `util`.`notificationConfig` INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES - (1, 'print-email', 'notification fixture one'); + (1, 'print-email', 'notification fixture one'), + (3, 'supplier-pay-method-update', 'A supplier pay method has been updated'); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES @@ -2746,3 +2747,4 @@ INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) INSERT INTO `vn`.`payDemDetail` (`id`, `detail`) VALUES (1, 1); + diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index effb70e358..1e8efb4b1d 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -2,7 +2,12 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('loopback model Supplier', () => { + let supplierOne; + let supplierTwo; + beforeAll(async() => { + supplierOne = await models.Supplier.findById(1); + supplierTwo = await models.Supplier.findById(442); const activeCtx = { accessToken: {userId: 9}, http: { @@ -25,9 +30,8 @@ describe('loopback model Supplier', () => { try { let error; const expectedError = 'You can not select this payment method without a registered bankery account'; - const supplier = await models.Supplier.findOne({where: {id: 1}}, options); - await supplier.updateAttribute('payMethodFk', 8, options) + await supplierOne.updateAttribute('payMethodFk', 8, options) .catch(e => { error = e; @@ -48,8 +52,7 @@ describe('loopback model Supplier', () => { try { let error; - const supplier = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('payMethodFk', 4, options) + await supplierTwo.updateAttribute('payMethodFk', 4, options) .catch(e => { error = e; }); @@ -67,9 +70,8 @@ describe('loopback model Supplier', () => { const options = {transaction: tx}; try { - const supplier = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('isPayMethodChecked', true, options); - await supplier.updateAttribute('payMethodFk', 5, options); + await supplierTwo.updateAttribute('isPayMethodChecked', true, options); + await supplierTwo.updateAttribute('payMethodFk', 5, options); const result = await models.Supplier.findOne({where: {id: 442}}, options); @@ -86,9 +88,8 @@ describe('loopback model Supplier', () => { const options = {transaction: tx}; try { - const supplier = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('isPayMethodChecked', true, options); - await supplier.updateAttribute('payMethodFk', 2, options); + await supplierTwo.updateAttribute('isPayMethodChecked', true, options); + await supplierTwo.updateAttribute('payMethodFk', 2, options); const result = await models.Supplier.findOne({where: {id: 442}}, options); @@ -105,15 +106,13 @@ describe('loopback model Supplier', () => { const options = {transaction: tx}; try { - const supplier = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('payMethodFk', 2, options); - - await supplier.updateAttribute('isPayMethodChecked', true, options); - await supplier.updateAttribute('payDay', 5, options); + await supplierTwo.updateAttribute('payMethodFk', 2, options); + await supplierTwo.updateAttribute('isPayMethodChecked', true, options); + await supplierTwo.updateAttribute('payDay', 5, options); const firstResult = await models.Supplier.findOne({where: {id: 442}}, options); - await supplier.updateAttribute('isPayMethodChecked', true, options); - await supplier.updateAttribute('payDemFk', 1, options); + await supplierTwo.updateAttribute('isPayMethodChecked', true, options); + await supplierTwo.updateAttribute('payDemFk', 1, options); const secondResult = await models.Supplier.findOne({where: {id: 442}}, options); expect(firstResult.isPayMethodChecked).toEqual(false); From 5cc8764a3f5f710e7c039ef42baa7b79d4811108 Mon Sep 17 00:00:00 2001 From: alexm <alexm@verdnatura.es> Date: Thu, 15 Dec 2022 13:54:17 +0100 Subject: [PATCH 18/28] acquireTimeout 10000 --- loopback/server/datasources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 00f6bf624e..1e8e4820bf 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -15,7 +15,7 @@ "legacyUtcDateProcessing": false, "timezone": "local", "connectTimeout": 40000, - "acquireTimeout": 20000, + "acquireTimeout": 10000, "waitForConnections": true }, "osticket": { From bab6fa0c9d2644b9fedd20331e590d44758e8fab Mon Sep 17 00:00:00 2001 From: alexm <alexm@verdnatura.es> Date: Thu, 15 Dec 2022 14:02:18 +0100 Subject: [PATCH 19/28] acquireTimeout: 60000 --- loopback/server/datasources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 1e8e4820bf..f5f277ffc3 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -15,7 +15,7 @@ "legacyUtcDateProcessing": false, "timezone": "local", "connectTimeout": 40000, - "acquireTimeout": 10000, + "acquireTimeout": 60000, "waitForConnections": true }, "osticket": { From ed68637059c266911118148347d2cd904bfed61d Mon Sep 17 00:00:00 2001 From: alexm <alexm@verdnatura.es> Date: Thu, 15 Dec 2022 15:05:17 +0100 Subject: [PATCH 20/28] disable outLayout --- front/salix/components/app/app.html | 5 ++- front/salix/components/login/login.html | 57 ++++++++++++++----------- front/salix/routes.js | 4 +- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/front/salix/components/app/app.html b/front/salix/components/app/app.html index f14fab2dd3..d32c9f68bc 100644 --- a/front/salix/components/app/app.html +++ b/front/salix/components/app/app.html @@ -1,8 +1,9 @@ <vn-layout ng-if="$ctrl.showLayout"> </vn-layout> -<vn-out-layout +<ui-view + name="login" ng-if="!$ctrl.showLayout"> -</vn-out-layout> +</ui-view> <vn-snackbar vn-id="snackbar"></vn-snackbar> <vn-debug-info></vn-debug-info> diff --git a/front/salix/components/login/login.html b/front/salix/components/login/login.html index a078fa0af0..807e4b284c 100644 --- a/front/salix/components/login/login.html +++ b/front/salix/components/login/login.html @@ -1,27 +1,32 @@ -<vn-textfield - label="User" - ng-model="$ctrl.user" - vn-id="userField" - vn-focus> -</vn-textfield> -<vn-textfield - label="Password" - ng-model="$ctrl.password" - type="password"> -</vn-textfield> -<vn-check - label="Do not close session" - ng-model="$ctrl.remember" - name="remember"> -</vn-check> -<div class="footer"> - <vn-submit label="Enter" ng-click="$ctrl.submit()"></vn-submit> - <div class="spinner-wrapper"> - <vn-spinner enable="$ctrl.loading"></vn-spinner> - </div> - <div class="vn-pt-lg"> - <a ui-sref="recoverPassword" translate> - I do not remember my password - </a> - </div> +<div class="box"> + <img src="./logo.svg"/> + <form name="form" ng-submit="$ctrl.submit()"> + <vn-textfield + label="User" + ng-model="$ctrl.user" + vn-id="userField" + vn-focus> + </vn-textfield> + <vn-textfield + label="Password" + ng-model="$ctrl.password" + type="password"> + </vn-textfield> + <vn-check + label="Do not close session" + ng-model="$ctrl.remember" + name="remember"> + </vn-check> + <div class="footer"> + <vn-submit label="Enter" ng-click="$ctrl.submit()"></vn-submit> + <div class="spinner-wrapper"> + <vn-spinner enable="$ctrl.loading"></vn-spinner> + </div> + <!--<div class="vn-pt-lg"> + <a ui-sref="recoverPassword" translate> + I do not remember my password + </a> + </div>--> + </div> + </form> </div> diff --git a/front/salix/routes.js b/front/salix/routes.js index be893800f9..613dc72884 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -9,7 +9,9 @@ function config($stateProvider, $urlRouterProvider) { .state('login', { url: '/login?continue', description: 'Login', - template: '<vn-login></vn-login>' + views: { + 'login': {template: '<vn-login></vn-login>'}, + } }) .state('recoverPassword', { url: '/recover-password', From 19cbd5b57b3a055e5dd1d1167c699dc38944b615 Mon Sep 17 00:00:00 2001 From: alexm <alexm@verdnatura.es> Date: Fri, 16 Dec 2022 08:43:34 +0100 Subject: [PATCH 21/28] fix css --- front/salix/components/login/style.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/salix/components/login/style.scss b/front/salix/components/login/style.scss index 8985893f2a..5a7e722459 100644 --- a/front/salix/components/login/style.scss +++ b/front/salix/components/login/style.scss @@ -25,7 +25,7 @@ vn-recover-password{ } } -vn-out-layout{ +vn-login{ position: absolute; height: 100%; width: 100%; From 47f624ec043f4c44cceb4a1983b1f54b77b89149 Mon Sep 17 00:00:00 2001 From: alexm <alexm@verdnatura.es> Date: Fri, 16 Dec 2022 09:01:30 +0100 Subject: [PATCH 22/28] skip e2e test --- e2e/paths/01-salix/04_recoverPassword.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e/paths/01-salix/04_recoverPassword.spec.js b/e2e/paths/01-salix/04_recoverPassword.spec.js index 80ef32cb51..67e6362d36 100644 --- a/e2e/paths/01-salix/04_recoverPassword.spec.js +++ b/e2e/paths/01-salix/04_recoverPassword.spec.js @@ -1,7 +1,8 @@ import selectors from '../../helpers/selectors'; import getBrowser from '../../helpers/puppeteer'; -describe('Login path', async() => { +// https://redmine.verdnatura.es/issues/4995 fix login +xdescribe('RecoverPassword path', async() => { let browser; let page; From b72cb64bf8f4322284160cd9f241f7b9051fb5c0 Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Fri, 16 Dec 2022 12:50:09 +0100 Subject: [PATCH 23/28] refs #4928 findById --- modules/supplier/back/models/specs/supplier.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 1e8efb4b1d..f317f1fb95 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -73,7 +73,7 @@ describe('loopback model Supplier', () => { await supplierTwo.updateAttribute('isPayMethodChecked', true, options); await supplierTwo.updateAttribute('payMethodFk', 5, options); - const result = await models.Supplier.findOne({where: {id: 442}}, options); + const result = await models.Supplier.findById(442, null, options); expect(result.isPayMethodChecked).toEqual(true); await tx.rollback(); @@ -91,7 +91,7 @@ describe('loopback model Supplier', () => { await supplierTwo.updateAttribute('isPayMethodChecked', true, options); await supplierTwo.updateAttribute('payMethodFk', 2, options); - const result = await models.Supplier.findOne({where: {id: 442}}, options); + const result = await models.Supplier.findById(442, null, options); expect(result.isPayMethodChecked).toEqual(false); await tx.rollback(); @@ -109,11 +109,11 @@ describe('loopback model Supplier', () => { await supplierTwo.updateAttribute('payMethodFk', 2, options); await supplierTwo.updateAttribute('isPayMethodChecked', true, options); await supplierTwo.updateAttribute('payDay', 5, options); - const firstResult = await models.Supplier.findOne({where: {id: 442}}, options); + const firstResult = await models.Supplier.findById(442, null, options); await supplierTwo.updateAttribute('isPayMethodChecked', true, options); await supplierTwo.updateAttribute('payDemFk', 1, options); - const secondResult = await models.Supplier.findOne({where: {id: 442}}, options); + const secondResult = await models.Supplier.findById(442, null, options); expect(firstResult.isPayMethodChecked).toEqual(false); expect(secondResult.isPayMethodChecked).toEqual(false); From 98c9e0ac50226fa153537ff93ec77814889bf0bf Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Fri, 16 Dec 2022 13:42:23 +0100 Subject: [PATCH 24/28] refs #4962 autoload added and second header --- front/core/components/smart-table/index.js | 8 ++-- front/core/components/smart-table/table.scss | 15 +++++++- .../front/future-search-panel/index.html | 8 ++-- modules/ticket/front/future/index.html | 37 +++++++++++-------- modules/ticket/front/future/index.js | 7 +++- 5 files changed, 49 insertions(+), 26 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 8d2c3c1531..770dcdf32b 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -147,7 +147,7 @@ export default class SmartTable extends Component { for (const column of this.columns) { if (viewConfig.configuration[column.field] == false) { const baseSelector = `smart-table[view-config-id="${this.viewConfigId}"] table`; - selectors.push(`${baseSelector} thead > tr > th:nth-child(${column.index + 1})`); + selectors.push(`${baseSelector} thead > tr:not([second-header]) > th:nth-child(${column.index + 1})`); selectors.push(`${baseSelector} tbody > tr > td:nth-child(${column.index + 1})`); } } @@ -235,7 +235,7 @@ export default class SmartTable extends Component { } registerColumns() { - const header = this.element.querySelector('thead > tr'); + const header = this.element.querySelector('thead > tr:not([second-header])'); if (!header) return; const columns = header.querySelectorAll('th'); @@ -254,7 +254,7 @@ export default class SmartTable extends Component { } emptyDataRows() { - const header = this.element.querySelector('thead > tr'); + const header = this.element.querySelector('thead > tr:not([second-header])'); const columns = header.querySelectorAll('th'); const tbody = this.element.querySelector('tbody'); if (tbody) { @@ -333,7 +333,7 @@ export default class SmartTable extends Component { } displaySearch() { - const header = this.element.querySelector('thead > tr'); + const header = this.element.querySelector('thead > tr:not([second-header])'); if (!header) return; const tbody = this.element.querySelector('tbody'); diff --git a/front/core/components/smart-table/table.scss b/front/core/components/smart-table/table.scss index c38c149ca3..996c41a74e 100644 --- a/front/core/components/smart-table/table.scss +++ b/front/core/components/smart-table/table.scss @@ -8,6 +8,16 @@ smart-table table { & > thead { border-bottom: $border; + & > tr[second-header] { + & > th + { + text-align: center; + border-bottom-style: groove; + font-weight: bold; + text-transform: uppercase; + } + } + & > * > th { font-weight: normal; } @@ -60,6 +70,9 @@ smart-table table { vertical-align: middle; } } + &[separator]{ + border-left-style: groove; + } vn-icon.bright, i.bright { color: #f7931e; } @@ -108,4 +121,4 @@ smart-table table { font-size: 1.375rem; text-align: center; } -} \ No newline at end of file +} diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index 93e0462363..c4df33ec46 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -17,13 +17,13 @@ <vn-horizontal class="vn-px-lg"> <vn-textfield vn-one - label="Max Lines" - ng-model="filter.lines"> + label="Max Liters" + ng-model="filter.liters"> </vn-textfield> <vn-textfield vn-one - label="Max Liters" - ng-model="filter.liters"> + label="Max Lines" + ng-model="filter.lines"> </vn-textfield> </vn-horizontal> <vn-horizontal class="vn-px-lg"> diff --git a/modules/ticket/front/future/index.html b/modules/ticket/front/future/index.html index 0b19120845..8633e7a388 100644 --- a/modules/ticket/front/future/index.html +++ b/modules/ticket/front/future/index.html @@ -1,7 +1,9 @@ <vn-crud-model vn-id="model" url="Tickets/getTicketsFuture" - limit="20"> + limit="20" + auto-load="true" + params="model.data"> </vn-crud-model> <vn-portal slot="topbar"> <vn-searchbar @@ -30,6 +32,11 @@ <slot-table> <table> <thead> + <tr second-header> + <td></td> + <th colspan="7" translate>Origin</th> + <th colspan="4" translate>Destination</th> + </tr> <tr> <th shrink> <vn-multi-check @@ -42,35 +49,35 @@ <span translate>Problems</span> </th> <th field="id"> - <span translate>Origin ID</span> + <span translate>ID</span> </th> <th field="shipped"> - <span translate>Origin Date</span> - </th> - <th field="state"> - <span translate>Origin State</span> + <span translate>Date</span> </th> <th field="ipt" title="Item Packing Type"> <span>IPT</span> </th> + <th field="state"> + <span translate>State</span> + </th> <th field="liters"> <span translate>Liters</span> </th> - <th field="lines"> + <th shrink field="lines"> <span translate>Available Lines</span> </th> - <th field="ticketFuture"> - <span translate>Destination ID</span> + <th field="ticketFuture" separator> + <span translate>ID</span> </th> <th field="tfShipped"> - <span translate>Destination Date</span> - </th> - <th field="tfState"> - <span translate>Destination State</span> + <span translate>Date</span> </th> <th field="tfIpt" title="Item Packing Type"> <span>IPT</span> </th> + <th shrink field="tfState"> + <span translate>State</span> + </th> </tr> </thead> <tbody> @@ -129,13 +136,13 @@ {{::ticket.shipped | date: 'dd/MM/yyyy'}} </span> </td> + <td>{{::ticket.ipt}}</td> <td> <span class="chip {{$ctrl.stateColor(ticket.state)}}"> {{::ticket.state}} </span> </td> - <td>{{::ticket.ipt}}</td> <td>{{::ticket.liters}}</td> <td>{{::ticket.lines}}</td> <td> @@ -150,13 +157,13 @@ {{::ticket.tfShipped | date: 'dd/MM/yyyy'}} </span> </td> + <td>{{::ticket.tfIpt}}</td> <td> <span class="chip {{$ctrl.stateColor(ticket.tfState)}}"> {{::ticket.tfState}} </span> </td> - <td>{{::ticket.tfIpt}}</td> </tr> </tbody> </table> diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index 918ed79b50..3489c92ad9 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -35,7 +35,7 @@ export default class Controller extends Section { autocomplete: { url: 'ItemPackingTypes', showField: 'description', - valueField: 'description' + valueField: 'code' } }, { @@ -43,7 +43,7 @@ export default class Controller extends Section { autocomplete: { url: 'ItemPackingTypes', showField: 'description', - valueField: 'description' + valueField: 'code' } }, ] @@ -59,6 +59,9 @@ export default class Controller extends Section { futureDated: today, warehouseFk: this.vnConfig.warehouseFk }; + this.$.model = { + data: this.filterParams + }; } compareDate(date) { From 6ef282feda237c62757c6abedd3ab87ffc79c79f Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Tue, 20 Dec 2022 09:54:28 +0100 Subject: [PATCH 25/28] refs #4962 updated merge, changed autoload, changed tf->Future --- .../225001/00-ticket_canbePostponed.sql | 14 +++---- e2e/helpers/selectors.js | 8 ++-- e2e/paths/05-ticket/21_future.spec.js | 28 +++++++------- loopback/locale/en.json | 2 +- loopback/locale/es.json | 2 +- .../methods/ticket-future/getTicketsFuture.js | 22 +++++------ .../spec/getTicketsFuture.spec.js | 33 ++--------------- modules/ticket/back/methods/ticket/merge.js | 34 ++++++++--------- .../back/methods/ticket/specs/merge.spec.js | 26 ++++++------- .../front/future-search-panel/index.html | 8 ++-- modules/ticket/front/future/index.html | 28 +++++++------- modules/ticket/front/future/index.js | 37 ++++++++++++------- modules/ticket/front/future/index.spec.js | 19 +++------- 13 files changed, 119 insertions(+), 142 deletions(-) diff --git a/db/changes/225001/00-ticket_canbePostponed.sql b/db/changes/225001/00-ticket_canbePostponed.sql index b1206799de..572824b4b7 100644 --- a/db/changes/225001/00-ticket_canbePostponed.sql +++ b/db/changes/225001/00-ticket_canbePostponed.sql @@ -15,21 +15,21 @@ BEGIN CREATE TEMPORARY TABLE tmp.filter (INDEX (id)) SELECT sv.ticketFk id, + sub2.id futureId, GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, CAST(sum(litros) AS DECIMAL(10,0)) liters, CAST(count(*) AS DECIMAL(10,0)) `lines`, st.name state, - sub2.id ticketFuture, - sub2.iptd tfIpt, - sub2.state tfState, + sub2.iptd futureIpt, + sub2.state futureState, t.clientFk, t.warehouseFk, ts.alertLevel, t.shipped, - sub2.shipped tfShipped, + sub2.shipped futureShipped, t.workerFk, st.code stateCode, - sub2.code tfStateCode + sub2.code futureStateCode FROM vn.saleVolume sv JOIN vn.sale s ON s.id = sv.saleFk JOIN vn.item i ON i.id = s.itemFk @@ -45,7 +45,7 @@ BEGIN SELECT * FROM ( SELECT - t.addressFk , + t.addressFk, t.id, t.shipped, st.name state, @@ -68,6 +68,6 @@ BEGIN AND al.code = 'FREE' AND tp.ticketFk IS NULL GROUP BY sv.ticketFk - HAVING ticketFuture; + HAVING futureId; END$$ DELIMITER ; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index e485259d8c..dba94dd222 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -740,11 +740,11 @@ export default { linesMax: 'vn-textfield[label="Max Lines"]', litersMax: 'vn-textfield[label="Max Liters"]', ipt: 'vn-autocomplete[label="Origin IPT"]', - tfIpt: 'vn-autocomplete[label="Destination IPT"]', + futureIpt: 'vn-autocomplete[label="Destination IPT"]', tableIpt: 'vn-autocomplete[name="ipt"]', - tableTfIpt: 'vn-autocomplete[name="tfIpt"]', + tableFutureIpt: 'vn-autocomplete[name="futureIpt"]', state: 'vn-autocomplete[label="Origin Grouped State"]', - tfState: 'vn-autocomplete[label="Destination Grouped State"]', + futureState: 'vn-autocomplete[label="Destination Grouped State"]', warehouseFk: 'vn-autocomplete[label="Warehouse"]', problems: 'vn-check[label="With problems"]', tableButtonSearch: 'vn-button[vn-tooltip="Search"]', @@ -753,7 +753,7 @@ export default { firstCheck: 'tbody > tr:nth-child(1) > td > vn-check', multiCheck: 'vn-multi-check', tableId: 'vn-textfield[name="id"]', - tableTfId: 'vn-textfield[name="ticketFuture"]', + tableFutureId: 'vn-textfield[name="futureId"]', tableLiters: 'vn-textfield[name="liters"]', tableLines: 'vn-textfield[name="lines"]', submit: 'vn-submit[label="Search"]', diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index d4dbffc942..45c39de862 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -49,9 +49,9 @@ describe('Ticket Future path', () => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.ipt); - await page.clearInput(selectors.ticketFuture.tfIpt); + await page.clearInput(selectors.ticketFuture.futureIpt); await page.clearInput(selectors.ticketFuture.state); - await page.clearInput(selectors.ticketFuture.tfState); + await page.clearInput(selectors.ticketFuture.futureState); await page.autocompleteSearch(selectors.ticketFuture.ipt, 'Horizontal'); await page.waitToClick(selectors.ticketFuture.submit); @@ -62,11 +62,11 @@ describe('Ticket Future path', () => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.ipt); - await page.clearInput(selectors.ticketFuture.tfIpt); + await page.clearInput(selectors.ticketFuture.futureIpt); await page.clearInput(selectors.ticketFuture.state); - await page.clearInput(selectors.ticketFuture.tfState); + await page.clearInput(selectors.ticketFuture.futureState); - await page.autocompleteSearch(selectors.ticketFuture.tfIpt, 'Horizontal'); + await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'Horizontal'); await page.waitToClick(selectors.ticketFuture.submit); await page.waitForNumberOfElements(selectors.ticketFuture.table, 0); }); @@ -75,9 +75,9 @@ describe('Ticket Future path', () => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.ipt); - await page.clearInput(selectors.ticketFuture.tfIpt); + await page.clearInput(selectors.ticketFuture.futureIpt); await page.clearInput(selectors.ticketFuture.state); - await page.clearInput(selectors.ticketFuture.tfState); + await page.clearInput(selectors.ticketFuture.futureState); await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); await page.waitToClick(selectors.ticketFuture.submit); @@ -88,19 +88,19 @@ describe('Ticket Future path', () => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.ipt); - await page.clearInput(selectors.ticketFuture.tfIpt); + await page.clearInput(selectors.ticketFuture.futureIpt); await page.clearInput(selectors.ticketFuture.state); - await page.clearInput(selectors.ticketFuture.tfState); + await page.clearInput(selectors.ticketFuture.futureState); - await page.autocompleteSearch(selectors.ticketFuture.tfState, 'Free'); + await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); await page.waitToClick(selectors.ticketFuture.submit); await page.waitForNumberOfElements(selectors.ticketFuture.table, 0); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.ipt); - await page.clearInput(selectors.ticketFuture.tfIpt); + await page.clearInput(selectors.ticketFuture.futureIpt); await page.clearInput(selectors.ticketFuture.state); - await page.clearInput(selectors.ticketFuture.tfState); + await page.clearInput(selectors.ticketFuture.futureState); await page.waitToClick(selectors.ticketFuture.submit); await page.waitForNumberOfElements(selectors.ticketFuture.table, 4); @@ -120,7 +120,7 @@ describe('Ticket Future path', () => { it('should search in smart-table with an ID Destination', async() => { await page.waitToClick(selectors.ticketFuture.tableButtonSearch); - await page.write(selectors.ticketFuture.tableTfId, '12'); + await page.write(selectors.ticketFuture.tableFutureId, '12'); await page.keyboard.press('Enter'); await page.waitForNumberOfElements(selectors.ticketFuture.table, 5); @@ -143,7 +143,7 @@ describe('Ticket Future path', () => { it('should search in smart-table with an IPT Destination', async() => { await page.waitToClick(selectors.ticketFuture.tableButtonSearch); - await page.autocompleteSearch(selectors.ticketFuture.tableTfIpt, 'Vertical'); + await page.autocompleteSearch(selectors.ticketFuture.tableFutureIpt, 'Vertical'); await page.waitForNumberOfElements(selectors.ticketFuture.table, 1); await page.waitToClick(selectors.ticketFuture.tableButtonSearch); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index d4695f72c2..f4284888f1 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -140,7 +140,7 @@ "You don't have grant privilege": "You don't have grant privilege", "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", "Email verify": "Email verify", - "Ticket merged": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) merged with [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})", + "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", "Sale(s) blocked, please contact production": "Sale(s) blocked, please contact production", "Receipt's bank was not found": "Receipt's bank was not found", "This receipt was not compensated": "This receipt was not compensated", diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1b0a504336..c12d6bbe5e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -241,7 +241,7 @@ "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", "You don't have grant privilege": "No tienes privilegios para dar privilegios", "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", - "Ticket merged": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) fusionado con [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})", + "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", "Already has this status": "Ya tiene este estado", "There aren't records for this week": "No existen registros para esta semana", "Empty data source": "Origen de datos vacio", diff --git a/modules/ticket/back/methods/ticket-future/getTicketsFuture.js b/modules/ticket/back/methods/ticket-future/getTicketsFuture.js index aa726deeaf..6798df5134 100644 --- a/modules/ticket/back/methods/ticket-future/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket-future/getTicketsFuture.js @@ -27,13 +27,13 @@ module.exports = Self => { required: true }, { - arg: 'liters', + arg: 'litersMax', type: 'number', description: 'Maximum volume of tickets to catapult', required: false }, { - arg: 'lines', + arg: 'linesMax', type: 'number', description: 'Maximum number of lines of tickets to catapult', required: false @@ -45,7 +45,7 @@ module.exports = Self => { required: false }, { - arg: 'tfIpt', + arg: 'futureIpt', type: 'string', description: 'Destination Item Packaging Type', required: false @@ -57,7 +57,7 @@ module.exports = Self => { required: false }, { - arg: 'tfId', + arg: 'futureId', type: 'number', description: 'Destination id', required: false @@ -69,7 +69,7 @@ module.exports = Self => { required: false }, { - arg: 'tfState', + arg: 'futureState', type: 'string', description: 'Destination state', required: false @@ -112,16 +112,16 @@ module.exports = Self => { return {'f.lines': {lte: value}}; case 'liters': return {'f.liters': {lte: value}}; - case 'tfId': - return {'f.ticketFuture': value}; + case 'futureId': + return {'f.futureId': value}; case 'ipt': return {'f.ipt': value}; - case 'tfIpt': - return {'f.tfIpt': value}; + case 'futureIpt': + return {'f.futureIpt': value}; case 'state': return {'f.stateCode': {like: `%${value}%`}}; - case 'tfState': - return {'f.tfStateCode': {like: `%${value}%`}}; + case 'futureState': + return {'f.futureStateCode': {like: `%${value}%`}}; } }); diff --git a/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js index 459c2eb1ee..ec5427c9b5 100644 --- a/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js +++ b/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js @@ -3,7 +3,6 @@ const models = require('vn-loopback/server/server').models; describe('TicketFuture getTicketsFuture()', () => { const today = new Date(); today.setHours(0, 0, 0, 0); - const tomorrow = new Date(today.getDate() + 1); it('should return the tickets passing the required data', async() => { const tx = await models.Ticket.beginTransaction({}); @@ -14,8 +13,6 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, }; @@ -39,8 +36,6 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, problems: true }; @@ -66,8 +61,6 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, problems: false }; @@ -93,8 +86,6 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, problems: null }; @@ -120,8 +111,6 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, state: 'OK' }; @@ -147,10 +136,8 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, - tfState: 'OK' + futureState: 'OK' }; const ctx = {req: {accessToken: {userId: 9}}, args}; @@ -174,8 +161,6 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, ipt: null }; @@ -201,8 +186,6 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, ipt: 0 }; @@ -228,10 +211,8 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, - tfIpt: null + futureIpt: null }; const ctx = {req: {accessToken: {userId: 9}}, args}; @@ -255,10 +236,8 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, - tfIpt: 0 + futureIpt: 0 }; const ctx = {req: {accessToken: {userId: 9}}, args}; @@ -282,8 +261,6 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, id: 13 }; @@ -309,10 +286,8 @@ describe('TicketFuture getTicketsFuture()', () => { const args = { originDated: today, futureDated: today, - litersMax: 9999, - linesMax: 9999, warehouseFk: 1, - tfId: 12 + futureId: 12 }; const ctx = {req: {accessToken: {userId: 9}}, args}; diff --git a/modules/ticket/back/methods/ticket/merge.js b/modules/ticket/back/methods/ticket/merge.js index 8a86eff6fa..8aaca10850 100644 --- a/modules/ticket/back/methods/ticket/merge.js +++ b/modules/ticket/back/methods/ticket/merge.js @@ -40,32 +40,32 @@ module.exports = Self => { try { for (let ticket of tickets) { - const fullPath = `${origin}/#!/ticket/${ticket.id}/summary`; - const fullPathFuture = `${origin}/#!/ticket/${ticket.ticketFuture}/summary`; + const originFullPath = `${origin}/#!/ticket/${ticket.originId}/summary`; + const destinationFullPath = `${origin}/#!/ticket/${ticket.destinationId}/summary`; const message = $t('Ticket merged', { - originDated: dateUtil.toString(new Date(ticket.shipped)), - futureDated: dateUtil.toString(new Date(ticket.tfShipped)), - id: ticket.id, - tfId: ticket.ticketFuture, - fullPath, - fullPathFuture + originDated: dateUtil.toString(new Date(ticket.originShipped)), + destinationDated: dateUtil.toString(new Date(ticket.destinationShipped)), + originId: ticket.originId, + destinationId: ticket.destinationId, + originFullPath, + destinationFullPath }); - if (!ticket.id || !ticket.ticketFuture) continue; + if (!ticket.originId || !ticket.destinationId) continue; - const ticketFutureLogRecord = { - originFk: ticket.ticketFuture, + const ticketDestinationLogRecord = { + originFk: ticket.destinationId, userFk: ctx.req.accessToken.userId, action: 'update', changedModel: 'Ticket', - changedModelId: ticket.ticketFuture, - changedModelValue: ticket.ticketFuture, + changedModelId: ticket.destinationId, + changedModelValue: ticket.destinationId, oldInstance: {}, - newInstance: {mergedTicket: ticket.id} + newInstance: {mergedTicket: ticket.originId} }; - await models.TicketLog.create(ticketFutureLogRecord, myOptions); - await models.Sale.updateAll({ticketFk: ticket.id}, {ticketFk: ticket.ticketFuture}, myOptions); - await models.Ticket.setDeleted(ctx, ticket.id, myOptions); + await models.TicketLog.create(ticketDestinationLogRecord, myOptions); + await models.Sale.updateAll({ticketFk: ticket.originId}, {ticketFk: ticket.destinationId}, myOptions); + await models.Ticket.setDeleted(ctx, ticket.originId, myOptions); await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message); } if (tx) diff --git a/modules/ticket/back/methods/ticket/specs/merge.spec.js b/modules/ticket/back/methods/ticket/specs/merge.spec.js index 713f86ad60..275484f670 100644 --- a/modules/ticket/back/methods/ticket/specs/merge.spec.js +++ b/modules/ticket/back/methods/ticket/specs/merge.spec.js @@ -3,15 +3,15 @@ const LoopBackContext = require('loopback-context'); describe('ticket merge()', () => { const tickets = [{ - id: 13, - ticketFuture: 12, - workerFk: 1, - originETD: new Date(), - destETD: new Date() + originId: 13, + destinationId: 12, + originShipped: new Date(), + destinationShipped: new Date(), + workerFk: 1 }]; const activeCtx = { - accessToken: { userId: 9 }, + accessToken: {userId: 9}, }; beforeEach(() => { @@ -22,26 +22,26 @@ describe('ticket merge()', () => { const ctx = { req: { - accessToken: { userId: 9 }, - headers: { origin: 'http://localhost:5000' }, + accessToken: {userId: 9}, + headers: {origin: 'http://localhost:5000'}, } }; ctx.req.__ = value => { return value; }; - it('should merge two tickets', async () => { + it('should merge two tickets', async() => { const tx = await models.Ticket.beginTransaction({}); try { - const options = { transaction: tx }; + const options = {transaction: tx}; const chatNotificationBeforeMerge = await models.Chat.find(); await models.Ticket.merge(ctx, tickets, options); - const createdTicketLog = await models.TicketLog.find({ where: { originFk: tickets[0].id } }, options); - const deletedTicket = await models.Ticket.findOne({ where: { id: tickets[0].id } }, options); - const salesTicketFuture = await models.Sale.find({ where: { ticketFk: tickets[0].ticketFuture } }, options); + const createdTicketLog = await models.TicketLog.find({where: {originFk: tickets[0].originId}}, options); + const deletedTicket = await models.Ticket.findOne({where: {id: tickets[0].originId}}, options); + const salesTicketFuture = await models.Sale.find({where: {ticketFk: tickets[0].destinationId}}, options); const chatNotificationAfterMerge = await models.Chat.find(); expect(createdTicketLog.length).toEqual(1); diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index c4df33ec46..18b574f2a8 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -18,12 +18,12 @@ <vn-textfield vn-one label="Max Liters" - ng-model="filter.liters"> + ng-model="filter.litersMax"> </vn-textfield> <vn-textfield vn-one label="Max Lines" - ng-model="filter.lines"> + ng-model="filter.linesMax"> </vn-textfield> </vn-horizontal> <vn-horizontal class="vn-px-lg"> @@ -43,7 +43,7 @@ label="Destination IPT" value-field="code" show-field="description" - ng-model="filter.tfIpt" + ng-model="filter.futureIpt" info="IPT"> <tpl-item> {{description}} @@ -66,7 +66,7 @@ label="Destination Grouped State" value-field="code" show-field="name" - ng-model="filter.tfState"> + ng-model="filter.futureState"> <tpl-item> {{name}} </tpl-item> diff --git a/modules/ticket/front/future/index.html b/modules/ticket/front/future/index.html index 8633e7a388..1af1fb9ba6 100644 --- a/modules/ticket/front/future/index.html +++ b/modules/ticket/front/future/index.html @@ -1,9 +1,7 @@ <vn-crud-model vn-id="model" url="Tickets/getTicketsFuture" - limit="20" - auto-load="true" - params="model.data"> + auto-load="false"> </vn-crud-model> <vn-portal slot="topbar"> <vn-searchbar @@ -45,7 +43,7 @@ check-field="checked"> </vn-multi-check> </th> - <th field="problems"> + <th field="totalProblems"> <span translate>Problems</span> </th> <th field="id"> @@ -66,16 +64,16 @@ <th shrink field="lines"> <span translate>Available Lines</span> </th> - <th field="ticketFuture" separator> + <th field="futureId" separator> <span translate>ID</span> </th> - <th field="tfShipped"> + <th field="futureShipped"> <span translate>Date</span> </th> - <th field="tfIpt" title="Item Packing Type"> + <th field="futureIpt" title="Item Packing Type"> <span>IPT</span> </th> - <th shrink field="tfState"> + <th shrink field="futureState"> <span translate>State</span> </th> </tr> @@ -147,21 +145,21 @@ <td>{{::ticket.lines}}</td> <td> <span - ng-click="ticketDescriptor.show($event, ticket.ticketFuture)" + ng-click="ticketDescriptor.show($event, ticket.futureId)" class="link"> - {{::ticket.ticketFuture}} + {{::ticket.futureId}} </span> </td> <td shrink-date> - <span class="chip {{$ctrl.compareDate(ticket.tfShipped)}}"> - {{::ticket.tfShipped | date: 'dd/MM/yyyy'}} + <span class="chip {{$ctrl.compareDate(ticket.futureShipped)}}"> + {{::ticket.futureShipped | date: 'dd/MM/yyyy'}} </span> </td> - <td>{{::ticket.tfIpt}}</td> + <td>{{::ticket.futureIpt}}</td> <td> <span - class="chip {{$ctrl.stateColor(ticket.tfState)}}"> - {{::ticket.tfState}} + class="chip {{$ctrl.stateColor(ticket.futureState)}}"> + {{::ticket.futureState}} </span> </td> </tr> diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index 3489c92ad9..56ba1608e8 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -11,15 +11,15 @@ export default class Controller extends Section { search: true, }, columns: [{ - field: 'problems', - searchable: false + field: 'totalProblems', + searchable: false, }, { field: 'shipped', searchable: false }, { - field: 'tfShipped', + field: 'futureShipped', searchable: false }, { @@ -27,7 +27,7 @@ export default class Controller extends Section { searchable: false }, { - field: 'tfState', + field: 'futureState', searchable: false }, { @@ -39,7 +39,7 @@ export default class Controller extends Section { } }, { - field: 'tfIpt', + field: 'futureIpt', autocomplete: { url: 'ItemPackingTypes', showField: 'description', @@ -48,6 +48,9 @@ export default class Controller extends Section { }, ] }; + } + + $postLink() { this.setDefaultFilter(); } @@ -59,9 +62,7 @@ export default class Controller extends Section { futureDated: today, warehouseFk: this.vnConfig.warehouseFk }; - this.$.model = { - data: this.filterParams - }; + this.$.model.applyFilter(null, this.filterParams); } compareDate(date) { @@ -114,7 +115,17 @@ export default class Controller extends Section { } moveTicketsFuture() { - let params = {tickets: this.checked}; + let ticketsToMove = []; + this.checked.forEach(ticket => { + ticketsToMove.push({ + originId: ticket.id, + destinationId: ticket.futureId, + originShipped: ticket.shipped, + destinationShipped: ticket.futureShipped, + workerFk: ticket.workerFk + }); + }); + let params = {tickets: ticketsToMove}; return this.$http.post('Tickets/merge', params) .then(() => { this.$.model.refresh(); @@ -126,16 +137,16 @@ export default class Controller extends Section { switch (param) { case 'id': return {'id': value}; - case 'ticketFuture': - return {'ticketFuture': value}; + case 'futureId': + return {'futureId': value}; case 'liters': return {'liters': value}; case 'lines': return {'lines': value}; case 'ipt': return {'ipt': value}; - case 'tfIpt': - return {'tfIpt': value}; + case 'futureIpt': + return {'futureIpt': value}; } } } diff --git a/modules/ticket/front/future/index.spec.js b/modules/ticket/front/future/index.spec.js index 9c6b97c8be..c609a4891a 100644 --- a/modules/ticket/front/future/index.spec.js +++ b/modules/ticket/front/future/index.spec.js @@ -2,16 +2,14 @@ import './index.js'; import crudModel from 'core/mocks/crud-model'; describe('Component vnTicketFuture', () => { + const today = new Date(); let controller; let $httpBackend; - let $window; - beforeEach(ngModule('ticket') - ); + beforeEach(ngModule('ticket')); - beforeEach(inject(($componentController, _$window_, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; - $window = _$window_; const $element = angular.element('<vn-ticket-future></vn-ticket-future>'); controller = $componentController('vnTicketFuture', {$element}); controller.$.model = crudModel; @@ -28,7 +26,6 @@ describe('Component vnTicketFuture', () => { describe('compareDate()', () => { it('should return warning when the date is the present', () => { - let today = new Date(); let result = controller.compareDate(today); expect(result).toEqual('warning'); @@ -83,18 +80,14 @@ describe('Component vnTicketFuture', () => { describe('dateRange()', () => { it('should return two dates with the hours at the start and end of the given date', () => { - const now = new Date(); - - const today = now.getDate(); - - const dateRange = controller.dateRange(now); + const dateRange = controller.dateRange(today); const start = dateRange[0].toString(); const end = dateRange[1].toString(); - expect(start).toContain(today); + expect(start).toContain(today.getDate()); expect(start).toContain('00:00:00'); - expect(end).toContain(today); + expect(end).toContain(today.getDate()); expect(end).toContain('23:59:59'); }); }); From 70b1854cc5badccd272aa8a966a87e41b8480e50 Mon Sep 17 00:00:00 2001 From: joan <joan@verdnatura.es> Date: Tue, 20 Dec 2022 10:20:31 +0100 Subject: [PATCH 26/28] Added version --- db/changes/225001/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 db/changes/225001/.gitkeep diff --git a/db/changes/225001/.gitkeep b/db/changes/225001/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From 47e1c05e475d0dbcf0b94e8f2c49c09631b49d51 Mon Sep 17 00:00:00 2001 From: joan <joan@verdnatura.es> Date: Tue, 20 Dec 2022 10:39:39 +0100 Subject: [PATCH 27/28] Renamed version --- db/changes/{225001 => 225201}/00-entryDeleteRef.sql | 0 db/changes/{225001 => 225201}/00-invoiceInConfig.sql | 0 db/changes/{225001 => 225201}/00-supplier_beforeUpdate.sql | 0 db/changes/{225001 => 225201}/01-modules.sql | 0 db/changes/{225001 => 225201}/02-starredModule.sql | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename db/changes/{225001 => 225201}/00-entryDeleteRef.sql (100%) rename db/changes/{225001 => 225201}/00-invoiceInConfig.sql (100%) rename db/changes/{225001 => 225201}/00-supplier_beforeUpdate.sql (100%) rename db/changes/{225001 => 225201}/01-modules.sql (100%) rename db/changes/{225001 => 225201}/02-starredModule.sql (100%) diff --git a/db/changes/225001/00-entryDeleteRef.sql b/db/changes/225201/00-entryDeleteRef.sql similarity index 100% rename from db/changes/225001/00-entryDeleteRef.sql rename to db/changes/225201/00-entryDeleteRef.sql diff --git a/db/changes/225001/00-invoiceInConfig.sql b/db/changes/225201/00-invoiceInConfig.sql similarity index 100% rename from db/changes/225001/00-invoiceInConfig.sql rename to db/changes/225201/00-invoiceInConfig.sql diff --git a/db/changes/225001/00-supplier_beforeUpdate.sql b/db/changes/225201/00-supplier_beforeUpdate.sql similarity index 100% rename from db/changes/225001/00-supplier_beforeUpdate.sql rename to db/changes/225201/00-supplier_beforeUpdate.sql diff --git a/db/changes/225001/01-modules.sql b/db/changes/225201/01-modules.sql similarity index 100% rename from db/changes/225001/01-modules.sql rename to db/changes/225201/01-modules.sql diff --git a/db/changes/225001/02-starredModule.sql b/db/changes/225201/02-starredModule.sql similarity index 100% rename from db/changes/225001/02-starredModule.sql rename to db/changes/225201/02-starredModule.sql From 4c6a73523512bee1e67bf500660159fb26a826b0 Mon Sep 17 00:00:00 2001 From: alexandre <alexandre@verdnatura.es> Date: Tue, 20 Dec 2022 11:53:54 +0100 Subject: [PATCH 28/28] refs #4962 moved sql and methods to ticket --- db/changes/{225001 => 225201}/00-ticket_canbePostponed.sql | 0 .../back/methods/{ticket-future => ticket}/getTicketsFuture.js | 0 .../spec => ticket/specs}/getTicketsFuture.spec.js | 2 +- modules/ticket/back/models/ticket-methods.js | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename db/changes/{225001 => 225201}/00-ticket_canbePostponed.sql (100%) rename modules/ticket/back/methods/{ticket-future => ticket}/getTicketsFuture.js (100%) rename modules/ticket/back/methods/{ticket-future/spec => ticket/specs}/getTicketsFuture.spec.js (99%) diff --git a/db/changes/225001/00-ticket_canbePostponed.sql b/db/changes/225201/00-ticket_canbePostponed.sql similarity index 100% rename from db/changes/225001/00-ticket_canbePostponed.sql rename to db/changes/225201/00-ticket_canbePostponed.sql diff --git a/modules/ticket/back/methods/ticket-future/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js similarity index 100% rename from modules/ticket/back/methods/ticket-future/getTicketsFuture.js rename to modules/ticket/back/methods/ticket/getTicketsFuture.js diff --git a/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js similarity index 99% rename from modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js rename to modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js index ec5427c9b5..c05ba764d5 100644 --- a/modules/ticket/back/methods/ticket-future/spec/getTicketsFuture.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('TicketFuture getTicketsFuture()', () => { +describe('ticket getTicketsFuture()', () => { const today = new Date(); today.setHours(0, 0, 0, 0); diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 8fd74d35c7..fe60cde8e3 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -33,7 +33,7 @@ module.exports = function(Self) { require('../methods/ticket/closeByTicket')(Self); require('../methods/ticket/closeByAgency')(Self); require('../methods/ticket/closeByRoute')(Self); - require('../methods/ticket-future/getTicketsFuture')(Self); + require('../methods/ticket/getTicketsFuture')(Self); require('../methods/ticket/merge')(Self); require('../methods/ticket/isRoleAdvanced')(Self); require('../methods/ticket/collectionLabel')(Self);