From 2c98563cfabb8994a99e3ecbcc10e6f435ad8da8 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 20 Oct 2022 07:39:33 +0200 Subject: [PATCH 01/27] Add buttons to bottom-right --- modules/route/front/index/index.html | 50 +++++++++++++++------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html index 7a64a9aff..b3e520aea 100644 --- a/modules/route/front/index/index.html +++ b/modules/route/front/index/index.html @@ -7,29 +7,6 @@ model="model" options="$ctrl.smartTableOptions" expr-builder="$ctrl.exprBuilder(param, value)"> - -
- - - - - - - -
-
@@ -190,6 +167,33 @@ tooltip-position="left"> + + + + + + + + + + + + From 8cbcb197bbd75b69c5f3aff54393725205a883e7 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 20 Oct 2022 08:14:11 +0200 Subject: [PATCH 02/27] fix downloadPDF wrong method --- modules/route/front/index/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html index b3e520aea..cc76d22f2 100644 --- a/modules/route/front/index/index.html +++ b/modules/route/front/index/index.html @@ -180,7 +180,7 @@ From 28bd535e2b2590d665ba95d81a607aceddc54cbb Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 20 Oct 2022 15:04:25 +0200 Subject: [PATCH 03/27] Implemented SMS to route clients --- modules/route/back/methods/route/sendSms.js | 46 +++++++++++++ modules/route/back/models/route.js | 1 + modules/route/front/index.js | 1 + modules/route/front/index/index.html | 30 +++++++-- modules/route/front/index/index.js | 60 +++++++++++++++++ modules/route/front/index/locale/es.yml | 4 +- modules/route/front/sms/index.html | 45 +++++++++++++ modules/route/front/sms/index.js | 47 ++++++++++++++ modules/route/front/sms/index.spec.js | 71 +++++++++++++++++++++ modules/route/front/sms/locale/es.yml | 9 +++ modules/route/front/sms/style.scss | 5 ++ 11 files changed, 311 insertions(+), 8 deletions(-) create mode 100644 modules/route/back/methods/route/sendSms.js create mode 100644 modules/route/front/sms/index.html create mode 100644 modules/route/front/sms/index.js create mode 100644 modules/route/front/sms/index.spec.js create mode 100644 modules/route/front/sms/locale/es.yml create mode 100644 modules/route/front/sms/style.scss diff --git a/modules/route/back/methods/route/sendSms.js b/modules/route/back/methods/route/sendSms.js new file mode 100644 index 000000000..9a93b040e --- /dev/null +++ b/modules/route/back/methods/route/sendSms.js @@ -0,0 +1,46 @@ +/* eslint-disable no-console */ + +module.exports = Self => { + Self.remoteMethodCtx('sendSms', { + description: 'Sends a SMS to each client of the routes, each client only recieves the SMS once', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'string', + required: true, + description: 'The routes Ids, is separated by commas', + http: {source: 'path'} + }, + { + arg: 'destination', + type: 'string', + description: 'A comma separated string of destinations', + required: true, + }, + { + arg: 'message', + type: 'string', + required: true, + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/sendSms`, + verb: 'POST' + } + }); + + Self.sendSms = async(ctx, id, destination, message) => { + const targetClients = destination.split(','); + + const allSms = []; + for (let client of targetClients) { + let sms = await Self.app.models.Sms.send(ctx, client, message); + allSms.push(sms); + } + + return allSms; + }; +}; diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index f5406728a..08cabd30e 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -12,6 +12,7 @@ module.exports = Self => { require('../methods/route/updateWorkCenter')(Self); require('../methods/route/driverRoutePdf')(Self); require('../methods/route/driverRouteEmail')(Self); + require('../methods/route/sendSms')(Self); Self.validate('kmStart', validateDistance, { message: 'Distance must be lesser than 1000' diff --git a/modules/route/front/index.js b/modules/route/front/index.js index 55cb745e1..c43048df5 100644 --- a/modules/route/front/index.js +++ b/modules/route/front/index.js @@ -15,3 +15,4 @@ import './agency-term/index'; import './agency-term/createInvoiceIn'; import './agency-term-search-panel'; import './ticket-popup'; +import './sms'; diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html index cc76d22f2..e9785d958 100644 --- a/modules/route/front/index/index.html +++ b/modules/route/front/index/index.html @@ -160,13 +160,6 @@
- - - - + + + + + + + +
+ + + + + e === ticket.clientFk).length > 0) + clientsFk.push(ticket.clientFk); + } + + for (let client of clientsFk) { + let currentClient = await this.$http.get(`Clients/${client}`); + clients.push(currentClient.data); + } + + let destination = ''; + let destinationFk = ''; + let routesId = ''; + + for (let client of clients) { + if (destination !== '') + destination = destination + ','; + if (destinationFk !== '') + destinationFk = destinationFk + ','; + destination = destination + client.phone; + destinationFk = destinationFk + client.id; + } + + for (let route of routes) { + if (routesId !== '') + routesId = routesId + ','; + routesId = routesId + route; + } + this.newSMS = Object.assign({ + routesId: routesId, + destinationFk: destinationFk, + destination: destination + }); + + this.$.sms.open(); + return true; + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; + } + } } Controller.$inject = ['$element', '$scope', 'vnReport']; diff --git a/modules/route/front/index/locale/es.yml b/modules/route/front/index/locale/es.yml index e4c5c8c55..3db84d81e 100644 --- a/modules/route/front/index/locale/es.yml +++ b/modules/route/front/index/locale/es.yml @@ -8,4 +8,6 @@ Hour finished: Hora fin Go to route: Ir a la ruta You must select a valid time: Debe seleccionar una hora válida You must select a valid date: Debe seleccionar una fecha válida -Mark as served: Marcar como servidas \ No newline at end of file +Mark as served: Marcar como servidas +Retrieving data from the routes: Recuperando datos de las rutas +Send SMS to all clients: Mandar sms a todos los clientes de las rutas \ No newline at end of file diff --git a/modules/route/front/sms/index.html b/modules/route/front/sms/index.html new file mode 100644 index 000000000..4f86b346f --- /dev/null +++ b/modules/route/front/sms/index.html @@ -0,0 +1,45 @@ + + +
+ + + + + + + + {{'Characters remaining' | translate}}: + + {{$ctrl.charactersRemaining()}} + + + +
+
+ + + + +
\ No newline at end of file diff --git a/modules/route/front/sms/index.js b/modules/route/front/sms/index.js new file mode 100644 index 000000000..701306071 --- /dev/null +++ b/modules/route/front/sms/index.js @@ -0,0 +1,47 @@ +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(`Routes/${this.sms.routesId}/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('vnRouteSms', { + template: require('./index.html'), + controller: Controller, + bindings: { + sms: '<', + } +}); diff --git a/modules/route/front/sms/index.spec.js b/modules/route/front/sms/index.spec.js new file mode 100644 index 000000000..b133db04d --- /dev/null +++ b/modules/route/front/sms/index.spec.js @@ -0,0 +1,71 @@ +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(''); + 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/route/front/sms/locale/es.yml b/modules/route/front/sms/locale/es.yml new file mode 100644 index 000000000..4d6022921 --- /dev/null +++ b/modules/route/front/sms/locale/es.yml @@ -0,0 +1,9 @@ +Send SMS: Enviar SMS +Routes to notify: Rutas a notificar +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/route/front/sms/style.scss b/modules/route/front/sms/style.scss new file mode 100644 index 000000000..84571a5f4 --- /dev/null +++ b/modules/route/front/sms/style.scss @@ -0,0 +1,5 @@ +@import "variables"; + +.SMSDialog { + min-width: 400px +} \ No newline at end of file From ca53ec7c238a5cd2bc3f8807504063acd9126a33 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 20 Oct 2022 15:04:59 +0200 Subject: [PATCH 04/27] Changed the location of the function --- modules/route/back/methods/route/sendSms.js | 34 +++++------ modules/route/front/index/index.html | 66 +++++++-------------- modules/route/front/index/index.js | 60 ------------------- modules/route/front/sms/index.html | 13 +--- modules/route/front/sms/index.js | 2 +- modules/route/front/sms/locale/es.yml | 2 +- modules/route/front/tickets/index.html | 39 ++++++++---- modules/route/front/tickets/index.js | 31 ++++++++++ 8 files changed, 99 insertions(+), 148 deletions(-) diff --git a/modules/route/back/methods/route/sendSms.js b/modules/route/back/methods/route/sendSms.js index 9a93b040e..fe881abd5 100644 --- a/modules/route/back/methods/route/sendSms.js +++ b/modules/route/back/methods/route/sendSms.js @@ -4,35 +4,29 @@ module.exports = Self => { Self.remoteMethodCtx('sendSms', { description: 'Sends a SMS to each client of the routes, each client only recieves the SMS once', accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'string', - required: true, - description: 'The routes Ids, is separated by commas', - http: {source: 'path'} - }, - { - arg: 'destination', - type: 'string', - description: 'A comma separated string of destinations', - required: true, - }, - { - arg: 'message', - type: 'string', - required: true, - }], + accepts: [ + { + arg: 'destination', + type: 'string', + description: 'A comma separated string of destinations', + required: true, + }, + { + arg: 'message', + type: 'string', + required: true, + }], returns: { type: 'object', root: true }, http: { - path: `/:id/sendSms`, + path: `/sendSms`, verb: 'POST' } }); - Self.sendSms = async(ctx, id, destination, message) => { + Self.sendSms = async(ctx, destination, message) => { const targetClients = destination.split(','); const allSms = []; diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html index e9785d958..7a64a9aff 100644 --- a/modules/route/front/index/index.html +++ b/modules/route/front/index/index.html @@ -7,6 +7,29 @@ model="model" options="$ctrl.smartTableOptions" expr-builder="$ctrl.exprBuilder(param, value)"> + +
+ + + + + + + +
+
@@ -160,42 +183,6 @@
- - - - - - - - - - - - - - - -
- - - - - e === ticket.clientFk).length > 0) - clientsFk.push(ticket.clientFk); - } - - for (let client of clientsFk) { - let currentClient = await this.$http.get(`Clients/${client}`); - clients.push(currentClient.data); - } - - let destination = ''; - let destinationFk = ''; - let routesId = ''; - - for (let client of clients) { - if (destination !== '') - destination = destination + ','; - if (destinationFk !== '') - destinationFk = destinationFk + ','; - destination = destination + client.phone; - destinationFk = destinationFk + client.id; - } - - for (let route of routes) { - if (routesId !== '') - routesId = routesId + ','; - routesId = routesId + route; - } - this.newSMS = Object.assign({ - routesId: routesId, - destinationFk: destinationFk, - destination: destination - }); - - this.$.sms.open(); - return true; - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - } } Controller.$inject = ['$element', '$scope', 'vnReport']; diff --git a/modules/route/front/sms/index.html b/modules/route/front/sms/index.html index 4f86b346f..0d7dd7c11 100644 --- a/modules/route/front/sms/index.html +++ b/modules/route/front/sms/index.html @@ -1,19 +1,10 @@ + message="Send SMS to the selected tickets">
- - + { + this.$http.post(`Routes/sendSms`, this.sms).then(res => { this.vnApp.showMessage(this.$t('SMS sent!')); if (res.data) this.emit('send', {response: res.data}); diff --git a/modules/route/front/sms/locale/es.yml b/modules/route/front/sms/locale/es.yml index 4d6022921..0168a6eb6 100644 --- a/modules/route/front/sms/locale/es.yml +++ b/modules/route/front/sms/locale/es.yml @@ -1,4 +1,4 @@ -Send SMS: Enviar SMS +Send SMS to the selected tickets: Enviar SMS a los tickets seleccionados Routes to notify: Rutas a notificar Message: Mensaje SMS sent!: ¡SMS enviado! diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index 1f91276e7..29f5cd861 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -29,13 +29,18 @@ disabled="!$ctrl.isChecked" ng-click="$ctrl.deletePriority()" vn-tooltip="Delete priority" - icon="filter_alt_off"> + icon="filter_alt"> + + @@ -149,19 +154,29 @@ route="$ctrl.$params" parent-reload="$ctrl.$.model.refresh()"> - - - +
+ + + + + + +
- \ No newline at end of file + + + + \ No newline at end of file diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js index e78d9b8b7..80f8ad4f4 100644 --- a/modules/route/front/tickets/index.js +++ b/modules/route/front/tickets/index.js @@ -161,6 +161,37 @@ class Controller extends Section { throw error; }); } + + async sendSms() { + try { + const clientsFk = []; + const clientsName = []; + const clients = []; + + const selectedTickets = this.getSelectedItems(this.$.$ctrl.tickets); + + for (let ticket of selectedTickets) { + clientsFk.push(ticket.clientFk); + let userContact = await this.$http.get(`Clients/${ticket.clientFk}`); + clientsName.push(userContact.data.name); + clients.push(userContact.data.phone); + } + + const destinationFk = String(clientsFk); + const destination = String(clients); + + this.newSMS = Object.assign({ + destinationFk: destinationFk, + destination: destination + }); + + this.$.sms.open(); + return true; + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; + } + } } ngModule.vnComponent('vnRouteTickets', { From 5bf425d8e351724463338ea536f94e8fc25cfa58 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 24 Oct 2022 08:22:04 +0200 Subject: [PATCH 05/27] Front test and sms require client #4157 @1h30m --- modules/route/front/sms/index.spec.js | 14 +++++++------- modules/route/front/tickets/index.html | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/route/front/sms/index.spec.js b/modules/route/front/sms/index.spec.js index b133db04d..42bf30931 100644 --- a/modules/route/front/sms/index.spec.js +++ b/modules/route/front/sms/index.spec.js @@ -1,17 +1,17 @@ import './index'; -describe('Ticket', () => { - describe('Component vnTicketSms', () => { +describe('Route', () => { + describe('Component vnRouteSms', () => { let controller; let $httpBackend; - beforeEach(ngModule('ticket')); + beforeEach(ngModule('route')); beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; let $scope = $rootScope.$new(); const $element = angular.element(''); - controller = $componentController('vnTicketSms', {$element, $scope}); + controller = $componentController('vnRouteSms', {$element, $scope}); controller.$.message = { input: { value: 'My SMS' @@ -21,11 +21,11 @@ describe('Ticket', () => { 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'}; + 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', `Tickets/11/sendSms`, params).respond(200, params); + $httpBackend.expect('POST', `Routes/sendSms`, params).respond(200, params); controller.onResponse(); $httpBackend.flush(); diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index 29f5cd861..a3d65772a 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -37,6 +37,7 @@ icon="format_list_numbered"> From 30933220aca2d32dfddd1ee4a2129aea66c58f64 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 24 Oct 2022 09:37:17 +0200 Subject: [PATCH 06/27] #4507 greuge.js/json now insert userFk @2h --- modules/client/back/models/greuge.js | 15 +++++++++++++++ modules/client/back/models/greuge.json | 4 ++++ modules/client/front/greuge/index/index.html | 2 ++ modules/client/front/greuge/index/locale/es.yml | 3 ++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/client/back/models/greuge.js b/modules/client/back/models/greuge.js index bd5f2865d..42820fd60 100644 --- a/modules/client/back/models/greuge.js +++ b/modules/client/back/models/greuge.js @@ -1,6 +1,21 @@ +const LoopBackContext = require('loopback-context'); + module.exports = function(Self) { require('../methods/greuge/sumAmount')(Self); + Self.observe('before save', function(ctx, next) { + const loopBackContext = LoopBackContext.getCurrentContext(); + + let userFk = loopBackContext.active.accessToken.userId; + + if (ctx.instance) + ctx.instance.userFk = userFk; + else + ctx.data.userFk = userFk; + + next(); + }); + Self.validatesLengthOf('description', { max: 45, message: 'Description should have maximum of 45 characters' diff --git a/modules/client/back/models/greuge.json b/modules/client/back/models/greuge.json index 918ff0ca5..e8790715a 100644 --- a/modules/client/back/models/greuge.json +++ b/modules/client/back/models/greuge.json @@ -34,6 +34,10 @@ "greugeTypeFk": { "type": "number", "required": true + }, + "userFk": { + "type": "number", + "required": true } }, diff --git a/modules/client/front/greuge/index/index.html b/modules/client/front/greuge/index/index.html index b48fe9466..cdc9c37d4 100644 --- a/modules/client/front/greuge/index/index.html +++ b/modules/client/front/greuge/index/index.html @@ -29,6 +29,7 @@ Date + Created by Comment Type Amount @@ -37,6 +38,7 @@ {{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }} + {{::greuge.userFk}} {{::greuge.description}} diff --git a/modules/client/front/greuge/index/locale/es.yml b/modules/client/front/greuge/index/locale/es.yml index 513e6ff7b..d1f202862 100644 --- a/modules/client/front/greuge/index/locale/es.yml +++ b/modules/client/front/greuge/index/locale/es.yml @@ -1,4 +1,5 @@ Date: Fecha Comment: Comentario Amount: Importe -Type: Tipo \ No newline at end of file +Type: Tipo +Created by: Creado por \ No newline at end of file From 3cfa56d610f3558ce8212475bdbd75ac22ef5cdb Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 25 Oct 2022 13:15:19 +0200 Subject: [PATCH 07/27] Add deliveryBoss ACL to the front --- modules/route/front/tickets/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index a3d65772a..dae894ac7 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -37,6 +37,8 @@ icon="format_list_numbered"> Date: Mon, 31 Oct 2022 14:43:31 +0100 Subject: [PATCH 08/27] Item islaid and test --- modules/item/back/methods/item/new.js | 10 ++++++++++ modules/item/back/methods/item/specs/new.spec.js | 10 ++++++++++ modules/item/back/models/item-type.json | 3 +++ 3 files changed, 23 insertions(+) diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index 0771b6b14..26ec32a9a 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -51,6 +51,16 @@ module.exports = Self => { const item = await models.Item.create(params, myOptions); + // set the item.isLaid to be the same as itemType.isLaid (itemType comes from item.typeFk) + + const itemType = await models.ItemType.findById(item.typeFk, myOptions); + + // Update the item with the new isLaid value + + item.isLaid = itemType.isLaid; + + await item.save(myOptions); + const typeTags = await models.ItemTypeTag.find({ where: {itemTypeFk: item.typeFk} }, myOptions); diff --git a/modules/item/back/methods/item/specs/new.spec.js b/modules/item/back/methods/item/specs/new.spec.js index 049ad0ff2..b9dd8d3ac 100644 --- a/modules/item/back/methods/item/specs/new.spec.js +++ b/modules/item/back/methods/item/specs/new.spec.js @@ -15,6 +15,11 @@ describe('item new()', () => { }; let item = await models.Item.new(itemParams, options); + + let itemType = await models.ItemType.findById(item.typeFk, options); + + item.isLaid = itemType.isLaid; + const temporalNameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}, options); const temporalName = await models.ItemTag.findOne({ @@ -26,9 +31,14 @@ describe('item new()', () => { item = await models.Item.findById(item.id, null, options); + itemType = await models.ItemType.findById(item.typeFk, options); + + item.isLaid = itemType.isLaid; + expect(item.intrastatFk).toEqual(5080000); expect(item.originFk).toEqual(1); expect(item.typeFk).toEqual(2); + expect(item.isLaid).toEqual(0); expect(item.name).toEqual('planta'); expect(temporalName.value).toEqual('planta'); diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index 74cdf3fc8..df80463e0 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -26,6 +26,9 @@ }, "isUnconventionalSize": { "type": "number" + }, + "isLaid": { + "type": "number" } }, "relations": { From 7d7af6eb495e59599772c37b58278e762774a261 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 4 Nov 2022 07:42:21 +0100 Subject: [PATCH 09/27] Modified model to allow modifications to isLaid --- modules/item/back/models/item.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 704c97434..2f58c30a9 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -143,6 +143,9 @@ }, "packingShelve": { "type": "number" + }, + "isLaid": { + "type": "boolean" } }, "relations": { From 11cf1ba414c13983be899f9b93c2bc838c21fced Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 4 Nov 2022 07:50:54 +0100 Subject: [PATCH 10/27] fix back test error --- modules/item/back/methods/item/specs/new.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/specs/new.spec.js b/modules/item/back/methods/item/specs/new.spec.js index b9dd8d3ac..7364faa7d 100644 --- a/modules/item/back/methods/item/specs/new.spec.js +++ b/modules/item/back/methods/item/specs/new.spec.js @@ -38,7 +38,7 @@ describe('item new()', () => { expect(item.intrastatFk).toEqual(5080000); expect(item.originFk).toEqual(1); expect(item.typeFk).toEqual(2); - expect(item.isLaid).toEqual(0); + expect(item.isLaid).toBeFalse(); expect(item.name).toEqual('planta'); expect(temporalName.value).toEqual('planta'); From 37292cee89db9578a6587cb6121d3fc19d05dabc Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 4 Nov 2022 08:12:46 +0100 Subject: [PATCH 11/27] remove comments --- modules/item/back/methods/item/new.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index 26ec32a9a..d6a176b46 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -51,12 +51,8 @@ module.exports = Self => { const item = await models.Item.create(params, myOptions); - // set the item.isLaid to be the same as itemType.isLaid (itemType comes from item.typeFk) - const itemType = await models.ItemType.findById(item.typeFk, myOptions); - // Update the item with the new isLaid value - item.isLaid = itemType.isLaid; await item.save(myOptions); From 638fd62aae298cf1349620d71f3b9b2cd671cdfd Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 10 Nov 2022 07:17:54 +0100 Subject: [PATCH 12/27] added requested changes, refs #4492 @40m --- modules/item/back/methods/item/new.js | 10 ++++------ modules/item/back/models/item-type.json | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index d6a176b46..fae37836f 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -49,14 +49,12 @@ module.exports = Self => { const provisionalName = params.provisionalName; delete params.provisionalName; + const itemType = await models.ItemType.findById(params.typeFk, myOptions); + + params.isLaid = itemType.isLaid; + const item = await models.Item.create(params, myOptions); - const itemType = await models.ItemType.findById(item.typeFk, myOptions); - - item.isLaid = itemType.isLaid; - - await item.save(myOptions); - const typeTags = await models.ItemTypeTag.find({ where: {itemTypeFk: item.typeFk} }, myOptions); diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index df80463e0..c5c920b2f 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -28,7 +28,7 @@ "type": "number" }, "isLaid": { - "type": "number" + "type": "boolean" } }, "relations": { From 891cd6b474500e5984e093017554407c2eba8ce4 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 10 Nov 2022 07:23:08 +0100 Subject: [PATCH 13/27] Added requestes changes refs #4157 --- modules/route/back/methods/route/sendSms.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/route/back/methods/route/sendSms.js b/modules/route/back/methods/route/sendSms.js index fe881abd5..d1c3efa35 100644 --- a/modules/route/back/methods/route/sendSms.js +++ b/modules/route/back/methods/route/sendSms.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ module.exports = Self => { Self.remoteMethodCtx('sendSms', { From 1327f0ae9ddb550c8b0536f4f34eb4375851feac Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 10 Nov 2022 08:18:05 +0100 Subject: [PATCH 14/27] Added requested changes, refs #4507 @1:20h --- .../10502-november/00-greuge.userFK_userFk.sql | 1 + modules/client/back/models/greuge.json | 16 ++++++++-------- modules/client/front/greuge/index/index.html | 2 +- modules/client/front/greuge/index/index.js | 6 ++++++ 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 db/changes/10502-november/00-greuge.userFK_userFk.sql diff --git a/db/changes/10502-november/00-greuge.userFK_userFk.sql b/db/changes/10502-november/00-greuge.userFK_userFk.sql new file mode 100644 index 000000000..2a5323fa3 --- /dev/null +++ b/db/changes/10502-november/00-greuge.userFK_userFk.sql @@ -0,0 +1 @@ +ALTER TABLE vn.greuge CHANGE userFK userFk int(10) unsigned DEFAULT NULL NULL; \ No newline at end of file diff --git a/modules/client/back/models/greuge.json b/modules/client/back/models/greuge.json index e8790715a..a694c7552 100644 --- a/modules/client/back/models/greuge.json +++ b/modules/client/back/models/greuge.json @@ -2,9 +2,9 @@ "name": "Greuge", "base": "Loggable", "log": { - "model": "ClientLog", - "relation": "client", - "showField": "description" + "model": "ClientLog", + "relation": "client", + "showField": "description" }, "options": { "mysql": { @@ -34,12 +34,7 @@ "greugeTypeFk": { "type": "number", "required": true - }, - "userFk": { - "type": "number", - "required": true } - }, "relations": { "client": { @@ -56,6 +51,11 @@ "type": "belongsTo", "model": "GreugeType", "foreignKey": "greugeTypeFk" + }, + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFK" } } } \ No newline at end of file diff --git a/modules/client/front/greuge/index/index.html b/modules/client/front/greuge/index/index.html index cdc9c37d4..44074ed1a 100644 --- a/modules/client/front/greuge/index/index.html +++ b/modules/client/front/greuge/index/index.html @@ -38,7 +38,7 @@ {{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }} - {{::greuge.userFk}} + {{::greuge.user.name}} {{::greuge.description}} diff --git a/modules/client/front/greuge/index/index.js b/modules/client/front/greuge/index/index.js index 2451167a4..7a5ccc531 100644 --- a/modules/client/front/greuge/index/index.js +++ b/modules/client/front/greuge/index/index.js @@ -8,6 +8,12 @@ class Controller extends Section { include: [ { relation: 'greugeType', + scope: { + fields: ['id', 'name'] + }, + }, + { + relation: 'user', scope: { fields: ['id', 'name'] } From c53e309071cadb12f1deca6fa7700248ba8d6afa Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 10 Nov 2022 08:19:54 +0100 Subject: [PATCH 15/27] Fix typo --- modules/client/back/models/greuge.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/back/models/greuge.json b/modules/client/back/models/greuge.json index a694c7552..625bf4e28 100644 --- a/modules/client/back/models/greuge.json +++ b/modules/client/back/models/greuge.json @@ -55,7 +55,7 @@ "user": { "type": "belongsTo", "model": "Account", - "foreignKey": "userFK" + "foreignKey": "userFk" } } } \ No newline at end of file From 8dd6012b1f8e50cc98ae398e96d127fced675e86 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 10 Nov 2022 08:27:47 +0100 Subject: [PATCH 16/27] Added worker descriptor popover --- modules/client/front/greuge/index/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/client/front/greuge/index/index.html b/modules/client/front/greuge/index/index.html index 44074ed1a..80e41e915 100644 --- a/modules/client/front/greuge/index/index.html +++ b/modules/client/front/greuge/index/index.html @@ -38,7 +38,8 @@ {{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }} - {{::greuge.user.name}} + {{::greuge.user.name}} {{::greuge.description}} @@ -59,3 +60,4 @@ vn-bind="+" fixed-bottom-right> + \ No newline at end of file From 8b06243041112365aa58f2f17470af11068c9357 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 10 Nov 2022 08:36:26 +0100 Subject: [PATCH 17/27] Fix link being the whole column --- modules/client/front/greuge/index/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/front/greuge/index/index.html b/modules/client/front/greuge/index/index.html index 80e41e915..459d92fc7 100644 --- a/modules/client/front/greuge/index/index.html +++ b/modules/client/front/greuge/index/index.html @@ -38,8 +38,8 @@ {{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }} - {{::greuge.user.name}} + {{::greuge.user.name}} {{::greuge.description}} From d1dce73a3374d6401392736aee8f30402e1fe7ee Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 14 Nov 2022 08:50:38 +0100 Subject: [PATCH 18/27] feat: creat email/vehicle-event-expired --- .../vehicle-event-expired/assets/css/import.js | 11 +++++++++++ .../email/vehicle-event-expired/attachments.json | 6 ++++++ .../email/vehicle-event-expired/locale/es.yml | 3 +++ .../vehicle-event-expired.html | 8 ++++++++ .../vehicle-event-expired/vehicle-event-expired.js | 9 +++++++++ .../vehicle-event-expired/assets/css/import.js | 13 ++++++++----- .../vehicle-event-expired/vehicle-event-expired.js | 2 +- print/templates/reports/zone/zone.js | 2 +- 8 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 print/templates/email/vehicle-event-expired/assets/css/import.js create mode 100644 print/templates/email/vehicle-event-expired/attachments.json create mode 100644 print/templates/email/vehicle-event-expired/locale/es.yml create mode 100644 print/templates/email/vehicle-event-expired/vehicle-event-expired.html create mode 100755 print/templates/email/vehicle-event-expired/vehicle-event-expired.js diff --git a/print/templates/email/vehicle-event-expired/assets/css/import.js b/print/templates/email/vehicle-event-expired/assets/css/import.js new file mode 100644 index 000000000..4b4bb7086 --- /dev/null +++ b/print/templates/email/vehicle-event-expired/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/vehicle-event-expired/attachments.json b/print/templates/email/vehicle-event-expired/attachments.json new file mode 100644 index 000000000..6b56392a0 --- /dev/null +++ b/print/templates/email/vehicle-event-expired/attachments.json @@ -0,0 +1,6 @@ +[ + { + "filename": "vehicle-event-expired.pdf", + "component": "vehicle-event-expired" + } +] diff --git a/print/templates/email/vehicle-event-expired/locale/es.yml b/print/templates/email/vehicle-event-expired/locale/es.yml new file mode 100644 index 000000000..f6fff468c --- /dev/null +++ b/print/templates/email/vehicle-event-expired/locale/es.yml @@ -0,0 +1,3 @@ +subject: Expiración Tarjetas Vehículos +title: Expiración Tarjetas Vehículos +description: A continuación se adjunta el informe de expiración de tarjetas vehículos diff --git a/print/templates/email/vehicle-event-expired/vehicle-event-expired.html b/print/templates/email/vehicle-event-expired/vehicle-event-expired.html new file mode 100644 index 000000000..f4c1ebc1b --- /dev/null +++ b/print/templates/email/vehicle-event-expired/vehicle-event-expired.html @@ -0,0 +1,8 @@ + +
+
+

{{ $t('title') }}

+

+
+
+
diff --git a/print/templates/email/vehicle-event-expired/vehicle-event-expired.js b/print/templates/email/vehicle-event-expired/vehicle-event-expired.js new file mode 100755 index 000000000..1c228d2b5 --- /dev/null +++ b/print/templates/email/vehicle-event-expired/vehicle-event-expired.js @@ -0,0 +1,9 @@ +const Component = require(`vn-print/core/component`); +const emailBody = new Component('email-body'); + +module.exports = { + name: 'vehicle-event-expired', + components: { + 'email-body': emailBody.build() + } +}; diff --git a/print/templates/reports/vehicle-event-expired/assets/css/import.js b/print/templates/reports/vehicle-event-expired/assets/css/import.js index fd8796c2b..37a98dfdd 100644 --- a/print/templates/reports/vehicle-event-expired/assets/css/import.js +++ b/print/templates/reports/vehicle-event-expired/assets/css/import.js @@ -1,9 +1,12 @@ -const Stylesheet = require(`${appPath}/core/stylesheet`); +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); module.exports = new Stylesheet([ - `${appPath}/common/css/spacing.css`, - `${appPath}/common/css/misc.css`, - `${appPath}/common/css/layout.css`, - `${appPath}/common/css/report.css`, + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/report.css`, `${__dirname}/style.css`]) .mergeStyles(); diff --git a/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js index 278caeabf..ab6cffc00 100755 --- a/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js +++ b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js @@ -1,4 +1,4 @@ -const Component = require(`${appPath}/core/component`); +const Component = require(`vn-print/core/component`); const reportBody = new Component('report-body'); module.exports = { diff --git a/print/templates/reports/zone/zone.js b/print/templates/reports/zone/zone.js index 463c28acf..720542cd6 100755 --- a/print/templates/reports/zone/zone.js +++ b/print/templates/reports/zone/zone.js @@ -1,4 +1,4 @@ -const Component = require(`${appPath}/core/component`); +const Component = require(`vn-print/core/component`); const reportBody = new Component('report-body'); module.exports = { From 3c771fc771cf1eb730b09e9cdfc768b2f6c7e12a Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 14 Nov 2022 08:53:00 +0100 Subject: [PATCH 19/27] refactor missing URL's refs #4609 --- print/templates/email/client-welcome/client-welcome.html | 2 +- print/templates/email/client-welcome/locale/es.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/print/templates/email/client-welcome/client-welcome.html b/print/templates/email/client-welcome/client-welcome.html index 07b61b3e6..585c1a11b 100644 --- a/print/templates/email/client-welcome/client-welcome.html +++ b/print/templates/email/client-welcome/client-welcome.html @@ -31,7 +31,7 @@
{{$t('clientId')}}: {{client.id}}
{{$t('user')}}: {{client.userName}}
{{$t('password')}}: ******** - ({{$t('passwordResetText')}}) + ({{$t('passwordResetText')}})

diff --git a/print/templates/email/client-welcome/locale/es.yml b/print/templates/email/client-welcome/locale/es.yml index 1257113ac..478fd242c 100644 --- a/print/templates/email/client-welcome/locale/es.yml +++ b/print/templates/email/client-welcome/locale/es.yml @@ -1,8 +1,8 @@ subject: Bienvenido a Verdnatura title: "¡Te damos la bienvenida!" dearClient: Estimado cliente -clientData: 'Tus datos para poder comprar en la web de Verdnatura (https://verdnatura.es) +clientData: 'Tus datos para poder comprar en la web de Verdnatura (https://shop.verdnatura.es) o en nuestras aplicaciones para iOS y Android, son' From 6e94d7f68e25bca8c13404e55e329c7bda7750c6 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 14 Nov 2022 11:00:13 +0100 Subject: [PATCH 20/27] fix: nombre variable incorrecto --- modules/ticket/front/sale/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 85a862bbb..f64d0b61b 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -89,7 +89,7 @@ class Controller extends Section { getUsesMana() { this.$http.get(`Sales/usesMana`) .then(res => { - this.useMana = res.data; + this.usesMana = res.data; }); } From 5c249dcbccacd95131642ddb93f1c58778077ea1 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 15 Nov 2022 08:24:10 +0100 Subject: [PATCH 21/27] refs #4767 @1h30m --- modules/route/front/descriptor/index.html | 7 +++++++ modules/route/front/descriptor/index.js | 8 ++++++++ modules/route/front/descriptor/index.spec.js | 16 ++++++++++++++++ modules/route/front/descriptor/locale/es.yml | 2 ++ 4 files changed, 33 insertions(+) diff --git a/modules/route/front/descriptor/index.html b/modules/route/front/descriptor/index.html index fc1d3419c..6d6fb082e 100644 --- a/modules/route/front/descriptor/index.html +++ b/modules/route/front/descriptor/index.html @@ -20,6 +20,13 @@ translate> Update volume + + Delete route +
diff --git a/modules/route/front/descriptor/index.js b/modules/route/front/descriptor/index.js index 2dc512b67..aa47044b1 100644 --- a/modules/route/front/descriptor/index.js +++ b/modules/route/front/descriptor/index.js @@ -34,6 +34,14 @@ class Controller extends Descriptor { }); } + deleteCurrentRoute() { + this.$http.delete(`Routes/${this.id}`) + .then(() => { + this.vnApp.showSuccess(this.$t('Route deleted')); + this.$state.go('route.index'); + }); + } + loadData() { const filter = { fields: [ diff --git a/modules/route/front/descriptor/index.spec.js b/modules/route/front/descriptor/index.spec.js index ab996d9b0..f43666c8b 100644 --- a/modules/route/front/descriptor/index.spec.js +++ b/modules/route/front/descriptor/index.spec.js @@ -23,4 +23,20 @@ describe('vnRouteDescriptorPopover', () => { expect(controller.route).toEqual(response); }); }); + + describe('deleteCurrentRoute()', () => { + it(`should perform a delete query to delete the current route`, () => { + const id = 1; + + jest.spyOn(controller.vnApp, 'showSuccess'); + + controller._id = id; + $httpBackend.expectDELETE(`Routes/${id}`).respond(200); + controller.deleteCurrentRoute(); + $httpBackend.flush(); + + expect(controller.route).toBeUndefined(); + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Route deleted'); + }); + }); }); diff --git a/modules/route/front/descriptor/locale/es.yml b/modules/route/front/descriptor/locale/es.yml index 63fa7202b..23068fbf8 100644 --- a/modules/route/front/descriptor/locale/es.yml +++ b/modules/route/front/descriptor/locale/es.yml @@ -4,4 +4,6 @@ Send route report: Enviar informe de ruta Show route report: Ver informe de ruta Update volume: Actualizar volumen Volume updated: Volumen actualizado +Delete route: Borrar ruta +Route deleted: Ruta borrada Are you sure you want to update the volume?: Estas seguro que quieres actualizar el volumen? \ No newline at end of file From c200e1af32f7ec464d2906323359f7a3925e7b02 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 15 Nov 2022 15:09:41 +0100 Subject: [PATCH 22/27] refactor: optimizado select --- .../00-timeBusiness_calculate.sql | 88 +++++++++++++++++++ .../specs/sendMail.spec.js | 9 -- 2 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 db/changes/10503-november/00-timeBusiness_calculate.sql diff --git a/db/changes/10503-november/00-timeBusiness_calculate.sql b/db/changes/10503-november/00-timeBusiness_calculate.sql new file mode 100644 index 000000000..ea13c4a8a --- /dev/null +++ b/db/changes/10503-november/00-timeBusiness_calculate.sql @@ -0,0 +1,88 @@ +DROP PROCEDURE IF EXISTS `vn`.`timeBusiness_calculate`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN +/** + * Horas que debe trabajar un empleado según contrato y día. + * @param vDatedFrom workerTimeControl + * @param vDatedTo workerTimeControl + * @table tmp.user(userFk) + * @return tmp.timeBusinessCalculate + */ + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; + CREATE TEMPORARY TABLE tmp.timeBusinessCalculate + (INDEX (departmentFk)) + SELECT dated, + businessFk, + userFk, + departmentFk, + hourStart, + hourEnd, + timeTable, + timeWorkSeconds, + SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal, + timeWorkSeconds / 3600 timeWorkDecimal, + timeWorkSeconds timeBusinessSeconds, + SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal, + timeWorkSeconds / 3600 timeBusinessDecimal, + name type, + permissionRate, + hoursWeek, + discountRate, + isAllowedToWork + FROM(SELECT t.dated, + b.id businessFk, + w.userFk, + b.departmentFk, + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart , + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd, + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5), " - ", LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) timeTable, + IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)), 0)) timeWorkSeconds, + at2.name, + at2.permissionRate, + at2.discountRate, + cl.hours_week hoursWeek, + at2.isAllowedToWork + FROM time t + LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo) + LEFT JOIN worker w ON w.id = b.workerFk + JOIN tmp.`user` u ON u.userFK = w.userFK + LEFT JOIN workCenter wc ON wc.id = b.workcenterFK + LEFT JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk + LEFT JOIN postgresql.journey j ON j.business_id = b.id AND j.day_id = WEEKDAY(t.dated) + 1 + LEFT JOIN postgresql.calendar_employee ce ON ce.businessFk = b.id AND ce.date = t.dated + LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id + WHERE t.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY w.userFk, t.dated + )sub; + + UPDATE tmp.timeBusinessCalculate t + LEFT JOIN postgresql.journey j ON j.business_id = t.businessFk + SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600, + t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600), + t.timeWorkDecimal = t.hoursWeek / 5, + t.timeBusinessSeconds = t.hoursWeek / 5 * 3600, + t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600), + t.timeBusinessDecimal = t.hoursWeek / 5 + WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND j.journey_id IS NULL ; + + UPDATE tmp.timeBusinessCalculate t + SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) , + t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600), + t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate) + WHERE permissionRate <> 0; + + UPDATE tmp.timeBusinessCalculate t + JOIN calendarHolidays ch ON ch.dated = t.dated + JOIN business b ON b.id = t.businessFk + AND b.workcenterFk = ch.workcenterFk + SET t.timeWorkSeconds = 0, + t.timeWorkSexagesimal = 0, + t.timeWorkDecimal = 0, + t.permissionrate = 1, + t.type = 'Festivo' + WHERE t.type IS NULL; +END$$ +DELIMITER ; diff --git a/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js b/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js index d0afd45b9..4cc6e54e3 100644 --- a/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js @@ -12,11 +12,6 @@ describe('workerTimeControl sendMail()', () => { }; - beforeAll(function() { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; - }); - it('should fill time control of a worker without records in Journey and with rest', async() => { const tx = await models.WorkerTimeControl.beginTransaction({}); @@ -124,9 +119,5 @@ describe('workerTimeControl sendMail()', () => { throw e; } }); - - afterAll(function() { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); }); From 925c3846227e406041e0b453d872378aa497ca72 Mon Sep 17 00:00:00 2001 From: Alex Moreno Date: Wed, 16 Nov 2022 06:36:35 +0000 Subject: [PATCH 23/27] Actualizar 'e2e/paths/05-ticket/02_expeditions_and_log.spec.js' remove focus --- e2e/paths/05-ticket/02_expeditions_and_log.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js index 66df3e9e6..f970247e5 100644 --- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js +++ b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Ticket expeditions and log path', () => { +describe('Ticket expeditions and log path', () => { let browser; let page; From 66e6a47692103667a86a9744e2fd1ca08379ef5d Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 16 Nov 2022 08:25:07 +0100 Subject: [PATCH 24/27] fix(e2e test expected withoutNegatives checkbox to not be checked already) --- e2e/paths/05-ticket/06_basic_data_steps.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/paths/05-ticket/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js index 46cbf29b8..fa901e325 100644 --- a/e2e/paths/05-ticket/06_basic_data_steps.spec.js +++ b/e2e/paths/05-ticket/06_basic_data_steps.spec.js @@ -104,7 +104,6 @@ describe('Ticket Edit basic data path', () => { await page.waitToClick(selectors.ticketBasicData.nextStepButton); - await page.waitToClick(selectors.ticketBasicData.withoutNegatives); await page.waitToClick(selectors.ticketBasicData.finalizeButton); await page.waitForState('ticket.card.summary'); From 7b3a1bfb22bff5082626b9929ba1bb8b7b3354a0 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 16 Nov 2022 08:28:12 +0100 Subject: [PATCH 25/27] requested changes --- db/changes/10502-november/00-greuge.userFK_userFk.sql | 1 - db/changes/10503-november/00-greuge.userFK_userFk.sql | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 db/changes/10502-november/00-greuge.userFK_userFk.sql create mode 100644 db/changes/10503-november/00-greuge.userFK_userFk.sql diff --git a/db/changes/10502-november/00-greuge.userFK_userFk.sql b/db/changes/10502-november/00-greuge.userFK_userFk.sql deleted file mode 100644 index 2a5323fa3..000000000 --- a/db/changes/10502-november/00-greuge.userFK_userFk.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vn.greuge CHANGE userFK userFk int(10) unsigned DEFAULT NULL NULL; \ No newline at end of file diff --git a/db/changes/10503-november/00-greuge.userFK_userFk.sql b/db/changes/10503-november/00-greuge.userFK_userFk.sql new file mode 100644 index 000000000..ec4bf3146 --- /dev/null +++ b/db/changes/10503-november/00-greuge.userFK_userFk.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`greuge` CHANGE `userFK` `userFk` int(10) unsigned DEFAULT NULL NULL; \ No newline at end of file From 4a063cc310dbebef76966d569678f824e0596a81 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 17 Nov 2022 09:25:18 +0100 Subject: [PATCH 26/27] refs #4780 verification deleted --- modules/client/back/methods/client/setPassword.js | 6 ------ .../back/methods/client/specs/setPassword.spec.js | 15 --------------- 2 files changed, 21 deletions(-) diff --git a/modules/client/back/methods/client/setPassword.js b/modules/client/back/methods/client/setPassword.js index 2f0ebca5b..e3fc9bbf8 100644 --- a/modules/client/back/methods/client/setPassword.js +++ b/modules/client/back/methods/client/setPassword.js @@ -23,12 +23,6 @@ module.exports = Self => { Self.setPassword = async function(ctx, id, newPassword) { const models = Self.app.models; - const userId = ctx.req.accessToken.userId; - - const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson'); - - if (!isSalesPerson) - throw new UserError(`Not enough privileges to edit a client`); const isClient = await models.Client.findById(id, null); const isUserAccount = await models.UserAccount.findById(id, null); diff --git a/modules/client/back/methods/client/specs/setPassword.spec.js b/modules/client/back/methods/client/specs/setPassword.spec.js index 13065ca12..03334918b 100644 --- a/modules/client/back/methods/client/specs/setPassword.spec.js +++ b/modules/client/back/methods/client/specs/setPassword.spec.js @@ -6,21 +6,6 @@ describe('Client setPassword', () => { req: {accessToken: {userId: salesPersonId}} }; - it(`should throw an error if you don't have enough permissions`, async() => { - let error; - const employeeId = 1; - const ctx = { - req: {accessToken: {userId: employeeId}} - }; - try { - await models.Client.setPassword(ctx, 1, 't0pl3v3l.p455w0rd!'); - } catch (e) { - error = e; - } - - expect(error.message).toEqual(`Not enough privileges to edit a client`); - }); - it('should throw an error the setPassword target is not just a client but a worker', async() => { let error; From 721f89b76c6fbc3593d82b410a0ef44541bd6778 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 17 Nov 2022 16:39:12 +0100 Subject: [PATCH 27/27] fix(ordersFilter): wrong table schema --- modules/monitor/back/methods/sales-monitor/ordersFilter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitor/back/methods/sales-monitor/ordersFilter.js b/modules/monitor/back/methods/sales-monitor/ordersFilter.js index 6ae4042b6..a80ea822e 100644 --- a/modules/monitor/back/methods/sales-monitor/ordersFilter.js +++ b/modules/monitor/back/methods/sales-monitor/ordersFilter.js @@ -53,7 +53,7 @@ module.exports = Self => { JOIN client c ON c.id = o.customer_id JOIN address a ON a.id = o.address_id JOIN agencyMode am ON am.id = o.agency_id - JOIN user u ON u.id = c.salesPersonFk + JOIN account.user u ON u.id = c.salesPersonFk JOIN workerTeamCollegues wtc ON c.salesPersonFk = wtc.collegueFk`); if (!filter.where) filter.where = {};